mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
game timer: Add chess-style buffer time option (#10598)
* UI Changes * Add new buffer time options * Main functionality * Final implementation Also added player UI for when they are using their buffer time (timer turns green)
This commit is contained in:
parent
b7543af939
commit
519b3988be
24 changed files with 273 additions and 16 deletions
|
|
@ -18,6 +18,7 @@ public class PriorityTimer extends TimerTask {
|
|||
private final Action taskOnTimeout;
|
||||
|
||||
private int count;
|
||||
private int bufferCount = 0;
|
||||
private Action taskOnTick;
|
||||
private States state = States.NONE;
|
||||
|
||||
|
|
@ -76,6 +77,14 @@ public class PriorityTimer extends TimerTask {
|
|||
this.count = count;
|
||||
}
|
||||
|
||||
public int getBufferCount() {
|
||||
return bufferCount;
|
||||
}
|
||||
|
||||
public void setBufferCount(int count) {
|
||||
this.bufferCount = count;
|
||||
}
|
||||
|
||||
public void setTaskOnTick(Action taskOnTick) {
|
||||
this.taskOnTick = taskOnTick;
|
||||
}
|
||||
|
|
@ -83,7 +92,13 @@ public class PriorityTimer extends TimerTask {
|
|||
@Override
|
||||
public void run() {
|
||||
if (state == States.RUNNING) {
|
||||
count--;
|
||||
// Count down buffer time first
|
||||
if (bufferCount > 0) {
|
||||
bufferCount--;
|
||||
} else {
|
||||
count--;
|
||||
}
|
||||
|
||||
if (taskOnTick != null) {
|
||||
try {
|
||||
taskOnTick.execute();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class GameView implements Serializable {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(GameView.class);
|
||||
private final int priorityTime;
|
||||
private final int bufferTime;
|
||||
private final List<PlayerView> players = new ArrayList<>();
|
||||
private CardsView hand;
|
||||
private PlayableObjectsList canPlayObjects;
|
||||
|
|
@ -68,6 +69,7 @@ public class GameView implements Serializable {
|
|||
Player createdForPlayer = null;
|
||||
this.isPlayer = createdForPlayerId != null;
|
||||
this.priorityTime = game.getPriorityTime();
|
||||
this.bufferTime = game.getBufferTime();
|
||||
for (Player player : state.getPlayers().values()) {
|
||||
players.add(new PlayerView(player, state, game, createdForPlayerId, watcherUserId));
|
||||
if (player.getId().equals(createdForPlayerId)) {
|
||||
|
|
@ -313,6 +315,10 @@ public class GameView implements Serializable {
|
|||
return priorityTime;
|
||||
}
|
||||
|
||||
public int getBufferTime() {
|
||||
return bufferTime;
|
||||
}
|
||||
|
||||
public UUID getActivePlayerId() {
|
||||
return activePlayerId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class PlayerView implements Serializable {
|
|||
private final List<UUID> attachments = new ArrayList<>();
|
||||
private final int statesSavedSize;
|
||||
private final int priorityTimeLeft;
|
||||
private final int bufferTimeLeft;
|
||||
private final boolean passedTurn; // F4
|
||||
private final boolean passedUntilEndOfTurn; // F5
|
||||
private final boolean passedUntilNextMain; // F6
|
||||
|
|
@ -74,6 +75,7 @@ public class PlayerView implements Serializable {
|
|||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.bufferTimeLeft = player.getBufferTimeLeft();
|
||||
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|
||||
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|
||||
|| player.getId().equals(game.getState().getChoosingPlayerId());
|
||||
|
|
@ -275,6 +277,10 @@ public class PlayerView implements Serializable {
|
|||
return priorityTimeLeft;
|
||||
}
|
||||
|
||||
public int getBufferTimeLeft() {
|
||||
return bufferTimeLeft;
|
||||
}
|
||||
|
||||
public boolean hasPriority() {
|
||||
return hasPriority;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public class TableView implements Serializable {
|
|||
if (table.getMatch().getGames().isEmpty()) {
|
||||
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded());
|
||||
addInfo.append(" Time: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString());
|
||||
addInfo.append(" Buffer: ").append(table.getMatch().getOptions().getMatchBufferTime().toString());
|
||||
if (table.getMatch().getFreeMulligans() > 0) {
|
||||
addInfo.append(" FM: ").append(table.getMatch().getFreeMulligans());
|
||||
}
|
||||
|
|
@ -150,6 +151,7 @@ public class TableView implements Serializable {
|
|||
stateText.append(" (").append(table.getTournament().getPlayers().size()).append('/').append(table.getNumberOfSeats()).append(')');
|
||||
}
|
||||
infoText.append(" Time: ").append(table.getTournament().getOptions().getMatchOptions().getMatchTimeLimit().toString());
|
||||
infoText.append(" Buffer: ").append(table.getTournament().getOptions().getMatchOptions().getMatchBufferTime().toString());
|
||||
if (table.getTournament().getOptions().getMatchOptions().getFreeMulligans() > 0) {
|
||||
infoText.append(" FM: ").append(table.getTournament().getOptions().getMatchOptions().getFreeMulligans());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue