From d6e7ff4d77327c2d5212473d4d696d0e2847060d Mon Sep 17 00:00:00 2001 From: Jeff Wadsworth Date: Wed, 22 Sep 2021 14:09:45 -0500 Subject: [PATCH] Fixed #8295 --- .../src/mage/cards/a/ArchmagesCharm.java | 2 +- Mage.Sets/src/mage/cards/o/OutOfTime.java | 53 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/ArchmagesCharm.java b/Mage.Sets/src/mage/cards/a/ArchmagesCharm.java index d74e8e6f61..5150961301 100644 --- a/Mage.Sets/src/mage/cards/a/ArchmagesCharm.java +++ b/Mage.Sets/src/mage/cards/a/ArchmagesCharm.java @@ -44,7 +44,7 @@ public final class ArchmagesCharm extends CardImpl { this.getSpellAbility().addMode(mode); // • Gain control of target nonland permanent with converted mana cost 1 or less. - mode = new Mode(new GainControlTargetEffect(Duration.Custom, true)); + mode = new Mode(new GainControlTargetEffect(Duration.EndOfGame, true)); mode.addTarget(new TargetPermanent(filter)); this.getSpellAbility().addMode(mode); } diff --git a/Mage.Sets/src/mage/cards/o/OutOfTime.java b/Mage.Sets/src/mage/cards/o/OutOfTime.java index 02a4c1188c..bf8907d190 100644 --- a/Mage.Sets/src/mage/cards/o/OutOfTime.java +++ b/Mage.Sets/src/mage/cards/o/OutOfTime.java @@ -5,8 +5,8 @@ import java.util.*; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.PhaseOutAllEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.VanishingSacrificeAbility; @@ -23,7 +23,6 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; -import mage.util.CardUtil; /** * @@ -56,7 +55,7 @@ public final class OutOfTime extends CardImpl { class OutOfTimePhaseOutEffect extends OneShotEffect { public OutOfTimePhaseOutEffect() { - super(Outcome.Detriment); + super(Outcome.AIDontUseIt); this.staticText = "untap all creatures, then phase them out until {this} leaves the battlefield. " + "Put a time counter on {this} for each creature phased out this way"; } @@ -83,13 +82,15 @@ class OutOfTimePhaseOutEffect extends OneShotEffect { } // https://magic.wizards.com/en/articles/archive/feature/modern-horizons-2-release-notes-2021-06-04 // If Out of Time leaves the battlefield before its enter the battlefield trigger resolves, creatures will untap, but they won't phase out. - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { + Permanent outOfTime = game.getPermanent(source.getSourceId()); + if (outOfTime != null) { new PhaseOutAllEffect(new ArrayList<>(creatureIds)).apply(game, source); new AddCountersSourceEffect(CounterType.TIME.createInstance(numCreatures)).apply(game, source); - game.getState().setValue(CardUtil.getCardZoneString("phasedOutCreatures", source.getSourceId(), game), creatureIds); + game.getState().setValue("phasedOutCreatures" + + source.getId().toString(), creatureIds); + game.getState().setValue("phasedOutBySourceId" + source.getSourceId(), source.getId()); game.addDelayedTriggeredAbility(new OutOfTimeDelayedTriggeredAbility(), source); - game.addEffect(new OutOfTimeReplcementEffect(), source); + game.addEffect(new OutOfTimeReplacementEffect(), source); } } return true; @@ -130,7 +131,7 @@ class OutOfTimeDelayedTriggeredAbility extends DelayedTriggeredAbility { class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect { public OutOfTimeLeavesBattlefieldEffect() { - super(Outcome.Benefit); + super(Outcome.Neutral); } private OutOfTimeLeavesBattlefieldEffect(final OutOfTimeLeavesBattlefieldEffect effect) { @@ -144,15 +145,18 @@ class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Set creatureIds = (Set) game.getState().getValue(CardUtil.getCardZoneString( - "phasedOutCreatures", source.getSourceId(), game, true)); + UUID sourceId = (UUID) game.getState().getValue("phasedOutBySourceId" + source.getSourceId()); + Set creatureIds = (Set) game.getState().getValue("phasedOutCreatures" + + sourceId.toString()); if (creatureIds != null) { for (UUID creatureId : creatureIds) { Permanent creature = game.getPermanent(creatureId); - if (creature != null && !creature.isPhasedIn()) { + if (creature != null + && !creature.isPhasedIn()) { creature.phaseIn(game); } } + game.getState().processAction(game); return true; } return false; @@ -160,19 +164,19 @@ class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect { } // Stops creatures from phasing back in on their controller's next turn -class OutOfTimeReplcementEffect extends ReplacementEffectImpl { +class OutOfTimeReplacementEffect extends ContinuousRuleModifyingEffectImpl { - public OutOfTimeReplcementEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + public OutOfTimeReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Neutral, false, false); } - private OutOfTimeReplcementEffect(final OutOfTimeReplcementEffect effect) { + private OutOfTimeReplacementEffect(final OutOfTimeReplacementEffect effect) { super(effect); } @Override - public OutOfTimeReplcementEffect copy() { - return new OutOfTimeReplcementEffect(this); + public OutOfTimeReplacementEffect copy() { + return new OutOfTimeReplacementEffect(this); } @Override @@ -181,14 +185,17 @@ class OutOfTimeReplcementEffect extends ReplacementEffectImpl { } @Override - public boolean applies(GameEvent event, Ability source, Game game) { - Set creatureIds = (Set) game.getState().getValue(CardUtil.getCardZoneString( - "phasedOutCreatures", source.getSourceId(), game)); - return creatureIds != null && creatureIds.contains(event.getTargetId()); + public boolean apply(Game game, Ability source) { + return true; } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public boolean applies(GameEvent event, Ability source, Game game) { + game.getState().processAction(game); + Set creatureIds = (Set) game.getState().getValue("phasedOutCreatures" + + source.getId().toString()); + return source.getSourceObjectZoneChangeCounter() == game.getState().getZoneChangeCounter(source.getSourceId()) // blinked + && creatureIds != null + && creatureIds.contains(event.getTargetId()); } }