From 071f03c491a9bb135c0ff30be7b672d6ca390f04 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 7 May 2021 08:10:29 -0400 Subject: [PATCH] [AFR] Implemented Vorpal Sword --- Mage.Sets/src/mage/cards/v/VorpalSword.java | 91 +++++++++++++++++++ .../sets/AdventuresInTheForgottenRealms.java | 1 + ...mageToAPlayerAttachedTriggeredAbility.java | 30 +++--- 3 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/v/VorpalSword.java diff --git a/Mage.Sets/src/mage/cards/v/VorpalSword.java b/Mage.Sets/src/mage/cards/v/VorpalSword.java new file mode 100644 index 0000000000..57073864ee --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VorpalSword.java @@ -0,0 +1,91 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.LoseGameTargetPlayerEffect; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.keyword.EquipAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VorpalSword extends CardImpl { + + public VorpalSword(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{B}"); + + this.subtype.add(SubType.EQUIPMENT); + + // Equipped creature gets +2/+0 and has deathtouch. + Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(2, 0)); + ability.addEffect(new GainAbilityAttachedEffect( + DeathtouchAbility.getInstance(), AttachmentType.EQUIPMENT + ).setText("and has deathtouch")); + this.addAbility(ability); + + // {5}{B}{B}{B}: Until end of turn, Vorpal Sword gains "Whenever equipped creature deals combat damage to a player, that player loses the game." + this.addAbility(new SimpleActivatedAbility(new GainAbilitySourceEffect( + new DealsDamageToAPlayerAttachedTriggeredAbility( + new LoseGameTargetPlayerEffect(), "equipped creature", + false, true + ), Duration.EndOfTurn + ), new ManaCostsImpl<>("{5}{B}{B}{B}"))); + + // Equip {B}{B} + this.addAbility(new EquipAbility(Outcome.Benefit, new ManaCostsImpl<>("{B}{B}"))); + } + + private VorpalSword(final VorpalSword card) { + super(card); + } + + @Override + public VorpalSword copy() { + return new VorpalSword(this); + } +} +// ’Twas brillig, and the slithy toves +// Did gyre and gimble in the wabe: +// All mimsy were the borogoves, +// And the mome raths outgrabe. + +// “Beware the Jabberwock, my son! +// The jaws that bite, the claws that catch! +// Beware the Jubjub bird, and shun +// The frumious Bandersnatch!” + +// He took his vorpal sword in hand; +// Long time the manxome foe he sought— +// So rested he by the Tumtum tree +// And stood awhile in thought. + +// And, as in uffish thought he stood, +// The Jabberwock, with eyes of flame, +// Came whiffling through the tulgey wood, +// And burbled as it came! + +// One, two! One, two! And through and through +// The vorpal blade went snicker-snack! +// He left it dead, and with its head +// He went galumphing back. + +// “And hast thou slain the Jabberwock? +// Come to my arms, my beamish boy! +// O frabjous day! Callooh! Callay!” +// He chortled in his joy. + +// ’Twas brillig, and the slithy toves +// Did gyre and gimble in the wabe: +// All mimsy were the borogoves, +// And the mome raths outgrabe. diff --git a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java index 333e4fea6a..4e7c079810 100644 --- a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java +++ b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java @@ -32,6 +32,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet { cards.add(new SetCardInfo("Portable Hole", 33, Rarity.COMMON, mage.cards.p.PortableHole.class)); cards.add(new SetCardInfo("Power Word Kill", 114, Rarity.UNCOMMON, mage.cards.p.PowerWordKill.class)); cards.add(new SetCardInfo("Swamp", 273, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Vorpal Sword", 124, Rarity.RARE, mage.cards.v.VorpalSword.class)); } } diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java index 9fdf532e9f..8e86a26bbc 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java @@ -15,10 +15,10 @@ import mage.target.targetpointer.FixedTarget; * @author Loki */ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbilityImpl { - private boolean setFixedTargetPointer; - private String attachedDescription; - private boolean onlyCombat; - private TargetController targetController; + private final boolean setFixedTargetPointer; + private final String attachedDescription; + private final boolean onlyCombat; + private final TargetController targetController; public DealsDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) { this(effect, attachedDescription, optional, false); @@ -73,17 +73,15 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili } DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; Permanent p = game.getPermanent(event.getSourceId()); - if ((!onlyCombat || damageEvent.isCombatDamage()) - && p != null && p.getAttachments().contains(this.getSourceId())) { - if (setFixedTargetPointer) { - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); - } - } - return true; + if ((onlyCombat && !damageEvent.isCombatDamage()) + || p == null || !p.getAttachments().contains(this.getSourceId())) { + return false; } - return false; + if (setFixedTargetPointer) { + getEffects().setValue("damage", event.getAmount()); + getEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); + } + return true; } @Override @@ -94,7 +92,7 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili sb.append(" combat"); } sb.append(" damage to "); - switch(targetController) { + switch (targetController) { case OPPONENT: sb.append("an opponent, "); break; @@ -108,6 +106,6 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili throw new UnsupportedOperationException(); } sb.append(super.getRule()); - return sb.toString(); + return sb.toString(); } }