mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Some fixes for programmatically generated flag events not polluting session flag history.
This commit is contained in:
parent
85a94df854
commit
f9a7aba5d9
7 changed files with 10 additions and 7 deletions
|
@ -62,7 +62,7 @@ module.exports = class God extends CocoClass
|
|||
|
||||
onTomeCast: (e) ->
|
||||
@lastSubmissionCount = e.submissionCount
|
||||
@lastFlagHistory = e.flagHistory
|
||||
@lastFlagHistory = (flag for flag in e.flagHistory when flag.source isnt 'code')
|
||||
@createWorld e.spells, e.preload, e.realTime
|
||||
|
||||
createWorld: (spells, preload, realTime) ->
|
||||
|
|
|
@ -138,8 +138,9 @@ module.exports = class LevelBus extends Bus
|
|||
return unless @onPoint()
|
||||
# Record the flag history.
|
||||
state = @session.get('state')
|
||||
return if _.isEqual state.flagHistory, e.world.flagHistory
|
||||
state.flagHistory = e.world.flagHistory
|
||||
flagHistory = (flag for flag in e.world.flagHistory when flag.source isnt 'code')
|
||||
return if _.isEqual state.flagHistory, flagHistory
|
||||
state.flagHistory = flagHistory
|
||||
@changedSessionProperties.state = true
|
||||
@session.set('state', state)
|
||||
@saveSession()
|
||||
|
|
|
@ -558,7 +558,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@playing = false # Will start when countdown is done.
|
||||
if @heroLank
|
||||
@previousCameraZoom = @camera.zoom
|
||||
@camera.zoomTo @heroLank.sprite, 4, 3000
|
||||
@camera.zoomTo @heroLank.sprite, 2, 3000
|
||||
|
||||
onRealTimePlaybackEnded: (e) ->
|
||||
return unless @realTime
|
||||
|
|
|
@ -126,6 +126,7 @@ _.extend LevelSessionSchema.properties,
|
|||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
source: {type: 'string', enum: ['click']} # Do not store 'code' flag events in the session.
|
||||
|
||||
code:
|
||||
type: 'object'
|
||||
|
|
|
@ -74,6 +74,7 @@ module.exports =
|
|||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
source: {type: 'string', enum: ['click', 'code']}
|
||||
|
||||
'level:next-game-pressed': c.object {}
|
||||
|
||||
|
|
|
@ -688,7 +688,6 @@ forest = [
|
|||
type: 'hero'
|
||||
id: 'coinucopia'
|
||||
description: 'Start playing in real-time with input flags as you collect gold coins!'
|
||||
disabled: not me.isAdmin()
|
||||
nextLevels:
|
||||
continue: 'copper-meadows'
|
||||
x: 77.54
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = class LevelFlagsView extends CocoView
|
|||
pos = x: e.worldPos.x, y: e.worldPos.y
|
||||
delay = if @realTimeFlags then multiplayerFlagDelay else 0
|
||||
now = @world.dt * @world.frames.length
|
||||
flag = player: me.id, team: me.team, color: @flagColor, pos: pos, time: now + delay, active: true
|
||||
flag = player: me.id, team: me.team, color: @flagColor, pos: pos, time: now + delay, active: true, source: 'click'
|
||||
@flags[@flagColor] = flag
|
||||
@flagHistory.push flag
|
||||
@realTimeFlags?.create flag
|
||||
|
@ -74,7 +74,7 @@ module.exports = class LevelFlagsView extends CocoView
|
|||
delete @flags[e.color]
|
||||
delay = if @realTimeFlags then multiplayerFlagDelay else 0
|
||||
now = @world.dt * @world.frames.length
|
||||
flag = player: me.id, team: me.team, color: e.color, time: now + delay, active: false
|
||||
flag = player: me.id, team: me.team, color: e.color, time: now + delay, active: false, source: 'click'
|
||||
@flagHistory.push flag
|
||||
Backbone.Mediator.publish 'level:flag-updated', flag
|
||||
#console.log e.color, 'deleted at time', flag.time
|
||||
|
@ -104,6 +104,7 @@ module.exports = class LevelFlagsView extends CocoView
|
|||
pos: e.get('pos')
|
||||
time: e.get('time')
|
||||
active: e.get('active')
|
||||
#source: 'click'? e.get('source')? nothing?
|
||||
@flagHistory.push flag
|
||||
Backbone.Mediator.publish 'level:flag-updated', flag
|
||||
|
||||
|
|
Loading…
Reference in a new issue