[STX] Implemented Teach by Example

This commit is contained in:
Evan Kranzler 2021-04-01 09:13:32 -04:00
parent a40eba211b
commit 8fbcf433ea
3 changed files with 94 additions and 14 deletions

View file

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

View file

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

View file

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