Trying to get session code merging to work again.

This commit is contained in:
Nick Winter 2014-02-25 14:46:48 -08:00
parent b86c32c3e2
commit 3c5902a1d2
4 changed files with 14 additions and 5 deletions

View file

@ -113,7 +113,9 @@ module.exports = class LevelBus extends Bus
@changedSessionProperties.teamSpells = true
@session.set({'teamSpells': @teamSpellMap})
@saveSession()
@onSpellChanged e # Save the new spell to the session, too.
console.log spellTeam, me.team, e.spell.spellKey
if spellTeam is me.team
@onSpellChanged e # Save the new spell to the session, too.
onScriptStateChanged: (e) ->
return unless @onPoint()

View file

@ -220,7 +220,7 @@ module.exports = class Simulator
#functionParameters: # TODOOOOO
if methodName is 'hear'
aetherOptions.functionParameters = ['speaker', 'message', 'data']
console.log "creating aether with options", aetherOptions
#console.log "creating aether with options", aetherOptions
return new Aether aetherOptions
class SimulationTask

View file

@ -342,4 +342,5 @@ module.exports = class HUDView extends View
@addMoreMessage = null
@animateEnterButton = null
clearInterval(@messageInterval) if @messageInterval
clearTimeout @hintNextSelectionTimeout if @hintNextSelectionTimeout
super()

View file

@ -135,17 +135,23 @@ module.exports = class PlayLevelView extends View
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
opponentSpells = []
for spellTeam, spells of @session.get('teamSpells') or {}
for spellTeam, spells of @session.get('teamSpells') ? otherSession?.get('teamSpells') ? {}
continue if spellTeam is team or not team
opponentSpells = opponentSpells.concat spells
otherSession = @levelLoader.opponentSession
opponentCode = otherSession?.get('submittedCode') or {}
console.log "otherSession", otherSession, "opponentSpells", opponentSpells
myCode = @session.get('code') or {}
for spell in opponentSpells
c = opponentCode[spell]
if c then myCode[spell] = c else delete myCode[spell]
[thang, spell] = spell.split '/'
c = opponentCode[thang]?[spell]
console.log "Got opponent code", c, "for", spell, "and had my code", myCode[spell]
myCode[thang] ?= {}
if c then myCode[thang][spell] = c else delete myCode[thang][spell]
console.log "Going to set session code from", _.cloneDeep(myCode)
@session.set('code', myCode)
console.log "Just set session code to", _.cloneDeep(@session.get('code'))
if @session.get('multiplayer') and otherSession?
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
@session.set 'multiplayer', false