[EOE] Implement Moonlit Meditation

This commit is contained in:
theelk801 2025-07-16 11:41:03 -04:00
parent 7adb06f60b
commit bf98d82e60
4 changed files with 150 additions and 32 deletions

View file

@ -24,10 +24,8 @@ import mage.target.TargetPermanent;
import mage.util.functions.CopyApplier; import mage.util.functions.CopyApplier;
import mage.util.functions.CopyTokenFunction; import mage.util.functions.CopyTokenFunction;
import mage.util.functions.EmptyCopyApplier; import mage.util.functions.EmptyCopyApplier;
import mage.watchers.Watcher; import mage.watchers.common.CreatedTokenWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
/** /**
@ -47,7 +45,7 @@ public final class EsixFractalBloom extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// The first time you would create one or more tokens during each of your turns, you may instead choose a creature other than Esix, Fractal Bloom and create that many tokens that are copies of that creature. // The first time you would create one or more tokens during each of your turns, you may instead choose a creature other than Esix, Fractal Bloom and create that many tokens that are copies of that creature.
this.addAbility(new SimpleStaticAbility(new EsixFractalBloomEffect()), new EsixFractalBloomWatcher()); this.addAbility(new SimpleStaticAbility(new EsixFractalBloomEffect()), new CreatedTokenWatcher());
} }
private EsixFractalBloom(final EsixFractalBloom card) { private EsixFractalBloom(final EsixFractalBloom card) {
@ -88,7 +86,7 @@ class EsixFractalBloomEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return source.isControlledBy(event.getPlayerId()) return source.isControlledBy(event.getPlayerId())
&& game.isActivePlayer(source.getControllerId()) && game.isActivePlayer(source.getControllerId())
&& !EsixFractalBloomWatcher.checkPlayer(source.getControllerId(), game) && !CreatedTokenWatcher.checkPlayer(source.getControllerId(), game)
&& game.getBattlefield().count( && game.getBattlefield().count(
filter, source.getControllerId(), source, game filter, source.getControllerId(), source, game
) > 0; ) > 0;
@ -149,30 +147,3 @@ class EsixFractalBloomEffect extends ReplacementEffectImpl {
return token; return token;
} }
} }
class EsixFractalBloomWatcher extends Watcher {
private final Set<UUID> createdThisTurn = new HashSet<>();
EsixFractalBloomWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.CREATED_TOKEN) {
createdThisTurn.add(event.getPlayerId());
}
}
@Override
public void reset() {
super.reset();
createdThisTurn.clear();
}
static boolean checkPlayer(UUID playerId, Game game) {
EsixFractalBloomWatcher watcher = game.getState().getWatcher(EsixFractalBloomWatcher.class);
return watcher != null && watcher.createdThisTurn.contains(playerId);
}
}

View file

@ -0,0 +1,145 @@
package mage.cards.m;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Controllable;
import mage.game.Game;
import mage.game.events.CreateTokenEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.target.TargetPermanent;
import mage.util.functions.CopyApplier;
import mage.util.functions.CopyTokenFunction;
import mage.util.functions.EmptyCopyApplier;
import mage.watchers.common.CreatedTokenWatcher;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class MoonlitMeditation extends CardImpl {
public MoonlitMeditation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
this.subtype.add(SubType.AURA);
// Enchant artifact or creature you control
TargetPermanent auraTarget = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE);
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
this.addAbility(new EnchantAbility(auraTarget));
// The first time you would create one or more tokens each turn, you may instead create that many tokens that are copies of enchanted permanent.
this.addAbility(new SimpleStaticAbility(new MoonlitMeditationEffect()), new CreatedTokenWatcher());
}
private MoonlitMeditation(final MoonlitMeditation card) {
super(card);
}
@Override
public MoonlitMeditation copy() {
return new MoonlitMeditation(this);
}
}
class MoonlitMeditationEffect extends ReplacementEffectImpl {
MoonlitMeditationEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, false);
staticText = "the first time you would create one or more tokens each turn, " +
"you may instead create that many tokens that are copies of enchanted permanent";
}
private MoonlitMeditationEffect(MoonlitMeditationEffect effect) {
super(effect);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CREATE_TOKEN;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return source.isControlledBy(event.getPlayerId())
&& !CreatedTokenWatcher.checkPlayer(source.getControllerId(), game);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = Optional
.ofNullable(source.getSourcePermanentIfItStillExists(game))
.map(Permanent::getAttachedTo)
.map(game::getPermanent)
.orElse(null);
if (permanent == null
|| !Optional
.ofNullable(source)
.map(Controllable::getControllerId)
.map(game::getPlayer)
.filter(player -> player.chooseUse(
Outcome.Benefit, "Replace the tokens with copies of " +
permanent.getLogName() + '?', source, game
))
.isPresent()) {
return false;
}
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
int amount = tokenEvent.getAmount();
tokenEvent.getTokens().clear();
tokenEvent.getTokens().put(copyPermanentToToken(permanent, game, source), amount);
return false;
}
@Override
public MoonlitMeditationEffect copy() {
return new MoonlitMeditationEffect(this);
}
private static Token copyPermanentToToken(Permanent permanent, Game game, Ability source) {
CopyApplier applier = new EmptyCopyApplier();
// handle copies of copies
Permanent copyFromPermanent = permanent;
for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
if (!(effect instanceof CopyEffect)) {
continue;
}
CopyEffect copyEffect = (CopyEffect) effect;
// there is another copy effect that our targetPermanent copies stats from
if (!copyEffect.getSourceId().equals(permanent.getId())) {
continue;
}
MageObject object = ((CopyEffect) effect).getTarget();
if (!(object instanceof Permanent)) {
continue;
}
copyFromPermanent = (Permanent) object;
if (copyEffect.getApplier() != null) {
applier = copyEffect.getApplier();
}
}
// create token and modify all attributes permanently (without game usage)
Token token = CopyTokenFunction.createTokenCopy(copyFromPermanent, game); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
applier.apply(game, token, source, permanent.getId());
return token;
}
}

View file

@ -159,6 +159,7 @@ public final class EdgeOfEternities extends ExpansionSet {
cards.add(new SetCardInfo("Mm'menon, the Right Hand", 290, Rarity.RARE, mage.cards.m.MmmenonTheRightHand.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mm'menon, the Right Hand", 290, Rarity.RARE, mage.cards.m.MmmenonTheRightHand.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mm'menon, the Right Hand", 68, Rarity.RARE, mage.cards.m.MmmenonTheRightHand.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mm'menon, the Right Hand", 68, Rarity.RARE, mage.cards.m.MmmenonTheRightHand.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Monoist Circuit-Feeder", 110, Rarity.UNCOMMON, mage.cards.m.MonoistCircuitFeeder.class)); cards.add(new SetCardInfo("Monoist Circuit-Feeder", 110, Rarity.UNCOMMON, mage.cards.m.MonoistCircuitFeeder.class));
cards.add(new SetCardInfo("Moonlit Meditation", 69, Rarity.RARE, mage.cards.m.MoonlitMeditation.class));
cards.add(new SetCardInfo("Mountain", 265, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Mountain", 265, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Mountain", 273, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mountain", 273, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 274, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mountain", 274, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));

View file

@ -59145,6 +59145,7 @@ Emissary Escort|Edge of Eternities|56|R|{1}{U}|Artifact Creature - Robot Soldier
Illvoi Galeblade|Edge of Eternities|58|C|{U}|Creature - Jellyfish Warrior|1|1|Flash$Flying${2}, Sacrifice this creature: Draw a card.| Illvoi Galeblade|Edge of Eternities|58|C|{U}|Creature - Jellyfish Warrior|1|1|Flash$Flying${2}, Sacrifice this creature: Draw a card.|
Mechanozoa|Edge of Eternities|66|C|{4}{U}{U}|Artifact Creature - Robot Jellyfish|5|5|When this creature enters, tap target artifact or creature an opponent controls and put a stun counter on it.$Warp {2}{U}| Mechanozoa|Edge of Eternities|66|C|{4}{U}{U}|Artifact Creature - Robot Jellyfish|5|5|When this creature enters, tap target artifact or creature an opponent controls and put a stun counter on it.$Warp {2}{U}|
Mm'menon, the Right Hand|Edge of Eternities|68|R|{3}{U}{U}|Legendary Creature - Jellyfish Advisor|3|4|Flying$You may look at the top card of your library any time.$You may cast artifact spells from the top of your library.$Artifacts you control have "{T}: Add {U}. Spend this mana only to cast a spell from anywhere other than your hand."| Mm'menon, the Right Hand|Edge of Eternities|68|R|{3}{U}{U}|Legendary Creature - Jellyfish Advisor|3|4|Flying$You may look at the top card of your library any time.$You may cast artifact spells from the top of your library.$Artifacts you control have "{T}: Add {U}. Spend this mana only to cast a spell from anywhere other than your hand."|
Moonlit Meditation|Edge of Eternities|69|R|{2}{U}|Enchantment - Aura|||Enchant artifact or creature you control$The first time you would create one or more tokens each turn, you may instead create that many tokens that are copies of enchanted permanent.|
Mouth of the Storm|Edge of Eternities|70|U|{6}{U}|Creature - Elemental|6|6|Flying$Ward {2}$When this creature enters, creatures your opponents control get -3/-0 until your next turn.| Mouth of the Storm|Edge of Eternities|70|U|{6}{U}|Creature - Elemental|6|6|Flying$Ward {2}$When this creature enters, creatures your opponents control get -3/-0 until your next turn.|
Quantum Riddler|Edge of Eternities|72|M|{3}{U}{U}|Creature - Sphinx|4|6|Flying$When this creature enters, draw a card.$As long as you have one or fewer cards in hand, if you would draw one or more cards, you draw that many cards plus one instead.$Warp {1}{U}| Quantum Riddler|Edge of Eternities|72|M|{3}{U}{U}|Creature - Sphinx|4|6|Flying$When this creature enters, draw a card.$As long as you have one or fewer cards in hand, if you would draw one or more cards, you draw that many cards plus one instead.$Warp {1}{U}|
Specimen Freighter|Edge of Eternities|76|U|{5}{U}|Artifact - Spacecraft|||When this Spacecraft enters, return up to two target non-Spacecraft creatures to their owners' hands.$Station$STATION 9+$Flying$Whenever this Spacecraft attacks, defending player mills four cards.$4/7| Specimen Freighter|Edge of Eternities|76|U|{5}{U}|Artifact - Spacecraft|||When this Spacecraft enters, return up to two target non-Spacecraft creatures to their owners' hands.$Station$STATION 9+$Flying$Whenever this Spacecraft attacks, defending player mills four cards.$4/7|