diff --git a/Mage.Sets/src/mage/cards/m/MaestrosTheater.java b/Mage.Sets/src/mage/cards/m/MaestrosTheater.java new file mode 100644 index 0000000000..f94bb2b173 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MaestrosTheater.java @@ -0,0 +1,57 @@ +package mage.cards.m; + +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.common.DoWhenCostPaid; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MaestrosTheater extends CardImpl { + + private static final FilterCard filter = new FilterCard("a basic Island, Swamp, or Mountain card"); + + static { + filter.add(SuperType.BASIC.getPredicate()); + filter.add(Predicates.or( + SubType.ISLAND.getPredicate(), + SubType.SWAMP.getPredicate(), + SubType.MOUNTAIN.getPredicate() + )); + } + + public MaestrosTheater(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + + // When Maestros Theater enters the battlefield, sacrifice it. When you do, search your library for a basic Island, Swamp, or Mountain card, put it onto the battlefield tapped, then shuffle and you gain 1 life. + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new SearchLibraryPutInPlayEffect( + new TargetCardInLibrary(filter), true, true + ), false); + ability.addEffect(new GainLifeEffect(1).concatBy("and")); + this.addAbility(new EntersBattlefieldTriggeredAbility(new DoWhenCostPaid( + ability, new SacrificeSourceCost(), null, false + ))); + } + + private MaestrosTheater(final MaestrosTheater card) { + super(card); + } + + @Override + public MaestrosTheater copy() { + return new MaestrosTheater(this); + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index b4d64f8ff4..8e9e043253 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -40,6 +40,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Light 'Em Up", 113, Rarity.COMMON, mage.cards.l.LightEmUp.class)); cards.add(new SetCardInfo("Lord Xander, the Collector", 197, Rarity.MYTHIC, mage.cards.l.LordXanderTheCollector.class)); cards.add(new SetCardInfo("Maestros Charm", 199, Rarity.UNCOMMON, mage.cards.m.MaestrosCharm.class)); + cards.add(new SetCardInfo("Maestros Theater", 251, Rarity.COMMON, mage.cards.m.MaestrosTheater.class)); cards.add(new SetCardInfo("Mountain", 268, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Murder", 88, Rarity.COMMON, mage.cards.m.Murder.class)); cards.add(new SetCardInfo("Obscura Charm", 208, Rarity.UNCOMMON, mage.cards.o.ObscuraCharm.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java index a58dc4974d..5e59c33ad6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java @@ -1,6 +1,5 @@ package mage.abilities.effects.common; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.common.delayed.ReflexiveTriggeredAbility; @@ -38,17 +37,23 @@ public class DoWhenCostPaid extends OneShotEffect { this.optional = effect.optional; } + private boolean checkOptional(Player player, Game game, Ability source) { + return optional && !player.chooseUse( + ability.getEffects().getOutcome(source, this.outcome), + CardUtil.replaceSourceName( + chooseUseText, CardUtil.getSourceName(game, source) + ), source, game + ); + } + @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source); - if (player == null || mageObject == null) { + if (player == null) { return false; } - String message = CardUtil.replaceSourceName(chooseUseText, mageObject.getLogName()); - Outcome payOutcome = ability.getEffects().getOutcome(source, this.outcome); if (!cost.canPay(source, source, player.getId(), game) - || (optional && !player.chooseUse(payOutcome, message, source, game))) { + || checkOptional(player, game, source)) { return false; } cost.clearPaid(); diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 8bffe072bd..f384fd416c 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -533,7 +533,7 @@ public final class CardUtil { } public static String replaceSourceName(String message, String sourceName) { - return message.replace("{this}", sourceName); + return message != null ? message.replace("{this}", sourceName) : null; } public static String booleanToFlipName(boolean flip) { diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 5203680ad3..4b1a41acd4 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -43932,7 +43932,7 @@ Devilish Valet|Streets of New Capenna|105|R|{2}{R}|Creature - Devil Warrior|1|3| Jaxis, the Troublemaker|Streets of New Capenna|112|R|{3}{R}|Legendary Creature - Human Warrior|2|3|{R}, {T}, Discard a card: Create a token that's a copy of another target creature you control. It gains haste and "When this creature dies, draw a card." Sacrifice it at the beginning of the next end step. Activate only as a sorcery.$Blitz {1}{R}| Light 'Em Up|Streets of New Capenna|113|C|{1}{R}|Sorcery|||Casualty 2$Light 'Em Up deals 2 damage to target creature or planeswalker.| Strangle|Streets of New Capenna|125|C|{R}|Sorcery|||Strangle deals 3 damage to target creature or planeswalker.| -Urabask, Heretic Praetor|Streets of New Capenna|129|M|{3}{R}{R}|Legendary Creature - Phyrexian Praetor|4|4|Haste$At the beginning of your upkeep, exile the top card of your library. You may play it this turn.$At the beginning of each opponent's upkeep, the next time they would draw a card this turn, instead they exile the top card of their library. They may play it this turn.| +Urabrask, Heretic Praetor|Streets of New Capenna|129|M|{3}{R}{R}|Legendary Creature - Phyrexian Praetor|4|4|Haste$At the beginning of your upkeep, exile the top card of your library. You may play it this turn.$At the beginning of each opponent's upkeep, the next time they would draw a card this turn, instead they exile the top card of their library. They may play it this turn.| Courier's Briefcase|Streets of New Capenna|142|U|{1}{G}|Artifact - Treasure|||When Courier's Briefcase enters the battlefield, create a 1/1 green and white Citizen creature token.${T}, Sacrifice Courier's Briefcase: Add one mana of any color.${W}{U}{B}{R}{G}, {T}, Sacrifice Courier's Briefcase: Draw three cards.| Gala Greeters|Streets of New Capenna|148|R|{1}{G}|Creature - Elf Druid|1|1|Alliance — Whenever another creature enters the battlefield under your control, choose one that hasn't been chosen this turn—$• Put a +1/+1 counter on Gala Greeters.$• Create a tapped Treasure token.$• You gain 2 life.| Brokers Ascendancy|Streets of New Capenna|170|R|{G}{W}{U}|Enchantment|||At the beginning of your end step, put a +1/+1 counter on each creature you control and a loyalty counter on each planeswalker you control.| @@ -43952,6 +43952,7 @@ Chrome Cat|Streets of New Capenna|236|C|{3}|Artifact Creature - Cat|3|2|When Chr Getaway Car|Streets of New Capenna|237|R|{3}|Artifact - Vehicle|4|3|Haste$Whenever Getaway Car attacks or blocks, return up to one target creature that crewed it this turn to its owner's hand.$Crew 1| Botanical Plaza|Streets of New Capenna|247|C||Land|||Botanical Plaza enters the battlefield tapped.${T}: Add {G} or {W}.${2}{G}{W}, {T}, Sacrifice Botanical Plaza: Draw a card.| Jetmir's Garden|Streets of New Capenna|250|R||Land - Mountain Forest Plains|||({T}: Add {R}, {G}, or {W}.)$Jetmir's Garden enters the battlefield tapped.$Cycling {3}| +Maestros Theater|Streets of New Capenna|251|C||Land|||When Maestros Theater enters the battlefield, sacrifice it. When you do, search your library for a basic Island, Swamp, or Mountain card, put it onto the battlefield tapped, then shuffle and you gain 1 life.| Racers' Ring|Streets of New Capenna|253|C||Land|||Racers' Ring enters the battlefield tapped.${T}: Add {R} or {G}.${2}{R}{G}, {T}, Sacrifice Racers' Ring: Draw a card.| Raffine's Tower|Streets of New Capenna|254|R||Land - Plains Island Swamp|||({T}: Add {W}, {U}, or {B}.)$Raffine's Tower enters the battlefield tapped.$Cycling {3}| Skybridge Towers|Streets of New Capenna|256|C||Land|||Skybridge Towers enters the battlefield tapped.${T}: Add {W} or {U}.${2}{W}{U}, {T}, Sacrifice Skybridge Towers: Draw a card.|