rework Worldheart Phoenix

This commit is contained in:
xenohedron 2024-02-17 01:10:10 -05:00
parent b0e8fec79f
commit f13c564ce7

View file

@ -1,23 +1,23 @@
package mage.cards.w; package mage.cards.w;
import mage.MageIdentifier; import mage.MageIdentifier;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.common.counter.AddCounterEnteringCreatureEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
import mage.watchers.Watcher;
import java.util.UUID; import java.util.UUID;
@ -40,8 +40,7 @@ public final class WorldheartPhoenix extends CardImpl {
// If you do, it enters the battlefield with two +1/+1 counters on it. // If you do, it enters the battlefield with two +1/+1 counters on it.
Ability ability = new SimpleStaticAbility(Zone.ALL, new WorldheartPhoenixPlayEffect()) Ability ability = new SimpleStaticAbility(Zone.ALL, new WorldheartPhoenixPlayEffect())
.setIdentifier(MageIdentifier.WorldheartPhoenixAlternateCast); .setIdentifier(MageIdentifier.WorldheartPhoenixAlternateCast);
ability.addEffect(new EntersBattlefieldEffect(new WorldheartPhoenixEntersBattlefieldEffect(), ability.addWatcher(new WorldheartPhoenixWatcher());
"If you do, it enters the battlefield with two +1/+1 counters on it"));
this.addAbility(ability); this.addAbility(ability);
} }
@ -54,12 +53,14 @@ public final class WorldheartPhoenix extends CardImpl {
public WorldheartPhoenix copy() { public WorldheartPhoenix copy() {
return new WorldheartPhoenix(this); return new WorldheartPhoenix(this);
} }
}
class WorldheartPhoenixPlayEffect extends AsThoughEffectImpl { class WorldheartPhoenixPlayEffect extends AsThoughEffectImpl {
public WorldheartPhoenixPlayEffect() { WorldheartPhoenixPlayEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit); super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit);
staticText = "You may cast {this} from your graveyard by paying {W}{U}{B}{R}{G} rather than paying its mana cost"; staticText = "You may cast {this} from your graveyard by paying {W}{U}{B}{R}{G} rather than paying its mana cost. " +
"If you do, it enters the battlefield with two +1/+1 counters on it";
} }
private WorldheartPhoenixPlayEffect(final WorldheartPhoenixPlayEffect effect) { private WorldheartPhoenixPlayEffect(final WorldheartPhoenixPlayEffect effect) {
@ -93,41 +94,24 @@ public final class WorldheartPhoenix extends CardImpl {
return false; return false;
} }
} }
class WorldheartPhoenixEntersBattlefieldEffect extends OneShotEffect { class WorldheartPhoenixWatcher extends Watcher {
public WorldheartPhoenixEntersBattlefieldEffect() { WorldheartPhoenixWatcher() {
super(Outcome.BoostCreature); super(WatcherScope.GAME);
staticText = "If you do, it enters the battlefield with two +1/+1 counters on it"; }
}
@Override
private WorldheartPhoenixEntersBattlefieldEffect(final WorldheartPhoenixEntersBattlefieldEffect effect) { public void watch(GameEvent event, Game game) {
super(effect); if (GameEvent.EventType.SPELL_CAST.equals(event.getType())
} && event.hasApprovingIdentifier(MageIdentifier.WorldheartPhoenixAlternateCast)) {
Spell target = game.getSpell(event.getTargetId());
@Override if (target != null) {
public boolean apply(Game game, Ability source) { game.getState().addEffect(new AddCounterEnteringCreatureEffect(new MageObjectReference(target.getCard(), game),
Permanent permanent = game.getPermanentEntering(source.getSourceId()); CounterType.P1P1.createInstance(2), Outcome.BoostCreature),
if (permanent != null) { target.getSpellAbility());
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); }
if (spellAbility != null }
&& spellAbility.getSourceId().equals(source.getSourceId()) }
&& permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) {
// TODO: No perfect solution because there could be other effects that allow to cast the card for this mana cost
if (spellAbility.getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) {
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
}
}
}
return true;
}
@Override
public WorldheartPhoenixEntersBattlefieldEffect copy() {
return new WorldheartPhoenixEntersBattlefieldEffect(this);
}
}
} }