2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("BattleStats", test => {
|
|
|
|
test.case("collects stats", check => {
|
2017-05-25 23:09:29 +00:00
|
|
|
let stats = new BattleStats();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, {});
|
2017-05-25 23:09:29 +00:00
|
|
|
|
|
|
|
stats.addStat("Test", 1, true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { Test: [1, 0] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
|
|
|
stats.addStat("Test", 1, true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { Test: [2, 0] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
|
|
|
stats.addStat("Test", 1, false);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { Test: [2, 1] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
|
|
|
stats.addStat("Other Test", 10, true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { Test: [2, 1], "Other Test": [10, 0] });
|
2017-05-25 23:09:29 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("collects damage dealt", check => {
|
2017-05-25 23:09:29 +00:00
|
|
|
let stats = new BattleStats();
|
|
|
|
let battle = new Battle();
|
|
|
|
let attacker = battle.fleets[0].addShip();
|
|
|
|
let defender = battle.fleets[1].addShip();
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, {});
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new ShipDamageDiff(attacker, 10, 12));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Damage dealt": [0, 22] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new ShipDamageDiff(defender, 40, 0));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Damage dealt": [40, 22] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new ShipDamageDiff(attacker, 5, 4));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Damage dealt": [40, 31] });
|
2017-05-25 23:09:29 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("collects distance moved", check => {
|
2017-05-25 23:09:29 +00:00
|
|
|
let stats = new BattleStats();
|
|
|
|
let battle = new Battle();
|
|
|
|
let attacker = battle.fleets[0].addShip();
|
|
|
|
let defender = battle.fleets[1].addShip();
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, {});
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new ShipMoveDiff(attacker, new ArenaLocationAngle(0, 0), new ArenaLocationAngle(10, 0)));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Move distance (km)": [10, 0] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new ShipMoveDiff(defender, new ArenaLocationAngle(10, 5), new ArenaLocationAngle(10, 63)));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Move distance (km)": [10, 58] });
|
2017-05-25 23:09:29 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("collects deployed drones", check => {
|
2017-05-25 23:09:29 +00:00
|
|
|
let stats = new BattleStats();
|
|
|
|
let battle = new Battle();
|
|
|
|
let attacker = battle.fleets[0].addShip();
|
|
|
|
let defender = battle.fleets[1].addShip();
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, {});
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new DroneDeployedDiff(new Drone(attacker)));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Drones deployed": [1, 0] });
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.log.add(new DroneDeployedDiff(new Drone(defender)));
|
2017-09-14 22:24:53 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0], true);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(stats.stats, { "Drones deployed": [1, 1] });
|
2017-05-25 23:09:29 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|