From f0ed08219c1bb831388c0eb8aab4779bb0a54fa6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 4 Nov 2020 09:06:40 -0500 Subject: [PATCH] [CMR] Implemented Glacian, Powerstone Engineer --- .../cards/g/GlacianPowerstoneEngineer.java | 140 ++++++++++++++++++ Mage.Sets/src/mage/sets/CommanderLegends.java | 1 + 2 files changed, 141 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java diff --git a/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java b/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java new file mode 100644 index 00000000000..6b2ba652d8b --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java @@ -0,0 +1,140 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.VariableCostImpl; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.PartnerAbility; +import mage.cards.*; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledArtifactPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GlacianPowerstoneEngineer extends CardImpl { + + public GlacianPowerstoneEngineer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ARTIFICER); + this.power = new MageInt(3); + this.toughness = new MageInt(6); + + // {T}, Tap X untapped artifacts you control: Look at the top X cards of your library. Put one of those cards into your hand and the rest into your graveyard. + Ability ability = new SimpleActivatedAbility(new GlacianPowerstoneEngineerEffect(), new TapSourceCost()); + ability.addCost(new GlacianPowerstoneEngineerCost()); + this.addAbility(ability); + + // Partner + this.addAbility(PartnerAbility.getInstance()); + } + + private GlacianPowerstoneEngineer(final GlacianPowerstoneEngineer card) { + super(card); + } + + @Override + public GlacianPowerstoneEngineer copy() { + return new GlacianPowerstoneEngineer(this); + } +} + +class GlacianPowerstoneEngineerEffect extends OneShotEffect { + + GlacianPowerstoneEngineerEffect() { + super(Outcome.Benefit); + staticText = "look at the top X cards of your library. " + + "Put one of those cards into your hand and the rest into your graveyard"; + } + + private GlacianPowerstoneEngineerEffect(final GlacianPowerstoneEngineerEffect effect) { + super(effect); + } + + @Override + public GlacianPowerstoneEngineerEffect copy() { + return new GlacianPowerstoneEngineerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int xValue = source.getManaCostsToPay().getX(); + for (Cost cost : source.getCosts()) { + if (cost instanceof GlacianPowerstoneEngineerCost) { + xValue = ((GlacianPowerstoneEngineerCost) cost).getAmount(); + break; + } + } + if (xValue < 1) { + return false; + } + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue)); + if (cards.isEmpty()) { + return false; + } + TargetCard targetCard = new TargetCardInLibrary(1, StaticFilters.FILTER_CARD); + player.choose(outcome, cards, targetCard, game); + Card card = game.getCard(targetCard.getFirstTarget()); + if (card != null && player.moveCards(card, Zone.HAND, source, game)) { + cards.remove(card); + } + player.moveCards(cards, Zone.GRAVEYARD, source, game); + return true; + } +} + +class GlacianPowerstoneEngineerCost extends VariableCostImpl { + + private static final FilterControlledPermanent filter + = new FilterControlledArtifactPermanent("untapped artifacts you control"); + + static { + filter.add(Predicates.not(TappedPredicate.instance)); + } + + GlacianPowerstoneEngineerCost() { + super("controlled untapped artifacts you would like to tap"); + this.text = "Tap X untapped artifacts you control"; + } + + private GlacianPowerstoneEngineerCost(final GlacianPowerstoneEngineerCost cost) { + super(cost); + } + + @Override + public GlacianPowerstoneEngineerCost copy() { + return new GlacianPowerstoneEngineerCost(this); + } + + @Override + public int getMaxValue(Ability source, Game game) { + return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + } + + @Override + public Cost getFixedCostsFromAnnouncedValue(int xValue) { + return new TapTargetCost(new TargetControlledPermanent(xValue, xValue, filter, true)); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 9525db8124e..68a24db82d1 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -110,6 +110,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Ghost of Ramirez DePietro", 71, Rarity.UNCOMMON, mage.cards.g.GhostOfRamirezDePietro.class)); cards.add(new SetCardInfo("Gift of Paradise", 229, Rarity.COMMON, mage.cards.g.GiftOfParadise.class)); cards.add(new SetCardInfo("Gilanra, Caller of Wirewood", 230, Rarity.UNCOMMON, mage.cards.g.GilanraCallerOfWirewood.class)); + cards.add(new SetCardInfo("Glacian, Powerstone Engineer", 72, Rarity.UNCOMMON, mage.cards.g.GlacianPowerstoneEngineer.class)); cards.add(new SetCardInfo("Gnostro, Voice of the Crags", 276, Rarity.RARE, mage.cards.g.GnostroVoiceOfTheCrags.class)); cards.add(new SetCardInfo("Gor Muldrak, Amphinologist", 277, Rarity.RARE, mage.cards.g.GorMuldrakAmphinologist.class)); cards.add(new SetCardInfo("Halana, Kessig Ranger", 231, Rarity.UNCOMMON, mage.cards.h.HalanaKessigRanger.class));