diff --git a/Mage.Sets/src/mage/cards/d/DiluvianPrimordial.java b/Mage.Sets/src/mage/cards/d/DiluvianPrimordial.java index 98bde31f8f6..5ebaeb3e536 100644 --- a/Mage.Sets/src/mage/cards/d/DiluvianPrimordial.java +++ b/Mage.Sets/src/mage/cards/d/DiluvianPrimordial.java @@ -1,4 +1,3 @@ - package mage.cards.d; import mage.MageInt; @@ -44,7 +43,10 @@ public final class DiluvianPrimordial extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - // When Diluvian Primordial enters the battlefield, for each opponent, you may cast up to one target instant or sorcery card from that player's graveyard without paying its mana cost. If a card cast this way would be put into a graveyard this turn, exile it instead. + // When Diluvian Primordial enters the battlefield, for each opponent, + // you may cast up to one target instant or sorcery card from that + // player's graveyard without paying its mana cost. If a card cast this way + // would be put into a graveyard this turn, exile it instead. Ability ability = new EntersBattlefieldTriggeredAbility(new DiluvianPrimordialEffect(), false); ability.setTargetAdjuster(DiluvianPrimordialAdjuster.instance); this.addAbility(ability); @@ -71,7 +73,8 @@ enum DiluvianPrimordialAdjuster implements TargetAdjuster { if (opponent == null) { continue; } - FilterCard filter = new FilterCard("instant or sorcery card from " + opponent.getLogName() + "'s graveyard"); + FilterCard filter = new FilterCard("instant or sorcery card from " + + opponent.getLogName() + "'s graveyard"); filter.add(new OwnerIdPredicate(opponentId)); filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY))); TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0, 1, filter); @@ -84,7 +87,10 @@ class DiluvianPrimordialEffect extends OneShotEffect { public DiluvianPrimordialEffect() { super(Outcome.PlayForFree); - this.staticText = "for each opponent, you may cast up to one target instant or sorcery card from that player's graveyard without paying its mana cost. If a card cast this way would be put into a graveyard this turn, exile it instead"; + this.staticText = "for each opponent, you may cast up to one target " + + "instant or sorcery card from that player's graveyard without " + + "paying its mana cost. If a card cast this way would be put " + + "into a graveyard this turn, exile it instead"; } public DiluvianPrimordialEffect(final DiluvianPrimordialEffect effect) { @@ -104,8 +110,12 @@ class DiluvianPrimordialEffect extends OneShotEffect { if (target instanceof TargetCardInOpponentsGraveyard) { Card targetCard = game.getCard(target.getFirstTarget()); if (targetCard != null) { - if (controller.chooseUse(outcome, "Cast " + targetCard.getLogName() + '?', source, game)) { - if (controller.cast(targetCard.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) { + if (controller.chooseUse(Outcome.PlayForFree, "Cast " + targetCard.getLogName() + '?', source, game)) { + game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), Boolean.TRUE); + Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(targetCard, game, true), + game, true, new MageObjectReference(source.getSourceObject(game), game)); + game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), null); + if (cardWasCast) { ContinuousEffect effect = new DiluvianPrimordialReplacementEffect(); effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId()))); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java b/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java index 0a7880c94c7..94c9c39694d 100644 --- a/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java +++ b/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java @@ -50,7 +50,10 @@ public final class DreadhordeArcanist extends CardImpl { // Trample this.addAbility(TrampleAbility.getInstance()); - // Whenever Dreadhorde Arcanist attacks, you may cast target instant or sorcery card with converted mana cost less than or equal to Dreadhorde Arcanist's power from your graveyard without paying its mana cost. If that card would be put into your graveyard this turn, exile it instead. + // Whenever Dreadhorde Arcanist attacks, you may cast target instant or + // sorcery card with converted mana cost less than or equal to Dreadhorde Arcanist's + // power from your graveyard without paying its mana cost. If that card would be put + // into your graveyard this turn, exile it instead. Ability ability = new AttacksTriggeredAbility(new DreadhordeArcanistEffect(), false); ability.addTarget(new TargetCardInYourGraveyard(filter)); this.addAbility(ability); @@ -80,10 +83,10 @@ enum DreadhordeArcanistPredicate implements ObjectSourcePlayerPredicateSpell mastery — If there are two or more instant and/or sorcery cards in your graveyard, you may cast up to two revealed instant and/or sorcery cards instead of one. + // Target opponent reveals the top seven cards of their library. + // You may cast an instant or sorcery card from among them without paying + // its mana cost. Then that player puts the rest into their graveyard. + // Spell mastery — If there are two or more instant and/or + // sorcery cards in your graveyard, you may cast up to two revealed instant + // and/or sorcery cards instead of one. getSpellAbility().addEffect(new TalentOfTheTelepathEffect()); getSpellAbility().addTarget(new TargetOpponent()); @@ -55,8 +58,12 @@ class TalentOfTheTelepathEffect extends OneShotEffect { public TalentOfTheTelepathEffect() { super(Outcome.PlayForFree); - this.staticText = "Target opponent reveals the top seven cards of their library. You may cast an instant or sorcery card from among them without paying its mana cost. Then that player puts the rest into their graveyard. " - + "
Spell mastery — If there are two or more instant and/or sorcery cards in your graveyard, you may cast up to two revealed instant and/or sorcery cards instead of one."; + this.staticText = "Target opponent reveals the top seven cards of their " + + "library. You may cast an instant or sorcery card from among them " + + "without paying its mana cost. Then that player puts the rest into their graveyard. " + + "
Spell mastery — If there are two or more instant " + + "and/or sorcery cards in your graveyard, you may cast up to two " + + "revealed instant and/or sorcery cards instead of one."; } public TalentOfTheTelepathEffect(final TalentOfTheTelepathEffect effect) { @@ -76,7 +83,8 @@ class TalentOfTheTelepathEffect extends OneShotEffect { if (targetOpponent != null && sourceObject != null) { Set allCards = targetOpponent.getLibrary().getTopCards(game, 7); Cards cards = new CardsImpl(allCards); - targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game); + targetOpponent.revealCards(sourceObject.getIdName() + " - " + + targetOpponent.getName() + "'s top library cards", cards, game); for (Card card : allCards) { if (filter.match(card, game)) { cardsToCast.add(card); @@ -95,14 +103,20 @@ class TalentOfTheTelepathEffect extends OneShotEffect { target.setNotTarget(true); while (numberOfSpells > 0 && !cardsToCast.isEmpty() - && controller.chooseUse(outcome, "Cast an instant or sorcery card from among them for free?", source, game) - && controller.choose(outcome, cardsToCast, target, game)) { + && controller.chooseUse(outcome, "Cast an instant or sorcery card " + + "from among them for free?", source, game) + && controller.choose(Outcome.PlayForFree, cardsToCast, target, game)) { Card card = cardsToCast.get(target.getFirstTarget(), game); if (card != null) { - controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); - numberOfSpells--; - cardsToCast.remove(card); - allCards.remove(card); + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE); + Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), + game, true, new MageObjectReference(source.getSourceObject(game), game)); + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null); + if (cardWasCast) { + numberOfSpells--; + cardsToCast.remove(card); + allCards.remove(card); + } } if (!controller.canRespond()) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TorrentialGearhulk.java b/Mage.Sets/src/mage/cards/t/TorrentialGearhulk.java index 399ee393157..8763da84e07 100644 --- a/Mage.Sets/src/mage/cards/t/TorrentialGearhulk.java +++ b/Mage.Sets/src/mage/cards/t/TorrentialGearhulk.java @@ -1,4 +1,3 @@ - package mage.cards.t; import java.util.UUID; @@ -49,7 +48,8 @@ public final class TorrentialGearhulk extends CardImpl { // Flash this.addAbility(FlashAbility.getInstance()); - // When Torrential Gearhulk enters the battlefield, you may cast target instant card from your graveyard without paying its mana cost. + // When Torrential Gearhulk enters the battlefield, you may cast target + // instant card from your graveyard without paying its mana cost. // If that card would be put into your graveyard this turn, exile it instead. Ability ability = new EntersBattlefieldTriggeredAbility(new TorrentialGearhulkEffect()); ability.addTarget(new TargetCardInYourGraveyard(filter)); @@ -69,7 +69,7 @@ public final class TorrentialGearhulk extends CardImpl { class TorrentialGearhulkEffect extends OneShotEffect { TorrentialGearhulkEffect() { - super(Outcome.Benefit); + super(Outcome.PlayForFree); this.staticText = "you may cast target instant card from your graveyard without paying its mana cost. " + "If that card would be put into your graveyard this turn, exile it instead"; } @@ -88,9 +88,13 @@ class TorrentialGearhulkEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); - if (card != null && card.getSpellAbility() != null) { + if (card != null) { if (controller.chooseUse(outcome, "Cast " + card.getLogName() + '?', source, game)) { - if (controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) { + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE); + Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), + game, true, new MageObjectReference(source.getSourceObject(game), game)); + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null); + if (cardWasCast) { ContinuousEffect effect = new TorrentialGearhulkReplacementEffect(card.getId()); effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId()))); game.addEffect(effect, source);