From b816055f9e9cede6cc429841d9727f51aeb9872d Mon Sep 17 00:00:00 2001 From: Scott Erickson <sderickson@gmail.com> Date: Mon, 19 May 2014 20:50:05 -0700 Subject: [PATCH] Fixed goal states to handle teams. --- app/lib/world/GoalManager.coffee | 6 ++++-- app/views/play/level_view.coffee | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/lib/world/GoalManager.coffee b/app/lib/world/GoalManager.coffee index 7e0e73250..549f4bf30 100644 --- a/app/lib/world/GoalManager.coffee +++ b/app/lib/world/GoalManager.coffee @@ -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 diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index fa04d1fc6..e3a874424 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -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: ->