mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 02:25:37 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
9e73bf52e8
11 changed files with 60 additions and 37 deletions
|
@ -108,7 +108,7 @@ class AudioPlayer extends CocoClass
|
||||||
# TODO: load Interface sounds somehow, somewhere, somewhen
|
# TODO: load Interface sounds somehow, somewhere, somewhen
|
||||||
|
|
||||||
preloadSoundReference: (sound) ->
|
preloadSoundReference: (sound) ->
|
||||||
name = @nameForSoundReference sound
|
return unless name = @nameForSoundReference sound
|
||||||
filename = '/file/' + name
|
filename = '/file/' + name
|
||||||
@preloadSound filename, name
|
@preloadSound filename, name
|
||||||
filename
|
filename
|
||||||
|
|
|
@ -97,12 +97,21 @@ module.exports = class LevelLoader extends CocoClass
|
||||||
heroConfig ?= {inventory: {}, thangType: '529ffbf1cf1818f2be000001'} # If we got here not from PlayLevelModal (like level editor preview), assign Tharin as the hero.
|
heroConfig ?= {inventory: {}, thangType: '529ffbf1cf1818f2be000001'} # If we got here not from PlayLevelModal (like level editor preview), assign Tharin as the hero.
|
||||||
session.set 'heroConfig', heroConfig unless _.isEqual heroConfig, session.get('heroConfig')
|
session.set 'heroConfig', heroConfig unless _.isEqual heroConfig, session.get('heroConfig')
|
||||||
url = "/db/thang.type/#{heroConfig.thangType}/version"
|
url = "/db/thang.type/#{heroConfig.thangType}/version"
|
||||||
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
|
if heroResource = @maybeLoadURL(url, ThangType, 'thang')
|
||||||
|
@worldNecessities.push heroResource
|
||||||
|
else
|
||||||
|
heroThangType = @supermodel.getModel url
|
||||||
|
@loadDefaultComponentsForThangType heroThangType
|
||||||
|
@loadThangsRequiredByThangType heroThangType
|
||||||
|
|
||||||
for itemThangType in _.values(heroConfig.inventory)
|
for itemThangType in _.values(heroConfig.inventory)
|
||||||
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original"
|
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original"
|
||||||
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
|
if itemResource = @maybeLoadURL(url, ThangType, 'thang')
|
||||||
|
@worldNecessities.push itemResource
|
||||||
|
else
|
||||||
|
itemThangType = @supermodel.getModel url
|
||||||
|
@loadDefaultComponentsForThangType itemThangType
|
||||||
|
@loadThangsRequiredByThangType itemThangType
|
||||||
|
|
||||||
# Grabbing the rest of the required data for the level
|
# Grabbing the rest of the required data for the level
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
|
|
||||||
setUpSprite: ->
|
setUpSprite: ->
|
||||||
for trigger, sounds of @thangType.get('soundTriggers') or {} when trigger isnt 'say'
|
for trigger, sounds of @thangType.get('soundTriggers') or {} when trigger isnt 'say'
|
||||||
AudioPlayer.preloadSoundReference sound for sound in sounds
|
AudioPlayer.preloadSoundReference sound for sound in sounds when sound
|
||||||
if @thangType.get('raster')
|
if @thangType.get('raster')
|
||||||
@stillLoading = false
|
@stillLoading = false
|
||||||
@actions = {}
|
@actions = {}
|
||||||
|
|
|
@ -68,6 +68,7 @@ module.exports = class World
|
||||||
|
|
||||||
setThang: (thang) ->
|
setThang: (thang) ->
|
||||||
for old, i in @thangs
|
for old, i in @thangs
|
||||||
|
console.error 'world trying to set', thang, 'over', old unless old? and thang?
|
||||||
if old.id is thang.id
|
if old.id is thang.id
|
||||||
@thangs[i] = thang
|
@thangs[i] = thang
|
||||||
@thangMap[thang.id] = thang
|
@thangMap[thang.id] = thang
|
||||||
|
|
|
@ -122,25 +122,6 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
||||||
margin-bottom: $heroContainerBottomMargin / 2 - 1
|
margin-bottom: $heroContainerBottomMargin / 2 - 1
|
||||||
border-top: 1px solid #aaa
|
border-top: 1px solid #aaa
|
||||||
|
|
||||||
.panel
|
|
||||||
text-align: center
|
|
||||||
width: 31.3%
|
|
||||||
margin: 5px 2% 5px 0
|
|
||||||
float: left
|
|
||||||
cursor: pointer
|
|
||||||
|
|
||||||
.panel-heading
|
|
||||||
padding: 5px
|
|
||||||
|
|
||||||
.panel-info .panel-body
|
|
||||||
background-color: #e0f0f5
|
|
||||||
|
|
||||||
.panel-body
|
|
||||||
height: 50px
|
|
||||||
padding: 5px
|
|
||||||
overflow: scroll
|
|
||||||
font-size: 12px
|
|
||||||
|
|
||||||
#available-equipment
|
#available-equipment
|
||||||
width: $stashWidth
|
width: $stashWidth
|
||||||
position: absolute
|
position: absolute
|
||||||
|
@ -163,6 +144,11 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
||||||
background-color: #e0f0f5
|
background-color: #e0f0f5
|
||||||
&.equipped
|
&.equipped
|
||||||
display: none
|
display: none
|
||||||
|
&.restricted
|
||||||
|
@include opacity(0.5)
|
||||||
|
|
||||||
|
.item-info:after
|
||||||
|
content: ' (locked)'
|
||||||
|
|
||||||
.item-view
|
.item-view
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|
|
@ -17,7 +17,10 @@ block modal-footer-content
|
||||||
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_go_ladder") Return to Ladder
|
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_go_ladder") Return to Ladder
|
||||||
else if hasNextLevel
|
else if hasNextLevel
|
||||||
button.btn.btn-success.next-level-button(data-dismiss="modal", data-i18n="play_level.victory_play_next_level") Play Next Level
|
button.btn.btn-success.next-level-button(data-dismiss="modal", data-i18n="play_level.victory_play_next_level") Play Next Level
|
||||||
a.btn.btn-primary(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_go_home") Go Home
|
else if level.get('type', true) === 'hero'
|
||||||
|
a.btn.btn-success(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_next_level") Play Next Level
|
||||||
|
else
|
||||||
|
a.btn.btn-primary(href="/", data-dismiss="modal", data-i18n="play_level.victory_go_home") Go Home
|
||||||
if me.get('anonymous')
|
if me.get('anonymous')
|
||||||
p.sign-up-poke
|
p.sign-up-poke
|
||||||
button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/SignupModal", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress
|
button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/SignupModal", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress
|
||||||
|
|
|
@ -23,6 +23,7 @@ module.exports = class GameMenuModal extends ModalView
|
||||||
@options.showDevBits = me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
|
@options.showDevBits = me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
|
||||||
@options.showInventory = @options.level.get('type', true) is 'hero'
|
@options.showInventory = @options.level.get('type', true) is 'hero'
|
||||||
@options.levelID = @options.level.get('slug')
|
@options.levelID = @options.level.get('slug')
|
||||||
|
@options.startingSessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
|
||||||
|
|
||||||
getRenderData: (context={}) ->
|
getRenderData: (context={}) ->
|
||||||
context = super(context)
|
context = super(context)
|
||||||
|
@ -51,7 +52,7 @@ module.exports = class GameMenuModal extends ModalView
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||||
|
|
||||||
updateConfig: ->
|
updateConfig: ->
|
||||||
sessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
|
sessionHeroConfig = @options.startingSessionHeroConfig
|
||||||
lastHeroConfig = me.get('heroConfig') ? {}
|
lastHeroConfig = me.get('heroConfig') ? {}
|
||||||
thangType = @subviews.choose_hero_view.selectedHero?.get 'original'
|
thangType = @subviews.choose_hero_view.selectedHero?.get 'original'
|
||||||
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
|
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
|
||||||
|
|
|
@ -39,7 +39,6 @@ module.exports = class InventoryView extends CocoView
|
||||||
super()
|
super()
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
@items.models = _.filter(@items.models, (item) => item.get('original') in @allowedItems) if @allowedItems
|
|
||||||
item.notInLevel = true for item in @items.models
|
item.notInLevel = true for item in @items.models
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -51,6 +50,8 @@ module.exports = class InventoryView extends CocoView
|
||||||
for item in @items.models
|
for item in @items.models
|
||||||
item.classes = item.getAllowedSlots()
|
item.classes = item.getAllowedSlots()
|
||||||
item.classes.push 'equipped' if item.get('original') in context.equipped
|
item.classes.push 'equipped' if item.get('original') in context.equipped
|
||||||
|
item.classes.push 'restricted' if @allowedItems and not (item.get('original') in @allowedItems)
|
||||||
|
@items.models.sort (a, b) -> ('restricted' in a.classes) - ('restricted' in b.classes)
|
||||||
|
|
||||||
context.slots = @slots
|
context.slots = @slots
|
||||||
context.equipment = _.clone @equipment
|
context.equipment = _.clone @equipment
|
||||||
|
@ -82,6 +83,7 @@ module.exports = class InventoryView extends CocoView
|
||||||
itemView.render()
|
itemView.render()
|
||||||
$(availableItemEl).append(itemView.$el)
|
$(availableItemEl).append(itemView.$el)
|
||||||
@registerSubView(itemView)
|
@registerSubView(itemView)
|
||||||
|
continue if $(availableItemEl).hasClass 'restricted'
|
||||||
dragHelper = itemView.$el.find('img').clone().addClass('draggable-item')
|
dragHelper = itemView.$el.find('img').clone().addClass('draggable-item')
|
||||||
do (dragHelper, itemView) =>
|
do (dragHelper, itemView) =>
|
||||||
itemView.$el.draggable
|
itemView.$el.draggable
|
||||||
|
@ -134,13 +136,17 @@ module.exports = class InventoryView extends CocoView
|
||||||
|
|
||||||
onAvailableItemClick: (e) ->
|
onAvailableItemClick: (e) ->
|
||||||
itemContainer = $(e.target).closest('.list-group-item')
|
itemContainer = $(e.target).closest('.list-group-item')
|
||||||
|
return if itemContainer.hasClass 'restricted'
|
||||||
wasActive = itemContainer.hasClass 'active'
|
wasActive = itemContainer.hasClass 'active'
|
||||||
@unselectAllAvailableEquipment()
|
@unselectAllAvailableEquipment()
|
||||||
@selectAvailableItem(itemContainer) unless wasActive
|
@selectAvailableItem(itemContainer) unless wasActive
|
||||||
@onSelectionChanged()
|
@onSelectionChanged()
|
||||||
|
|
||||||
onAvailableItemDoubleClick: (e) ->
|
onAvailableItemDoubleClick: (e) ->
|
||||||
@selectAvailableItem $(e.target).closest('.list-group-item') if e
|
if e
|
||||||
|
itemContainer = $(e.target).closest('.list-group-item')
|
||||||
|
return if itemContainer.hasClass 'restricted'
|
||||||
|
@selectAvailableItem itemContainer
|
||||||
@onSelectionChanged()
|
@onSelectionChanged()
|
||||||
slot = @getSelectedSlot()
|
slot = @getSelectedSlot()
|
||||||
slot = @$el.find('.item-slot:not(.disabled):first') if not slot.length
|
slot = @$el.find('.item-slot:not(.disabled):first') if not slot.length
|
||||||
|
@ -316,7 +322,13 @@ module.exports = class InventoryView extends CocoView
|
||||||
necessaryGear = gearByLevel[@options.levelID]
|
necessaryGear = gearByLevel[@options.levelID]
|
||||||
for slot, item of necessaryGear ? {}
|
for slot, item of necessaryGear ? {}
|
||||||
@equipment[slot] ?= gear[item]
|
@equipment[slot] ?= gear[item]
|
||||||
@allowedItems = _.union(_.values(gear), _.values(@equipment)) if necessaryGear # If it's one of these levels, don't show the extra items.
|
|
||||||
|
# Restrict available items to those that would be available by this item.
|
||||||
|
@allowedItems = []
|
||||||
|
for level, items of gearByLevel
|
||||||
|
for slot, item of items
|
||||||
|
@allowedItems.push gear[item] unless gear[item] in @allowedItems
|
||||||
|
break if level is @options.levelID
|
||||||
|
|
||||||
onHeroSelectionUpdated: (e) ->
|
onHeroSelectionUpdated: (e) ->
|
||||||
@selectedHero = e.hero
|
@selectedHero = e.hero
|
||||||
|
|
|
@ -199,7 +199,12 @@ module.exports = class LevelHUDView extends CocoView
|
||||||
group.append('<span class="hud-hint">' + sk + '</span>')
|
group.append('<span class="hud-hint">' + sk + '</span>')
|
||||||
group.append($('<button class="btn btn-small banner with-dot">' + s + ' <div class="dot"></div></button>'))
|
group.append($('<button class="btn btn-small banner with-dot">' + s + ' <div class="dot"></div></button>'))
|
||||||
@lastResponses = null
|
@lastResponses = null
|
||||||
@bubble.append($("<h3>#{@speaker ? 'Captain Anya'}</h3>"))
|
if @speaker is 'Hero Placeholder'
|
||||||
|
# Doesn't work if it fires from a script; we don't really know who we are then.
|
||||||
|
name = {knight: 'Tharin', captain: 'Anya'}[@speakerSprite?.thang?.id] ? 'Hero'
|
||||||
|
else
|
||||||
|
name = @speaker
|
||||||
|
@bubble.append($("<h3>#{name}</h3>"))
|
||||||
@animator = new DialogueAnimator(message, @bubble)
|
@animator = new DialogueAnimator(message, @bubble)
|
||||||
@messageInterval = setInterval(@addMoreMessage, 1000 / 30) # 30 FPS
|
@messageInterval = setInterval(@addMoreMessage, 1000 / 30) # 30 FPS
|
||||||
|
|
||||||
|
|
|
@ -369,12 +369,15 @@ module.exports = class PlayLevelView extends RootView
|
||||||
return if @alreadyLoadedState
|
return if @alreadyLoadedState
|
||||||
@alreadyLoadedState = true
|
@alreadyLoadedState = true
|
||||||
state = @originalSessionState
|
state = @originalSessionState
|
||||||
if state.frame and @level.get('type', true) isnt 'ladder' # https://github.com/codecombat/codecombat/issues/714
|
|
||||||
Backbone.Mediator.publish 'level:set-time', time: 0, frameOffset: state.frame
|
|
||||||
if @level.get('type', true) is 'hero'
|
if @level.get('type', true) is 'hero'
|
||||||
Backbone.Mediator.publish 'tome:select-primary-sprite', {}
|
Backbone.Mediator.publish 'tome:select-primary-sprite', {}
|
||||||
@surface.focusOnHero()
|
@surface.focusOnHero()
|
||||||
else if state.selected
|
Backbone.Mediator.publish 'level:set-time', time: 0
|
||||||
|
Backbone.Mediator.publish 'level:set-playing', playing: true
|
||||||
|
else
|
||||||
|
if state.frame and @level.get('type', true) isnt 'ladder' # https://github.com/codecombat/codecombat/issues/714
|
||||||
|
Backbone.Mediator.publish 'level:set-time', time: 0, frameOffset: state.frame
|
||||||
|
if state.selected
|
||||||
# TODO: Should also restore selected spell here by saving spellName
|
# TODO: Should also restore selected spell here by saving spellName
|
||||||
Backbone.Mediator.publish 'level:select-sprite', thangID: state.selected, spellName: null
|
Backbone.Mediator.publish 'level:select-sprite', thangID: state.selected, spellName: null
|
||||||
if state.playing?
|
if state.playing?
|
||||||
|
|
|
@ -34,6 +34,9 @@ module.exports = class VictoryModal extends ModalView
|
||||||
@session = options.session
|
@session = options.session
|
||||||
@saveReviewEventually = _.debounce(@saveReviewEventually, 2000)
|
@saveReviewEventually = _.debounce(@saveReviewEventually, 2000)
|
||||||
@loadExistingFeedback()
|
@loadExistingFeedback()
|
||||||
|
if @level.get('type', true) is 'hero'
|
||||||
|
@closeButton = false
|
||||||
|
@closesOnClickOutside = false
|
||||||
super options
|
super options
|
||||||
|
|
||||||
loadExistingFeedback: ->
|
loadExistingFeedback: ->
|
||||||
|
|
Loading…
Reference in a new issue