From d9f2877016e03e520691e7cdfe508c8f96df6e93 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Fri, 8 Jan 2021 22:03:41 -0600 Subject: [PATCH] [KHM] Implemented Goldspan Dragon (#7348) * [KHM] Implemented Goldspan Dragon * [KHM] Goldspan Dragon - Fixed triggered ability --- .../src/mage/cards/g/GoldspanDragon.java | 112 ++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 113 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GoldspanDragon.java diff --git a/Mage.Sets/src/mage/cards/g/GoldspanDragon.java b/Mage.Sets/src/mage/cards/g/GoldspanDragon.java new file mode 100644 index 00000000000..a95c1427d3a --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GoldspanDragon.java @@ -0,0 +1,112 @@ +package mage.cards.g; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.effects.mana.AddManaOfAnyColorEffect; +import mage.abilities.mana.SimpleManaAbility; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.TreasureToken; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; + +/** + * + * @author weirddan455 + */ +public final class GoldspanDragon extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent(SubType.TREASURE, "Treasure"); + + public GoldspanDragon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}"); + + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Goldspan Dragon attacks or becomes the target of a spell, create a Treasure token. + this.addAbility(new GoldspanDragonTriggeredAbility()); + + // Treasures you control have "{T}, Sacrifice this artifact: Add two mana of any one color." + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost()); + Cost cost = new SacrificeSourceCost(); + cost.setText("sacrifice this artifact"); + ability.addCost(cost); + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(ability, Duration.WhileOnBattlefield, filter))); + } + + private GoldspanDragon(final GoldspanDragon card) { + super(card); + } + + @Override + public GoldspanDragon copy() { + return new GoldspanDragon(this); + } +} + +class GoldspanDragonTriggeredAbility extends TriggeredAbilityImpl { + + GoldspanDragonTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new TreasureToken())); + } + + private GoldspanDragonTriggeredAbility(final GoldspanDragonTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS + || event.getType() == GameEvent.EventType.TARGETED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + switch (event.getType()) { + case DECLARED_ATTACKERS: + return game.getCombat().getAttackers().contains(this.getSourceId()); + case TARGETED: + if (event.getTargetId().equals(getSourceId())) { + StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); + return sourceObject instanceof Spell; + } + default: + return false; + } + } + + @Override + public String getRule() { + return "Whenever {this} attacks or becomes the target of a spell, " + super.getRule(); + } + + @Override + public GoldspanDragonTriggeredAbility copy() { + return new GoldspanDragonTriggeredAbility(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 8da2b57e57d..194001a0a57 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -62,6 +62,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Gilded Assault Cart", 390, Rarity.UNCOMMON, mage.cards.g.GildedAssaultCart.class)); cards.add(new SetCardInfo("Glacial Floodplain", 257, Rarity.COMMON, mage.cards.g.GlacialFloodplain.class)); cards.add(new SetCardInfo("Gladewalker Ritualist", 392, Rarity.UNCOMMON, mage.cards.g.GladewalkerRitualist.class)); + cards.add(new SetCardInfo("Goldspan Dragon", 139, Rarity.MYTHIC, mage.cards.g.GoldspanDragon.class)); cards.add(new SetCardInfo("Halvar, God of Battle", 15, Rarity.MYTHIC, mage.cards.h.HalvarGodOfBattle.class)); cards.add(new SetCardInfo("Hengegate Pathway", 260, Rarity.RARE, mage.cards.h.HengegatePathway.class)); cards.add(new SetCardInfo("Highland Forest", 261, Rarity.COMMON, mage.cards.h.HighlandForest.class));