From d313bc7ad606c915989514f6d681095775b8455e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 13 Sep 2022 06:55:12 -0400 Subject: [PATCH] [40K] Implemented Imotekh, the Stormlord --- .../src/mage/cards/d/DesecratedTomb.java | 55 ++-------------- .../src/mage/cards/i/ImotekhTheStormlord.java | 62 +++++++++++++++++++ Mage.Sets/src/mage/sets/Warhammer40000.java | 1 + .../CardsLeaveGraveyardTriggeredAbility.java | 13 +++- .../src/main/java/mage/constants/SubType.java | 1 + .../permanent/token/NecronWarriorToken.java | 35 +++++++++++ 6 files changed, 116 insertions(+), 51 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/i/ImotekhTheStormlord.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/NecronWarriorToken.java diff --git a/Mage.Sets/src/mage/cards/d/DesecratedTomb.java b/Mage.Sets/src/mage/cards/d/DesecratedTomb.java index 58fd0ebde1..5a6b70ff52 100644 --- a/Mage.Sets/src/mage/cards/d/DesecratedTomb.java +++ b/Mage.Sets/src/mage/cards/d/DesecratedTomb.java @@ -1,18 +1,13 @@ package mage.cards.d; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.CardsLeaveGraveyardTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeGroupEvent; +import mage.filter.StaticFilters; import mage.game.permanent.token.BatToken; -import java.util.Objects; import java.util.UUID; /** @@ -24,7 +19,9 @@ public final class DesecratedTomb extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // Whenever one or more creature cards leave your graveyard, create a 1/1 black Bat creature token with flying. - this.addAbility(new DesecratedTombTriggeredAbility()); + this.addAbility(new CardsLeaveGraveyardTriggeredAbility( + new CreateTokenEffect(new BatToken()), StaticFilters.FILTER_CARD_CREATURES + )); } private DesecratedTomb(final DesecratedTomb card) { @@ -36,45 +33,3 @@ public final class DesecratedTomb extends CardImpl { return new DesecratedTomb(this); } } - -class DesecratedTombTriggeredAbility extends TriggeredAbilityImpl { - - DesecratedTombTriggeredAbility() { - super(Zone.BATTLEFIELD, new CreateTokenEffect(new BatToken()), false); - } - - private DesecratedTombTriggeredAbility(final DesecratedTombTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; - return zEvent != null - && Zone.GRAVEYARD == zEvent.getFromZone() - && Zone.GRAVEYARD != zEvent.getToZone() - && zEvent.getCards() != null - && zEvent.getCards() - .stream() - .filter(Objects::nonNull) - .filter(card -> card.isCreature(game)) - .map(Card::getOwnerId) - .anyMatch(getControllerId()::equals); - } - - @Override - public DesecratedTombTriggeredAbility copy() { - return new DesecratedTombTriggeredAbility(this); - } - - @Override - public String getRule() { - return "Whenever one or more creature cards leave your graveyard, " + - "create a 1/1 black Bat creature token with flying."; - } -} diff --git a/Mage.Sets/src/mage/cards/i/ImotekhTheStormlord.java b/Mage.Sets/src/mage/cards/i/ImotekhTheStormlord.java new file mode 100644 index 0000000000..fce539095b --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/ImotekhTheStormlord.java @@ -0,0 +1,62 @@ +package mage.cards.i; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.CardsLeaveGraveyardTriggeredAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.MenaceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.filter.StaticFilters; +import mage.game.permanent.token.NecronWarriorToken; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ImotekhTheStormlord extends CardImpl { + + public ImotekhTheStormlord(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}{B}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.NECRON); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Phaeron -- Whenever one or more artifact cards leave your graveyard, create two 2/2 black Necron Warrior artifact creature tokens. + this.addAbility(new CardsLeaveGraveyardTriggeredAbility( + new CreateTokenEffect(new NecronWarriorToken(), 2), + StaticFilters.FILTER_CARD_ARTIFACTS + ).withFlavorWord("Phaeron")); + + // Grand Strategist -- At the beginning of combat on your turn, another target creature you control gets +2/+2 and gains menace until end of turn. + Ability ability = new BeginningOfCombatTriggeredAbility( + new BoostTargetEffect(2, 2) + .setText("another target creature you control gets +2/+2"), + TargetController.YOU, false + ); + ability.addEffect(new GainAbilityTargetEffect(new MenaceAbility(false)) + .setText("and gains menace until end of turn")); + ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE)); + this.addAbility(ability.withFlavorWord("Grand Strategist")); + } + + private ImotekhTheStormlord(final ImotekhTheStormlord card) { + super(card); + } + + @Override + public ImotekhTheStormlord copy() { + return new ImotekhTheStormlord(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Warhammer40000.java b/Mage.Sets/src/mage/sets/Warhammer40000.java index 95940f8b25..eb06601f24 100644 --- a/Mage.Sets/src/mage/sets/Warhammer40000.java +++ b/Mage.Sets/src/mage/sets/Warhammer40000.java @@ -27,6 +27,7 @@ public final class Warhammer40000 extends ExpansionSet { cards.add(new SetCardInfo("Deathleaper, Terror Weapon", 115, Rarity.RARE, mage.cards.d.DeathleaperTerrorWeapon.class)); cards.add(new SetCardInfo("Fabricate", 181, Rarity.RARE, mage.cards.f.Fabricate.class)); cards.add(new SetCardInfo("Hardened Scales", 215, Rarity.RARE, mage.cards.h.HardenedScales.class)); + cards.add(new SetCardInfo("Imotekh the Stormlord", 5, Rarity.MYTHIC, mage.cards.i.ImotekhTheStormlord.class)); cards.add(new SetCardInfo("Inquisitor Greyfax", 3, Rarity.MYTHIC, mage.cards.i.InquisitorGreyfax.class)); cards.add(new SetCardInfo("Sol Ring", 249, Rarity.UNCOMMON, mage.cards.s.SolRing.class)); } diff --git a/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java index b75b73e535..9c82a0e589 100644 --- a/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java @@ -4,6 +4,8 @@ import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.cards.Card; import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeGroupEvent; @@ -15,13 +17,21 @@ import java.util.Objects; */ public class CardsLeaveGraveyardTriggeredAbility extends TriggeredAbilityImpl { + private final FilterCard filter; + public CardsLeaveGraveyardTriggeredAbility(Effect effect) { + this(effect, StaticFilters.FILTER_CARD_CARDS); + } + + public CardsLeaveGraveyardTriggeredAbility(Effect effect, FilterCard filter) { super(Zone.BATTLEFIELD, effect, false); - setTriggerPhrase("Whenever one or more cards leave your graveyard, "); + this.filter = filter; + setTriggerPhrase("Whenever one or more " + filter + " leave your graveyard, "); } private CardsLeaveGraveyardTriggeredAbility(final CardsLeaveGraveyardTriggeredAbility ability) { super(ability); + this.filter = ability.filter; } @Override @@ -39,6 +49,7 @@ public class CardsLeaveGraveyardTriggeredAbility extends TriggeredAbilityImpl { && zEvent.getCards() .stream() .filter(Objects::nonNull) + .filter(card -> filter.match(card, getControllerId(), this, game)) .map(Card::getOwnerId) .anyMatch(this::isControlledBy); } diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index a7851c995a..596eebce0b 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -255,6 +255,7 @@ public enum SubType { NAGA("Naga", SubTypeSet.CreatureType), NAUTILUS("Nautilus", SubTypeSet.CreatureType), NAUTOLAN("Nautolan", SubTypeSet.CreatureType, true), // Star Wars + NECRON("Necron", SubTypeSet.CreatureType), NEIMOIDIAN("Neimoidian", SubTypeSet.CreatureType, true), // Star Wars NEPHILIM("Nephilim", SubTypeSet.CreatureType), NIGHTMARE("Nightmare", SubTypeSet.CreatureType), diff --git a/Mage/src/main/java/mage/game/permanent/token/NecronWarriorToken.java b/Mage/src/main/java/mage/game/permanent/token/NecronWarriorToken.java new file mode 100644 index 0000000000..e7ace281be --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/NecronWarriorToken.java @@ -0,0 +1,35 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.Arrays; + +/** + * @author TheElk801 + */ +public final class NecronWarriorToken extends TokenImpl { + + public NecronWarriorToken() { + super("Necron Warrior Token", "2/2 black Necron Warrior artifact creature token"); + cardType.add(CardType.ARTIFACT); + cardType.add(CardType.CREATURE); + color.setBlack(true); + subtype.add(SubType.NECRON); + subtype.add(SubType.WARRIOR); + power = new MageInt(2); + toughness = new MageInt(2); + + availableImageSetCodes.addAll(Arrays.asList("40K")); + } + + public NecronWarriorToken(final NecronWarriorToken token) { + super(token); + } + + @Override + public NecronWarriorToken copy() { + return new NecronWarriorToken(this); + } +}