mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Monarch ability - fixed rollback error on monarch player leaves the game;
This commit is contained in:
parent
926f5f0621
commit
a6f79580d7
1 changed files with 7 additions and 3 deletions
|
@ -2754,7 +2754,7 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
// If the current monarch leaves the game. When that happens, the player whose turn it is becomes the monarch.
|
// If the current monarch leaves the game. When that happens, the player whose turn it is becomes the monarch.
|
||||||
// If the monarch leaves the game on their turn, the next player in turn order becomes the monarch.
|
// If the monarch leaves the game on their turn, the next player in turn order becomes the monarch.
|
||||||
if (playerId.equals(getMonarchId())) {
|
if (playerId.equals(getMonarchId())) {
|
||||||
if (!isActivePlayer(playerId)) {
|
if (!isActivePlayer(playerId) && getActivePlayerId() != null) {
|
||||||
setMonarchId(null, getActivePlayerId());
|
setMonarchId(null, getActivePlayerId());
|
||||||
} else {
|
} else {
|
||||||
Player nextPlayer = getPlayerList().getNext(this, true);
|
Player nextPlayer = getPlayerList().getNext(this, true);
|
||||||
|
@ -3370,16 +3370,20 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMonarchId(Ability source, UUID monarchId) {
|
public void setMonarchId(Ability source, UUID monarchId) {
|
||||||
if (monarchId.equals(getMonarchId())) { // Nothing happens if you're already the monarch
|
if (monarchId.equals(getMonarchId())) {
|
||||||
|
// Nothing happens if you're already the monarch
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replaceEvent(GameEvent.getEvent(GameEvent.EventType.BECOME_MONARCH, monarchId, source, monarchId))) {
|
if (replaceEvent(GameEvent.getEvent(GameEvent.EventType.BECOME_MONARCH, monarchId, source, monarchId))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player newMonarch = getPlayer(monarchId);
|
|
||||||
if (getMonarchId() == null) {
|
if (getMonarchId() == null) {
|
||||||
getState().addDesignation(new Monarch(), this, monarchId);
|
getState().addDesignation(new Monarch(), this, monarchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player newMonarch = getPlayer(monarchId);
|
||||||
if (newMonarch != null) {
|
if (newMonarch != null) {
|
||||||
getState().setMonarchId(monarchId);
|
getState().setMonarchId(monarchId);
|
||||||
informPlayers(newMonarch.getLogName() + " is the monarch");
|
informPlayers(newMonarch.getLogName() + " is the monarch");
|
||||||
|
|
Loading…
Reference in a new issue