From d713f37003f698e8d27d2c5251b6897241a43da6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 13 Jul 2021 09:10:07 -0400 Subject: [PATCH] [AFC] Implemented Bag of Tricks --- Mage.Sets/src/mage/cards/b/BagOfTricks.java | 79 +++++++++++++++++++ .../mage/sets/ForgottenRealmsCommander.java | 1 + 2 files changed, 80 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BagOfTricks.java diff --git a/Mage.Sets/src/mage/cards/b/BagOfTricks.java b/Mage.Sets/src/mage/cards/b/BagOfTricks.java new file mode 100644 index 0000000000..4d4fb098f3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BagOfTricks.java @@ -0,0 +1,79 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BagOfTricks extends CardImpl { + + public BagOfTricks(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{G}"); + + // {4}{G}, {T}: Roll a d8. Reveal cards from the top of your library until you reveal a creature card with mana value equal to the result. Put that card onto the battlefield and the rest on the bottom of your library in a random order. + Ability ability = new SimpleActivatedAbility(new BagOfTricksEffect(), new ManaCostsImpl<>("{4}{G}")); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private BagOfTricks(final BagOfTricks card) { + super(card); + } + + @Override + public BagOfTricks copy() { + return new BagOfTricks(this); + } +} + +class BagOfTricksEffect extends OneShotEffect { + + BagOfTricksEffect() { + super(Outcome.Benefit); + staticText = "roll a d8. Reveal cards from the top of your library until you reveal a creature card " + + "with mana value equal to the result. Put that card onto the battlefield " + + "and the rest on the bottom of your library in a random order"; + } + + private BagOfTricksEffect(final BagOfTricksEffect effect) { + super(effect); + } + + @Override + public BagOfTricksEffect copy() { + return new BagOfTricksEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int result = player.rollDice(source, game, 8); + Cards cards = new CardsImpl(); + for (Card card : player.getLibrary().getCards(game)) { + cards.add(card); + if (card.isCreature(game) && card.getManaValue() == result) { + player.moveCards(card, Zone.BATTLEFIELD, source, game); + break; + } + } + player.revealCards(source, cards, game); + cards.retainZone(Zone.LIBRARY, game); + player.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java index 168808e06b..1deacf295d 100644 --- a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java +++ b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java @@ -31,6 +31,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet { cards.add(new SetCardInfo("Ashen Rider", 175, Rarity.MYTHIC, mage.cards.a.AshenRider.class)); cards.add(new SetCardInfo("Atarka, World Render", 176, Rarity.RARE, mage.cards.a.AtarkaWorldRender.class)); cards.add(new SetCardInfo("Azorius Chancery", 224, Rarity.UNCOMMON, mage.cards.a.AzoriusChancery.class)); + cards.add(new SetCardInfo("Bag of Tricks", 37, Rarity.RARE, mage.cards.b.BagOfTricks.class)); cards.add(new SetCardInfo("Baleful Strix", 177, Rarity.RARE, mage.cards.b.BalefulStrix.class)); cards.add(new SetCardInfo("Bant Charm", 178, Rarity.UNCOMMON, mage.cards.b.BantCharm.class)); cards.add(new SetCardInfo("Bant Panorama", 225, Rarity.COMMON, mage.cards.b.BantPanorama.class));