Implemented Pharika's Spawn

This commit is contained in:
Evan Kranzler 2020-01-02 09:45:04 -05:00
parent 1e1ca5a170
commit 86fe25e68b
3 changed files with 105 additions and 3 deletions

View file

@ -0,0 +1,86 @@
package mage.cards.p;
import mage.MageInt;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EscapesWithAbility;
import mage.abilities.effects.common.SacrificeOpponentsEffect;
import mage.abilities.keyword.EscapeAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class PharikasSpawn extends CardImpl {
public PharikasSpawn(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add(SubType.GORGON);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Escape{5}{B}, Exile three other cards from your graveyard.
this.addAbility(new EscapeAbility(this, "{5}{B}", 3));
// Pharika's Spawn escapes with two +1/+1 counters on it. When it enters the battlefield this way, each opponent sacrifices a non-Gorgon creature.
this.addAbility(new EscapesWithAbility(2, new PharikasSpawnDelayedTriggeredAbility()));
}
private PharikasSpawn(final PharikasSpawn card) {
super(card);
}
@Override
public PharikasSpawn copy() {
return new PharikasSpawn(this);
}
}
class PharikasSpawnDelayedTriggeredAbility extends DelayedTriggeredAbility {
private static final FilterPermanent filter = new FilterCreaturePermanent("a non-Gorgon creature");
static {
filter.add(Predicates.not(new SubtypePredicate(SubType.GORGON)));
}
PharikasSpawnDelayedTriggeredAbility() {
super(new SacrificeOpponentsEffect(filter), Duration.EndOfTurn, true);
}
private PharikasSpawnDelayedTriggeredAbility(final PharikasSpawnDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public PharikasSpawnDelayedTriggeredAbility copy() {
return new PharikasSpawnDelayedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getTargetId().equals(getSourceId());
}
@Override
public String getRule() {
return "When it enters the battlefield this way, each opponent sacrifices a non-Gorgon creature.";
}
}

View file

@ -74,6 +74,7 @@ public final class TherosBeyondDeath extends ExpansionSet {
cards.add(new SetCardInfo("Nyxborn Colossus", 191, Rarity.COMMON, mage.cards.n.NyxbornColossus.class));
cards.add(new SetCardInfo("Nyxborn Courser", 29, Rarity.COMMON, mage.cards.n.NyxbornCourser.class));
cards.add(new SetCardInfo("Ox of Agonas", 147, Rarity.MYTHIC, mage.cards.o.OxOfAgonas.class));
cards.add(new SetCardInfo("Pharika's Spawn", 112, Rarity.UNCOMMON, mage.cards.p.PharikasSpawn.class));
cards.add(new SetCardInfo("Plains", 250, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Purphoros, Bronze-Blooded", 150, Rarity.MYTHIC, mage.cards.p.PurphorosBronzeBlooded.class));
cards.add(new SetCardInfo("Reverent Hoplite", 33, Rarity.UNCOMMON, mage.cards.r.ReverentHoplite.class));

View file

@ -1,6 +1,7 @@
package mage.abilities.common;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.SpellAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
@ -22,15 +23,22 @@ import java.util.UUID;
public class EscapesWithAbility extends EntersBattlefieldAbility {
private final int counters;
private final DelayedTriggeredAbility delayedTriggeredAbility;
public EscapesWithAbility(int counters) {
super(new EscapesWithEffect(counters), false);
this(counters, null);
}
public EscapesWithAbility(int counters, DelayedTriggeredAbility delayedTriggeredAbility) {
super(new EscapesWithEffect(counters, delayedTriggeredAbility), false);
this.counters = counters;
this.delayedTriggeredAbility = delayedTriggeredAbility;
}
private EscapesWithAbility(final EscapesWithAbility ability) {
super(ability);
this.counters = ability.counters;
this.delayedTriggeredAbility = ability.delayedTriggeredAbility;
}
@Override
@ -41,22 +49,26 @@ public class EscapesWithAbility extends EntersBattlefieldAbility {
@Override
public String getRule() {
return "{this} escapes with " + CardUtil.numberToText(counters, "a")
+ " +1/+1 counter" + (counters > 1 ? 's' : "") + " on it.";
+ " +1/+1 counter" + (counters > 1 ? 's' : "") + " on it."
+ (this.delayedTriggeredAbility != null ? " " + this.delayedTriggeredAbility.getRule() : "");
}
}
class EscapesWithEffect extends OneShotEffect {
private final int counter;
private final DelayedTriggeredAbility delayedTriggeredAbility;
EscapesWithEffect(int counter) {
EscapesWithEffect(int counter, DelayedTriggeredAbility delayedTriggeredAbility) {
super(Outcome.BoostCreature);
this.counter = counter;
this.delayedTriggeredAbility = delayedTriggeredAbility;
}
private EscapesWithEffect(final EscapesWithEffect effect) {
super(effect);
this.counter = effect.counter;
this.delayedTriggeredAbility = effect.delayedTriggeredAbility;
}
@Override
@ -77,6 +89,9 @@ class EscapesWithEffect extends OneShotEffect {
}
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
permanent.addCounters(CounterType.P1P1.createInstance(counter), source, game, appliedEffects);
if (this.delayedTriggeredAbility != null) {
game.addDelayedTriggeredAbility(this.delayedTriggeredAbility, source);
}
return true;
}