2017-11-14 00:07:06 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("DeployDroneAction", test => {
|
|
|
|
test.case("stores useful information", check => {
|
2018-02-08 15:16:03 +00:00
|
|
|
let ship = new Ship();
|
|
|
|
let action = new DeployDroneAction("testdrone");
|
|
|
|
ship.actions.addCustom(action);
|
|
|
|
|
|
|
|
check.equals(action.code, "testdrone");
|
|
|
|
check.equals(action.getVerb(ship), "Deploy");
|
2017-02-07 00:08:07 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
ship.actions.toggle(action, true);
|
|
|
|
check.equals(action.getVerb(ship), "Recall");
|
2017-02-07 00:08:07 +00:00
|
|
|
});
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("allows to deploy in range", check => {
|
2017-02-07 00:08:07 +00:00
|
|
|
let ship = new Ship();
|
|
|
|
ship.setArenaPosition(0, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
let action = new DeployDroneAction("testdrone", { power: 0 }, { deploy_distance: 8 });
|
|
|
|
ship.actions.addCustom(action);
|
2017-02-07 00:08:07 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkTarget(ship, new Target(8, 0, null)), new Target(8, 0, null));
|
|
|
|
check.equals(action.checkTarget(ship, new Target(12, 0, null)), new Target(8, 0, null));
|
2017-02-07 00:08:07 +00:00
|
|
|
|
|
|
|
let other = new Ship();
|
|
|
|
other.setArenaPosition(8, 0);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(action.checkTarget(ship, new Target(8, 0, other)), null);
|
2017-02-07 00:08:07 +00:00
|
|
|
});
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("deploys a new drone", check => {
|
2017-11-14 00:07:06 +00:00
|
|
|
let battle = TestTools.createBattle();
|
2019-05-19 22:32:15 +00:00
|
|
|
let ship = battle.fleets[0].ships[0];
|
2017-03-07 19:27:46 +00:00
|
|
|
ship.setArenaPosition(0, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship, 100, 0, 3);
|
2017-11-14 00:07:06 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
let action = new DeployDroneAction("testdrone", { power: 2 }, { deploy_distance: 8, drone_radius: 4, drone_effects: [new DamageEffect(50)] });
|
|
|
|
ship.actions.addCustom(action);
|
2017-11-14 00:07:06 +00:00
|
|
|
|
|
|
|
TestTools.actionChain(check, battle, [
|
|
|
|
[ship, action, new Target(5, 0)],
|
|
|
|
], [
|
|
|
|
check => {
|
|
|
|
check.equals(battle.drones.count(), 0, "drones=0");
|
|
|
|
},
|
|
|
|
check => {
|
|
|
|
check.equals(battle.drones.count(), 1, "drones=1");
|
|
|
|
|
|
|
|
let drone = battle.drones.list()[0];
|
|
|
|
check.equals(drone.code, "testdrone");
|
|
|
|
check.same(drone.owner, ship.id);
|
|
|
|
check.equals(drone.x, 5);
|
|
|
|
check.equals(drone.y, 0);
|
|
|
|
check.equals(drone.radius, 4);
|
|
|
|
compare_effects(check, drone.effects, [new DamageEffect(50)]);
|
|
|
|
}
|
|
|
|
])
|
2017-02-07 00:08:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|