Re-denormalize session if things have changed. Removed some logs.
This commit is contained in:
parent
0fd1c03b7f
commit
172242d226
2 changed files with 8 additions and 9 deletions
app
|
@ -110,16 +110,19 @@ module.exports = class LevelLoader extends CocoClass
|
||||||
@updateCompleted = true
|
@updateCompleted = true
|
||||||
|
|
||||||
denormalizeSession: ->
|
denormalizeSession: ->
|
||||||
return if @session.get 'levelName'
|
return if @sessionDenormalized
|
||||||
patch =
|
patch =
|
||||||
'levelName': @level.get('name')
|
'levelName': @level.get('name')
|
||||||
'levelID': @level.get('slug') or @level.id
|
'levelID': @level.get('slug') or @level.id
|
||||||
if me.id is @session.get 'creator'
|
if me.id is @session.get 'creator'
|
||||||
patch.creatorName = me.get('name')
|
patch.creatorName = me.get('name')
|
||||||
|
for key, value of patch
|
||||||
@session.set key, value for key, value of patch
|
if @session.get(key) is value
|
||||||
tempSession = new LevelSession _id: @session.id
|
delete patch[key]
|
||||||
tempSession.save(patch, {patch: true})
|
unless _.isEmpty patch
|
||||||
|
@session.set key, value for key, value of patch
|
||||||
|
tempSession = new LevelSession _id: @session.id
|
||||||
|
tempSession.save(patch, {patch: true})
|
||||||
@sessionDenormalized = true
|
@sessionDenormalized = true
|
||||||
|
|
||||||
# World init
|
# World init
|
||||||
|
|
|
@ -141,17 +141,13 @@ module.exports = class PlayLevelView extends View
|
||||||
|
|
||||||
otherSession = @levelLoader.opponentSession
|
otherSession = @levelLoader.opponentSession
|
||||||
opponentCode = otherSession?.get('submittedCode') or {}
|
opponentCode = otherSession?.get('submittedCode') or {}
|
||||||
console.log "otherSession", otherSession, "opponentSpells", opponentSpells
|
|
||||||
myCode = @session.get('code') or {}
|
myCode = @session.get('code') or {}
|
||||||
for spell in opponentSpells
|
for spell in opponentSpells
|
||||||
[thang, spell] = spell.split '/'
|
[thang, spell] = spell.split '/'
|
||||||
c = opponentCode[thang]?[spell]
|
c = opponentCode[thang]?[spell]
|
||||||
console.log "Got opponent code", c, "for", spell, "and had my code", myCode[spell]
|
|
||||||
myCode[thang] ?= {}
|
myCode[thang] ?= {}
|
||||||
if c then myCode[thang][spell] = c else delete myCode[thang][spell]
|
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)
|
@session.set('code', myCode)
|
||||||
console.log "Just set session code to", _.cloneDeep(@session.get('code'))
|
|
||||||
if @session.get('multiplayer') and otherSession?
|
if @session.get('multiplayer') and otherSession?
|
||||||
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
|
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
|
||||||
@session.set 'multiplayer', false
|
@session.set 'multiplayer', false
|
||||||
|
|
Reference in a new issue