From 44d836129b1a434d25d463da1c60c44a14e33f9f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 31 Oct 2022 20:22:49 -0400 Subject: [PATCH] [BRO] Implemented Tawnos, the Toymaker --- .../src/mage/cards/d/DonalHeraldOfWings.java | 19 ++-- .../src/mage/cards/t/TawnosTheToymaker.java | 106 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 3 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/t/TawnosTheToymaker.java diff --git a/Mage.Sets/src/mage/cards/d/DonalHeraldOfWings.java b/Mage.Sets/src/mage/cards/d/DonalHeraldOfWings.java index 433c6e39f25..c7af1395a1e 100644 --- a/Mage.Sets/src/mage/cards/d/DonalHeraldOfWings.java +++ b/Mage.Sets/src/mage/cards/d/DonalHeraldOfWings.java @@ -20,7 +20,6 @@ import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.players.Player; -import mage.target.targetpointer.FixedTarget; import mage.util.functions.StackObjectCopyApplier; import java.util.UUID; @@ -52,7 +51,7 @@ public class DonalHeraldOfWings extends CardImpl { // except the copy is a 1/1 Spirit in addition to its other types. // Do this only once each turn. (The copy becomes a token.) this.addAbility(new SpellCastControllerTriggeredAbility( - new DonalHeraldOfWingsEffect(), filterSpell, true, true + new DonalHeraldOfWingsEffect(), filterSpell, true ).setDoOnlyOnce(true)); } @@ -80,19 +79,15 @@ class DonalHeraldOfWingsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { + Spell spell = (Spell) getValue("spellCast"); + if (controller == null || spell == null) { return false; } - - // Get the card that was cast - if (this.getTargetPointer() == null) { - return false; - } - Spell originalSpell = game.getStack().getSpell(((FixedTarget) this.getTargetPointer()).getTarget()); - // Create a token copy - originalSpell.createCopyOnStack(game, source, controller.getId(), false, 1, DonalHeraldOfWingsApplier.instance); - + spell.createCopyOnStack( + game, source, controller.getId(), false, + 1, DonalHeraldOfWingsApplier.instance + ); return true; } diff --git a/Mage.Sets/src/mage/cards/t/TawnosTheToymaker.java b/Mage.Sets/src/mage/cards/t/TawnosTheToymaker.java new file mode 100644 index 00000000000..8d08315ecef --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TawnosTheToymaker.java @@ -0,0 +1,106 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterSpell; +import mage.filter.common.FilterCreatureSpell; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.MageObjectReferencePredicate; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; +import mage.players.Player; +import mage.util.functions.StackObjectCopyApplier; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TawnosTheToymaker extends CardImpl { + + private static final FilterSpell filter = new FilterCreatureSpell("a Beast or Bird creature spell"); + + static { + filter.add(Predicates.or( + SubType.BEAST.getPredicate(), + SubType.BIRD.getPredicate() + )); + } + + public TawnosTheToymaker(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ARTIFICER); + this.power = new MageInt(3); + this.toughness = new MageInt(5); + + // Whenever you cast a Beast or Bird creature spell, you may copy it, except it's an artifact in addition to its other types. + this.addAbility(new SpellCastControllerTriggeredAbility(new TawnosTheToymakerEffect(), filter, false)); + } + + private TawnosTheToymaker(final TawnosTheToymaker card) { + super(card); + } + + @Override + public TawnosTheToymaker copy() { + return new TawnosTheToymaker(this); + } +} + +class TawnosTheToymakerEffect extends OneShotEffect { + + TawnosTheToymakerEffect() { + super(Outcome.Benefit); + staticText = "copy it, except the copy is an artifact in addition to its other types"; + } + + private TawnosTheToymakerEffect(final TawnosTheToymakerEffect effect) { + super(effect); + } + + @Override + public TawnosTheToymakerEffect copy() { + return new TawnosTheToymakerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Spell spell = (Spell) getValue("spellCast"); + if (controller == null || spell == null) { + return false; + } + // Create a token copy + spell.createCopyOnStack( + game, source, controller.getId(), false, + 1, TawnosTheToymakerApplier.instance + ); + return true; + } +} + +enum TawnosTheToymakerApplier implements StackObjectCopyApplier { + instance; + + @Override + public void modifySpell(StackObject copiedSpell, Game game) { + copiedSpell.addCardType(CardType.ARTIFACT); + } + + @Override + public MageObjectReferencePredicate getNextNewTargetType() { + return null; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index d2d9e7e4af1..3d59754e8a8 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -72,6 +72,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Stern Lesson", 64, Rarity.COMMON, mage.cards.s.SternLesson.class)); cards.add(new SetCardInfo("Surge Engine", 81, Rarity.MYTHIC, mage.cards.s.SurgeEngine.class)); cards.add(new SetCardInfo("Swamp", 282, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS)); + cards.add(new SetCardInfo("Tawnos, the Toymaker", 222, Rarity.RARE, mage.cards.t.TawnosTheToymaker.class)); cards.add(new SetCardInfo("Teferi, Temporal Pilgrim", 66, Rarity.MYTHIC, mage.cards.t.TeferiTemporalPilgrim.class)); cards.add(new SetCardInfo("The Mightstone and Weakstone", "238a", Rarity.RARE, mage.cards.t.TheMightstoneAndWeakstone.class)); cards.add(new SetCardInfo("Third Path Savant", 67, Rarity.COMMON, mage.cards.t.ThirdPathSavant.class));