From f5245ade016fc1f28f6d50e9da823a4669e33ef0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 20 May 2015 23:27:00 +0200 Subject: [PATCH] * Game timer - Fixed that the timer count down was not shown while selecting the starting player and deciding for mulligan. --- Mage.Common/src/mage/view/PlayerView.java | 3 ++- Mage/src/mage/game/GameImpl.java | 8 +++++--- Mage/src/mage/game/GameState.java | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index 645ce9c25f9..343e30332c7 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -90,7 +90,8 @@ public class PlayerView implements Serializable { this.hasPriority = player.getId().equals(state.getPriorityPlayerId()); this.priorityTimeLeft = player.getPriorityTimeLeft(); this.timerActive = (this.hasPriority && player.isGameUnderControl()) || - (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId())); + (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId())) || + player.getId().equals(game.getState().getChoosingPlayerId()); this.hasLeft = player.hasLeft(); for (Card card: player.getGraveyard().getCards(game)) { diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 0dd2f2f8811..d3a1749bba7 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -811,9 +811,10 @@ public abstract class GameImpl implements Game, Serializable { choosingPlayer = this.getPlayer(choosingPlayerId); } if (choosingPlayer == null) { - choosingPlayer = getPlayer(pickChoosingPlayer()); + choosingPlayerId = pickChoosingPlayer(); + choosingPlayer = getPlayer(choosingPlayerId); } - + getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) { startingPlayerId = targetPlayer.getTargets().get(0); Player startingPlayer = state.getPlayer(startingPlayerId); @@ -859,6 +860,7 @@ public abstract class GameImpl implements Game, Serializable { GameEvent event = new GameEvent(GameEvent.EventType.CAN_TAKE_MULLIGAN, null, null, playerId); if (!replaceEvent(event)) { fireEvent(event); + getState().setChoosingPlayerId(playerId); if (player.chooseMulligan(this)) { keep = false; } @@ -880,7 +882,7 @@ public abstract class GameImpl implements Game, Serializable { } saveState(false); } while (!mulliganPlayers.isEmpty()); - + getState().setChoosingPlayerId(null); // add watchers for (UUID playerId : state.getPlayerList(startingPlayerId)) { state.getWatchers().add(new PlayerDamagedBySourceWatcher(playerId)); diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 22839899441..6f4c02c23cd 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -87,8 +87,9 @@ public class GameState implements Serializable, Copyable { private final Watchers watchers; - private UUID activePlayerId; - private UUID priorityPlayerId; + private UUID activePlayerId; // playerId which turn it is + private UUID priorityPlayerId; // player that has currently priority + private UUID choosingPlayerId; // player that makes a choice at game start private SpellStack stack; private Command command; private Exile exile; @@ -134,6 +135,7 @@ public class GameState implements Serializable, Copyable { this.playerList = state.playerList.copy(); this.activePlayerId = state.activePlayerId; this.priorityPlayerId = state.priorityPlayerId; + this.choosingPlayerId = state.choosingPlayerId; this.turn = state.turn.copy(); this.stack = state.stack.copy(); this.command = state.command.copy(); @@ -360,6 +362,14 @@ public class GameState implements Serializable, Copyable { this.priorityPlayerId = priorityPlayerId; } + public UUID getChoosingPlayerId() { + return choosingPlayerId; + } + + public void setChoosingPlayerId(UUID choosingPlayerId) { + this.choosingPlayerId = choosingPlayerId; + } + public Battlefield getBattlefield() { return this.battlefield; }