From 17e42d2895bca5fa7b8c59c2d14ba27e69c81f71 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 8 Nov 2022 08:40:17 -0500 Subject: [PATCH] [BRO] Implement Meticulous Excavation --- .../mage/cards/m/MeticulousExcavation.java | 78 +++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MeticulousExcavation.java diff --git a/Mage.Sets/src/mage/cards/m/MeticulousExcavation.java b/Mage.Sets/src/mage/cards/m/MeticulousExcavation.java new file mode 100644 index 00000000000..3847f745780 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MeticulousExcavation.java @@ -0,0 +1,78 @@ +package mage.cards.m; + +import mage.abilities.Ability; +import mage.abilities.common.ActivateIfConditionActivatedAbility; +import mage.abilities.condition.common.MyTurnCondition; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.UnearthAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MeticulousExcavation extends CardImpl { + + public MeticulousExcavation(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + + // {2}{W}: Return target permanent you control to its owner's hand. If it has unearth, instead exile it, then return that card to its owner's hand. Activate only during your turn. + Ability ability = new ActivateIfConditionActivatedAbility( + Zone.BATTLEFIELD, new MeticulousExcavationEffect(), + new ManaCostsImpl<>("{2}{W}"), MyTurnCondition.instance + ); + ability.addTarget(new TargetControlledPermanent()); + this.addAbility(ability); + } + + private MeticulousExcavation(final MeticulousExcavation card) { + super(card); + } + + @Override + public MeticulousExcavation copy() { + return new MeticulousExcavation(this); + } +} + +class MeticulousExcavationEffect extends OneShotEffect { + + MeticulousExcavationEffect() { + super(Outcome.Benefit); + staticText = "return target permanent you control to its owner's hand. " + + "If it has unearth, instead exile it, then return that card to its owner's hand"; + } + + private MeticulousExcavationEffect(final MeticulousExcavationEffect effect) { + super(effect); + } + + @Override + public MeticulousExcavationEffect copy() { + return new MeticulousExcavationEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (player == null || permanent == null) { + return false; + } + if (!permanent.getAbilities(game).containsClass(UnearthAbility.class)) { + return player.moveCards(permanent, Zone.HAND, source, game); + } + player.moveCards(permanent, Zone.EXILED, source, game); + return player.moveCards(game.getCard(permanent.getMainCard().getId()), Zone.HAND, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 1b12e896bc9..2a7e995645d 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -163,6 +163,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Mass Production", 15, Rarity.UNCOMMON, mage.cards.m.MassProduction.class)); cards.add(new SetCardInfo("Mechanized Warfare", 139, Rarity.RARE, mage.cards.m.MechanizedWarfare.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mechanized Warfare", 338, Rarity.RARE, mage.cards.m.MechanizedWarfare.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Meticulous Excavation", 16, Rarity.UNCOMMON, mage.cards.m.MeticulousExcavation.class)); cards.add(new SetCardInfo("Mightstone's Animation", 58, Rarity.COMMON, mage.cards.m.MightstonesAnimation.class)); cards.add(new SetCardInfo("Military Discipline", 17, Rarity.COMMON, mage.cards.m.MilitaryDiscipline.class)); cards.add(new SetCardInfo("Mine Worker", 239, Rarity.COMMON, mage.cards.m.MineWorker.class));