Fixes for timers.

This commit is contained in:
magenoxx 2013-06-20 15:50:06 +04:00
parent 724e7eff21
commit 7c187a1d2a
3 changed files with 19 additions and 6 deletions

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -106,7 +106,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> 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.