1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-11 01:01:05 -09:00
This commit is contained in:
Jeff Wadsworth 2021-09-22 14:09:45 -05:00
parent 4ab41a5b12
commit d6e7ff4d77
2 changed files with 31 additions and 24 deletions
Mage.Sets/src/mage/cards

View file

@ -44,7 +44,7 @@ public final class ArchmagesCharm extends CardImpl {
this.getSpellAbility().addMode(mode); this.getSpellAbility().addMode(mode);
// Gain control of target nonland permanent with converted mana cost 1 or less. // 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)); mode.addTarget(new TargetPermanent(filter));
this.getSpellAbility().addMode(mode); this.getSpellAbility().addMode(mode);
} }

View file

@ -5,8 +5,8 @@ import java.util.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.PhaseOutAllEffect; import mage.abilities.effects.common.PhaseOutAllEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.VanishingSacrificeAbility; import mage.abilities.keyword.VanishingSacrificeAbility;
@ -23,7 +23,6 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/** /**
* *
@ -56,7 +55,7 @@ public final class OutOfTime extends CardImpl {
class OutOfTimePhaseOutEffect extends OneShotEffect { class OutOfTimePhaseOutEffect extends OneShotEffect {
public OutOfTimePhaseOutEffect() { public OutOfTimePhaseOutEffect() {
super(Outcome.Detriment); super(Outcome.AIDontUseIt);
this.staticText = "untap all creatures, then phase them out until {this} leaves the battlefield. " 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"; + "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 // 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. // 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()); Permanent outOfTime = game.getPermanent(source.getSourceId());
if (permanent != null) { if (outOfTime != null) {
new PhaseOutAllEffect(new ArrayList<>(creatureIds)).apply(game, source); new PhaseOutAllEffect(new ArrayList<>(creatureIds)).apply(game, source);
new AddCountersSourceEffect(CounterType.TIME.createInstance(numCreatures)).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.addDelayedTriggeredAbility(new OutOfTimeDelayedTriggeredAbility(), source);
game.addEffect(new OutOfTimeReplcementEffect(), source); game.addEffect(new OutOfTimeReplacementEffect(), source);
} }
} }
return true; return true;
@ -130,7 +131,7 @@ class OutOfTimeDelayedTriggeredAbility extends DelayedTriggeredAbility {
class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect { class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect {
public OutOfTimeLeavesBattlefieldEffect() { public OutOfTimeLeavesBattlefieldEffect() {
super(Outcome.Benefit); super(Outcome.Neutral);
} }
private OutOfTimeLeavesBattlefieldEffect(final OutOfTimeLeavesBattlefieldEffect effect) { private OutOfTimeLeavesBattlefieldEffect(final OutOfTimeLeavesBattlefieldEffect effect) {
@ -144,15 +145,18 @@ class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Set<UUID> creatureIds = (Set<UUID>) game.getState().getValue(CardUtil.getCardZoneString( UUID sourceId = (UUID) game.getState().getValue("phasedOutBySourceId" + source.getSourceId());
"phasedOutCreatures", source.getSourceId(), game, true)); Set<UUID> creatureIds = (Set<UUID>) game.getState().getValue("phasedOutCreatures"
+ sourceId.toString());
if (creatureIds != null) { if (creatureIds != null) {
for (UUID creatureId : creatureIds) { for (UUID creatureId : creatureIds) {
Permanent creature = game.getPermanent(creatureId); Permanent creature = game.getPermanent(creatureId);
if (creature != null && !creature.isPhasedIn()) { if (creature != null
&& !creature.isPhasedIn()) {
creature.phaseIn(game); creature.phaseIn(game);
} }
} }
game.getState().processAction(game);
return true; return true;
} }
return false; return false;
@ -160,19 +164,19 @@ class OutOfTimeLeavesBattlefieldEffect extends OneShotEffect {
} }
// Stops creatures from phasing back in on their controller's next turn // Stops creatures from phasing back in on their controller's next turn
class OutOfTimeReplcementEffect extends ReplacementEffectImpl { class OutOfTimeReplacementEffect extends ContinuousRuleModifyingEffectImpl {
public OutOfTimeReplcementEffect() { public OutOfTimeReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Neutral, false, false);
} }
private OutOfTimeReplcementEffect(final OutOfTimeReplcementEffect effect) { private OutOfTimeReplacementEffect(final OutOfTimeReplacementEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public OutOfTimeReplcementEffect copy() { public OutOfTimeReplacementEffect copy() {
return new OutOfTimeReplcementEffect(this); return new OutOfTimeReplacementEffect(this);
} }
@Override @Override
@ -181,14 +185,17 @@ class OutOfTimeReplcementEffect extends ReplacementEffectImpl {
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean apply(Game game, Ability source) {
Set<UUID> creatureIds = (Set<UUID>) game.getState().getValue(CardUtil.getCardZoneString( return true;
"phasedOutCreatures", source.getSourceId(), game));
return creatureIds != null && creatureIds.contains(event.getTargetId());
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return true; game.getState().processAction(game);
Set<UUID> creatureIds = (Set<UUID>) game.getState().getValue("phasedOutCreatures"
+ source.getId().toString());
return source.getSourceObjectZoneChangeCounter() == game.getState().getZoneChangeCounter(source.getSourceId()) // blinked
&& creatureIds != null
&& creatureIds.contains(event.getTargetId());
} }
} }