From 8def408d41dc2992123b32da35716439b7710fa3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 6 Nov 2022 17:31:08 -0500 Subject: [PATCH] [BRC] Implement Wondrous Crucible --- .../src/mage/cards/w/WondrousCrucible.java | 93 +++++++++++++++++++ .../mage/sets/TheBrothersWarCommander.java | 1 + 2 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WondrousCrucible.java diff --git a/Mage.Sets/src/mage/cards/w/WondrousCrucible.java b/Mage.Sets/src/mage/cards/w/WondrousCrucible.java new file mode 100644 index 00000000000..bac0acd93e1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WondrousCrucible.java @@ -0,0 +1,93 @@ +package mage.cards.w; + +import mage.ApprovingObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.WardAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.util.RandomUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WondrousCrucible extends CardImpl { + + public WondrousCrucible(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{7}"); + + // Permanents you control have ward {2}. + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + new WardAbility(new GenericManaCost(2), false), Duration.WhileOnBattlefield + ))); + + // At the beginning of your end step, mill two cards, then exile a nonland card at random from your graveyard. Copy it. You may cast the copy without paying its mana cost. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new WondrousCrucibleEffect(), TargetController.YOU, false + )); + } + + private WondrousCrucible(final WondrousCrucible card) { + super(card); + } + + @Override + public WondrousCrucible copy() { + return new WondrousCrucible(this); + } +} + +class WondrousCrucibleEffect extends OneShotEffect { + + WondrousCrucibleEffect() { + super(Outcome.Benefit); + staticText = "mill two cards, then exile a nonland card at random from your graveyard. " + + "Copy it. You may cast the copy without paying its mana cost"; + } + + private WondrousCrucibleEffect(final WondrousCrucibleEffect effect) { + super(effect); + } + + @Override + public WondrousCrucibleEffect copy() { + return new WondrousCrucibleEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + player.millCards(2, source, game); + Card card = RandomUtil.randomFromCollection( + player.getGraveyard().getCards(StaticFilters.FILTER_CARD_NON_LAND, game) + ); + if (card == null) { + return true; + } + Card copiedCard = game.copyCard(card, source, player.getId()); + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE); + player.cast( + player.chooseAbilityForCast(copiedCard, game, false), + game, false, new ApprovingObject(source, game) + ); + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java b/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java index bc47220c7f7..76ed2de031f 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java @@ -182,6 +182,7 @@ public final class TheBrothersWarCommander extends ExpansionSet { cards.add(new SetCardInfo("Wayfarer's Bauble", 171, Rarity.COMMON, mage.cards.w.WayfarersBauble.class)); cards.add(new SetCardInfo("Whirler Rogue", 101, Rarity.UNCOMMON, mage.cards.w.WhirlerRogue.class)); cards.add(new SetCardInfo("Wire Surgeons", 10, Rarity.RARE, mage.cards.w.WireSurgeons.class)); + cards.add(new SetCardInfo("Wondrous Crucible", 20, Rarity.RARE, mage.cards.w.WondrousCrucible.class)); cards.add(new SetCardInfo("Workshop Elders", 102, Rarity.RARE, mage.cards.w.WorkshopElders.class)); cards.add(new SetCardInfo("Wreck Hunter", 11, Rarity.RARE, mage.cards.w.WreckHunter.class)); }