2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("ExclusionAreas", test => {
|
|
|
|
test.case("constructs from a ship or battle", check => {
|
2017-08-17 17:51:22 +00:00
|
|
|
let battle = new Battle();
|
|
|
|
battle.border = 17;
|
|
|
|
battle.ship_separation = 31;
|
|
|
|
let ship1 = battle.fleets[0].addShip();
|
|
|
|
ship1.setArenaPosition(12, 5);
|
|
|
|
let ship2 = battle.fleets[1].addShip();
|
|
|
|
ship2.setArenaPosition(43, 89);
|
|
|
|
|
|
|
|
let exclusion = ExclusionAreas.fromBattle(battle);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 31);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(12, 5), new ArenaLocationAngle(43, 89)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
|
|
|
|
exclusion = ExclusionAreas.fromBattle(battle, [ship1], 120);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 120);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(43, 89)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
|
|
|
|
exclusion = ExclusionAreas.fromBattle(battle, [ship2], 10);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 31);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(12, 5)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
|
|
|
|
exclusion = ExclusionAreas.fromShip(ship1);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 31);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(43, 89)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
|
|
|
|
exclusion = ExclusionAreas.fromShip(ship2, 99);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 99);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(12, 5)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
|
|
|
|
exclusion = ExclusionAreas.fromShip(ship2, 10, false);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(exclusion.hard_border, 17);
|
|
|
|
check.equals(exclusion.effective_obstacle, 31);
|
|
|
|
check.equals(exclusion.obstacles, [new ArenaLocationAngle(12, 5), new ArenaLocationAngle(43, 89)]);
|
2017-08-17 17:51:22 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|