2017-05-25 23:09:29 +00:00
|
|
|
module TS.SpaceTac.Specs {
|
|
|
|
describe("BattleStats", function () {
|
|
|
|
it("collects stats", function () {
|
|
|
|
let stats = new BattleStats();
|
|
|
|
expect(stats.stats).toEqual({});
|
|
|
|
|
|
|
|
stats.addStat("Test", 1, true);
|
|
|
|
expect(stats.stats).toEqual({ Test: [1, 0] });
|
|
|
|
|
|
|
|
stats.addStat("Test", 1, true);
|
|
|
|
expect(stats.stats).toEqual({ Test: [2, 0] });
|
|
|
|
|
|
|
|
stats.addStat("Test", 1, false);
|
|
|
|
expect(stats.stats).toEqual({ Test: [2, 1] });
|
|
|
|
|
|
|
|
stats.addStat("Other Test", 10, true);
|
|
|
|
expect(stats.stats).toEqual({ Test: [2, 1], "Other Test": [10, 0] });
|
|
|
|
})
|
|
|
|
|
|
|
|
it("collects damage dealt", function () {
|
|
|
|
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-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({});
|
|
|
|
|
|
|
|
battle.log.add(new DamageEvent(attacker, 10, 12));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Damage dealt": [0, 22] });
|
|
|
|
|
|
|
|
battle.log.add(new DamageEvent(defender, 40, 0));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Damage dealt": [40, 22] });
|
|
|
|
|
|
|
|
battle.log.add(new DamageEvent(attacker, 5, 4));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Damage dealt": [40, 31] });
|
|
|
|
})
|
|
|
|
|
|
|
|
it("collects distance moved", function () {
|
|
|
|
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-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({});
|
|
|
|
|
2017-05-30 16:24:55 +00:00
|
|
|
battle.log.add(new MoveEvent(attacker, new ArenaLocationAngle(0, 0), new ArenaLocationAngle(10, 0)));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Move distance (km)": [10, 0] });
|
|
|
|
|
2017-05-30 16:24:55 +00:00
|
|
|
battle.log.add(new MoveEvent(defender, new ArenaLocationAngle(10, 5), new ArenaLocationAngle(10, 63)));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Move distance (km)": [10, 58] });
|
|
|
|
})
|
|
|
|
|
|
|
|
it("collects deployed drones", function () {
|
|
|
|
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-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({});
|
|
|
|
|
|
|
|
battle.log.add(new DroneDeployedEvent(new Drone(attacker)));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Drones deployed": [1, 0] });
|
|
|
|
|
|
|
|
battle.log.add(new DroneDeployedEvent(new Drone(defender)));
|
2017-05-29 23:15:32 +00:00
|
|
|
stats.processLog(battle.log, battle.fleets[0]);
|
2017-05-25 23:09:29 +00:00
|
|
|
expect(stats.stats).toEqual({ "Drones deployed": [1, 1] });
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|