From 493ac284ca5f8adce5c2701f821ccdfc761b13e4 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Sun, 23 Apr 2023 10:50:44 -0500 Subject: [PATCH] Implemented Recommission (#9758) --- Mage.Sets/src/mage/cards/r/Recommission.java | 119 +++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 120 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/Recommission.java diff --git a/Mage.Sets/src/mage/cards/r/Recommission.java b/Mage.Sets/src/mage/cards/r/Recommission.java new file mode 100644 index 0000000000..e29d437058 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/Recommission.java @@ -0,0 +1,119 @@ +package mage.cards.r; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author weirddan455 + */ +public final class Recommission extends CardImpl { + + private static final FilterCard filter + = new FilterCard("artifact or creature card with mana value 3 or less from your graveyard"); + + static { + filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate())); + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4)); + } + + public Recommission(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{W}"); + + // Return target artifact or creature card with mana value 3 or less from your graveyard to the battlefield. If a creature enters the battlefield this way, it enters with an additional +1/+1 counter on it. + this.getSpellAbility().addEffect(new RecommissionEffect()); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter)); + } + + private Recommission(final Recommission card) { + super(card); + } + + @Override + public Recommission copy() { + return new Recommission(this); + } +} + +class RecommissionEffect extends OneShotEffect { + + public RecommissionEffect() { + super(Outcome.PutCardInPlay); + this.staticText = "Return target artifact or creature card with mana value 3 or less from your graveyard to the battlefield. If a creature enters the battlefield this way, it enters with an additional +1/+1 counter on it."; + } + + private RecommissionEffect(final RecommissionEffect effect) { + super(effect); + } + + @Override + public RecommissionEffect copy() { + return new RecommissionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(targetPointer.getFirst(game, source)); + if (controller == null || card == null) { + return false; + } + game.addEffect(new RecommissionCounterEffect(), source); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + return true; + } +} + +class RecommissionCounterEffect extends ReplacementEffectImpl { + + public RecommissionCounterEffect() { + super(Duration.EndOfStep, Outcome.BoostCreature); + } + + private RecommissionCounterEffect(final RecommissionCounterEffect effect) { + super(effect); + } + + @Override + public RecommissionCounterEffect copy() { + return new RecommissionCounterEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return targetPointer.getTargets(game, source).contains(event.getTargetId()); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); + if (permanent == null || !permanent.isCreature(game)) { + return false; + } + permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects()); + discard(); + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 8e74ac8442..dc7465c6e2 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -228,6 +228,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Ravenous Gigamole", 113, Rarity.COMMON, mage.cards.r.RavenousGigamole.class)); cards.add(new SetCardInfo("Raze to the Ground", 149, Rarity.COMMON, mage.cards.r.RazeToTheGround.class)); cards.add(new SetCardInfo("Razorlash Transmogrant", 122, Rarity.RARE, mage.cards.r.RazorlashTransmogrant.class)); + cards.add(new SetCardInfo("Recommission", 22, Rarity.COMMON, mage.cards.r.Recommission.class)); cards.add(new SetCardInfo("Reconstructed Thopter", 242, Rarity.UNCOMMON, mage.cards.r.ReconstructedThopter.class)); cards.add(new SetCardInfo("Recruitment Officer", 23, Rarity.UNCOMMON, mage.cards.r.RecruitmentOfficer.class)); cards.add(new SetCardInfo("Repair and Recharge", 24, Rarity.UNCOMMON, mage.cards.r.RepairAndRecharge.class));