mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Fixed #759.
This commit is contained in:
parent
4bd058d1be
commit
3325c55c3f
2 changed files with 11 additions and 23 deletions
|
@ -83,9 +83,7 @@ module.exports = class Simulator extends CocoClass
|
|||
@setupGodSpells()
|
||||
|
||||
setupGoalManager: ->
|
||||
@god.goalManager = new GoalManager @world
|
||||
@god.goalManager.goals = @god.level.goals
|
||||
@god.goalManager.goalStates = @manuallyGenerateGoalStates()
|
||||
@god.goalManager = new GoalManager @world, @level.get 'goals'
|
||||
|
||||
commenceSimulationAndSetupCallback: ->
|
||||
@god.createWorld()
|
||||
|
@ -157,32 +155,21 @@ module.exports = class Simulator extends CocoClass
|
|||
return taskResults
|
||||
|
||||
calculateSessionRank: (sessionID, goalStates, teamSessionMap) ->
|
||||
humansDestroyed = goalStates["destroy-humans"].status is "success"
|
||||
ogresDestroyed = goalStates["destroy-ogres"].status is "success"
|
||||
if humansDestroyed is ogresDestroyed
|
||||
ogreGoals = (goalState for key, goalState of goalStates when goalState.team is 'ogres')
|
||||
humanGoals = (goalState for key, goalState of goalStates when goalState.team is 'humans')
|
||||
ogresWon = _.all ogreGoals, {status: 'success'}
|
||||
humansWon = _.all humanGoals, {status: 'success'}
|
||||
if ogresWon is humansWon
|
||||
return 0
|
||||
else if humansDestroyed and teamSessionMap["ogres"] is sessionID
|
||||
else if ogresWon and teamSessionMap["ogres"] is sessionID
|
||||
return 0
|
||||
else if humansDestroyed and teamSessionMap["ogres"] isnt sessionID
|
||||
else if ogresWon and teamSessionMap["ogres"] isnt sessionID
|
||||
return 1
|
||||
else if ogresDestroyed and teamSessionMap["humans"] is sessionID
|
||||
else if humansWon and teamSessionMap["humans"] is sessionID
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
||||
manuallyGenerateGoalStates: ->
|
||||
goalStates =
|
||||
"destroy-humans":
|
||||
keyFrame: 0
|
||||
killed:
|
||||
"Human Base": false
|
||||
status: "incomplete"
|
||||
"destroy-ogres":
|
||||
keyFrame:0
|
||||
killed:
|
||||
"Ogre Base": false
|
||||
status: "incomplete"
|
||||
|
||||
setupGodSpells: ->
|
||||
@generateSpellsObject()
|
||||
@god.spells = @spells
|
||||
|
|
|
@ -95,7 +95,7 @@ module.exports = class GoalManager extends CocoClass
|
|||
return if @goalStates[goal.id]?
|
||||
@goals.push(goal)
|
||||
goal.isPositive = @goalIsPositive goal.id
|
||||
@goalStates[goal.id] = {status: 'incomplete', keyFrame: 0}
|
||||
@goalStates[goal.id] = {status: 'incomplete', keyFrame: 0, team: goal.team}
|
||||
@notifyGoalChanges()
|
||||
return unless goal.notificationGoal
|
||||
f = (channel) => (event) => @onNote(channel, event)
|
||||
|
@ -123,6 +123,7 @@ module.exports = class GoalManager extends CocoClass
|
|||
state = {
|
||||
status: null # should eventually be either 'success', 'failure', or 'incomplete'
|
||||
keyFrame: 0 # when it became a 'success' or 'failure'
|
||||
team: goal.team
|
||||
}
|
||||
@initGoalState(state, [goal.killThangs, goal.saveThangs], 'killed')
|
||||
for getTo in goal.getAllToLocations ? []
|
||||
|
|
Loading…
Reference in a new issue