2017-11-14 00:07:06 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("BaseAction", test => {
|
2017-12-20 21:21:12 +00:00
|
|
|
test.case("may be applied and reverted", check => {
|
|
|
|
let battle = TestTools.createBattle();
|
2019-05-19 22:32:15 +00:00
|
|
|
let ship = battle.fleets[0].ships[0];
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship, 100, 0, 10);
|
|
|
|
let action = TestTools.addWeapon(ship, 0, 3, 100, 50);
|
|
|
|
action.configureCooldown(2, 1);
|
2017-12-20 21:21:12 +00:00
|
|
|
|
|
|
|
TestTools.actionChain(check, battle, [
|
|
|
|
[ship, action, Target.newFromLocation(0, 0)],
|
|
|
|
[ship, action, Target.newFromLocation(0, 0)],
|
|
|
|
], [
|
|
|
|
check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let cooldown = ship.actions.getCooldown(action);
|
|
|
|
check.equals(cooldown.uses, 0, "uses");
|
|
|
|
check.equals(cooldown.heat, 0, "heat");
|
2017-12-20 21:21:12 +00:00
|
|
|
},
|
|
|
|
check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let cooldown = ship.actions.getCooldown(action);
|
|
|
|
check.equals(cooldown.uses, 1, "uses");
|
|
|
|
check.equals(cooldown.heat, 0, "heat");
|
2017-12-20 21:21:12 +00:00
|
|
|
},
|
|
|
|
check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let cooldown = ship.actions.getCooldown(action);
|
|
|
|
check.equals(cooldown.uses, 2, "uses");
|
|
|
|
check.equals(cooldown.heat, 1, "heat");
|
2017-12-20 21:21:12 +00:00
|
|
|
},
|
|
|
|
]);
|
|
|
|
})
|
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
test.case("checks against overheat", check => {
|
|
|
|
let action = new BaseAction("test");
|
2017-05-16 23:12:05 +00:00
|
|
|
let ship = new Ship();
|
2018-02-08 15:16:03 +00:00
|
|
|
ship.actions.addCustom(action);
|
|
|
|
let cooldown = ship.actions.getCooldown(action);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), null);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.use();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), null);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.configure(2, 3);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), null);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.use();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), null);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.use();
|
2018-04-04 16:17:10 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), ActionUnavailability.OVERHEATED);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.cool();
|
2018-04-04 16:17:10 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), ActionUnavailability.OVERHEATED);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.cool();
|
2018-04-04 16:17:10 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), ActionUnavailability.OVERHEATED);
|
2017-05-16 23:12:05 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
cooldown.cool();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkCannotBeApplied(ship), null);
|
2017-10-01 16:33:48 +00:00
|
|
|
})
|
2018-03-29 22:57:53 +00:00
|
|
|
|
|
|
|
test.case("helps applying a targetting filter", check => {
|
|
|
|
let fleet1 = new Fleet();
|
|
|
|
let fleet2 = new Fleet();
|
|
|
|
let ship1a = fleet1.addShip();
|
|
|
|
let ship1b = fleet1.addShip();
|
|
|
|
let ship2a = fleet2.addShip();
|
|
|
|
let ship2b = fleet2.addShip();
|
|
|
|
let ships = [ship1a, ship1b, ship2a, ship2b];
|
|
|
|
|
2019-11-22 10:02:53 +00:00
|
|
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionImpactFilter.ALL),
|
2018-03-29 22:57:53 +00:00
|
|
|
[ship1a, ship1b, ship2a, ship2b], "ALL");
|
2019-11-22 10:02:53 +00:00
|
|
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionImpactFilter.ALL_BUT_SELF),
|
2018-03-29 22:57:53 +00:00
|
|
|
[ship1b, ship2a, ship2b], "ALL_BUT_SELF");
|
2019-11-22 10:02:53 +00:00
|
|
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionImpactFilter.ALLIES),
|
2018-03-29 22:57:53 +00:00
|
|
|
[ship1a, ship1b], "ALLIES");
|
2019-11-22 10:02:53 +00:00
|
|
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionImpactFilter.ALLIES_BUT_SELF),
|
2018-03-29 22:57:53 +00:00
|
|
|
[ship1b], "ALLIES_BUT_SELF");
|
2019-11-22 10:02:53 +00:00
|
|
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionImpactFilter.ENEMIES),
|
2018-03-29 22:57:53 +00:00
|
|
|
[ship2a, ship2b], "ENEMIES");
|
|
|
|
});
|
2015-02-26 00:00:00 +00:00
|
|
|
});
|
|
|
|
}
|