[MIR] Implement Haunting Apparition (#11545)

note: further improvement needed in future, see PR comments
This commit is contained in:
Cameron Merkel 2023-12-19 00:36:39 -06:00 committed by GitHub
parent e449282c8f
commit a5ba710de9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,89 @@
package mage.cards.h;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
* @author Cguy7777
*/
public final class HauntingApparition extends CardImpl {
public HauntingApparition(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{B}");
this.subtype.add(SubType.SPIRIT);
this.power = new MageInt(1);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
// As Haunting Apparition enters the battlefield, choose an opponent.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// Haunting Apparition's power is equal to 1 plus the number of green creature cards in the chosen player's graveyard.
Effect effect = new SetBasePowerSourceEffect(OnePlusGreenCreatureCardsInChosenOpponentsGraveyardCount.instance);
effect.setText("{this}'s power is equal to 1 plus the number of green creature cards in the chosen player's graveyard");
this.addAbility(new SimpleStaticAbility(Zone.ALL, effect));
}
private HauntingApparition(final HauntingApparition card) {
super(card);
}
@Override
public HauntingApparition copy() {
return new HauntingApparition(this);
}
}
enum OnePlusGreenCreatureCardsInChosenOpponentsGraveyardCount implements DynamicValue {
instance;
private static final FilterCreatureCard filter = new FilterCreatureCard();
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {
UUID playerId = (UUID) game.getState().getValue(sourceAbility.getSourceId() + ChooseOpponentEffect.VALUE_KEY);
Player chosenOpponent = game.getPlayer(playerId);
if (chosenOpponent != null) {
return 1 + chosenOpponent.getGraveyard().count(filter, game);
}
}
return 1;
}
@Override
public OnePlusGreenCreatureCardsInChosenOpponentsGraveyardCount copy() {
return instance;
}
@Override
public String getMessage() {
return "1 plus the number of green creature cards in the chosen player's graveyard";
}
}

View file

@ -161,6 +161,7 @@ public final class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Harbinger of Night", 128, Rarity.RARE, mage.cards.h.HarbingerOfNight.class));
cards.add(new SetCardInfo("Harbor Guardian", 266, Rarity.UNCOMMON, mage.cards.h.HarborGuardian.class));
cards.add(new SetCardInfo("Harmattan Efreet", 69, Rarity.UNCOMMON, mage.cards.h.HarmattanEfreet.class));
cards.add(new SetCardInfo("Haunting Apparition", 267, Rarity.UNCOMMON, mage.cards.h.HauntingApparition.class));
cards.add(new SetCardInfo("Hazerider Drake", 268, Rarity.UNCOMMON, mage.cards.h.HazeriderDrake.class));
cards.add(new SetCardInfo("Healing Salve", 20, Rarity.COMMON, mage.cards.h.HealingSalve.class));
cards.add(new SetCardInfo("Hivis of the Scale", 182, Rarity.RARE, mage.cards.h.HivisOfTheScale.class));