From 548b05a1a882bbcdc3e68ce4246c07f45707e6ab Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 3 May 2023 07:28:23 -0400 Subject: [PATCH] [MAT] Implement Reckless Handling --- .../src/mage/cards/r/RecklessHandling.java | 78 +++++++++++++++++++ .../sets/MarchOfTheMachineTheAftermath.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RecklessHandling.java diff --git a/Mage.Sets/src/mage/cards/r/RecklessHandling.java b/Mage.Sets/src/mage/cards/r/RecklessHandling.java new file mode 100644 index 0000000000..40e9b09fbc --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RecklessHandling.java @@ -0,0 +1,78 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RecklessHandling extends CardImpl { + + public RecklessHandling(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}"); + + // Search your library for an artifact card, reveal it, put it into your hand, shuffle, then discard a card at random. If an artifact card was discarded this way, Reckless Handling deals 2 damage to each opponent. + this.getSpellAbility().addEffect(new SearchLibraryPutInHandEffect( + new TargetCardInLibrary(StaticFilters.FILTER_CARD_ARTIFACT_AN), true, true + ).setText("search your library for an artifact card, reveal it, put it into your hand, shuffle")); + this.getSpellAbility().addEffect(new RecklessHandlingEffect()); + } + + private RecklessHandling(final RecklessHandling card) { + super(card); + } + + @Override + public RecklessHandling copy() { + return new RecklessHandling(this); + } +} + +class RecklessHandlingEffect extends OneShotEffect { + + RecklessHandlingEffect() { + super(Outcome.Benefit); + staticText = ", then discard a card at random. If an artifact card " + + "was discarded this way, {this} deals 2 damage to each opponent"; + } + + private RecklessHandlingEffect(final RecklessHandlingEffect effect) { + super(effect); + } + + @Override + public RecklessHandlingEffect copy() { + return new RecklessHandlingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || player.getHand().isEmpty()) { + return false; + } + Card card = player.discard(1, true, false, source, game).getRandom(game); + if (card == null || !card.isArtifact(game)) { + return false; + } + for (UUID playerId : game.getOpponents(source.getControllerId())) { + Player opponent = game.getPlayer(playerId); + if (opponent != null) { + opponent.damage(2, source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java index df1c6d5e7a..50631c766e 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java @@ -26,6 +26,7 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet { cards.add(new SetCardInfo("Jolrael, Voice of Zhalfir", 33, Rarity.RARE, mage.cards.j.JolraelVoiceOfZhalfir.class)); cards.add(new SetCardInfo("Kolaghan Warmonger", 17, Rarity.UNCOMMON, mage.cards.k.KolaghanWarmonger.class)); cards.add(new SetCardInfo("Markov Baron", 14, Rarity.UNCOMMON, mage.cards.m.MarkovBaron.class)); + cards.add(new SetCardInfo("Reckless Handling", 19, Rarity.UNCOMMON, mage.cards.r.RecklessHandling.class)); cards.add(new SetCardInfo("Spark Rupture", 5, Rarity.RARE, mage.cards.s.SparkRupture.class)); cards.add(new SetCardInfo("The Kenriths' Royal Funeral", 34, Rarity.RARE, mage.cards.t.TheKenrithsRoyalFuneral.class)); cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class));