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

63 lines
3.2 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("Drone", test => {
2017-11-29 22:03:58 +00:00
test.case("applies area effects when deployed", check => {
let battle = TestTools.createBattle();
let ship = nn(battle.playing_ship);
TestTools.setShipModel(ship, 100, 0, 10);
2018-03-26 15:30:43 +00:00
let weapon = new DeployDroneAction("testdrone", { power: 2 }, { deploy_distance: 300, drone_radius: 30, drone_effects: [new AttributeEffect("evasion", 15)] });
ship.actions.addCustom(weapon);
2017-11-29 22:03:58 +00:00
let engine = TestTools.addEngine(ship, 1000);
TestTools.actionChain(check, battle, [
[ship, weapon, Target.newFromLocation(150, 50)], // deploy out of effects radius
[ship, engine, Target.newFromLocation(110, 50)], // move out of effects radius
[ship, engine, Target.newFromLocation(130, 50)], // move in effects radius
[ship, weapon, Target.newFromShip(ship)], // recall
[ship, weapon, Target.newFromLocation(130, 70)], // deploy in effects radius
2017-11-29 22:03:58 +00:00
], [
check => {
check.equals(ship.active_effects.count(), 0, "active effects");
check.equals(ship.getValue("power"), 10, "power");
check.equals(battle.drones.count(), 0, "drone count");
},
check => {
check.equals(ship.active_effects.count(), 0, "active effects");
check.equals(ship.getValue("power"), 8, "power");
check.equals(battle.drones.count(), 1, "drone count");
},
check => {
check.equals(ship.active_effects.count(), 0, "active effects");
check.equals(ship.getValue("power"), 7, "power");
check.equals(battle.drones.count(), 1, "drone count");
},
check => {
check.equals(ship.active_effects.count(), 1, "active effects");
check.equals(ship.getValue("power"), 6, "power");
check.equals(battle.drones.count(), 1, "drone count");
},
check => {
check.equals(ship.active_effects.count(), 0, "active effects");
check.equals(ship.getValue("power"), 8, "power");
check.equals(battle.drones.count(), 0, "drone count");
},
check => {
check.equals(ship.active_effects.count(), 1, "active effects");
check.equals(ship.getValue("power"), 6, "power");
check.equals(battle.drones.count(), 1, "drone count");
},
]);
});
2017-05-10 17:48:28 +00:00
2017-10-26 21:47:13 +00:00
test.case("builds a textual description", check => {
2017-05-10 17:48:28 +00:00
let drone = new Drone(new Ship());
2017-11-29 22:03:58 +00:00
check.equals(drone.getDescription(), "While deployed:\n• do nothing");
2017-05-10 17:48:28 +00:00
drone.effects = [
new DamageEffect(5),
2018-03-26 15:30:43 +00:00
new AttributeEffect("evasion", 1)
2017-05-10 17:48:28 +00:00
]
2018-03-26 15:30:43 +00:00
check.equals(drone.getDescription(), "While deployed:\n• do 5 damage\n• evasion +1");
2017-05-10 17:48:28 +00:00
});
2017-02-06 21:46:55 +00:00
});
}