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
|
nextGoalID: 0
|
||||||
|
|
||||||
constructor: (@world, @initialGoals) ->
|
constructor: (@world, @initialGoals, @team) ->
|
||||||
super()
|
super()
|
||||||
@init()
|
@init()
|
||||||
|
|
||||||
|
@ -114,7 +114,9 @@ module.exports = class GoalManager extends CocoClass
|
||||||
|
|
||||||
checkOverallStatus: (ignoreIncomplete=false) ->
|
checkOverallStatus: (ignoreIncomplete=false) ->
|
||||||
overallStatus = null
|
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 = '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 = 'failure' if statuses.length > 0 and 'failure' in statuses
|
||||||
overallStatus
|
overallStatus
|
||||||
|
|
|
@ -211,9 +211,10 @@ module.exports = class PlayLevelView extends View
|
||||||
team ?= 'humans'
|
team ?= 'humans'
|
||||||
me.team = team
|
me.team = team
|
||||||
Backbone.Mediator.publish 'level:team-set', team: team
|
Backbone.Mediator.publish 'level:team-set', team: team
|
||||||
|
@team = team
|
||||||
|
|
||||||
initGoalManager: ->
|
initGoalManager: ->
|
||||||
@goalManager = new GoalManager(@world, @level.get('goals'))
|
@goalManager = new GoalManager(@world, @level.get('goals'), @team)
|
||||||
@god.setGoalManager @goalManager
|
@god.setGoalManager @goalManager
|
||||||
|
|
||||||
insertSubviews: ->
|
insertSubviews: ->
|
||||||
|
|
Reference in a new issue