From 5c7993af38a84a828325e6d2308b2793fed4bcf3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 22 Jun 2018 08:25:52 -0400 Subject: [PATCH] Implemented Doublecast --- Mage.Sets/src/mage/cards/d/Doublecast.java | 83 ++++++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2019.java | 1 + 2 files changed, 84 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/Doublecast.java diff --git a/Mage.Sets/src/mage/cards/d/Doublecast.java b/Mage.Sets/src/mage/cards/d/Doublecast.java new file mode 100644 index 0000000000..eee0d791c4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/Doublecast.java @@ -0,0 +1,83 @@ +package mage.cards.d; + +import java.util.UUID; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CopyTargetSpellEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author TheElk801 + */ +public final class Doublecast extends CardImpl { + + public Doublecast(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}{R}"); + + // When you cast your next instant or sorcery spell this turn, copy that spell. You may choose new targets for the copy. + this.getSpellAbility().addEffect( + new CreateDelayedTriggeredAbilityEffect(new DoublecastAbility()) + .setText("When you cast your next instant or sorcery spell this turn, " + + "copy that spell. You may choose new targets for the copy") + ); + } + + public Doublecast(final Doublecast card) { + super(card); + } + + @Override + public Doublecast copy() { + return new Doublecast(this); + } +} + +class DoublecastAbility extends DelayedTriggeredAbility { + + public DoublecastAbility() { + super(new CopyTargetSpellEffect(true), Duration.EndOfTurn); + } + + public DoublecastAbility(final DoublecastAbility ability) { + super(ability); + } + + @Override + public DoublecastAbility copy() { + return new DoublecastAbility(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 (event.getPlayerId().equals(this.getControllerId())) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null && (spell.isInstant() || spell.isSorcery())) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "When you cast your next instant or sorcery spell this turn, " + + "copy that spell. You may choose new targets for the copy."; + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2019.java b/Mage.Sets/src/mage/sets/CoreSet2019.java index 5b94f241b3..a60b213932 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2019.java +++ b/Mage.Sets/src/mage/sets/CoreSet2019.java @@ -83,6 +83,7 @@ public final class CoreSet2019 extends ExpansionSet { cards.add(new SetCardInfo("Disperse", 50, Rarity.COMMON, mage.cards.d.Disperse.class)); cards.add(new SetCardInfo("Divination", 51, Rarity.COMMON, mage.cards.d.Divination.class)); cards.add(new SetCardInfo("Djinn of Wishes", 52, Rarity.RARE, mage.cards.d.DjinnOfWishes.class)); + cards.add(new SetCardInfo("Doublecast", 137, Rarity.UNCOMMON, mage.cards.d.Doublecast.class)); cards.add(new SetCardInfo("Draconic Disciple", 215, Rarity.UNCOMMON, mage.cards.d.DraconicDisciple.class)); cards.add(new SetCardInfo("Dragon's Hoard", 232, Rarity.RARE, mage.cards.d.DragonsHoard.class)); cards.add(new SetCardInfo("Druid of Horns", 176, Rarity.UNCOMMON, mage.cards.d.DruidOfHorns.class));