mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 23:13:59 -04:00
Fixed simulator
The format of something must have suddenly changed?
This commit is contained in:
parent
f89768d76d
commit
bb76fb241c
1 changed files with 14 additions and 7 deletions
|
@ -178,7 +178,6 @@ module.exports = class Simulator
|
||||||
generateSpellKeyToSourceMapPropertiesFromThang: (thang) =>
|
generateSpellKeyToSourceMapPropertiesFromThang: (thang) =>
|
||||||
for component in thang.components
|
for component in thang.components
|
||||||
continue unless @componentHasProgrammableMethods component
|
continue unless @componentHasProgrammableMethods component
|
||||||
|
|
||||||
for methodName, method of component.config.programmableMethods
|
for methodName, method of component.config.programmableMethods
|
||||||
spellKey = @generateSpellKeyFromThangIDAndMethodName thang.id, methodName
|
spellKey = @generateSpellKeyFromThangIDAndMethodName thang.id, methodName
|
||||||
|
|
||||||
|
@ -187,9 +186,11 @@ module.exports = class Simulator
|
||||||
@transpileSpell thang, spellKey, methodName
|
@transpileSpell thang, spellKey, methodName
|
||||||
|
|
||||||
generateSpellKeyFromThangIDAndMethodName: (thang, methodName) ->
|
generateSpellKeyFromThangIDAndMethodName: (thang, methodName) ->
|
||||||
spellKeyComponents = [thang.id, methodName]
|
spellKeyComponents = [thang, methodName]
|
||||||
spellKeyComponents[0] = _.string.slugify spellKeyComponents[0]
|
spellKeyComponents[0] = _.string.slugify spellKeyComponents[0]
|
||||||
spellKeyComponents.join '/'
|
spellKey = spellKeyComponents.join '/'
|
||||||
|
spellKey
|
||||||
|
|
||||||
|
|
||||||
createSpellAndAssignName: (spellKey, spellName) ->
|
createSpellAndAssignName: (spellKey, spellName) ->
|
||||||
@spells[spellKey] ?= {}
|
@spells[spellKey] ?= {}
|
||||||
|
@ -202,7 +203,7 @@ module.exports = class Simulator
|
||||||
|
|
||||||
transpileSpell: (thang, spellKey, methodName) ->
|
transpileSpell: (thang, spellKey, methodName) ->
|
||||||
slugifiedThangID = _.string.slugify thang.id
|
slugifiedThangID = _.string.slugify thang.id
|
||||||
source = @currentUserCodeMap[slugifiedThangID]?[methodName] ? ""
|
source = @currentUserCodeMap[[slugifiedThangID,methodName].join '/'] ? ""
|
||||||
@spells[spellKey].thangs[thang.id].aether.transpile source
|
@spells[spellKey].thangs[thang.id].aether.transpile source
|
||||||
|
|
||||||
createAether: (methodName, method) ->
|
createAether: (methodName, method) ->
|
||||||
|
@ -253,12 +254,18 @@ class SimulationTask
|
||||||
|
|
||||||
generateSpellKeyToSourceMap: ->
|
generateSpellKeyToSourceMap: ->
|
||||||
spellKeyToSourceMap = {}
|
spellKeyToSourceMap = {}
|
||||||
|
|
||||||
for session in @rawData.sessions
|
for session in @rawData.sessions
|
||||||
teamSpells = session.teamSpells[session.team]
|
teamSpells = session.teamSpells[session.team]
|
||||||
_.merge spellKeyToSourceMap, _.pick(session.code, teamSpells)
|
teamCode = {}
|
||||||
|
for thangName, thangSpells of session.code
|
||||||
|
for spellName, spell of thangSpells
|
||||||
|
fullSpellName = [thangName,spellName].join '/'
|
||||||
|
if _.contains(teamSpells, fullSpellName)
|
||||||
|
teamCode[fullSpellName]=spell
|
||||||
|
|
||||||
|
_.merge spellKeyToSourceMap, teamCode
|
||||||
commonSpells = session.teamSpells["common"]
|
commonSpells = session.teamSpells["common"]
|
||||||
_.merge spellKeyToSourceMap, _.pick(session.code, commonSpells) if commonSpells?
|
_.merge spellKeyToSourceMap, _.pick(session.code, commonSpells) if commonSpells?
|
||||||
|
|
||||||
|
|
||||||
spellKeyToSourceMap
|
spellKeyToSourceMap
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue