From 30b3e2e658ecc40965143cc2589d4106d0c9f523 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Thu, 21 Jan 2021 09:40:31 -0600 Subject: [PATCH] [KHM] Implemented Resplendent Marshal (#7419) --- .../src/mage/cards/r/ResplendentMarshal.java | 109 ++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + .../costs/common/ExileFromGraveCost.java | 11 ++ 3 files changed, 121 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/ResplendentMarshal.java diff --git a/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java b/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java new file mode 100644 index 0000000000..e5eab14ae5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java @@ -0,0 +1,109 @@ +package mage.cards.r; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldOrDiesSourceTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.common.ExileFromGraveCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoWhenCostPaid; +import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author weirddan455 + */ +public final class ResplendentMarshal extends CardImpl { + + private static final FilterCreatureCard filter + = new FilterCreatureCard("another creature card from your graveyard"); + + static { + filter.add(AnotherPredicate.instance); + } + + public ResplendentMarshal(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); + + this.subtype.add(SubType.ANGEL); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // When Resplendent Marshal enters the battlefield or dies, you may exile another creature card from your graveyard. + // When you do, put a +1/+1 counter on each creature you control other than Resplendent Marshal that shares a creature type with the exiled card. + this.addAbility(new EntersBattlefieldOrDiesSourceTriggeredAbility( + new DoWhenCostPaid( + new ReflexiveTriggeredAbility(new ResplendentMarshalEffect(), false, + "put a +1/+1 counter on each creature you control other than Resplendent Marshal that shares a creature type with the exiled card"), + new ExileFromGraveCost(new TargetCardInYourGraveyard(filter), true), + "Exile another creature card from your graveyard?" + ), false + )); + } + + private ResplendentMarshal(final ResplendentMarshal card) { + super(card); + } + + @Override + public ResplendentMarshal copy() { + return new ResplendentMarshal(this); + } +} + +class ResplendentMarshalEffect extends OneShotEffect { + + public ResplendentMarshalEffect() { + super(Outcome.Benefit); + } + + private ResplendentMarshalEffect (final ResplendentMarshalEffect effect) { + super(effect); + } + + @Override + public ResplendentMarshalEffect copy() { + return new ResplendentMarshalEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + Card exiledCard = game.getCard(targetPointer.getFirst(game, source)); + if (controller != null && sourceObject != null && exiledCard != null) { + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + if (permanent.shareCreatureTypes(exiledCard, game)) { + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + if (!game.isSimulation()) { + game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + + " puts a +1/+1 counter on " + permanent.getLogName()); + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 3bf40839c0..6b66aaf6e1 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -250,6 +250,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Reflections of Littjara", 73, Rarity.RARE, mage.cards.r.ReflectionsOfLittjara.class)); cards.add(new SetCardInfo("Renegade Reaper", 386, Rarity.UNCOMMON, mage.cards.r.RenegadeReaper.class)); cards.add(new SetCardInfo("Replicating Ring", 244, Rarity.UNCOMMON, mage.cards.r.ReplicatingRing.class)); + cards.add(new SetCardInfo("Resplendent Marshal", 22, Rarity.MYTHIC, mage.cards.r.ResplendentMarshal.class)); cards.add(new SetCardInfo("Return Upon the Tide", 106, Rarity.UNCOMMON, mage.cards.r.ReturnUponTheTide.class)); cards.add(new SetCardInfo("Revitalize", 23, Rarity.COMMON, mage.cards.r.Revitalize.class)); cards.add(new SetCardInfo("Rimewood Falls", 266, Rarity.COMMON, mage.cards.r.RimewoodFalls.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java b/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java index 50c0c2d59c..b512f6da35 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java @@ -16,6 +16,7 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInASingleGraveyard; import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; /** @@ -25,6 +26,7 @@ import mage.util.CardUtil; public class ExileFromGraveCost extends CostImpl { private final List exiledCards = new ArrayList<>(); + private boolean setTargetPointer = false; public ExileFromGraveCost(TargetCardInYourGraveyard target) { target.setNotTarget(true); @@ -57,9 +59,15 @@ public class ExileFromGraveCost extends CostImpl { this.text = "exile " + target.getTargetName(); } + public ExileFromGraveCost(TargetCardInYourGraveyard target, boolean setTargetPointer) { + this(target); + this.setTargetPointer = setTargetPointer; + } + public ExileFromGraveCost(final ExileFromGraveCost cost) { super(cost); this.exiledCards.addAll(cost.getExiledCards()); + this.setTargetPointer = cost.setTargetPointer; } @Override @@ -77,6 +85,9 @@ public class ExileFromGraveCost extends CostImpl { Cards cardsToExile = new CardsImpl(); cardsToExile.addAll(exiledCards); controller.moveCards(cardsToExile, Zone.EXILED, ability, game); + if (setTargetPointer) { + source.getEffects().setTargetPointer(new FixedTarget(targets.getFirstTarget(), game)); + } paid = true; }