diff --git a/Mage.Sets/src/mage/cards/s/SpryAndMighty.java b/Mage.Sets/src/mage/cards/s/SpryAndMighty.java new file mode 100644 index 00000000000..d5ec63115b7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SpryAndMighty.java @@ -0,0 +1,102 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.TrampleAbility; +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.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.targetpointer.FixedTargets; +import mage.util.CardUtil; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class SpryAndMighty extends CardImpl { + + public SpryAndMighty(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}"); + + // Choose two creatures you control. You draw X cards and the chosen creatures get +X/+X and gain trample until end of turn, where X is the difference between the chosen creatures' powers. + this.getSpellAbility().addEffect(new SpryAndMightyEffect()); + } + + private SpryAndMighty(final SpryAndMighty card) { + super(card); + } + + @Override + public SpryAndMighty copy() { + return new SpryAndMighty(this); + } +} + +class SpryAndMightyEffect extends OneShotEffect { + + SpryAndMightyEffect() { + super(Outcome.Benefit); + staticText = "choose two creatures you control. You draw X cards and the chosen creatures get +X/+X " + + "and gain trample until end of turn, where X is the difference between the chosen creatures' powers"; + } + + private SpryAndMightyEffect(final SpryAndMightyEffect effect) { + super(effect); + } + + @Override + public SpryAndMightyEffect copy() { + return new SpryAndMightyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !game.getBattlefield().contains( + StaticFilters.FILTER_CONTROLLED_CREATURE, + source.getControllerId(), source, game, 2 + )) { + return false; + } + TargetPermanent target = new TargetControlledCreaturePermanent(2); + target.withNotTarget(true); + player.choose(outcome, target, source, game); + List permanents = target + .getTargets() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + if (permanents.size() != 2) { + return false; + } + game.informPlayers( + CardUtil.getSourceLogName(game, source) + ": " + + player.getLogName() + " chooses " + + permanents.get(0).getLogName() + " and " + + permanents.get(1).getLogName() + ); + int diff = Math.abs(permanents.get(0).getPower().getValue() - permanents.get(1).getPower().getValue()); + if (diff > 0) { + player.drawCards(diff, source, game); + game.addEffect(new BoostTargetEffect(diff, diff) + .setTargetPointer(new FixedTargets(permanents, game)), source); + } + game.addEffect(new GainAbilityTargetEffect(TrampleAbility.getInstance()) + .setTargetPointer(new FixedTargets(permanents, game)), source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/LorwynEclipsed.java b/Mage.Sets/src/mage/sets/LorwynEclipsed.java index dd1df1b497c..8edf5f1f5c5 100644 --- a/Mage.Sets/src/mage/sets/LorwynEclipsed.java +++ b/Mage.Sets/src/mage/sets/LorwynEclipsed.java @@ -319,6 +319,8 @@ public final class LorwynEclipsed extends ExpansionSet { cards.add(new SetCardInfo("Spell Snare", 71, Rarity.UNCOMMON, mage.cards.s.SpellSnare.class)); cards.add(new SetCardInfo("Spiral into Solitude", 36, Rarity.COMMON, mage.cards.s.SpiralIntoSolitude.class)); cards.add(new SetCardInfo("Springleaf Drum", 260, Rarity.UNCOMMON, mage.cards.s.SpringleafDrum.class)); + cards.add(new SetCardInfo("Spry and Mighty", 195, Rarity.RARE, mage.cards.s.SpryAndMighty.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Spry and Mighty", 329, Rarity.RARE, mage.cards.s.SpryAndMighty.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Squawkroaster", 160, Rarity.UNCOMMON, mage.cards.s.Squawkroaster.class)); cards.add(new SetCardInfo("Stalactite Dagger", 261, Rarity.COMMON, mage.cards.s.StalactiteDagger.class)); cards.add(new SetCardInfo("Steam Vents", "348b", Rarity.RARE, mage.cards.s.SteamVents.class, NON_FULL_USE_VARIOUS));