forked from External/mage
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue