[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
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";

View file

@ -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<TurnPhase> 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)) {

View file

@ -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;
}
}