diff --git a/Mage.Sets/src/mage/cards/d/DivineGambit.java b/Mage.Sets/src/mage/cards/d/DivineGambit.java new file mode 100644 index 00000000000..a3c3ff8c2cc --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DivineGambit.java @@ -0,0 +1,97 @@ +package mage.cards.d; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInHand; + +/** + * + * @author weirddan455 + */ +public final class DivineGambit extends CardImpl { + + private static final FilterPermanent filter + = new FilterPermanent("artifact, creature, or enchantment an opponent controls"); + + static { + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + CardType.CREATURE.getPredicate(), + CardType.ENCHANTMENT.getPredicate() + )); + filter.add(TargetController.OPPONENT.getControllerPredicate()); + } + + public DivineGambit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}{W}"); + + // Exile target artifact, creature, or enchantment an opponent controls. + // That player may put a permanent card from their hand onto the battlefield. + this.getSpellAbility().addEffect(new ExileTargetEffect()); + this.getSpellAbility().addEffect(new DivineGambitEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + } + + private DivineGambit(final DivineGambit card) { + super(card); + } + + @Override + public DivineGambit copy() { + return new DivineGambit(this); + } +} + +class DivineGambitEffect extends OneShotEffect { + + public DivineGambitEffect() { + super(Outcome.PutCardInPlay); + this.staticText = "That player may put a permanent card from their hand onto the battlefield"; + } + + private DivineGambitEffect(final DivineGambitEffect effect) { + super(effect); + } + + @Override + public DivineGambitEffect copy() { + return new DivineGambitEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + if (permanent != null) { + Player player = game.getPlayer(permanent.getControllerId()); + if (player != null) { + if (player.chooseUse(outcome, "Put a permanent card from your hand onto the battlefield?", source, game)) { + TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_PERMANENT); + if (player.chooseTarget(outcome, target, source, game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + return player.moveCards(card, Zone.BATTLEFIELD, source, game); + } + } + } + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 7f50f86dc2a..8c0e0c88778 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -67,6 +67,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Canopy Tactician", 378, Rarity.RARE, mage.cards.c.CanopyTactician.class)); cards.add(new SetCardInfo("Cleaving Reaper", 376, Rarity.RARE, mage.cards.c.CleavingReaper.class)); cards.add(new SetCardInfo("Darkbore Pathway", 254, Rarity.RARE, mage.cards.d.DarkborePathway.class)); + cards.add(new SetCardInfo("Divine Gambit", 8, Rarity.UNCOMMON, mage.cards.d.DivineGambit.class)); cards.add(new SetCardInfo("Dogged Pursuit", 85, Rarity.COMMON, mage.cards.d.DoggedPursuit.class)); cards.add(new SetCardInfo("Doomskar Oracle", 10, Rarity.COMMON, mage.cards.d.DoomskarOracle.class)); cards.add(new SetCardInfo("Elderfang Ritualist", 385, Rarity.UNCOMMON, mage.cards.e.ElderfangRitualist.class));