forked from External/mage
Added option to select time limit (also none) on match or tournament creation.
This commit is contained in:
parent
a573d2c026
commit
738efcc47f
15 changed files with 367 additions and 214 deletions
|
|
@ -353,7 +353,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
PlayerView player = game.getPlayers().get(playerSeat);
|
||||
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true);
|
||||
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true, game.getPriorityTime());
|
||||
players.put(player.getPlayerId(), sessionPlayer);
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
|
|
@ -385,7 +385,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
col = numColumns - 1;
|
||||
}
|
||||
player = game.getPlayers().get(playerNum);
|
||||
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false);
|
||||
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false, game.getPriorityTime());
|
||||
players.put(player.getPlayerId(), playerPanel);
|
||||
c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
addPopupMenu();
|
||||
}
|
||||
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime) {
|
||||
this();
|
||||
init(player, bigCard, gameId);
|
||||
init(player, bigCard, gameId, priorityTime);
|
||||
update(player);
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
});
|
||||
}
|
||||
|
||||
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
||||
public final void init(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime) {
|
||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard, priorityTime);
|
||||
this.battlefieldPanel.init(gameId, bigCard);
|
||||
this.gameId = gameId;
|
||||
if (MageFrame.getSession().isTestMode()) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ import mage.client.util.Command;
|
|||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.constants.Constants;
|
||||
import mage.remote.Session;
|
||||
import mage.utils.timer.PriorityTimer;
|
||||
import mage.view.CardView;
|
||||
|
|
@ -112,7 +111,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard, int priorityTime) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
|
|
@ -120,24 +119,27 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
cheat.setVisible(session.isTestMode());
|
||||
cheat.setFocusable(false);
|
||||
|
||||
long delay = 1000L;
|
||||
timer = new PriorityTimer(Constants.PRIORITY_TIME_SEC, delay, new mage.interfaces.Action() {
|
||||
@Override
|
||||
public void execute() throws MageException {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
final PriorityTimer pt = timer;
|
||||
timer.setTaskOnTick(new mage.interfaces.Action() {
|
||||
@Override
|
||||
public void execute() throws MageException {
|
||||
int priorityTimeValue = pt.getCount();
|
||||
String text = getPriorityTimeLeftString(priorityTimeValue);
|
||||
PlayerPanelExt.this.avatar.setTopText(text);
|
||||
PlayerPanelExt.this.avatar.repaint();
|
||||
}
|
||||
});
|
||||
timer.init();
|
||||
if (priorityTime > 0) {
|
||||
long delay = 1000L;
|
||||
|
||||
timer = new PriorityTimer(priorityTime, delay, new mage.interfaces.Action() {
|
||||
@Override
|
||||
public void execute() throws MageException {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
final PriorityTimer pt = timer;
|
||||
timer.setTaskOnTick(new mage.interfaces.Action() {
|
||||
@Override
|
||||
public void execute() throws MageException {
|
||||
int priorityTimeValue = pt.getCount();
|
||||
String text = getPriorityTimeLeftString(priorityTimeValue);
|
||||
PlayerPanelExt.this.avatar.setTopText(text);
|
||||
PlayerPanelExt.this.avatar.repaint();
|
||||
}
|
||||
});
|
||||
timer.init();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(PlayerView player) {
|
||||
|
|
@ -206,11 +208,19 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
this.avatar.setText(player.getName());
|
||||
if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) {
|
||||
if (this.timer != null) {
|
||||
if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) {
|
||||
String priorityTimeValue = getPriorityTimeLeftString(player);
|
||||
this.timer.setCount(player.getPriorityTimeLeft());
|
||||
this.avatar.setTopText(priorityTimeValue);
|
||||
}
|
||||
if (player.hasPriority()) {
|
||||
this.timer.resume();
|
||||
} else {
|
||||
this.timer.pause();
|
||||
}
|
||||
}
|
||||
|
||||
this.btnPlayer.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.avatar.setBorder(greenBorder);
|
||||
|
|
@ -223,11 +233,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
this.btnPlayer.setBorder(emptyBorder);
|
||||
}
|
||||
|
||||
if (player.hasPriority()) {
|
||||
this.timer.resume();
|
||||
} else {
|
||||
this.timer.pause();
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (player.getTopCard() != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue