From 8f3c54632c7976a3b7c8b94b1d847c92c5b4a38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 20 Dec 2017 19:23:33 +0100 Subject: [PATCH] Fixed toggle actions not being reset at the end of battle --- TODO.md | 1 - src/core/Ship.spec.ts | 9 +++++++++ src/core/Ship.ts | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index d20da42..5de8f8c 100644 --- a/TODO.md +++ b/TODO.md @@ -41,7 +41,6 @@ Character sheet Battle ------ -* Toggle actions are not reset at the end of battle * Investigate cooldown not resetting properly the usage count * Replace success factor percentage with a bar * Add a voluntary retreat option diff --git a/src/core/Ship.spec.ts b/src/core/Ship.spec.ts index 737b27c..b289bf5 100644 --- a/src/core/Ship.spec.ts +++ b/src/core/Ship.spec.ts @@ -314,6 +314,11 @@ module TK.SpaceTac.Specs { ship.setValue("power", 2); ship.active_effects.add(new StickyEffect(new AttributeLimitEffect("power_capacity", 3), 12)); ship.updateAttributes(); + let action1 = new BaseAction(); + let action2 = new ToggleAction(new Equipment()); + action2.activated = true; + let action3 = new ToggleAction(new Equipment()); + check.patch(ship, "getAvailableActions", () => [action1, action2, action3]); check.in("before", check => { check.equals(ship.getValue("hull"), 5, "hull"); @@ -321,6 +326,8 @@ module TK.SpaceTac.Specs { check.equals(ship.getValue("power"), 2, "power"); check.equals(ship.active_effects.count(), 1, "effects count"); check.equals(ship.getAttribute("power_capacity"), 3, "power capacity"); + check.equals(action2.activated, true, "action 2 activation"); + check.equals(action3.activated, false, "action 3 activation"); }); ship.restoreInitialState(); @@ -331,6 +338,8 @@ module TK.SpaceTac.Specs { check.equals(ship.getValue("power"), 5, "power"); check.equals(ship.active_effects.count(), 0, "effects count"); check.equals(ship.getAttribute("power_capacity"), 5, "power capacity"); + check.equals(action2.activated, false, "action 2 activation"); + check.equals(action3.activated, false, "action 3 activation"); }); }); diff --git a/src/core/Ship.ts b/src/core/Ship.ts index 696565e..fcbbee6 100644 --- a/src/core/Ship.ts +++ b/src/core/Ship.ts @@ -258,6 +258,11 @@ module TK.SpaceTac { this.restoreHealth(); this.initializePower(); this.listEquipment().forEach(equipment => equipment.cooldown.reset()); + this.getAvailableActions().forEach(action => { + if (action instanceof ToggleAction) { + action.activated = false; + } + }); } /**