From 970bd300c016861581e02f96c65e0948d32e85c4 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 1 Jun 2023 21:09:50 -0400 Subject: [PATCH] [LTR] Implement Display of Power --- .../src/mage/cards/d/DisplayOfPower.java | 74 +++++++++++++++++++ Mage.Sets/src/mage/cards/s/SeeDouble.java | 41 +--------- Mage.Sets/src/mage/cards/t/TheBathSong.java | 2 +- .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + .../common/CantBeCopiedSourceEffect.java | 43 +++++++++++ 5 files changed, 121 insertions(+), 40 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DisplayOfPower.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/CantBeCopiedSourceEffect.java diff --git a/Mage.Sets/src/mage/cards/d/DisplayOfPower.java b/Mage.Sets/src/mage/cards/d/DisplayOfPower.java new file mode 100644 index 0000000000..2d91b75557 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DisplayOfPower.java @@ -0,0 +1,74 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CantBeCopiedSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.target.TargetSpell; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DisplayOfPower extends CardImpl { + + public DisplayOfPower(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}{R}"); + + // This spell can't be copied. + this.addAbility(new SimpleStaticAbility(Zone.STACK, new CantBeCopiedSourceEffect()).setRuleAtTheTop(true)); + + // Copy any number of target instant and/or sorcery spells. You may choose new targets for the copies. + this.getSpellAbility().addEffect(new DisplayOfPowerEffect()); + this.getSpellAbility().addTarget(new TargetSpell( + 0, Integer.MAX_VALUE, + StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY + )); + } + + private DisplayOfPower(final DisplayOfPower card) { + super(card); + } + + @Override + public DisplayOfPower copy() { + return new DisplayOfPower(this); + } +} + +class DisplayOfPowerEffect extends OneShotEffect { + + DisplayOfPowerEffect() { + super(Outcome.Benefit); + staticText = "copy any number of target instant and/or sorcery spells. You may choose new targets for the copies"; + } + + private DisplayOfPowerEffect(final DisplayOfPowerEffect effect) { + super(effect); + } + + @Override + public DisplayOfPowerEffect copy() { + return new DisplayOfPowerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID targetId : getTargetPointer().getTargets(game, source)) { + Spell spell = game.getSpell(targetId); + if (spell != null) { + spell.createCopyOnStack(game, source, source.getControllerId(), true); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/s/SeeDouble.java b/Mage.Sets/src/mage/cards/s/SeeDouble.java index 30e87322a7..19c1156f10 100644 --- a/Mage.Sets/src/mage/cards/s/SeeDouble.java +++ b/Mage.Sets/src/mage/cards/s/SeeDouble.java @@ -1,20 +1,15 @@ package mage.cards.s; -import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.common.CardsInOpponentGraveyardCondition; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.CantBeCopiedSourceEffect; import mage.abilities.effects.common.CopyTargetSpellEffect; import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; import mage.target.TargetSpell; import mage.target.common.TargetCreaturePermanent; @@ -29,7 +24,7 @@ public final class SeeDouble extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); // This spell can't be copied. - this.addAbility(new SimpleStaticAbility(Zone.STACK, new SeeDoubleEffect()).setRuleAtTheTop(true)); + this.addAbility(new SimpleStaticAbility(Zone.STACK, new CantBeCopiedSourceEffect()).setRuleAtTheTop(true)); // Choose one. If an opponent has eight or more cards in their graveyard, you may choose both. this.getSpellAbility().getModes().setChooseText( @@ -56,35 +51,3 @@ public final class SeeDouble extends CardImpl { return new SeeDouble(this); } } - -class SeeDoubleEffect extends ReplacementEffectImpl { - - SeeDoubleEffect() { - super(Duration.WhileOnStack, Outcome.Benefit); - staticText = "this spell can't be copied"; - } - - private SeeDoubleEffect(final SeeDoubleEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.COPY_STACKOBJECT; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - return event.getTargetId().equals(source.getSourceId()); - } - - @Override - public SeeDoubleEffect copy() { - return new SeeDoubleEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/t/TheBathSong.java b/Mage.Sets/src/mage/cards/t/TheBathSong.java index 03680c9986..d5ea235084 100644 --- a/Mage.Sets/src/mage/cards/t/TheBathSong.java +++ b/Mage.Sets/src/mage/cards/t/TheBathSong.java @@ -38,7 +38,7 @@ public final class TheBathSong extends CardImpl { sagaAbility.addChapterEffect( this, SagaChapter.CHAPTER_III, SagaChapter.CHAPTER_III, new Effects( new ShuffleIntoLibraryTargetEffect(), new BasicManaEffect(Mana.BlueMana(2)) - ), new TargetCardInYourGraveyard() + ), new TargetCardInYourGraveyard(0, Integer.MAX_VALUE) ); this.addAbility(sagaAbility); diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index aa37eaa6cf..be7e32003c 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -28,6 +28,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Call of the Ring", 79, Rarity.RARE, mage.cards.c.CallOfTheRing.class)); cards.add(new SetCardInfo("Cast into the Fire", 118, Rarity.COMMON, mage.cards.c.CastIntoTheFire.class)); cards.add(new SetCardInfo("Council's Deliberation", 48, Rarity.UNCOMMON, mage.cards.c.CouncilsDeliberation.class)); + cards.add(new SetCardInfo("Display of Power", 119, Rarity.RARE, mage.cards.d.DisplayOfPower.class)); cards.add(new SetCardInfo("Dunland Crebain", 82, Rarity.COMMON, mage.cards.d.DunlandCrebain.class)); cards.add(new SetCardInfo("Dunedain Blade", 6, Rarity.COMMON, mage.cards.d.DunedainBlade.class)); cards.add(new SetCardInfo("Easterling Vanguard", 83, Rarity.COMMON, mage.cards.e.EasterlingVanguard.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeCopiedSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeCopiedSourceEffect.java new file mode 100644 index 0000000000..b599ce90a4 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeCopiedSourceEffect.java @@ -0,0 +1,43 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * @author TheElk801 + */ +public class CantBeCopiedSourceEffect extends ReplacementEffectImpl { + + public CantBeCopiedSourceEffect() { + super(Duration.WhileOnStack, Outcome.Benefit); + staticText = "this spell can't be copied"; + } + + private CantBeCopiedSourceEffect(final CantBeCopiedSourceEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.COPY_STACKOBJECT; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getTargetId().equals(source.getSourceId()); + } + + @Override + public CantBeCopiedSourceEffect copy() { + return new CantBeCopiedSourceEffect(this); + } +}