diff --git a/src/core/BattleStats.spec.ts b/src/core/BattleStats.spec.ts index c4d128b..63ba336 100644 --- a/src/core/BattleStats.spec.ts +++ b/src/core/BattleStats.spec.ts @@ -25,17 +25,17 @@ module TK.SpaceTac.Specs { stats.processLog(battle.log, battle.fleets[0]); check.equals(stats.stats, {}); - battle.log.add(new ShipDamageDiff(attacker, 1, 3, 2)); + battle.log.add(new ShipDamageDiff(defender, 1, 3, 2)); stats.processLog(battle.log, battle.fleets[0], true); - check.equals(stats.stats, { "Damage to hull": [0, 1], "Damage shielded": [0, 3], "Damage evaded": [0, 2] }); + check.equals(stats.stats, { "Damage taken": [0, 1], "Damage shielded": [0, 3], "Damage evaded": [0, 2] }); - battle.log.add(new ShipDamageDiff(defender, 2, 1, 3)); + battle.log.add(new ShipDamageDiff(attacker, 2, 1, 3)); stats.processLog(battle.log, battle.fleets[0], true); - check.equals(stats.stats, { "Damage to hull": [2, 1], "Damage shielded": [1, 3], "Damage evaded": [3, 2] }); + check.equals(stats.stats, { "Damage taken": [2, 1], "Damage shielded": [1, 3], "Damage evaded": [3, 2] }); - battle.log.add(new ShipDamageDiff(attacker, 1, 1, 1)); + battle.log.add(new ShipDamageDiff(defender, 1, 1, 1)); stats.processLog(battle.log, battle.fleets[0], true); - check.equals(stats.stats, { "Damage to hull": [2, 2], "Damage shielded": [1, 4], "Damage evaded": [3, 3] }); + check.equals(stats.stats, { "Damage taken": [2, 2], "Damage shielded": [1, 4], "Damage evaded": [3, 3] }); }) test.case("collects distance moved", check => { diff --git a/src/core/BattleStats.ts b/src/core/BattleStats.ts index b8cabc2..9f2d4e1 100644 --- a/src/core/BattleStats.ts +++ b/src/core/BattleStats.ts @@ -37,7 +37,7 @@ module TK.SpaceTac { /** * Process a battle log */ - processLog(log: BattleLog, attacker: Fleet, clear = false) { + processLog(log: BattleLog, attacker: Fleet, clear = true) { if (clear) { this.stats = {}; } @@ -49,9 +49,9 @@ module TK.SpaceTac { let diff_ship = diff.ship_id; let attacker_ship = any(attacker.ships, ship => ship.is(diff_ship)); if (diff instanceof ShipDamageDiff) { - this.addStat("Damage evaded", diff.evaded, !attacker_ship); - this.addStat("Damage shielded", diff.shield, !attacker_ship); - this.addStat("Damage to hull", diff.hull, !attacker_ship); + this.addStat("Damage evaded", diff.evaded, attacker_ship); + this.addStat("Damage shielded", diff.shield, attacker_ship); + this.addStat("Damage taken", diff.hull, attacker_ship); } else if (diff instanceof ShipMoveDiff) { this.addStat("Move distance (km)", diff.getDistance(), attacker_ship); } else if (diff instanceof DroneDeployedDiff) { diff --git a/src/ui/battle/ShipList.spec.ts b/src/ui/battle/ShipList.spec.ts index 5f37d9b..60ec5a5 100644 --- a/src/ui/battle/ShipList.spec.ts +++ b/src/ui/battle/ShipList.spec.ts @@ -53,7 +53,7 @@ module TK.SpaceTac.UI.Specs { battle.setPlayingShip(battle.play_order[0]); list.refresh(false); check.in("started", check => { - check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-18, 962), "first ship position"); + check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-14, 962), "first ship position"); check.equals(nn(list.findItem(battle.play_order[1])).position, new Phaser.Point(2, 843), "second ship position"); }); @@ -61,7 +61,7 @@ module TK.SpaceTac.UI.Specs { list.refresh(false); check.in("end turn", check => { check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(2, 843), "first ship position"); - check.equals(nn(list.findItem(battle.play_order[1])).position, new Phaser.Point(-18, 962), "second ship position"); + check.equals(nn(list.findItem(battle.play_order[1])).position, new Phaser.Point(-14, 962), "second ship position"); }); ship = battle.fleets[1].addShip(); @@ -71,7 +71,7 @@ module TK.SpaceTac.UI.Specs { list.setShipsFromBattle(battle, false); check.in("third ship added", check => { check.equals(list.items.length, 3, "item count"); - check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-18, 962), "first ship position"); + check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-14, 962), "first ship position"); check.equals(nn(list.findItem(battle.play_order[1])).position, new Phaser.Point(2, 843), "second ship position"); check.equals(nn(list.findItem(battle.play_order[2])).position, new Phaser.Point(2, 744), "third ship position"); }); @@ -81,7 +81,7 @@ module TK.SpaceTac.UI.Specs { list.refresh(false); check.in("ship dead", check => { check.equals(list.items.length, 3, "item count"); - check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-18, 962), "first ship position"); + check.equals(nn(list.findItem(battle.play_order[0])).position, new Phaser.Point(-14, 962), "first ship position"); check.equals(nn(list.findItem(dead)).position, new Phaser.Point(200, 843), "dead ship position"); check.equals(nn(list.findItem(battle.play_order[1])).position, new Phaser.Point(2, 843), "second ship position"); });