From 19344b00a4fc65e208a39961b9133f73f166a2a3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 20 Sep 2020 21:31:21 -0400 Subject: [PATCH] [ZNR] fixed Moraug, Fury of Akoum creating extra turns incorrectly (#7046) --- .../src/mage/cards/m/MoraugFuryOfAkoum.java | 27 +++++++------------ .../condition/common/AddendumCondition.java | 10 +------ .../main/java/mage/constants/TurnPhase.java | 14 +++++----- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Mage.Sets/src/mage/cards/m/MoraugFuryOfAkoum.java b/Mage.Sets/src/mage/cards/m/MoraugFuryOfAkoum.java index 80ebbc3960..706958eb2c 100644 --- a/Mage.Sets/src/mage/cards/m/MoraugFuryOfAkoum.java +++ b/Mage.Sets/src/mage/cards/m/MoraugFuryOfAkoum.java @@ -63,9 +63,7 @@ enum MoraugFuryOfAkoumCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.isActivePlayer(source.getControllerId()) - && (game.getPhase().getType() == TurnPhase.PRECOMBAT_MAIN - || game.getPhase().getType() == TurnPhase.POSTCOMBAT_MAIN); + return game.isActivePlayer(source.getControllerId()) && game.getPhase().getType().isMain(); } } @@ -118,24 +116,23 @@ class MoraugFuryOfAkoumCombatEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.COMBAT, game.getPhase().getType(), false); + TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.COMBAT,TurnPhase.COMBAT, false); game.getState().getTurnMods().add(combat); - MoraugFuryOfAkoumDelayedTriggeredAbility delayedTriggeredAbility = new MoraugFuryOfAkoumDelayedTriggeredAbility(); - delayedTriggeredAbility.setConnectedTurnMod(combat.getId()); - game.addDelayedTriggeredAbility(delayedTriggeredAbility, source); + game.addDelayedTriggeredAbility(new MoraugFuryOfAkoumDelayedTriggeredAbility(combat.getId()), source); return true; } } class MoraugFuryOfAkoumDelayedTriggeredAbility extends DelayedTriggeredAbility { - private UUID connectedTurnMod; + private final UUID connectedTurnMod; private boolean enabled; - MoraugFuryOfAkoumDelayedTriggeredAbility() { + MoraugFuryOfAkoumDelayedTriggeredAbility(UUID connectedTurnMod) { super(new UntapAllControllerEffect( StaticFilters.FILTER_CONTROLLED_CREATURES ), Duration.EndOfTurn, true, false); + this.connectedTurnMod = connectedTurnMod; } private MoraugFuryOfAkoumDelayedTriggeredAbility(MoraugFuryOfAkoumDelayedTriggeredAbility ability) { @@ -151,28 +148,24 @@ class MoraugFuryOfAkoumDelayedTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.PHASE_CHANGED || event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE; + return event.getType() == GameEvent.EventType.PHASE_CHANGED + || event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.PHASE_CHANGED && this.connectedTurnMod.equals(event.getSourceId())) { + if (event.getType() == GameEvent.EventType.PHASE_CHANGED + && this.connectedTurnMod.equals(event.getSourceId())) { enabled = true; return false; } if (event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE && enabled) { - // add additional post combat phase after that - game.getState().getTurnMods().add(new TurnMod(getControllerId(), TurnPhase.POSTCOMBAT_MAIN, TurnPhase.COMBAT, false)); enabled = false; return true; } return false; } - public void setConnectedTurnMod(UUID connectedTurnMod) { - this.connectedTurnMod = connectedTurnMod; - } - @Override public String getRule() { return "At the beginning of that combat, untap all creatures you control"; diff --git a/Mage/src/main/java/mage/abilities/condition/common/AddendumCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AddendumCondition.java index 4bc9f34d73..b982b23060 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AddendumCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AddendumCondition.java @@ -1,15 +1,10 @@ - package mage.abilities.condition.common; import mage.abilities.Ability; import mage.abilities.condition.Condition; -import mage.constants.TurnPhase; import mage.game.Game; import mage.game.stack.Spell; -import java.util.EnumSet; -import java.util.Set; - /** * @author LevelX2 */ @@ -17,14 +12,11 @@ import java.util.Set; public enum AddendumCondition implements Condition { instance; - private static final Set turnPhases = EnumSet.of( - TurnPhase.PRECOMBAT_MAIN, TurnPhase.POSTCOMBAT_MAIN - ); @Override public boolean apply(Game game, Ability source) { if (!game.isActivePlayer(source.getControllerId()) || - !turnPhases.contains(game.getTurn().getPhase().getType())) { + !game.getPhase().getType().isMain()) { return false; } if (CastFromEverywhereSourceCondition.instance.apply(game, source)) { diff --git a/Mage/src/main/java/mage/constants/TurnPhase.java b/Mage/src/main/java/mage/constants/TurnPhase.java index 8efc82971e..d55dc66779 100644 --- a/Mage/src/main/java/mage/constants/TurnPhase.java +++ b/Mage/src/main/java/mage/constants/TurnPhase.java @@ -1,15 +1,14 @@ package mage.constants; /** - * * @author North */ public enum TurnPhase { - BEGINNING ("Beginning"), - PRECOMBAT_MAIN ("Precombat Main"), - COMBAT ("Combat"), - POSTCOMBAT_MAIN ("Postcombat Main"), - END ("End"); + BEGINNING("Beginning"), + PRECOMBAT_MAIN("Precombat Main"), + COMBAT("Combat"), + POSTCOMBAT_MAIN("Postcombat Main"), + END("End"); private final String text; @@ -22,4 +21,7 @@ public enum TurnPhase { return text; } + public boolean isMain() { + return this == PRECOMBAT_MAIN || this == POSTCOMBAT_MAIN; + } }