[ZNR] fixed Moraug, Fury of Akoum creating extra turns incorrectly (#7046)

This commit is contained in:
Evan Kranzler 2020-09-20 21:31:21 -04:00
parent a95e92455c
commit 19344b00a4
3 changed files with 19 additions and 32 deletions

View file

@ -63,9 +63,7 @@ enum MoraugFuryOfAkoumCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return game.isActivePlayer(source.getControllerId()) return game.isActivePlayer(source.getControllerId()) && game.getPhase().getType().isMain();
&& (game.getPhase().getType() == TurnPhase.PRECOMBAT_MAIN
|| game.getPhase().getType() == TurnPhase.POSTCOMBAT_MAIN);
} }
} }
@ -118,24 +116,23 @@ class MoraugFuryOfAkoumCombatEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { 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); game.getState().getTurnMods().add(combat);
MoraugFuryOfAkoumDelayedTriggeredAbility delayedTriggeredAbility = new MoraugFuryOfAkoumDelayedTriggeredAbility(); game.addDelayedTriggeredAbility(new MoraugFuryOfAkoumDelayedTriggeredAbility(combat.getId()), source);
delayedTriggeredAbility.setConnectedTurnMod(combat.getId());
game.addDelayedTriggeredAbility(delayedTriggeredAbility, source);
return true; return true;
} }
} }
class MoraugFuryOfAkoumDelayedTriggeredAbility extends DelayedTriggeredAbility { class MoraugFuryOfAkoumDelayedTriggeredAbility extends DelayedTriggeredAbility {
private UUID connectedTurnMod; private final UUID connectedTurnMod;
private boolean enabled; private boolean enabled;
MoraugFuryOfAkoumDelayedTriggeredAbility() { MoraugFuryOfAkoumDelayedTriggeredAbility(UUID connectedTurnMod) {
super(new UntapAllControllerEffect( super(new UntapAllControllerEffect(
StaticFilters.FILTER_CONTROLLED_CREATURES StaticFilters.FILTER_CONTROLLED_CREATURES
), Duration.EndOfTurn, true, false); ), Duration.EndOfTurn, true, false);
this.connectedTurnMod = connectedTurnMod;
} }
private MoraugFuryOfAkoumDelayedTriggeredAbility(MoraugFuryOfAkoumDelayedTriggeredAbility ability) { private MoraugFuryOfAkoumDelayedTriggeredAbility(MoraugFuryOfAkoumDelayedTriggeredAbility ability) {
@ -151,28 +148,24 @@ class MoraugFuryOfAkoumDelayedTriggeredAbility extends DelayedTriggeredAbility {
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { 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 @Override
public boolean checkTrigger(GameEvent event, Game game) { 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; enabled = true;
return false; return false;
} }
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE && enabled) { 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; enabled = false;
return true; return true;
} }
return false; return false;
} }
public void setConnectedTurnMod(UUID connectedTurnMod) {
this.connectedTurnMod = connectedTurnMod;
}
@Override @Override
public String getRule() { public String getRule() {
return "At the beginning of that combat, untap all creatures you control"; return "At the beginning of that combat, untap all creatures you control";

View file

@ -1,15 +1,10 @@
package mage.abilities.condition.common; package mage.abilities.condition.common;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.constants.TurnPhase;
import mage.game.Game; import mage.game.Game;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import java.util.EnumSet;
import java.util.Set;
/** /**
* @author LevelX2 * @author LevelX2
*/ */
@ -17,14 +12,11 @@ import java.util.Set;
public enum AddendumCondition implements Condition { public enum AddendumCondition implements Condition {
instance; instance;
private static final Set<TurnPhase> turnPhases = EnumSet.of(
TurnPhase.PRECOMBAT_MAIN, TurnPhase.POSTCOMBAT_MAIN
);
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (!game.isActivePlayer(source.getControllerId()) || if (!game.isActivePlayer(source.getControllerId()) ||
!turnPhases.contains(game.getTurn().getPhase().getType())) { !game.getPhase().getType().isMain()) {
return false; return false;
} }
if (CastFromEverywhereSourceCondition.instance.apply(game, source)) { if (CastFromEverywhereSourceCondition.instance.apply(game, source)) {

View file

@ -1,15 +1,14 @@
package mage.constants; package mage.constants;
/** /**
*
* @author North * @author North
*/ */
public enum TurnPhase { public enum TurnPhase {
BEGINNING ("Beginning"), BEGINNING("Beginning"),
PRECOMBAT_MAIN ("Precombat Main"), PRECOMBAT_MAIN("Precombat Main"),
COMBAT ("Combat"), COMBAT("Combat"),
POSTCOMBAT_MAIN ("Postcombat Main"), POSTCOMBAT_MAIN("Postcombat Main"),
END ("End"); END("End");
private final String text; private final String text;
@ -22,4 +21,7 @@ public enum TurnPhase {
return text; return text;
} }
public boolean isMain() {
return this == PRECOMBAT_MAIN || this == POSTCOMBAT_MAIN;
}
} }