From 7cd97ffd0250d1aeec6c3ab4376e3f5222a6ddd2 Mon Sep 17 00:00:00 2001 From: Grath <1895280+Grath@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:39:42 -0400 Subject: [PATCH] [40K] Implement The Lost and the Damned (#9648) * [40K] Implement The Lost and the Damned Heavily inspired by Faldorn, but this triggers on "anywhere but hand" instead of "exile". * Add The Lost and the Damned to the 40k set. * Make Spawn tokens red, rather than colorless. * Add slightly-jank handling for lands and spells which you do not own, which cannot have been played from your hand and thus should trigger The Lost and the Damned. * Clean up land ownership check with proper method rather than just comparison. --- .../src/mage/cards/t/TheLostAndTheDamned.java | 82 +++++++++++++++++++ Mage.Sets/src/mage/sets/Warhammer40000.java | 1 + .../mage/game/permanent/token/SpawnToken.java | 1 + 3 files changed, 84 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TheLostAndTheDamned.java diff --git a/Mage.Sets/src/mage/cards/t/TheLostAndTheDamned.java b/Mage.Sets/src/mage/cards/t/TheLostAndTheDamned.java new file mode 100644 index 00000000000..b585b9f25b8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheLostAndTheDamned.java @@ -0,0 +1,82 @@ +package mage.cards.t; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.token.SpawnToken; +import mage.game.stack.Spell; + +import java.util.Optional; +import java.util.UUID; + +public final class TheLostAndTheDamned extends CardImpl { + + public TheLostAndTheDamned(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}{R}"); + + // Whenever a land enters the battlefield under your control from anywhere other than your hand or you cast a spell from anywhere other than your hand, create 3/3 red Spawn creature token. + this.addAbility(new TheLostAndTheDamnedTriggeredAbility()); + } + + private TheLostAndTheDamned(final TheLostAndTheDamned card) { + super(card); + } + + @Override + public TheLostAndTheDamned copy() { + return new TheLostAndTheDamned(this); + } +} + +class TheLostAndTheDamnedTriggeredAbility extends TriggeredAbilityImpl { + + TheLostAndTheDamnedTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new SpawnToken())); + setTriggerPhrase("Whenever a land enters the battlefield under your control from anywhere other than your hand or you cast a spell from anywhere other than your hand, "); + } + + private TheLostAndTheDamnedTriggeredAbility(final TheLostAndTheDamnedTriggeredAbility ability) { + super(ability); + } + + @Override + public TheLostAndTheDamnedTriggeredAbility copy() { + return new TheLostAndTheDamnedTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + || event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!this.isControlledBy(event.getPlayerId())) { + return false; + } + switch (event.getType()) { + case ENTERS_THE_BATTLEFIELD: + EntersTheBattlefieldEvent eEvent = (EntersTheBattlefieldEvent) event; + return (!eEvent.getFromZone().match(Zone.HAND) || !(eEvent.getTarget().isOwnedBy(this.controllerId))) // if it's someone else's land, you can't have played it from your hand. This handles playing lands from opponent's hands. + && eEvent.getTarget().isLand(game); + case SPELL_CAST: + return (!Optional + .ofNullable(game.getSpell(event.getTargetId())) + .map(Spell::getFromZone) + .orElse(Zone.ALL) + .equals(Zone.HAND) || !Optional + .ofNullable(game.getSpell(event.getTargetId())) + .map(Spell::getOwnerId) + .orElse(this.controllerId) + .equals(this.controllerId)); // if it's someone else's spell, it can't have been in your hand. This handles playing spells from opponent's hands. + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Warhammer40000.java b/Mage.Sets/src/mage/sets/Warhammer40000.java index baa011c7a2b..f7ccef34312 100644 --- a/Mage.Sets/src/mage/sets/Warhammer40000.java +++ b/Mage.Sets/src/mage/sets/Warhammer40000.java @@ -241,6 +241,7 @@ public final class Warhammer40000 extends ExpansionSet { cards.add(new SetCardInfo("Tervigon", 100, Rarity.RARE, mage.cards.t.Tervigon.class)); cards.add(new SetCardInfo("The First Tyrannic War", 121, Rarity.RARE, mage.cards.t.TheFirstTyrannicWar.class)); cards.add(new SetCardInfo("The Flesh Is Weak", 122, Rarity.RARE, mage.cards.t.TheFleshIsWeak.class)); + cards.add(new SetCardInfo("The Lost and the Damned", 129, Rarity.UNCOMMON, mage.cards.t.TheLostAndTheDamned.class)); cards.add(new SetCardInfo("The Swarmlord", 4, Rarity.MYTHIC, mage.cards.t.TheSwarmlord.class)); cards.add(new SetCardInfo("The War in Heaven", 69, Rarity.RARE, mage.cards.t.TheWarInHeaven.class)); cards.add(new SetCardInfo("Their Name Is Death", 62, Rarity.RARE, mage.cards.t.TheirNameIsDeath.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java b/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java index 4811018d8ba..8ed2a5ee784 100644 --- a/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java +++ b/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java @@ -12,6 +12,7 @@ public final class SpawnToken extends TokenImpl { public SpawnToken() { super("Spawn Token", "3/3 red Spawn creature token"); cardType.add(CardType.CREATURE); + color.setRed(true); this.subtype.add(SubType.SPAWN); power = new MageInt(3); toughness = new MageInt(3);