2017-11-14 00:07:06 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("ToggleAction", test => {
|
|
|
|
test.case("returns correct targetting mode", check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let action = new ToggleAction("testtoggle");
|
|
|
|
let ship = new Ship();
|
|
|
|
ship.actions.addCustom(action);
|
2017-10-03 16:11:30 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
check.same(action.getTargettingMode(ship), ActionTargettingMode.SELF_CONFIRM);
|
2017-10-03 16:11:30 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
ship.actions.toggle(action, true);
|
|
|
|
check.same(action.getTargettingMode(ship), ActionTargettingMode.SELF_CONFIRM);
|
2017-10-03 16:11:30 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
action = new ToggleAction("testtoggle", { radius: 50 });
|
|
|
|
ship.actions.addCustom(action);
|
|
|
|
check.same(action.getTargettingMode(ship), ActionTargettingMode.SURROUNDINGS);
|
|
|
|
|
|
|
|
ship.actions.toggle(action, true);
|
|
|
|
check.same(action.getTargettingMode(ship), ActionTargettingMode.SELF_CONFIRM);
|
2017-10-03 16:11:30 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("collects impacted ships", check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let action = new ToggleAction("testtoggle", { radius: 50 });
|
2017-10-03 16:11:30 +00:00
|
|
|
let battle = new Battle();
|
2018-07-17 14:17:46 +00:00
|
|
|
battle.grid = new PixelArenaGrid();
|
2017-10-03 16:11:30 +00:00
|
|
|
let ship1 = battle.fleets[0].addShip();
|
|
|
|
ship1.setArenaPosition(0, 0);
|
|
|
|
let ship2 = battle.fleets[0].addShip();
|
|
|
|
ship2.setArenaPosition(0, 30);
|
|
|
|
let ship3 = battle.fleets[0].addShip();
|
|
|
|
ship3.setArenaPosition(0, 60);
|
|
|
|
|
|
|
|
let result = action.getImpactedShips(ship1, Target.newFromShip(ship1));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(result, [ship1, ship2]);
|
2017-10-03 16:11:30 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|