[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
This commit is contained in:
Joseph Zeffiro 2021-07-25 14:22:03 -04:00 committed by GitHub
parent 8942896e59
commit 0e4b304778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 110 additions and 0 deletions

View file

@ -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 "";
}
}

View file

@ -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));