diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/DragonlordsPrerogative.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/DragonlordsPrerogative.java new file mode 100644 index 0000000000..42dc56ae9f --- /dev/null +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/DragonlordsPrerogative.java @@ -0,0 +1,114 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.dragonsoftarkir; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.RevealTargetFromHandCost; +import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect; +import mage.abilities.effects.ContinuousRuleModifyingEffect; +import mage.abilities.effects.common.CantBeCounteredSourceEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.target.common.TargetCardInHand; + +/** + * + * @author jeffwadsworth + */ +public class DragonlordsPrerogative extends CardImpl { + + private static final FilterCard filter = new FilterCard("a Dragon card from your hand"); + + static { + filter.add(new SubtypePredicate("Dragon")); + } + + public DragonlordsPrerogative(UUID ownerId) { + super(ownerId, 52, "Dragonlord's Prerogative", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{4}{U}{U}"); + this.expansionSetCode = "DTK"; + + // As an additional cost to cast Dragonlord's Prerogative, you may reveal a Dragon card from your hand. + // If you revealed a Dragon card or controlled a Dragon as you cast Dragonlord's Prerogative, Dragonlord's Prerogative can't be countered. + // Draw four cards. + + this.getSpellAbility().addCost(new RevealTargetFromHandCost(new TargetCardInHand(0, 1, filter))); + Condition condition = new DragonlordsPrerogativeCondition(); + ContinuousRuleModifyingEffect cantBeCountered = new CantBeCounteredSourceEffect(); + ConditionalContinuousRuleModifyingEffect conditionalCantBeCountered = new ConditionalContinuousRuleModifyingEffect(cantBeCountered, condition); + conditionalCantBeCountered.setText("If you revealed a Dragon card or controlled a Dragon as you cast {this}, {this} can't be countered"); + Ability ability = new SimpleStaticAbility(Zone.STACK, conditionalCantBeCountered); + this.addAbility(ability); + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(4)); + + } + + public DragonlordsPrerogative(final DragonlordsPrerogative card) { + super(card); + } + + @Override + public DragonlordsPrerogative copy() { + return new DragonlordsPrerogative(this); + } +} + +class DragonlordsPrerogativeCondition implements Condition { + + private final static FilterControlledPermanent filter = new FilterControlledPermanent("Dragon"); + + static { + filter.add(new SubtypePredicate("Dragon")); + } + + @Override + public boolean apply(Game game, Ability source) { + boolean applies = false; + Spell spell = game.getStack().getSpell(source.getSourceId()); + if (spell != null) { + RevealTargetFromHandCost cost = (RevealTargetFromHandCost) spell.getSpellAbility().getCosts().get(0); + if (cost != null) { + applies = !cost.getTargets().isEmpty(); + } + } + if (!applies) { + applies = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0; + } + return applies; + } +} diff --git a/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java b/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java index 3226e4b272..e97ad38c71 100644 --- a/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java +++ b/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java @@ -1,34 +1,31 @@ /* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - -// author jeff - - + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +// author jeffwadsworth package mage.abilities.costs.common; import java.util.UUID; @@ -43,21 +40,21 @@ import mage.players.Player; import mage.target.common.TargetCardInHand; public class RevealTargetFromHandCost extends CostImpl { - + public int convertedManaCosts = 0; protected int numberCardsRevealed = 0; - + public RevealTargetFromHandCost(TargetCardInHand target) { this.addTarget(target); this.text = "reveal " + target.getTargetName(); } - + public RevealTargetFromHandCost(RevealTargetFromHandCost cost) { super(cost); this.convertedManaCosts = cost.convertedManaCosts; this.numberCardsRevealed = cost.numberCardsRevealed; } - + @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) { if (targets.choose(Outcome.Benefit, controllerId, sourceId, game)) { @@ -65,29 +62,33 @@ public class RevealTargetFromHandCost extends CostImpl { numberCardsRevealed = 0; Player player = game.getPlayer(controllerId); Cards cards = new CardsImpl(); - for (UUID targetId: targets.get(0).getTargets()) { + for (UUID targetId : targets.get(0).getTargets()) { Card card = player.getHand().get(targetId, game); - if (card == null) - return false; - convertedManaCosts += card.getManaCost().convertedManaCost(); - numberCardsRevealed++; - cards.add(card); + if (card != null) { + convertedManaCosts += card.getManaCost().convertedManaCost(); + numberCardsRevealed++; + cards.add(card); + } + player.revealCards("card cost", cards, game); paid = true; + return paid; + } + if (!paid && targets.get(0).getNumberOfTargets() == 0) { + paid = true; // e.g. for optional additional costs. example: Dragonlord's Prerogative + return paid; } - player.revealCards("card cost", cards, game); // this is not a boolean - return paid; } paid = false; return paid; } - + public int getConvertedCosts() { - return convertedManaCosts; - } + return convertedManaCosts; + } public int getNumberRevealedCards() { - return numberCardsRevealed; - } + return numberCardsRevealed; + } @Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index eb4634e26a..9bbde31946 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -25676,25 +25676,32 @@ Profound Journey|Dragons of Tarkir|30|R|{5}{W}{W}|Sorcery|||Return target perman Radiant Purge|Dragons of Tarkir|31|R|{1}{W}|Instant|||Exile target multicolored creature or multicolored enchantment.| Sandcrafter Mage|Dragons of Tarkir|33|C|{2}{W}|Creature - Human Wizard|2|2|When Sandcrafter Mage enters the battlefield, bolster 1 (Choose a creature with the least toughness among the creatures you control and put a +1/+1 counter on it.)| Sunscorch Regent|Dragons of Tarkir|41|R|{3}{W}{W}|Creature - Dragon|4|3|Flying$Whenever an opponent casts a spell, put a +1/+1 counter on Sunscorch Regent and you gain 1 life.| +Surge of Righteousness|Dragons of Tarkir|42|U|Instant|||Destroy target black or red creature that's attacking or blocking. You gain 2 life.| Anticipate|Dragons of Tarkir|45|C|{1}{U}|Instant|||Look at the top three cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order.| Dragonlord's Prerogative|Dragons of Tarkir|52|R|{4}{U}{U}|Instant||As an additional cost to cast Dragonlord's Prerogative, you may reveal a Dragon card from your hand.$If you reveal a Dragon card or controlled a Dragon as you cast Dragonlord's Prerogative, Dragonlord's Prerogative can't be countered.$Draw four cards.| +Encase in Ice|Dragons of Tarkir|54|{1}{U}|Enchantment - Aura|||Flash$Enchant red or green creature$When Encase in Ice enters the battlefield, tap enchanted creature.$Enchanted creature doesn't untap during its controller's untap step.| Gudul Lurker|Dragons of Tarkir|56|U|{U}|Creature - Salamander|1|1|Gudul Lurker can't be blocked.$Megamorph {U} (You may cast this card face down as a 2/2 creature for {3}. Turn it up anytime for its megamorph cost and put a +1/+1 counter on it.)| +Mirror Mockery|Dragons of Tarkir|62|R|{1}{U}|Enchantment - Aura|||Enchant creature$Whenever enchanted creature attacks, you may put a token onto the battlefield that's a copy of that creature. Exile that token at the end of combat.| Ojutai's Summons|Dragons of Tarkir|68|C|{3}{U}{U}|Sorcery|||Put a 2/2 blue Djinn Monk creature token with flying onto the battlefield.$Rebound (If you cast this spell from your hand, exile it as it resolves. At the beginning of your next upkeep, you may cast this card from exile without paying its mana cost.)| Shorecrasher Elemental|Dragons of Tarkir|73|M|{U}{U}{U}|Creature - Elemental|3|3|{U}: Exile Shorecrasher Elemental, then return it to the battlefield face down under its owner's control.${1}: Shorecrasher Elemental gets +1/-1 or -1/+1 until end of turn.$Megamorph {4}{U} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it.)| +Silumgar's Scorn|Dragtons of Tarkir|78|U|{U}{U}|Instant|||As an additional cost to cast Silumgar's Scorn, you may reveal a Dragon card from your hand.$Counter target spell unless its controller pays {1}. If you revealed a Dragon card or controlled a Dragon as you cast Silumgar's Scorn, counter that spell instead.| Stratus Dancer|Dragons of Tarkir|80|R|{1}{U}|Creature - Djinn Monk|2|1|Flying$Megamorph {1}{U} You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time from its megamorph cost and put a +1/+1 counter on it.)| Acid-Spewer Dragon|Dragons of Tarkir|86|U|{5}{B}|Creature - Dragon|3|3|Flying, deathtouch$Megamorph {5}{B}{B} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it.)$When Acid-Spewer Dragon is turned face up, put a +1/+1 counter on each other Dragon creature you control.| Blood-Chin Fanatic|Dragons of Tarkir|88|R|{1}{B}{B}|Creature - Orc Warrior|3|3|{1}{B}, Sacrifice another Warrior creature: Target player loses X life and you gain X life, where X is the sacrificed creature's power.| Deathbringer Regent|Dragons of Tarkir|96|R|{5}{B}{B}|Creature - Dragon|5|6|Flying$When Deathbringer Regent enters the battlefield, if you cast it from your hand and there are five or more other creatures on the battlefield, destroy all other creatures.| Marang River Skeleton|Dragons of Tarkir|108|U|{1}{B}|Creature - Skeleton|1|1|{B}: Regenerate Marang River Skeleton.$Megamorph {3}{B} You may cast this card face down as a 2/2 creature for {3}. Turn it face up at any time for its megamorph cost and put a +1/+1 counter on it.)| Risen Executioner|Dragons of Tarkir|116|M|{2}{B}{B}|Creature - Zombie Warrior|4|3|Risen Executioner can't block.$Other Zombie creatures you control get +1/+1.$You may cast Risen Executioner from your graveyard if you pay {1} more to cast it for each other creature card in your graveyard.| +Self-Inflicted Wound|Dragons of Tarkir|117|{1}{B}|Sorcery|||Target opponent sacrifices a green or white creature. If that player does, he or she loses 2 life.| Sidisi, Undead Vizier|Dragons of Tarkir|120|R|{3}{B}{B}|Legendary Creature - Zombie Naga|4|6|Deathtouch$Exploit (When this creature enters the battlefield, you may sacrifice a creature.)$When Sidisi, Undead Vizier exploits a creature, you may search your library for a card, put it into your hand, then shuffle your library.| Silumgar Assassin|Dragons of Tarkir|121|R|{1}{B}|Creature - Human Assassin|2|1|Creatures with power greater than Silumgar Assassin's power can't block it.$Megamorph {2}{B} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up at any time for its megamorph cost and put a +1/+1 counter on it.)$When Silumgar Assassin is turned face up, destroy target creature with power 3 or less an opponent controls.| Silumgar Butcher|Dragons of Tarkir|122|C|{4}{B}|Creature - Zombie Djinn|3|3|Exploit (When this creature enters the battlefield, you may sacrifice a creature.)$When Silumgar Butcher exploits a creature, target creature gets -3/-3 until end of turn.| Ultimate Price|Dragons of Tarkir|124|U|{1}{B}|Instant|||Destroy target monocolored creature.| Crater Elemental|Dragons of Tarkir|132|R|{{2}{R}|Creature - Elemental|0|6|{R}, {T}, Sacrifice Crater Elemental: Crater Elemental deals 4 damage to target creature.$Formidable - {2}{R}: Crater Elemental has base power 8 until end of turn. Activate this ability only if creatures you control have total power 8 or greater.| Descent of the Dragons|Dragons of Tarkir|133|M|{4}{R}{R}|Sorcery||Destroy any number of target creatures. For each creature destroyed this way, its controller puts a 4/4 red Dragon creature token with flying onto the battlefield.| +Draconic Roar|Dragons of Tarkir|154|U|{1}{R}|Instant - As an additional cost to cast Draconic Roar, you may reveal a Dragon card from your hand.$Draconic Roar deals 3 damage to target creature. If you revealed a Dragon card or controlled a Dragon as you cast Draconic Roar, Draconic Roar deals 3 damage to that creature's controller.| Dragon Fodder|Dragons of Tarkir|135|C|{1}{R}|Sorcery|||Put two 1/1 red Goblin creature tokens onto the battlefield.| Dragon Tempest|Dragons of Tarkir|136|R|{1}{R}|Enchantment|||Whenever a creature with flying enters the battlefield under your control, it gains haste until the end of turn.$Whenever a Dragon enters the battlefield under your control, it deals X damage to target creature or player, where X is the number of Dragons you control.| +Dragon Whisperer|Dragons of Tarkir|137|M|{R}{R}|Creature - Human Shaman|2|2|{R}: Dragon Whisperer gains flying until end of turn.${1}{R}: Dragon Whisperer get +1/+0 until end of turn$ - {4}{R}{R}: Put a 4/4 red Dragon creature token with flying onto the battlefield. Activate this ability only if creatures you control have total power 8 or greater.| Dragonlord's Servant|Dragons of Tarkir|138|U|{1}{R}|Creature - Goblin Shaman|1|3|Dragon spells you cast cost {1} less to cast.| Lightning Berserker|Dragons of Tarkir|146|U|{R}|Creature - Human Berserker|1|1|{R}: Lightning Berserker gets +1/+0 until end of turn.$Dash {R} (You may cast this spell for its dash cost. If you do, it gains haste, and it's returned from the battlefield to its owner's hand at the beginning of the next end step.)| Roast|Dragons of Tarkir|151|U|{1}{R}|Sorcery|||Roast deals 5 damage to target creature without flying.| @@ -25707,6 +25714,7 @@ Aerie Bowmasters|Dragons of Tarkir|170|C|{2}|{G}{G}|Creature - Hound Archer|Reac Collected Company|Dragons of Tarkir|177|R|{3}{G}|Instant|||Look at the top six cards of your library. Put up to two creature cards with converted mana cost 3 or less from among them onto the battlefield. Put the rest on the bottom of your library in any order.| Deathmist Raptor|Dragons of Tarkir|180|M|{1}{G}{G}|Creature - Lizard Beast|3|3|Deathtouch$Whenever a permanent you control is turned face up, you may return Deathmist Raptor from your graveyard to the battlefield face up or face down.$Megamorph {4}{G} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it.)| Den Protector|Dragons of Tarkir|181|R|{1}{G}|Creature - Human Warrior|2|1|Creatures with power less than Den Protector's power can't block it.$Megamorph {1}{G} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it.)| +Display of Dominance|Dragons of Tarkir|182|{1}{G}|Instant|||Choose one - Destroy target blue or black noncreature permanent; or Permanents you control can't be the targets of blue or black spells your opponents control this turn.| Epic Confrontation|Dragons of Tarkir|185|C|{1}{G}|Sorcery|||Target creature you control gets +1/+2 until end of turn. It fights target creature you don't control.| Foe-Razer Regent|Dragons of Tarkir|187|R|{5}{G}{G}|Creature - Dragon|4|5|Flying$When Foe-Razer Regent enters the battlefield, you may have it fight target creature you don't control.$Whenever a creature you control fights, put two +1/+1 counters on it at the beginning of the next end step.| Salt Road Ambushers|Dragons of Tarkir|198|U|{3}{G}|Creature - Hound Warrior|3|3|Whenever another permanent you control is turned face up, if it's a creature, put two +1/+1 counters on it.$Megamorph {3}{G}{G} You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it.)|