From a6f79580d78393610168b901fde05f90784f6dc3 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 17 Dec 2020 06:58:01 +0400 Subject: [PATCH] * Monarch ability - fixed rollback error on monarch player leaves the game; --- Mage/src/main/java/mage/game/GameImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 3b24c52b99..66fde913fa 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -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 monarch leaves the game on their turn, the next player in turn order becomes the monarch. if (playerId.equals(getMonarchId())) { - if (!isActivePlayer(playerId)) { + if (!isActivePlayer(playerId) && getActivePlayerId() != null) { setMonarchId(null, getActivePlayerId()); } else { Player nextPlayer = getPlayerList().getNext(this, true); @@ -3370,16 +3370,20 @@ public abstract class GameImpl implements Game, Serializable { @Override 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; } + if (replaceEvent(GameEvent.getEvent(GameEvent.EventType.BECOME_MONARCH, monarchId, source, monarchId))) { return; } - Player newMonarch = getPlayer(monarchId); + if (getMonarchId() == null) { getState().addDesignation(new Monarch(), this, monarchId); } + + Player newMonarch = getPlayer(monarchId); if (newMonarch != null) { getState().setMonarchId(monarchId); informPlayers(newMonarch.getLogName() + " is the monarch");