diff --git a/TODO b/TODO index 664ad92..342aff4 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,6 @@ * Do not focus on ship while targetting for area effects (dissociate hover and target) * Active effects are not enough visible in ship list (maybe better in arena ?) * Discrete power display, instead of the continuous power bar -* When actions are inavailable at turn start, icon border is faded but not the icon itself (as it is when it fades during turn) * Changing active view does not cancel pending "setTimeout"s. * Drones: add tooltip * Drones: add hull points and take area damage diff --git a/src/core/Battle.spec.ts b/src/core/Battle.spec.ts index b36024b..e0cbc9c 100644 --- a/src/core/Battle.spec.ts +++ b/src/core/Battle.spec.ts @@ -252,5 +252,21 @@ module TS.SpaceTac { expected.initial = true; expect(battle.log.events).toEqual([expected]); }); + + it("checks if a player is able to play", function () { + let battle = new Battle(); + let player = new Player(); + + expect(battle.canPlay(player)).toBe(false); + + let ship = new Ship(); + battle.playing_ship = ship; + + expect(battle.canPlay(player)).toBe(false); + + ship.fleet.player = player; + + expect(battle.canPlay(player)).toBe(true); + }); }); } diff --git a/src/core/Battle.ts b/src/core/Battle.ts index 2f692e2..4336b86 100644 --- a/src/core/Battle.ts +++ b/src/core/Battle.ts @@ -63,8 +63,8 @@ module TS.SpaceTac { canPlay(player: Player): boolean { if (this.ended) { return false; - } else if (this.playing_ship.getPlayer() === player) { - return this.playing_ship.isAbleToPlay(); + } else if (this.playing_ship && this.playing_ship.getPlayer() == player) { + return this.playing_ship.isAbleToPlay(false); } else { return false; } diff --git a/src/ui/battle/ActionIcon.ts b/src/ui/battle/ActionIcon.ts index e8c824a..76585c6 100644 --- a/src/ui/battle/ActionIcon.ts +++ b/src/ui/battle/ActionIcon.ts @@ -80,7 +80,7 @@ module TS.SpaceTac.UI { Tools.setHoverClick(this, show_info, hide_info, () => this.processClick()); // Initialize - this.updateActiveStatus(); + this.updateActiveStatus(true); } // Process a click event on the action icon @@ -157,10 +157,10 @@ module TS.SpaceTac.UI { } // Update the active status, from the action canBeUsed result - updateActiveStatus(): void { + updateActiveStatus(force = false): void { var old_active = this.active; this.active = this.action.canBeUsed(this.battleview.battle, this.ship); - if (this.active != old_active) { + if (force || (this.active != old_active)) { Animation.setVisibility(this.game, this.layer_active, this.active, 500); this.game.tweens.create(this.layer_icon).to({ alpha: this.active ? 1 : 0.3 }, 500).start(); this.input.useHandCursor = this.active;