From 060766bb0a2f284304506142d49fe49ef06dbfea Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 8 May 2019 17:36:31 +0200 Subject: [PATCH] * Updated UntapAllDuringEachOtherPlayersUntapStepEffect to also work correct with EndTurn effects played last turn. --- ...lDuringEachOtherPlayersUntapStepEffect.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java index 0b8c11b397..bc2b0c8935 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java @@ -33,13 +33,13 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Boolean applied = (Boolean) game.getState().getValue(source.getSourceId() + "applied"); - if (applied == null) { - applied = Boolean.FALSE; - } - if (!applied && layer == Layer.RulesEffects) { - if (!source.isControlledBy(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) { - game.getState().setValue(source.getSourceId() + "applied", true); + if (layer == Layer.RulesEffects && game.getStep().getType() == PhaseStep.UNTAP && !source.isControlledBy(game.getActivePlayerId())) { + Integer appliedTurn = (Integer) game.getState().getValue(source.getSourceId() + "appliedTurn"); + if (appliedTurn == null) { + appliedTurn = 0; + } + if (appliedTurn < game.getTurnNum()) { + game.getState().setValue(source.getSourceId() + "appliedTurn", game.getTurnNum()); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { @@ -50,10 +50,6 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff } } } - } else if (applied && layer == Layer.RulesEffects) { - if (game.getStep().getType() == PhaseStep.END_TURN) { - game.getState().setValue(source.getSourceId() + "applied", false); - } } return true; }