From 7c187a1d2aba9c662e473e6d06e5140c8718645d Mon Sep 17 00:00:00 2001 From: magenoxx Date: Thu, 20 Jun 2013 15:50:06 +0400 Subject: [PATCH] Fixes for timers. --- .../java/mage/client/game/PlayerPanelExt.java | 17 ++++++++++++----- Mage.Common/src/mage/view/PlayerView.java | 6 ++++++ Mage/src/mage/players/PlayerImpl.java | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 0890cde733..7f54cd24ee 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -206,21 +206,28 @@ public class PlayerPanelExt extends javax.swing.JPanel { } } this.avatar.setText(player.getName()); - String priorityTimeValue = getPriorityTimeLeftString(player); - this.timer.setCount(player.getPriorityTimeLeft()); - this.avatar.setTopText(priorityTimeValue); + if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) { + String priorityTimeValue = getPriorityTimeLeftString(player); + this.timer.setCount(player.getPriorityTimeLeft()); + this.avatar.setTopText(priorityTimeValue); + } this.btnPlayer.setText(player.getName()); if (player.isActive()) { this.avatar.setBorder(greenBorder); this.btnPlayer.setBorder(greenBorder); - this.timer.resume(); } else if (player.hasLeft()) { this.avatar.setBorder(redBorder); this.btnPlayer.setBorder(redBorder); - this.timer.pause(); } else { this.avatar.setBorder(emptyBorder); this.btnPlayer.setBorder(emptyBorder); + } + + if (player.hasPriority()) { + System.out.println("resume: " + player.getName()); + this.timer.resume(); + } else { + System.out.println("pause: " + player.getName()); this.timer.pause(); } diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index f0e46419ea..711e037d85 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -54,6 +54,7 @@ public class PlayerView implements Serializable { private int libraryCount; private int handCount; private boolean isActive; + private boolean hasPriority; private boolean hasLeft; private ManaPoolView manaPool; private SimpleCardsView graveyard = new SimpleCardsView(); @@ -74,6 +75,7 @@ public class PlayerView implements Serializable { this.handCount = player.getHand().size(); this.manaPool = new ManaPoolView(player.getManaPool()); this.isActive = (player.getId().equals(state.getActivePlayerId())); + this.hasPriority = player.getId().equals(state.getPriorityPlayerId()); this.hasLeft = player.hasLeft(); for (Card card: player.getGraveyard().getCards(game)) { graveyard.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.isFaceDown())); @@ -197,4 +199,8 @@ public class PlayerView implements Serializable { public int getPriorityTimeLeft() { return priorityTimeLeft; } + + public boolean hasPriority() { + return hasPriority; + } } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index ded8742beb..12bdedd2e5 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -106,7 +106,7 @@ public abstract class PlayerImpl> implements Player, Ser protected boolean passedTurn; protected int turns; protected int storedBookmark = -1; - protected int priorityTimeLeft; + protected int priorityTimeLeft = Integer.MAX_VALUE; /** * This indicates that player passed all turns until his own turn starts.