mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
Added setGoalState
This commit is contained in:
parent
cd4fa9b8c2
commit
e060d4b73d
1 changed files with 10 additions and 0 deletions
|
@ -212,6 +212,16 @@ module.exports = class GoalManager extends CocoClass
|
|||
else
|
||||
state[progressObjectName][thang] = false
|
||||
|
||||
setGoalState: (goalID, status) ->
|
||||
state = @goalStates[goalID]
|
||||
state.status = status
|
||||
if overallStatus = @checkOverallStatus true
|
||||
matchedGoals = (_.find(@goals, {id: goalID}) for goalID, goalState of @goalStates when goalState.status is overallStatus)
|
||||
mostEagerGoal = _.min matchedGoals, 'worldEndsAfter'
|
||||
victory = overallStatus is "success"
|
||||
tentative = overallStatus is "success"
|
||||
@world.endWorld victory, mostEagerGoal.worldEndsAfter, tentative if mostEagerGoal isnt Infinity
|
||||
|
||||
updateGoalState: (goalID, thangID, progressObjectName, frameNumber) ->
|
||||
# A thang has done something related to the goal!
|
||||
# Mark it down and update the goal state.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue