From 902fec22ddae3817d4742b4e20836343762873fc Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Mon, 8 Nov 2021 09:58:20 -0600 Subject: [PATCH] [VOW] Implemented Spiked Ripsaw --- .../src/mage/cards/f/FractalHarness.java | 4 +- Mage.Sets/src/mage/cards/s/SpikedRipsaw.java | 55 +++++++++++++++++++ .../src/mage/sets/InnistradCrimsonVow.java | 1 + .../AttacksAttachedTriggeredAbility.java | 15 ++++- 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/s/SpikedRipsaw.java diff --git a/Mage.Sets/src/mage/cards/f/FractalHarness.java b/Mage.Sets/src/mage/cards/f/FractalHarness.java index 94186a3ee6a..5d409f34796 100644 --- a/Mage.Sets/src/mage/cards/f/FractalHarness.java +++ b/Mage.Sets/src/mage/cards/f/FractalHarness.java @@ -35,7 +35,7 @@ public final class FractalHarness extends CardImpl { // Whenever equipped creature attacks, double the number of +1/+1 counters on it. this.addAbility(new AttacksAttachedTriggeredAbility( - new FractalHarnessDoubleEffect(), AttachmentType.EQUIPMENT, false + new FractalHarnessDoubleEffect(), AttachmentType.EQUIPMENT, false, true )); // Equip {2} @@ -108,7 +108,7 @@ class FractalHarnessDoubleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent((UUID) getValue("sourceId")); + Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SpikedRipsaw.java b/Mage.Sets/src/mage/cards/s/SpikedRipsaw.java new file mode 100644 index 00000000000..d335ad211db --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SpikedRipsaw.java @@ -0,0 +1,55 @@ +package mage.cards.s; + +import java.util.UUID; + +import mage.abilities.common.AttacksAttachedTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.constants.AttachmentType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.common.FilterControlledPermanent; + +/** + * + * @author weirddan455 + */ +public final class SpikedRipsaw extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.FOREST, "forest"); + + public SpikedRipsaw(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}{G}"); + + this.subtype.add(SubType.EQUIPMENT); + + // Equipped creature gets +3/+3. + this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(3, 3))); + + // Whenever equipped creature attacks, you may sacrifice a Forest. If you do, that creature gains trample until end of turn. + this.addAbility(new AttacksAttachedTriggeredAbility( + new DoIfCostPaid(new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, "that creature gains trample until end of turn"), new SacrificeTargetCost(filter)), + AttachmentType.EQUIPMENT, false, true + )); + + // Equip {3} + this.addAbility(new EquipAbility(3)); + } + + private SpikedRipsaw(final SpikedRipsaw card) { + super(card); + } + + @Override + public SpikedRipsaw copy() { + return new SpikedRipsaw(this); + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index c5dde583488..852ff2722ed 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -262,6 +262,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Snarling Wolf", 219, Rarity.COMMON, mage.cards.s.SnarlingWolf.class)); cards.add(new SetCardInfo("Sorin the Mirthless", 131, Rarity.MYTHIC, mage.cards.s.SorinTheMirthless.class)); cards.add(new SetCardInfo("Spectral Binding", 48, Rarity.COMMON, mage.cards.s.SpectralBinding.class)); + cards.add(new SetCardInfo("Spiked Ripsaw", 220, Rarity.UNCOMMON, mage.cards.s.SpikedRipsaw.class)); cards.add(new SetCardInfo("Splendid Reclamation", 221, Rarity.RARE, mage.cards.s.SplendidReclamation.class)); cards.add(new SetCardInfo("Spore Crawler", 222, Rarity.COMMON, mage.cards.s.SporeCrawler.class)); cards.add(new SetCardInfo("Sporeback Wolf", 223, Rarity.COMMON, mage.cards.s.SporebackWolf.class)); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java index 089bec735da..c7ec728ab2a 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java @@ -8,6 +8,7 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; import java.util.Locale; @@ -19,6 +20,7 @@ import java.util.Locale; public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { private AttachmentType attachmentType; + private final boolean setTargetPointer; public AttacksAttachedTriggeredAbility(Effect effect) { this(effect, false); @@ -29,13 +31,19 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { } public AttacksAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean optional) { + this(effect, attachmentType, optional, false); + } + + public AttacksAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean optional, boolean setTargetPointer) { super(Zone.BATTLEFIELD, effect, optional); this.attachmentType = attachmentType; + this.setTargetPointer = setTargetPointer; } public AttacksAttachedTriggeredAbility(final AttacksAttachedTriggeredAbility abiltity) { super(abiltity); this.attachmentType = abiltity.attachmentType; + this.setTargetPointer = abiltity.setTargetPointer; } @Override @@ -56,7 +64,12 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { getEffects().setValue("sourceId", event.getSourceId()); // TODO: Passing a permanent object like this can cause bugs. May need refactoring to use UUID instead. // See https://github.com/magefree/mage/issues/8377 - getEffects().setValue("attachedPermanent", game.getPermanent(event.getSourceId())); + // 11-08-2021: Added a new constructor to set target pointer. Should probably be using this instead. + Permanent attachedPermanent = game.getPermanent(event.getSourceId()); + getEffects().setValue("attachedPermanent", attachedPermanent); + if (setTargetPointer && attachedPermanent != null) { + getEffects().setTargetPointer(new FixedTarget(attachedPermanent, game)); + } return true; } return false;