From 0e4b304778f7ea1fd755ba762228d5afba250298 Mon Sep 17 00:00:00 2001 From: Joseph Zeffiro <32608602+zeffirojoe@users.noreply.github.com> Date: Sun, 25 Jul 2021 14:22:03 -0400 Subject: [PATCH] [AFC] Implemented Catti-brie of Mithral Hall (#8037) * [AFC] Implemented Catti-brie of Mithral Hall * rename copied code * Removing counters as cost * removing unnecessary custom class --- .../mage/cards/c/CattiBrieOfMithralHall.java | 109 ++++++++++++++++++ .../mage/sets/ForgottenRealmsCommander.java | 1 + 2 files changed, 110 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CattiBrieOfMithralHall.java diff --git a/Mage.Sets/src/mage/cards/c/CattiBrieOfMithralHall.java b/Mage.Sets/src/mage/cards/c/CattiBrieOfMithralHall.java new file mode 100644 index 0000000000..06a4c725b8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CattiBrieOfMithralHall.java @@ -0,0 +1,109 @@ +package mage.cards.c; + +import java.util.UUID; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.RemoveAllCountersSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.EquipmentAttachedCount; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.ReachAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterAttackingOrBlockingCreature; +import mage.game.Game; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author zeffirojoe + */ +public final class CattiBrieOfMithralHall extends CardImpl { + + private static final FilterAttackingOrBlockingCreature filter = new FilterAttackingOrBlockingCreature( + "attacking or blocking creature an opponent controls"); + + static { + filter.add(TargetController.OPPONENT.getControllerPredicate()); + } + + public CattiBrieOfMithralHall(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[] { CardType.CREATURE }, "{G}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ARCHER); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // First strike + this.addAbility(FirstStrikeAbility.getInstance()); + + // Reach + this.addAbility(ReachAbility.getInstance()); + + // Whenever Catti-brie of Mithral Hall attacks, put a +1/+1 counter on it for + // each Equipment attached to it. + EquipmentAttachedCount amount = new EquipmentAttachedCount(); + this.addAbility(new AttacksTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance(), amount, false))); + + // {1}, Remove all +1/+1 counters from Catti-brie: It deals X damage to target + // attacking or blocking creature an opponent controls, where X is the number of + // counters removed this way. + Ability damageAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new DamageTargetEffect(CattiBrieRemovedCounterValue.instance), new ManaCostsImpl("{1}")); + damageAbility.addTarget(new TargetCreaturePermanent(filter)); + damageAbility.addCost(new RemoveAllCountersSourceCost(CounterType.P1P1)); + + this.addAbility(damageAbility); + } + + private CattiBrieOfMithralHall(final CattiBrieOfMithralHall card) { + super(card); + } + + @Override + public CattiBrieOfMithralHall copy() { + return new CattiBrieOfMithralHall(this); + } +} + +enum CattiBrieRemovedCounterValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + int countersRemoved = 0; + for (Cost cost : sourceAbility.getCosts()) { + if (cost instanceof RemoveAllCountersSourceCost) { + countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters(); + } + } + return countersRemoved; + } + + @Override + public CattiBrieRemovedCounterValue copy() { + return instance; + } + + @Override + public String getMessage() { + return ""; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java index b6a7c190cc..d747f21d50 100644 --- a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java +++ b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java @@ -48,6 +48,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet { cards.add(new SetCardInfo("Burnished Hart", 200, Rarity.UNCOMMON, mage.cards.b.BurnishedHart.class)); cards.add(new SetCardInfo("Canopy Vista", 227, Rarity.RARE, mage.cards.c.CanopyVista.class)); cards.add(new SetCardInfo("Cataclysmic Gearhulk", 65, Rarity.MYTHIC, mage.cards.c.CataclysmicGearhulk.class)); + cards.add(new SetCardInfo("Catti-brie of Mithral Hall", 44, Rarity.RARE, mage.cards.c.CattiBrieOfMithralHall.class)); cards.add(new SetCardInfo("Chain Reaction", 116, Rarity.RARE, mage.cards.c.ChainReaction.class)); cards.add(new SetCardInfo("Chameleon Colossus", 153, Rarity.RARE, mage.cards.c.ChameleonColossus.class)); cards.add(new SetCardInfo("Champion of Wits", 80, Rarity.RARE, mage.cards.c.ChampionOfWits.class));