diff --git a/Mage.Sets/src/mage/cards/p/Powerbalance.java b/Mage.Sets/src/mage/cards/p/Powerbalance.java new file mode 100644 index 00000000000..f4518a93c01 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/Powerbalance.java @@ -0,0 +1,86 @@ +package mage.cards.p; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.common.SpellCastOpponentTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SetTargetPointer; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author grimreap124 + */ +public final class Powerbalance extends CardImpl { + + public Powerbalance(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}{R}"); + + + // Whenever an opponent casts a spell, you may reveal the top card of your library. If you do, you may cast that card without paying its mana cost if the two spells have the same mana value. + this.addAbility(new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new PowerbalanceEffect(), StaticFilters.FILTER_SPELL_A, true, SetTargetPointer.SPELL)); + } + + private Powerbalance(final Powerbalance card) { + super(card); + } + + @Override + public Powerbalance copy() { + return new Powerbalance(this); + } +} + +class PowerbalanceEffect extends OneShotEffect { + + PowerbalanceEffect() { + super(Outcome.Neutral); + this.staticText = "you may reveal the top card of your library. If you do, you may cast that card without paying its mana cost if the two spells have the same mana value"; + } + + private PowerbalanceEffect(final PowerbalanceEffect effect) { + super(effect); + } + + @Override + public PowerbalanceEffect copy() { + return new PowerbalanceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (controller != null && sourcePermanent != null) { + Spell spell = (Spell) game.getStack().getStackObject(getTargetPointer().getFirst(game, source)); + if (spell != null) { + Card topcard = controller.getLibrary().getFromTop(game); + if (topcard != null) { + CardsImpl cards = new CardsImpl(); + cards.add(topcard); + controller.revealCards(sourcePermanent.getName(), cards, game); + if (topcard.getManaValue() == spell.getManaValue()) { + return CardUtil.castSpellWithAttributesForFree(controller, source, game, topcard); + } + } + return true; + } + } + return false; + } + + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index bb358562b62..e91c66f8ba2 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -212,6 +212,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Plains", 304, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Planar Genesis", 198, Rarity.UNCOMMON, mage.cards.p.PlanarGenesis.class)); cards.add(new SetCardInfo("Polluted Delta", 224, Rarity.RARE, mage.cards.p.PollutedDelta.class)); + cards.add(new SetCardInfo("Powerbalance", 131, Rarity.RARE, mage.cards.p.Powerbalance.class)); cards.add(new SetCardInfo("Priest of Titania", 286, Rarity.UNCOMMON, mage.cards.p.PriestOfTitania.class)); cards.add(new SetCardInfo("Propagator Drone", 167, Rarity.UNCOMMON, mage.cards.p.PropagatorDrone.class)); cards.add(new SetCardInfo("Proud Pack-Rhino", 41, Rarity.UNCOMMON, mage.cards.p.ProudPackRhino.class));