1
0
Fork 0
spacetac/src/core/Player.spec.ts

38 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac {
2017-10-26 21:47:13 +00:00
testing("Player", test => {
test.case("keeps track of visited locations", check => {
2017-01-29 18:34:38 +00:00
let player = new Player();
let universe = new Universe();
let star1 = universe.addStar();
let star2 = universe.addStar();
let loc1a = star1.addLocation(StarLocationType.PLANET);
let loc1b = star1.addLocation(StarLocationType.PLANET);
let loc2a = star2.addLocation(StarLocationType.PLANET);
let loc2b = star2.addLocation(StarLocationType.PLANET);
universe.updateLocations();
2017-01-29 18:34:38 +00:00
function checkVisited(s1 = false, s2 = false, v1a = false, v1b = false, v2a = false, v2b = false) {
2017-10-26 21:47:13 +00:00
check.same(player.hasVisitedSystem(star1), s1);
check.same(player.hasVisitedSystem(star2), s2);
check.same(player.hasVisitedLocation(loc1a), v1a);
check.same(player.hasVisitedLocation(loc1b), v1b);
check.same(player.hasVisitedLocation(loc2a), v2a);
check.same(player.hasVisitedLocation(loc2b), v2b);
2017-01-29 18:34:38 +00:00
}
checkVisited();
player.fleet.setLocation(loc1b);
2017-01-29 18:34:38 +00:00
checkVisited(true, false, false, true, false, false);
player.fleet.setLocation(loc1a);
2017-01-29 18:34:38 +00:00
checkVisited(true, false, true, true, false, false);
player.fleet.setLocation(loc2a);
2017-01-29 18:34:38 +00:00
checkVisited(true, true, true, true, true, false);
player.fleet.setLocation(loc2a);
2017-01-29 18:34:38 +00:00
checkVisited(true, true, true, true, true, false);
});
});
}