diff --git a/Mage.Sets/src/mage/cards/d/Doublecast.java b/Mage.Sets/src/mage/cards/d/Doublecast.java index aa968a1269e..78376a5a5b9 100644 --- a/Mage.Sets/src/mage/cards/d/Doublecast.java +++ b/Mage.Sets/src/mage/cards/d/Doublecast.java @@ -1,8 +1,6 @@ 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; @@ -14,8 +12,9 @@ import mage.game.events.GameEvent; import mage.game.stack.Spell; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class Doublecast extends CardImpl { @@ -43,11 +42,11 @@ public final class Doublecast extends CardImpl { class DoublecastAbility extends DelayedTriggeredAbility { - public DoublecastAbility() { + DoublecastAbility() { super(new CopyTargetSpellEffect(true), Duration.EndOfTurn); } - public DoublecastAbility(final DoublecastAbility ability) { + private DoublecastAbility(final DoublecastAbility ability) { super(ability); } @@ -63,16 +62,15 @@ class DoublecastAbility extends DelayedTriggeredAbility { @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.isInstantOrSorcery()) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - } - return true; - } + if (!isControlledBy(event.getPlayerId())) { + return false; } - return false; + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell == null || !spell.isInstantOrSorcery()) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TeachByExample.java b/Mage.Sets/src/mage/cards/t/TeachByExample.java new file mode 100644 index 00000000000..5aceb1021b3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TeachByExample.java @@ -0,0 +1,81 @@ +package mage.cards.t; + +import mage.abilities.DelayedTriggeredAbility; +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; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TeachByExample extends CardImpl { + + public TeachByExample(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U/R}{U/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 TeachByExampleAbility()) + .setText("When you cast your next instant or sorcery spell this turn, " + + "copy that spell. You may choose new targets for the copy") + ); + } + + private TeachByExample(final TeachByExample card) { + super(card); + } + + @Override + public TeachByExample copy() { + return new TeachByExample(this); + } +} + +class TeachByExampleAbility extends DelayedTriggeredAbility { + + TeachByExampleAbility() { + super(new CopyTargetSpellEffect(true), Duration.EndOfTurn); + } + + private TeachByExampleAbility(final TeachByExampleAbility ability) { + super(ability); + } + + @Override + public TeachByExampleAbility copy() { + return new TeachByExampleAbility(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.getStack().getSpell(event.getTargetId()); + if (spell == null || !spell.isInstantOrSorcery()) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); + return true; + } + + @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/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index e13f1e08e48..73f14b89c74 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -134,6 +134,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Sudden Breakthrough", 116, Rarity.COMMON, mage.cards.s.SuddenBreakthrough.class)); cards.add(new SetCardInfo("Swamp", 370, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Tanazir Quandrix", 240, Rarity.MYTHIC, mage.cards.t.TanazirQuandrix.class)); + cards.add(new SetCardInfo("Teach by Example", 241, Rarity.COMMON, mage.cards.t.TeachByExample.class)); cards.add(new SetCardInfo("Thrilling Discovery", 243, Rarity.COMMON, mage.cards.t.ThrillingDiscovery.class)); cards.add(new SetCardInfo("Thunderous Orator", 35, Rarity.UNCOMMON, mage.cards.t.ThunderousOrator.class)); cards.add(new SetCardInfo("Torrent Sculptor", 159, Rarity.RARE, mage.cards.t.TorrentSculptor.class));