From a7a45763b3e5d0bf5a674d8393d65781edbd175a Mon Sep 17 00:00:00 2001 From: theelk801 Date: Mon, 17 Apr 2023 18:26:27 -0400 Subject: [PATCH] [MOM] Implement Complete the Circuit --- .../src/mage/cards/c/CompleteTheCircuit.java | 85 +++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + .../CopyNextSpellDelayedTriggeredAbility.java | 14 ++- 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/c/CompleteTheCircuit.java diff --git a/Mage.Sets/src/mage/cards/c/CompleteTheCircuit.java b/Mage.Sets/src/mage/cards/c/CompleteTheCircuit.java new file mode 100644 index 00000000000..b80d52cd696 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CompleteTheCircuit.java @@ -0,0 +1,85 @@ +package mage.cards.c; + +import mage.abilities.Ability; +import mage.abilities.common.delayed.CopyNextSpellDelayedTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.continuous.CastAsThoughItHadFlashAllEffect; +import mage.abilities.keyword.ConvokeAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.stack.Spell; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CompleteTheCircuit extends CardImpl { + + private static final FilterCard filter = new FilterCard("sorcery spells"); + + static { + filter.add(CardType.SORCERY.getPredicate()); + } + + public CompleteTheCircuit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{5}{U}"); + + // Convoke + this.addAbility(new ConvokeAbility()); + + // You may cast sorcery spells this turn as though they had flash. + this.getSpellAbility().addEffect(new CastAsThoughItHadFlashAllEffect(Duration.EndOfTurn, filter)); + + // When you next cast an instant or sorcery spell this turn, copy that spell twice. You may choose new targets for the copies. + this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect( + new CopyNextSpellDelayedTriggeredAbility( + StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, + new CompleteTheCircuitEffect(), "When you next cast an instant or sorcery spell " + + "this turn, copy that spell twice. You may choose new targets for the copies." + ) + )); + } + + private CompleteTheCircuit(final CompleteTheCircuit card) { + super(card); + } + + @Override + public CompleteTheCircuit copy() { + return new CompleteTheCircuit(this); + } +} + +class CompleteTheCircuitEffect extends OneShotEffect { + + CompleteTheCircuitEffect() { + super(Outcome.Benefit); + } + + private CompleteTheCircuitEffect(final CompleteTheCircuitEffect effect) { + super(effect); + } + + @Override + public CompleteTheCircuitEffect copy() { + return new CompleteTheCircuitEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = (Spell) getValue("spellCast"); + if (spell != null) { + spell.createCopyOnStack(game, source, source.getControllerId(), true, 2); + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index cded25b294d..af859a3596d 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -78,6 +78,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Coming In Hot", 136, Rarity.COMMON, mage.cards.c.ComingInHot.class)); cards.add(new SetCardInfo("Compleated Conjurer", 49, Rarity.UNCOMMON, mage.cards.c.CompleatedConjurer.class)); cards.add(new SetCardInfo("Compleated Huntmaster", 96, Rarity.UNCOMMON, mage.cards.c.CompleatedHuntmaster.class)); + cards.add(new SetCardInfo("Complete the Circuit", 52, Rarity.RARE, mage.cards.c.CompleteTheCircuit.class)); cards.add(new SetCardInfo("Consuming Aetherborn", 97, Rarity.COMMON, mage.cards.c.ConsumingAetherborn.class)); cards.add(new SetCardInfo("Converter Beast", 180, Rarity.COMMON, mage.cards.c.ConverterBeast.class)); cards.add(new SetCardInfo("Copper Host Crusher", 181, Rarity.UNCOMMON, mage.cards.c.CopperHostCrusher.class)); diff --git a/Mage/src/main/java/mage/abilities/common/delayed/CopyNextSpellDelayedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/delayed/CopyNextSpellDelayedTriggeredAbility.java index 5a263b8a5ab..7831c0b940c 100644 --- a/Mage/src/main/java/mage/abilities/common/delayed/CopyNextSpellDelayedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/delayed/CopyNextSpellDelayedTriggeredAbility.java @@ -1,6 +1,7 @@ package mage.abilities.common.delayed; import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.CopyTargetSpellEffect; import mage.constants.Duration; import mage.filter.FilterSpell; @@ -16,19 +17,26 @@ import mage.target.targetpointer.FixedTarget; public class CopyNextSpellDelayedTriggeredAbility extends DelayedTriggeredAbility { private final FilterSpell filter; + private final String rule; public CopyNextSpellDelayedTriggeredAbility() { this(StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY); } public CopyNextSpellDelayedTriggeredAbility(FilterSpell filter) { - super(new CopyTargetSpellEffect(true), Duration.EndOfTurn); + this(filter, new CopyTargetSpellEffect(true), null); + } + + public CopyNextSpellDelayedTriggeredAbility(FilterSpell filter, Effect effect, String rule) { + super(effect, Duration.EndOfTurn); this.filter = filter; + this.rule = rule; } private CopyNextSpellDelayedTriggeredAbility(final CopyNextSpellDelayedTriggeredAbility ability) { super(ability); this.filter = ability.filter; + this.rule = ability.rule; } @Override @@ -50,12 +58,16 @@ public class CopyNextSpellDelayedTriggeredAbility extends DelayedTriggeredAbilit if (spell == null || !filter.match(spell, getControllerId(), this, game)) { return false; } + this.getEffects().setValue("spellCast", spell); this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); return true; } @Override public String getRule() { + if (rule != null && !rule.isEmpty()) { + return rule; + } return "When you cast your next " + filter.getMessage() + " this turn, " + "copy that spell. You may choose new targets for the copy."; }