diff --git a/Mage.Sets/src/mage/cards/c/CausticExhale.java b/Mage.Sets/src/mage/cards/c/CausticExhale.java new file mode 100644 index 00000000000..e98d0568b03 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CausticExhale.java @@ -0,0 +1,41 @@ +package mage.cards.c; + +import mage.abilities.costs.OrCost; +import mage.abilities.costs.common.BeholdDragonCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CausticExhale extends CardImpl { + + public CausticExhale(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}"); + + // As an additional cost to cast this spell, behold a Dragon or pay {1}. + this.getSpellAbility().addCost(new OrCost( + "behold a Dragon or pay {1}", + new BeholdDragonCost(), new GenericManaCost(1) + )); + + // Target creature gets -3/-3 until end of turn. + this.getSpellAbility().addEffect(new BoostTargetEffect(-3, -3)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + private CausticExhale(final CausticExhale card) { + super(card); + } + + @Override + public CausticExhale copy() { + return new CausticExhale(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java index ae57d1b5415..1cbcab624b5 100644 --- a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java +++ b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java @@ -26,6 +26,7 @@ public final class TarkirDragonstorm extends ExpansionSet { cards.add(new SetCardInfo("Bloodfell Caves", 250, Rarity.COMMON, mage.cards.b.BloodfellCaves.class)); cards.add(new SetCardInfo("Blossoming Sands", 251, Rarity.COMMON, mage.cards.b.BlossomingSands.class)); cards.add(new SetCardInfo("Boulderborn Dragon", 239, Rarity.COMMON, mage.cards.b.BoulderbornDragon.class)); + cards.add(new SetCardInfo("Caustic Exhale", 74, Rarity.COMMON, mage.cards.c.CausticExhale.class)); cards.add(new SetCardInfo("Craterhoof Behemoth", 138, Rarity.MYTHIC, mage.cards.c.CraterhoofBehemoth.class)); cards.add(new SetCardInfo("Cruel Truths", 76, Rarity.COMMON, mage.cards.c.CruelTruths.class)); cards.add(new SetCardInfo("Devoted Duelist", 104, Rarity.COMMON, mage.cards.d.DevotedDuelist.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/BeholdDragonCost.java b/Mage/src/main/java/mage/abilities/costs/common/BeholdDragonCost.java new file mode 100644 index 00000000000..3502a9a0888 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/costs/common/BeholdDragonCost.java @@ -0,0 +1,109 @@ +package mage.abilities.costs.common; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.CostImpl; +import mage.cards.Card; +import mage.cards.CardsImpl; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInHand; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class BeholdDragonCost extends CostImpl { + + private static final FilterPermanent filterPermanent = new FilterControlledPermanent(SubType.DRAGON); + private static final FilterCard filterCard = new FilterCard("a Dragon card"); + + static { + filterCard.add(SubType.DRAGON.getPredicate()); + } + + public BeholdDragonCost() { + super(); + this.text = "behold a Dragon"; + } + + private BeholdDragonCost(final BeholdDragonCost cost) { + super(cost); + } + + @Override + public BeholdDragonCost copy() { + return new BeholdDragonCost(this); + } + + @Override + public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + return Optional + .ofNullable(game.getPlayer(controllerId)) + .map(Player::getHand) + .map(cards -> cards.count(filterCard, game) > 0) + .orElse(false) + || game + .getBattlefield() + .contains(filterPermanent, controllerId, source, game, 1); + } + + @Override + public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { + Player player = game.getPlayer(controllerId); + if (player == null) { + paid = false; + return paid; + } + boolean hasPermanent = game + .getBattlefield() + .contains(filterPermanent, controllerId, source, game, 1); + boolean hasHand = player.getHand().count(filterCard, game) > 0; + boolean usePermanent; + if (hasPermanent && hasHand) { + usePermanent = player.chooseUse( + Outcome.Neutral, "Choose a Dragon you control or reveal one from your hand?", + null, "Choose controlled", "Reveal from hand", source, game); + } else if (hasPermanent) { + usePermanent = true; + } else if (hasHand) { + usePermanent = false; + } else { + paid = false; + return paid; + } + if (usePermanent) { + TargetPermanent target = new TargetPermanent(filterPermanent); + target.withNotTarget(true); + player.choose(Outcome.Neutral, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent == null) { + paid = false; + return paid; + } + game.informPlayers(player.getLogName() + " chooses to behold " + permanent.getLogName()); + paid = true; + return true; + } + TargetCard target = new TargetCardInHand(filterCard); + player.choose(Outcome.Neutral, player.getHand(), target, source, game); + Card card = game.getCard(target.getFirstTarget()); + if (card == null) { + paid = false; + return paid; + } + player.revealCards(source, new CardsImpl(card), game); + paid = true; + return paid; + } +}