2014-01-03 13:32:13 -05:00
|
|
|
xdescribe 'GoalManager', ->
|
2014-06-30 22:16:26 -04:00
|
|
|
GoalManager = require 'lib/world/GoalManager'
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
liveState =
|
|
|
|
stateMap:
|
2014-06-30 22:16:26 -04:00
|
|
|
'1': {health: 10}
|
|
|
|
'2': {health: 5}
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
halfLiveState =
|
|
|
|
stateMap:
|
2014-06-30 22:16:26 -04:00
|
|
|
'1': {health: 0}
|
|
|
|
'2': {health: 5}
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
deadState =
|
|
|
|
stateMap:
|
2014-06-30 22:16:26 -04:00
|
|
|
'1': {health: 0}
|
|
|
|
'2': {health: -5}
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
it 'can tell when everyone is dead', ->
|
|
|
|
gm = new GoalManager(1)
|
|
|
|
world =
|
|
|
|
frames: [liveState, liveState, liveState]
|
|
|
|
gm.setWorld(world)
|
2014-06-30 22:16:26 -04:00
|
|
|
|
|
|
|
goal = {id: 'die', name: 'Kill Everyone', killGuy: ['1', '2']}
|
2014-01-03 13:32:13 -05:00
|
|
|
gm.addGoal goal
|
2014-06-30 22:16:26 -04:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
expect(gm.goalStates['die'].complete).toBe(false)
|
|
|
|
|
|
|
|
world.frames.push(deadState)
|
|
|
|
world.frames.push(deadState)
|
|
|
|
gm.setWorld(world)
|
|
|
|
expect(gm.goalStates['die'].complete).toBe(true)
|
|
|
|
expect(gm.goalStates['die'].frameCompleted).toBe(3)
|
|
|
|
|
|
|
|
it 'can tell when someone is saved', ->
|
|
|
|
gm = new GoalManager(1)
|
|
|
|
world =
|
|
|
|
frames: [liveState, liveState, liveState, deadState, deadState]
|
|
|
|
gm.setWorld(world)
|
2014-06-30 22:16:26 -04:00
|
|
|
|
|
|
|
goal = {id: 'live', name: 'Save guy 2', saveGuy: '2'}
|
2014-01-03 13:32:13 -05:00
|
|
|
gm.addGoal goal
|
2014-06-30 22:16:26 -04:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
expect(gm.goalStates['live'].complete).toBe(false)
|
|
|
|
world =
|
|
|
|
frames: [liveState, liveState, liveState, liveState, liveState]
|
|
|
|
gm.setWorld(world)
|
|
|
|
expect(gm.goalStates['live'].complete).toBe(true)
|
|
|
|
|
|
|
|
# world.frames.push(deadState)
|
|
|
|
# world.frames.push(deadState)
|
|
|
|
# gm.setWorld(world)
|
|
|
|
# expect(gm.goalStates['live'].complete).toBe(true)
|
2014-06-30 22:16:26 -04:00
|
|
|
# expect(gm.goalStates['live'].frameCompleted).toBe(3)
|