mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
rework Worldheart Phoenix
This commit is contained in:
parent
b0e8fec79f
commit
f13c564ce7
1 changed files with 55 additions and 71 deletions
|
|
@ -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,80 +53,65 @@ 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() {
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
private WorldheartPhoenixPlayEffect(final WorldheartPhoenixPlayEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorldheartPhoenixPlayEffect copy() {
|
|
||||||
return new WorldheartPhoenixPlayEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
|
||||||
if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
|
|
||||||
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
|
||||||
Player player = game.getPlayer(affectedControllerId);
|
|
||||||
if (player != null) {
|
|
||||||
player.setCastSourceIdWithAlternateMana(
|
|
||||||
sourceId, new ManaCostsImpl<>("{W}{U}{B}{R}{G}"), null,
|
|
||||||
MageIdentifier.WorldheartPhoenixAlternateCast
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
WorldheartPhoenixPlayEffect() {
|
||||||
|
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. " +
|
||||||
|
"If you do, it enters the battlefield with two +1/+1 counters on it";
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorldheartPhoenixEntersBattlefieldEffect extends OneShotEffect {
|
private WorldheartPhoenixPlayEffect(final WorldheartPhoenixPlayEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
public WorldheartPhoenixEntersBattlefieldEffect() {
|
@Override
|
||||||
super(Outcome.BoostCreature);
|
public boolean apply(Game game, Ability source) {
|
||||||
staticText = "If you do, it enters the battlefield with two +1/+1 counters on it";
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldheartPhoenixEntersBattlefieldEffect(final WorldheartPhoenixEntersBattlefieldEffect effect) {
|
@Override
|
||||||
super(effect);
|
public WorldheartPhoenixPlayEffect copy() {
|
||||||
}
|
return new WorldheartPhoenixPlayEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
|
||||||
if (permanent != null) {
|
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
||||||
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
|
Player player = game.getPlayer(affectedControllerId);
|
||||||
if (spellAbility != null
|
if (player != null) {
|
||||||
&& spellAbility.getSourceId().equals(source.getSourceId())
|
player.setCastSourceIdWithAlternateMana(
|
||||||
&& permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) {
|
sourceId, new ManaCostsImpl<>("{W}{U}{B}{R}{G}"), null,
|
||||||
// TODO: No perfect solution because there could be other effects that allow to cast the card for this mana cost
|
MageIdentifier.WorldheartPhoenixAlternateCast
|
||||||
if (spellAbility.getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) {
|
);
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
@Override
|
|
||||||
public WorldheartPhoenixEntersBattlefieldEffect copy() {
|
|
||||||
return new WorldheartPhoenixEntersBattlefieldEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WorldheartPhoenixWatcher extends Watcher {
|
||||||
|
|
||||||
|
WorldheartPhoenixWatcher() {
|
||||||
|
super(WatcherScope.GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (GameEvent.EventType.SPELL_CAST.equals(event.getType())
|
||||||
|
&& event.hasApprovingIdentifier(MageIdentifier.WorldheartPhoenixAlternateCast)) {
|
||||||
|
Spell target = game.getSpell(event.getTargetId());
|
||||||
|
if (target != null) {
|
||||||
|
game.getState().addEffect(new AddCounterEnteringCreatureEffect(new MageObjectReference(target.getCard(), game),
|
||||||
|
CounterType.P1P1.createInstance(2), Outcome.BoostCreature),
|
||||||
|
target.getSpellAbility());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue