From 14c5bf9a623cbdad681ed210328151f765c7938c Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Wed, 20 Jan 2021 14:49:59 -0600 Subject: [PATCH] - [KHM} Added Valor of the Worthy --- .../src/mage/cards/v/ValorOfTheWorthy.java | 90 +++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 91 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/ValorOfTheWorthy.java diff --git a/Mage.Sets/src/mage/cards/v/ValorOfTheWorthy.java b/Mage.Sets/src/mage/cards/v/ValorOfTheWorthy.java new file mode 100644 index 00000000000..ce69c489717 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/ValorOfTheWorthy.java @@ -0,0 +1,90 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; + +import java.util.UUID; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.ZoneChangeTriggeredAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.SpiritWhiteToken; +import mage.target.common.TargetCreaturePermanent; + +/** + * @author jeffwadsworth + */ +public final class ValorOfTheWorthy extends CardImpl { + + public ValorOfTheWorthy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetCreaturePermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted creature gets +1/+1. + this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield))); + + // When enchanted creature leaves the battlefield, create a 1/1 white Spirit creature token with flying. + this.addAbility(new LeavesTheBattlefieldAttachedTriggeredAbility()); + + } + + private ValorOfTheWorthy(final ValorOfTheWorthy card) { + super(card); + } + + @Override + public ValorOfTheWorthy copy() { + return new ValorOfTheWorthy(this); + } +} + +class LeavesTheBattlefieldAttachedTriggeredAbility extends ZoneChangeTriggeredAbility { + + public LeavesTheBattlefieldAttachedTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new SpiritWhiteToken()), "When enchanted creature leaves the battlefield, ", Boolean.FALSE); + } + + public LeavesTheBattlefieldAttachedTriggeredAbility(final LeavesTheBattlefieldAttachedTriggeredAbility ability) { + super(ability); + } + + @Override + public LeavesTheBattlefieldAttachedTriggeredAbility copy() { + return new LeavesTheBattlefieldAttachedTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); + if (enchantment != null + && enchantment.getAttachedTo() != null + && event.getTargetId().equals(enchantment.getAttachedTo())) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if ((zEvent.getFromZone() == Zone.BATTLEFIELD)) { + return true; + } + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 968532c27be..b57caf2364d 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -314,6 +314,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Valki, God of Lies", 114, Rarity.MYTHIC, mage.cards.v.ValkiGodOfLies.class)); cards.add(new SetCardInfo("Valkyrie Harbinger", 374, Rarity.RARE, mage.cards.v.ValkyrieHarbinger.class)); cards.add(new SetCardInfo("Valkyrie's Sword", 36, Rarity.UNCOMMON, mage.cards.v.ValkyriesSword.class)); + cards.add(new SetCardInfo("Valor of the Worthy", 37, Rarity.COMMON, mage.cards.v.ValorOfTheWorthy.class)); cards.add(new SetCardInfo("Varragoth, Bloodsky Sire", 115, Rarity.RARE, mage.cards.v.VarragothBloodskySire.class)); cards.add(new SetCardInfo("Vault Robber", 158, Rarity.COMMON, mage.cards.v.VaultRobber.class)); cards.add(new SetCardInfo("Vega, the Watcher", 233, Rarity.UNCOMMON, mage.cards.v.VegaTheWatcher.class));