2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("Maneuver", test => {
|
2018-01-09 19:23:35 +00:00
|
|
|
test.case("uses move-fire simulation to build a list of battle diffs", check => {
|
2017-05-18 21:10:16 +00:00
|
|
|
let battle = new Battle();
|
|
|
|
let ship1 = battle.fleets[0].addShip();
|
2018-01-09 19:23:35 +00:00
|
|
|
let ship2 = battle.fleets[1].addShip();
|
2017-05-18 21:10:16 +00:00
|
|
|
let ship3 = battle.fleets[1].addShip();
|
2018-01-09 19:23:35 +00:00
|
|
|
let ship4 = battle.fleets[1].addShip();
|
2017-05-18 21:10:16 +00:00
|
|
|
ship1.setArenaPosition(0, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship1, 20, 20, 10);
|
2018-01-09 19:23:35 +00:00
|
|
|
ship2.setArenaPosition(500, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship2, 70, 100);
|
2018-01-09 19:23:35 +00:00
|
|
|
ship3.setArenaPosition(560, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship3, 80, 30);
|
2018-01-09 19:23:35 +00:00
|
|
|
ship4.setArenaPosition(640, 0);
|
2018-02-08 15:16:03 +00:00
|
|
|
TestTools.setShipModel(ship4, 30, 30);
|
|
|
|
|
|
|
|
let weapon = TestTools.addWeapon(ship1, 50, 2, 200, 100);
|
|
|
|
let engine = TestTools.addEngine(ship1, 100);
|
2017-05-18 23:22:48 +00:00
|
|
|
|
2018-02-08 15:16:03 +00:00
|
|
|
let maneuver = new Maneuver(ship1, weapon, Target.newFromLocation(530, 0));
|
|
|
|
check.contains(maneuver.effects, new ShipActionUsedDiff(ship1, engine, Target.newFromLocation(331, 0)), "engine use");
|
2018-01-09 19:23:35 +00:00
|
|
|
check.contains(maneuver.effects, new ShipValueDiff(ship1, "power", -4), "engine power");
|
|
|
|
check.contains(maneuver.effects, new ShipMoveDiff(ship1, ship1.location, new ArenaLocationAngle(331, 0), engine), "move");
|
2018-02-08 15:16:03 +00:00
|
|
|
check.contains(maneuver.effects, new ShipActionUsedDiff(ship1, weapon, Target.newFromLocation(530, 0)), "weapon use");
|
2018-01-09 19:23:35 +00:00
|
|
|
check.contains(maneuver.effects, new ProjectileFiredDiff(ship1, weapon, Target.newFromLocation(530, 0)), "weapon power");
|
|
|
|
check.contains(maneuver.effects, new ShipValueDiff(ship1, "power", -2), "weapon power");
|
|
|
|
check.contains(maneuver.effects, new ShipValueDiff(ship2, "shield", -50), "ship2 shield value");
|
|
|
|
check.contains(maneuver.effects, new ShipValueDiff(ship3, "shield", -30), "ship3 shield value");
|
|
|
|
check.contains(maneuver.effects, new ShipValueDiff(ship3, "hull", -20), "ship3 hull value");
|
|
|
|
check.contains(maneuver.effects, new ShipDamageDiff(ship2, 0, 50, 50), "ship2 damage");
|
|
|
|
check.contains(maneuver.effects, new ShipDamageDiff(ship3, 20, 30, 50), "ship3 damage");
|
2017-05-18 23:22:48 +00:00
|
|
|
});
|
2017-05-18 21:10:16 +00:00
|
|
|
});
|
|
|
|
}
|