From 6249f08def5989b6ad64dfb7fe4403d699136caa Mon Sep 17 00:00:00 2001 From: rockydirtbag Date: Wed, 28 Jun 2023 05:44:23 +0200 Subject: [PATCH] Implemented [LTR] Gandalf the White (#10528) --- .../src/mage/cards/g/GandalfTheWhite.java | 124 ++++++++++++++++++ .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + 2 files changed, 125 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GandalfTheWhite.java diff --git a/Mage.Sets/src/mage/cards/g/GandalfTheWhite.java b/Mage.Sets/src/mage/cards/g/GandalfTheWhite.java new file mode 100644 index 0000000000..3c0908ce29 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GandalfTheWhite.java @@ -0,0 +1,124 @@ +package mage.cards.g; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.continuous.CastAsThoughItHadFlashAllEffect; +import mage.constants.*; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.events.NumberOfTriggersEvent; +import mage.game.events.ZoneChangeEvent; + +/** + * + * @author rockydirtbag + */ +public final class GandalfTheWhite extends CardImpl { + + private static final FilterCard filter = new FilterCard("legendary spells and artifact spells"); + + static { + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + SuperType.LEGENDARY.getPredicate())); + } + public GandalfTheWhite(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.AVATAR); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(4); + this.toughness = new MageInt(5); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // You may cast legendary spells and artifact spells as though they had flash. + this.addAbility(new SimpleStaticAbility( + new CastAsThoughItHadFlashAllEffect(Duration.WhileOnBattlefield, filter) + )); + // If a legendary permanent or an artifact entering or leaving the battlefield causes a triggered ability of a permanent you control to trigger, that ability triggers an additional time. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GandalfTheWhiteDoublingEffect())); + } + + private GandalfTheWhite(final GandalfTheWhite card) { + super(card); + } + + @Override + public GandalfTheWhite copy() { + return new GandalfTheWhite(this); + } +} + +class GandalfTheWhiteDoublingEffect extends ReplacementEffectImpl { + GandalfTheWhiteDoublingEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "If a legendary permanent or an artifact entering or leaving the battlefield causes a triggered ability of a permanent you control to trigger, that ability triggers an additional time."; + } + + GandalfTheWhiteDoublingEffect(final GandalfTheWhiteDoublingEffect effect) { + super(effect); + } + + @Override + public GandalfTheWhiteDoublingEffect copy() { + return new GandalfTheWhiteDoublingEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.NUMBER_OF_TRIGGERS; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event; + // Only triggers of the controller of Gandalf + if (source.isControlledBy(event.getPlayerId())) { + GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent(); + // 1) EtB triggers + if (sourceEvent != null + && sourceEvent.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && sourceEvent instanceof EntersTheBattlefieldEvent) { + EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) sourceEvent; + // Only for entering artifacts or legendaries + if (entersTheBattlefieldEvent.getTarget().isArtifact(game) + || entersTheBattlefieldEvent.getTarget().isLegendary(game)) { + // Only for triggers of permanents + return game.getPermanent(numberOfTriggersEvent.getSourceId()) != null; + } + } + // 2) LtB triggers + if (sourceEvent != null + && sourceEvent.getType() == GameEvent.EventType.ZONE_CHANGE + && sourceEvent instanceof ZoneChangeEvent) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) sourceEvent; + // Only for leaving artifacts or legendaries + if ((zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() != Zone.BATTLEFIELD) + && (zEvent.getTarget().isLegendary(game) || zEvent.getTarget().isArtifact(game))) { + // Only for triggers of permanents + return game.getPermanentOrLKIBattlefield(numberOfTriggersEvent.getSourceId()) != null; + } + } + } + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(event.getAmount() + 1); + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index ca8e4a53ad..74a9cd6a03 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -101,6 +101,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Galadriel of Lothlorien", 206, Rarity.RARE, mage.cards.g.GaladrielOfLothlorien.class)); cards.add(new SetCardInfo("Galadriel, Gift-Giver", 296, Rarity.RARE, mage.cards.g.GaladrielGiftGiver.class)); cards.add(new SetCardInfo("Gandalf the Grey", 207, Rarity.RARE, mage.cards.g.GandalfTheGrey.class)); + cards.add(new SetCardInfo("Gandalf the White", 19, Rarity.MYTHIC, mage.cards.g.GandalfTheWhite.class)); cards.add(new SetCardInfo("Gandalf's Sanction", 208, Rarity.UNCOMMON, mage.cards.g.GandalfsSanction.class)); cards.add(new SetCardInfo("Gandalf, Friend of the Shire", 50, Rarity.UNCOMMON, mage.cards.g.GandalfFriendOfTheShire.class)); cards.add(new SetCardInfo("Generous Ent", 169, Rarity.COMMON, mage.cards.g.GenerousEnt.class));