From 8c2ee477faf1af9a6b0ddf4d941fd8bdb334981b Mon Sep 17 00:00:00 2001 From: theelk801 Date: Mon, 17 Apr 2023 19:23:55 -0400 Subject: [PATCH] [MOM] Implement Ghalta and Mavren --- .../src/mage/cards/g/GhaltaAndMavren.java | 103 ++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + .../game/permanent/token/DinosaurXXToken.java | 38 +++++++ 3 files changed, 142 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GhaltaAndMavren.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/DinosaurXXToken.java diff --git a/Mage.Sets/src/mage/cards/g/GhaltaAndMavren.java b/Mage.Sets/src/mage/cards/g/GhaltaAndMavren.java new file mode 100644 index 00000000000..f3cfd39169d --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GhaltaAndMavren.java @@ -0,0 +1,103 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.keyword.TrampleAbility; +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.FilterPermanent; +import mage.filter.common.FilterAttackingCreature; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.Game; +import mage.game.permanent.token.DinosaurXXToken; +import mage.game.permanent.token.IxalanVampireToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GhaltaAndMavren extends CardImpl { + + static final FilterPermanent filter = new FilterAttackingCreature("other attacking creatures"); + + static { + filter.add(AnotherPredicate.instance); + } + + private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter); + + public GhaltaAndMavren(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}{W}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.DINOSAUR); + this.subtype.add(SubType.VAMPIRE); + this.power = new MageInt(12); + this.toughness = new MageInt(12); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Whenever you attack, choose one -- + // * Create a tapped and attacking X/X green Dinosaur creature token with trample, where X is the greatest power among other attacking creatures. + Ability ability = new AttacksWithCreaturesTriggeredAbility(new GhaltaAndMavrenEffect(), 1); + + // * Create X 1/1 white Vampire creature tokens with lifelink, where X is the number of other attacking creatures. + ability.addMode(new Mode(new CreateTokenEffect(new IxalanVampireToken(), xValue))); + this.addAbility(ability); + } + + private GhaltaAndMavren(final GhaltaAndMavren card) { + super(card); + } + + @Override + public GhaltaAndMavren copy() { + return new GhaltaAndMavren(this); + } +} + +class GhaltaAndMavrenEffect extends OneShotEffect { + + GhaltaAndMavrenEffect() { + super(Outcome.Benefit); + staticText = "create a tapped and attacking X/X green Dinosaur creature token with trample, " + + "where X is the greatest power among other attacking creatures"; + } + + private GhaltaAndMavrenEffect(final GhaltaAndMavrenEffect effect) { + super(effect); + } + + @Override + public GhaltaAndMavrenEffect copy() { + return new GhaltaAndMavrenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int power = game + .getBattlefield() + .getActivePermanents(GhaltaAndMavren.filter, source.getControllerId(), source, game) + .stream() + .map(MageObject::getPower) + .mapToInt(MageInt::getValue) + .max() + .orElse(0); + return new DinosaurXXToken(power).putOntoBattlefield( + 1, game, source, source.getControllerId(), true, true + ); + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 764dbfd1ee7..0120f21968a 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -128,6 +128,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Furnace-Blessed Conqueror", 38, Rarity.UNCOMMON, mage.cards.f.FurnaceBlessedConqueror.class)); cards.add(new SetCardInfo("Furtive Analyst", 59, Rarity.COMMON, mage.cards.f.FurtiveAnalyst.class)); cards.add(new SetCardInfo("Gargantuan Slabhorn", 240, Rarity.UNCOMMON, mage.cards.g.GargantuanSlabhorn.class)); + cards.add(new SetCardInfo("Ghalta and Mavren", 225, Rarity.RARE, mage.cards.g.GhaltaAndMavren.class)); cards.add(new SetCardInfo("Gift of Compleation", 106, Rarity.UNCOMMON, mage.cards.g.GiftOfCompleation.class)); cards.add(new SetCardInfo("Gitaxian Mindstinger", 88, Rarity.COMMON, mage.cards.g.GitaxianMindstinger.class)); cards.add(new SetCardInfo("Gitaxian Spellstalker", 151, Rarity.UNCOMMON, mage.cards.g.GitaxianSpellstalker.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/DinosaurXXToken.java b/Mage/src/main/java/mage/game/permanent/token/DinosaurXXToken.java new file mode 100644 index 00000000000..b82c33a4398 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/DinosaurXXToken.java @@ -0,0 +1,38 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.TrampleAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.Arrays; + +/** + * @author TheElk801 + */ +public final class DinosaurXXToken extends TokenImpl { + + public DinosaurXXToken() { + this(0); + } + + public DinosaurXXToken(int xValue) { + super("Dinosaur Token", "X/X green Dinosaur creature token with trample"); + cardType.add(CardType.CREATURE); + color.setGreen(true); + subtype.add(SubType.DINOSAUR); + power = new MageInt(xValue); + toughness = new MageInt(xValue); + addAbility(TrampleAbility.getInstance()); + + availableImageSetCodes = Arrays.asList("MOM"); + } + + private DinosaurXXToken(final DinosaurXXToken token) { + super(token); + } + + public DinosaurXXToken copy() { + return new DinosaurXXToken(this); + } +}