mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Fixed some issues with the sample code.
This commit is contained in:
parent
6a8d3082f3
commit
00e2fc99a2
4 changed files with 9 additions and 4 deletions
|
@ -94,7 +94,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
return unless @level.get('type', true) is 'hero'
|
||||
heroConfig = session.get('heroConfig')
|
||||
heroConfig ?= me.get('heroConfig')
|
||||
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 all else fails, assign Tharin as the hero.
|
||||
session.set 'heroConfig', heroConfig unless _.isEqual heroConfig, session.get('heroConfig')
|
||||
url = "/db/thang.type/#{heroConfig.thangType}/version"
|
||||
if heroResource = @maybeLoadURL(url, ThangType, 'thang')
|
||||
|
|
|
@ -58,8 +58,10 @@ module.exports = class GameMenuModal extends ModalView
|
|||
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
|
||||
patchSession = patchMe = false
|
||||
props = {}
|
||||
props.thangType = thangType if thangType
|
||||
props.inventory = inventory if _.size inventory
|
||||
if thangType or not sessionHeroConfig.thangType
|
||||
props.thangType = thangType ? '529ffbf1cf1818f2be000001' # Default to Tharin if it somehow doesn't get set.
|
||||
if _.size(inventory) or not sessionHeroConfig.inventory
|
||||
props.inventory = inventory
|
||||
for key, val of props when val
|
||||
patchSession ||= not _.isEqual val, sessionHeroConfig[key]
|
||||
patchMe ||= not _.isEqual val, lastHeroConfig[key]
|
||||
|
|
|
@ -37,6 +37,7 @@ module.exports = class Spell
|
|||
@source = @originalSource
|
||||
@parameters = p.parameters
|
||||
if @permissions.readwrite.length and sessionSource = @session.getSourceFor(@spellKey)
|
||||
if sessionSource isnt '// Should fill in some default source\n' # TODO: figure out why session is getting this default source in there and stop it
|
||||
@source = sessionSource
|
||||
@thangs = {}
|
||||
if @canRead() # We can avoid creating these views if we'll never use them.
|
||||
|
@ -55,6 +56,7 @@ module.exports = class Spell
|
|||
@worker = null
|
||||
|
||||
setLanguage: (@language) ->
|
||||
console.log 'setting language to', @language, 'so using original source', @languages[language] ? @languages.javascript
|
||||
@originalSource = @languages[language] ? @languages.javascript
|
||||
|
||||
addThang: (thang) ->
|
||||
|
|
|
@ -61,6 +61,7 @@ module.exports = class TomeView extends CocoView
|
|||
afterRender: ->
|
||||
super()
|
||||
@worker = @createWorker()
|
||||
#programmableThangs = _.filter @options.thangs, (t) -> t.isProgrammable and t.spriteName isnt 'Hero Placeholder'
|
||||
programmableThangs = _.filter @options.thangs, 'isProgrammable'
|
||||
@createSpells programmableThangs, programmableThangs[0]?.world # Do before spellList, thangList, and castButton
|
||||
@spellList = @insertSubView new SpellListView spells: @spells, supermodel: @supermodel
|
||||
|
|
Loading…
Reference in a new issue