mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-20 18:10:44 -04:00
Fixed goal states to handle teams.
This commit is contained in:
parent
8b5014a053
commit
b816055f9e
2 changed files with 6 additions and 3 deletions
app
|
@ -15,7 +15,7 @@ module.exports = class GoalManager extends CocoClass
|
|||
|
||||
nextGoalID: 0
|
||||
|
||||
constructor: (@world, @initialGoals) ->
|
||||
constructor: (@world, @initialGoals, @team) ->
|
||||
super()
|
||||
@init()
|
||||
|
||||
|
@ -114,7 +114,9 @@ module.exports = class GoalManager extends CocoClass
|
|||
|
||||
checkOverallStatus: (ignoreIncomplete=false) ->
|
||||
overallStatus = null
|
||||
statuses = if @goalStates then (val.status for key, val of @goalStates) else []
|
||||
goals = if @goalStates then _.values @goalStates else []
|
||||
goals = (g for g in goals when g.team in [undefined, @team]) if @team
|
||||
statuses = if @goalStates then (goal.status for goal in goals) else []
|
||||
overallStatus = 'success' if statuses.length > 0 and _.every(statuses, (s) -> s is 'success' or (ignoreIncomplete and s is null))
|
||||
overallStatus = 'failure' if statuses.length > 0 and 'failure' in statuses
|
||||
overallStatus
|
||||
|
|
|
@ -211,9 +211,10 @@ module.exports = class PlayLevelView extends View
|
|||
team ?= 'humans'
|
||||
me.team = team
|
||||
Backbone.Mediator.publish 'level:team-set', team: team
|
||||
@team = team
|
||||
|
||||
initGoalManager: ->
|
||||
@goalManager = new GoalManager(@world, @level.get('goals'))
|
||||
@goalManager = new GoalManager(@world, @level.get('goals'), @team)
|
||||
@god.setGoalManager @goalManager
|
||||
|
||||
insertSubviews: ->
|
||||
|
|
Loading…
Reference in a new issue