[MOM] Implement Complete the Circuit

This commit is contained in:
theelk801 2023-04-17 18:26:27 -04:00
parent 7160a907c9
commit a7a45763b3
3 changed files with 99 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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));

View file

@ -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.";
}