From 9568dec3a8f3b9d2db69e5a6f2d4e0ac47879bfe Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 10 Apr 2021 16:07:52 -0400 Subject: [PATCH] [STX] Implemented Reflective Golem --- .../src/mage/cards/b/BeamsplitterMage.java | 1 - .../src/mage/cards/r/ReflectiveGolem.java | 102 ++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/r/ReflectiveGolem.java diff --git a/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java b/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java index 54ef32c95d1..8fe0826044c 100644 --- a/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java +++ b/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java @@ -87,7 +87,6 @@ class BeamsplitterMageTriggeredAbility extends TriggeredAbilityImpl { if (spell == null || !spell.isInstantOrSorcery()) { return false; } - boolean targetsSource = false; if (spell.getSpellAbilities() .stream() .map(AbilityImpl::getModes) diff --git a/Mage.Sets/src/mage/cards/r/ReflectiveGolem.java b/Mage.Sets/src/mage/cards/r/ReflectiveGolem.java new file mode 100644 index 00000000000..75eff465369 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/ReflectiveGolem.java @@ -0,0 +1,102 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.AbilityImpl; +import mage.abilities.Mode; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.CopyTargetSpellEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.target.Target; +import mage.target.targetpointer.FixedTarget; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ReflectiveGolem extends CardImpl { + + public ReflectiveGolem(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + + this.subtype.add(SubType.GOLEM); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Whenever you cast an instant or sorcery spell that targets only Reflective Golem, you may pay {2}. If you do, copy that spell. You may choose new targets for the copy. + this.addAbility(new ReflectiveGolemTriggeredAbility()); + } + + private ReflectiveGolem(final ReflectiveGolem card) { + super(card); + } + + @Override + public ReflectiveGolem copy() { + return new ReflectiveGolem(this); + } +} + +class ReflectiveGolemTriggeredAbility extends TriggeredAbilityImpl { + + ReflectiveGolemTriggeredAbility() { + super(Zone.BATTLEFIELD, new DoIfCostPaid(new CopyTargetSpellEffect(), new GenericManaCost(2)), false); + } + + private ReflectiveGolemTriggeredAbility(final ReflectiveGolemTriggeredAbility ability) { + super(ability); + } + + @Override + public ReflectiveGolemTriggeredAbility copy() { + return new ReflectiveGolemTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!isControlledBy(event.getPlayerId())) { + return false; + } + Spell spell = game.getSpellOrLKIStack(event.getTargetId()); + if (spell == null || !spell.isInstantOrSorcery()) { + return false; + } + if (spell.getSpellAbilities() + .stream() + .map(AbilityImpl::getModes) + .flatMap(m -> m.getSelectedModes().stream().map(m::get)) + .filter(Objects::nonNull) + .map(Mode::getTargets) + .flatMap(Collection::stream) + .filter(t -> !t.isNotTarget()) + .map(Target::getTargets) + .flatMap(Collection::stream) + .anyMatch(uuid -> !getSourceId().equals(uuid) && uuid != null)) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(spell, game)); + return true; + } + + @Override + public String getRule() { + return "Whenever you cast an instant or sorcery spell that targets only {this}, " + + "you may pay {2}. If you do, copy that spell. You may choose new targets for the copy."; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index 1d7965de864..ec73770e21d 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -209,6 +209,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Reckless Amplimancer", 141, Rarity.COMMON, mage.cards.r.RecklessAmplimancer.class)); cards.add(new SetCardInfo("Reconstruct History", 222, Rarity.UNCOMMON, mage.cards.r.ReconstructHistory.class)); cards.add(new SetCardInfo("Reduce to Memory", 25, Rarity.UNCOMMON, mage.cards.r.ReduceToMemory.class)); + cards.add(new SetCardInfo("Reflective Golem", 257, Rarity.UNCOMMON, mage.cards.r.ReflectiveGolem.class)); cards.add(new SetCardInfo("Reject", 50, Rarity.COMMON, mage.cards.r.Reject.class)); cards.add(new SetCardInfo("Relic Sloth", 223, Rarity.COMMON, mage.cards.r.RelicSloth.class)); cards.add(new SetCardInfo("Resculpt", 51, Rarity.COMMON, mage.cards.r.Resculpt.class));