mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
added resume flag to priority
This commit is contained in:
parent
a1f1ed44c0
commit
2987dcc776
4 changed files with 23 additions and 15 deletions
|
|
@ -157,7 +157,7 @@ public interface Game extends MageItem, Serializable {
|
||||||
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
|
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
|
||||||
public void applyEffects();
|
public void applyEffects();
|
||||||
public boolean checkStateAndTriggered();
|
public boolean checkStateAndTriggered();
|
||||||
public void playPriority(UUID activePlayerId);
|
public void playPriority(UUID activePlayerId, boolean resuming);
|
||||||
public boolean endTurn(UUID playerId);
|
public boolean endTurn(UUID playerId);
|
||||||
|
|
||||||
//game transaction methods
|
//game transaction methods
|
||||||
|
|
|
||||||
|
|
@ -361,8 +361,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
Player player = getPlayer(players.get());
|
Player player = getPlayer(players.get());
|
||||||
state.resume();
|
state.resume();
|
||||||
if (!isGameOver()) {
|
if (!isGameOver()) {
|
||||||
if (simulation)
|
// if (simulation)
|
||||||
logger.info("Turn " + Integer.toString(state.getTurnNum()));
|
// logger.info("Turn " + Integer.toString(state.getTurnNum()));
|
||||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
||||||
if (checkStopOnTurnOption()) return;
|
if (checkStopOnTurnOption()) return;
|
||||||
state.getTurn().resumePlay(this);
|
state.getTurn().resumePlay(this);
|
||||||
|
|
@ -573,12 +573,17 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playPriority(UUID activePlayerId) {
|
public void playPriority(UUID activePlayerId, boolean resuming) {
|
||||||
int bookmark = 0;
|
int bookmark = 0;
|
||||||
try {
|
try {
|
||||||
while (!isPaused() && !isGameOver()) {
|
while (!isPaused() && !isGameOver()) {
|
||||||
|
if (!resuming) {
|
||||||
state.getPlayers().resetPassed();
|
state.getPlayers().resetPassed();
|
||||||
state.getPlayerList().setCurrent(activePlayerId);
|
state.getPlayerList().setCurrent(activePlayerId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
state.getPlayerList().setCurrent(this.getPriorityPlayerId());
|
||||||
|
}
|
||||||
Player player;
|
Player player;
|
||||||
while (!isPaused() && !isGameOver()) {
|
while (!isPaused() && !isGameOver()) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -587,11 +592,14 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
player = getPlayer(state.getPlayerList().get());
|
player = getPlayer(state.getPlayerList().get());
|
||||||
state.setPriorityPlayerId(player.getId());
|
state.setPriorityPlayerId(player.getId());
|
||||||
while (!player.isPassed() && !player.hasLost() && !player.hasLeft() && !isPaused() && !isGameOver()) {
|
while (!player.isPassed() && !player.hasLost() && !player.hasLeft() && !isPaused() && !isGameOver()) {
|
||||||
|
if (!resuming) {
|
||||||
checkStateAndTriggered();
|
checkStateAndTriggered();
|
||||||
if (isPaused() || isGameOver()) return;
|
if (isPaused() || isGameOver()) return;
|
||||||
// resetPassed should be called if player performs any action
|
// resetPassed should be called if player performs any action
|
||||||
player.priority(this);
|
player.priority(this);
|
||||||
if (isPaused() || isGameOver()) return;
|
if (isPaused()) return;
|
||||||
|
}
|
||||||
|
resuming = false;
|
||||||
applyEffects();
|
applyEffects();
|
||||||
}
|
}
|
||||||
if (isPaused() || isGameOver()) return;
|
if (isPaused() || isGameOver()) return;
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ public abstract class Phase<T extends Phase<T>> implements Serializable {
|
||||||
if (!currentStep.skipStep(game, activePlayerId)) {
|
if (!currentStep.skipStep(game, activePlayerId)) {
|
||||||
prePriority(game, activePlayerId);
|
prePriority(game, activePlayerId);
|
||||||
if (!game.isPaused() && !game.isGameOver())
|
if (!game.isPaused() && !game.isGameOver())
|
||||||
currentStep.priority(game, activePlayerId);
|
currentStep.priority(game, activePlayerId, false);
|
||||||
if (!game.isPaused() && !game.isGameOver())
|
if (!game.isPaused() && !game.isGameOver())
|
||||||
postPriority(game, activePlayerId);
|
postPriority(game, activePlayerId);
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +185,7 @@ public abstract class Phase<T extends Phase<T>> implements Serializable {
|
||||||
prePriority(game, activePlayerId);
|
prePriority(game, activePlayerId);
|
||||||
case PRIORITY:
|
case PRIORITY:
|
||||||
if (!game.isPaused() && !game.isGameOver())
|
if (!game.isPaused() && !game.isGameOver())
|
||||||
currentStep.priority(game, activePlayerId);
|
currentStep.priority(game, activePlayerId, true);
|
||||||
case POST:
|
case POST:
|
||||||
if (!game.isPaused() && !game.isGameOver())
|
if (!game.isPaused() && !game.isGameOver())
|
||||||
postPriority(game, activePlayerId);
|
postPriority(game, activePlayerId);
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,10 @@ public abstract class Step<T extends Step<T>> implements Serializable {
|
||||||
game.fireEvent(new GameEvent(preStepEvent, null, null, activePlayerId));
|
game.fireEvent(new GameEvent(preStepEvent, null, null, activePlayerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void priority(Game game, UUID activePlayerId) {
|
public void priority(Game game, UUID activePlayerId, boolean resuming) {
|
||||||
if (hasPriority) {
|
if (hasPriority) {
|
||||||
stepPart = StepPart.PRIORITY;
|
stepPart = StepPart.PRIORITY;
|
||||||
game.playPriority(activePlayerId);
|
game.playPriority(activePlayerId, resuming);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue