mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-24 21:13:35 -04:00
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
|
||||
|
||||
denormalizeSession: ->
|
||||
return if @session.get 'levelName'
|
||||
return if @sessionDenormalized
|
||||
patch =
|
||||
'levelName': @level.get('name')
|
||||
'levelID': @level.get('slug') or @level.id
|
||||
if me.id is @session.get 'creator'
|
||||
patch.creatorName = me.get('name')
|
||||
|
||||
@session.set key, value for key, value of patch
|
||||
tempSession = new LevelSession _id: @session.id
|
||||
tempSession.save(patch, {patch: true})
|
||||
for key, value of patch
|
||||
if @session.get(key) is value
|
||||
delete patch[key]
|
||||
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
|
||||
|
||||
# World init
|
||||
|
|
|
@ -141,17 +141,13 @@ module.exports = class PlayLevelView extends View
|
|||
|
||||
otherSession = @levelLoader.opponentSession
|
||||
opponentCode = otherSession?.get('submittedCode') or {}
|
||||
console.log "otherSession", otherSession, "opponentSpells", opponentSpells
|
||||
myCode = @session.get('code') or {}
|
||||
for spell in opponentSpells
|
||||
[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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue