From 98aaa780812256b45d174384d870bb14457de9bf Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Thu, 5 Aug 2021 15:38:39 -0500 Subject: [PATCH] - Fixed #8044 and #7842 --- .../src/mage/cards/i/IntetTheDreamer.java | 9 +- .../mage/cards/j/JadziOracleOfArcavios.java | 100 +++++++++++++++--- .../abilities/effects/AsThoughEffectImpl.java | 30 ++++-- .../abilities/keyword/ForetellAbility.java | 30 +++--- 4 files changed, 129 insertions(+), 40 deletions(-) diff --git a/Mage.Sets/src/mage/cards/i/IntetTheDreamer.java b/Mage.Sets/src/mage/cards/i/IntetTheDreamer.java index d65b1ac6dfb..10289acecc4 100644 --- a/Mage.Sets/src/mage/cards/i/IntetTheDreamer.java +++ b/Mage.Sets/src/mage/cards/i/IntetTheDreamer.java @@ -121,6 +121,7 @@ class IntetTheDreamerAsThoughEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + // note to always discard the effect if anything fails UUID targetId = getTargetPointer().getFirst(game, source); if (targetId == null) { this.discard(); @@ -132,7 +133,7 @@ class IntetTheDreamerAsThoughEffect extends AsThoughEffectImpl { return false; } - // split cards + // split cards, etc objectId = card.getMainCard().getId(); if (objectId.equals(targetId) @@ -147,7 +148,11 @@ class IntetTheDreamerAsThoughEffect extends AsThoughEffectImpl { allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game); // while Intet remains on battlefield - return new SourceRemainsInZoneCondition(Zone.BATTLEFIELD).apply(game, source); + if(!(new SourceRemainsInZoneCondition(Zone.BATTLEFIELD).apply(game, source))) { + this.discard(); + return false; + } + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java b/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java index 0fa53272abf..2069d23c7e2 100644 --- a/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java +++ b/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java @@ -2,7 +2,6 @@ package mage.cards.j; import mage.ApprovingObject; import mage.abilities.Ability; -import mage.abilities.SpellAbility; import mage.abilities.common.MagecraftAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.condition.Condition; @@ -25,6 +24,10 @@ import mage.players.Player; import mage.target.common.TargetCardInHand; import java.util.UUID; +import mage.cards.AdventureCard; +import mage.cards.ModalDoubleFacesCardHalf; +import mage.cards.SplitCard; +import mage.cards.SplitCardHalf; /** * @author TheElk801 @@ -65,8 +68,8 @@ public final class JadziOracleOfArcavios extends ModalDoubleFacesCard { this.getRightHalfCard().getSpellAbility().addEffect(new ConditionalOneShotEffect( new DoIfCostPaid( new ReturnToHandSourceEffect(), new DiscardCardCost() - ), condition, "Then if you control eight or more lands, " + - "you may discard a card. If you do, return {this} to its owner's hand." + ), condition, "Then if you control eight or more lands, " + + "you may discard a card. If you do, return {this} to its owner's hand." )); this.getRightHalfCard().getSpellAbility().addHint(LandsYouControlHint.instance); } @@ -85,8 +88,8 @@ class JadziOracleOfArcaviosEffect extends OneShotEffect { JadziOracleOfArcaviosEffect() { super(Outcome.Benefit); - staticText = "reveal the top card of your library. If it's a nonland card, you may cast it " + - "by paying {1} rather than paying its mana cost. If it's a land card, put it onto the battlefield"; + staticText = "reveal the top card of your library. If it's a nonland card, you may cast it " + + "by paying {1} rather than paying its mana cost. If it's a land card, put it onto the battlefield"; } private JadziOracleOfArcaviosEffect(final JadziOracleOfArcaviosEffect effect) { @@ -100,29 +103,92 @@ class JadziOracleOfArcaviosEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { return false; } - Card card = player.getLibrary().getFromTop(game); + Card card = controller.getLibrary().getFromTop(game); if (card == null) { return false; } - player.revealCards(source, new CardsImpl(card), game); + controller.revealCards(source, new CardsImpl(card), game); if (card.isLand(game)) { - return player.moveCards(card, Zone.BATTLEFIELD, source, game); + // this is a bit wierd in game, though it works fine + // note that MDFC land cards are handled differently: they can't be moved + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - if (!player.chooseUse(outcome, "Cast " + card.getName() + " by paying {1}?", source, game)) { + + // query player + if (!controller.chooseUse(outcome, "Cast " + card.getName() + " by paying {1}?", source, game)) { return false; } - SpellAbility spellAbility = player.chooseAbilityForCast(card, game, true); - if (spellAbility == null) { - return false; + + // handle split-cards + if (card instanceof SplitCard) { + SplitCardHalf leftHalfCard = ((SplitCard) card).getLeftHalfCard(); + SplitCardHalf rightHalfCard = ((SplitCard) card).getRightHalfCard(); + controller.setCastSourceIdWithAlternateMana(leftHalfCard.getId(), new ManaCostsImpl<>("{1}"), null); + controller.setCastSourceIdWithAlternateMana(rightHalfCard.getId(), new ManaCostsImpl<>("{1}"), null); } - game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE); - player.setCastSourceIdWithAlternateMana(card.getId(), new ManaCostsImpl<>("{1}"), null); - player.cast(spellAbility, game, false, new ApprovingObject(source, game)); + + // handle MDFC + if (card instanceof ModalDoubleFacesCard) { + ModalDoubleFacesCardHalf leftHalfCard = ((ModalDoubleFacesCard) card).getLeftHalfCard(); + ModalDoubleFacesCardHalf rightHalfCard = ((ModalDoubleFacesCard) card).getRightHalfCard(); + // some MDFC cards are lands. IE: sea gate restoration + if (!leftHalfCard.isLand(game)) { + controller.setCastSourceIdWithAlternateMana(leftHalfCard.getId(), new ManaCostsImpl<>("{1}"), null); + } + if (!rightHalfCard.isLand(game)) { + controller.setCastSourceIdWithAlternateMana(rightHalfCard.getId(), new ManaCostsImpl<>("{1}"), null); + } + game.getState().setValue("PlayFromNotOwnHandZone" + ((ModalDoubleFacesCard) card).getLeftHalfCard().getId(), Boolean.TRUE); + game.getState().setValue("PlayFromNotOwnHandZone" + ((ModalDoubleFacesCard) card).getRightHalfCard().getId(), Boolean.TRUE); + } + + // handle adventure cards + if (card instanceof AdventureCard) { + Card creatureCard = card.getMainCard(); + Card spellCard = ((AdventureCard) card).getSpellCard(); + controller.setCastSourceIdWithAlternateMana(creatureCard.getId(), new ManaCostsImpl<>("{1}"), null); + controller.setCastSourceIdWithAlternateMana(spellCard.getId(), new ManaCostsImpl<>("{1}"), null); + game.getState().setValue("PlayFromNotOwnHandZone" + creatureCard.getId(), Boolean.TRUE); + game.getState().setValue("PlayFromNotOwnHandZone" + spellCard.getId(), Boolean.TRUE); + } + + // normal card + if (!(card instanceof SplitCard) + || !(card instanceof ModalDoubleFacesCard) + || !(card instanceof AdventureCard)) { + controller.setCastSourceIdWithAlternateMana(card.getMainCard().getId(), new ManaCostsImpl<>("{1}"), null); + } + + // cast it + controller.cast(controller.chooseAbilityForCast(card.getMainCard(), game, false), + game, false, new ApprovingObject(source, game)); + + // turn off effect after cast on every possible card-face + if (card instanceof SplitCard) { + SplitCardHalf leftHalfCard = ((SplitCard) card).getLeftHalfCard(); + SplitCardHalf rightHalfCard = ((SplitCard) card).getRightHalfCard(); + game.getState().setValue("PlayFromNotOwnHandZone" + leftHalfCard.getId(), null); + game.getState().setValue("PlayFromNotOwnHandZone" + rightHalfCard.getId(), null); + } + if (card instanceof ModalDoubleFacesCard) { + ModalDoubleFacesCardHalf leftHalfCard = ((ModalDoubleFacesCard) card).getLeftHalfCard(); + ModalDoubleFacesCardHalf rightHalfCard = ((ModalDoubleFacesCard) card).getRightHalfCard(); + game.getState().setValue("PlayFromNotOwnHandZone" + leftHalfCard.getId(), null); + game.getState().setValue("PlayFromNotOwnHandZone" + rightHalfCard.getId(), null); + } + if (card instanceof AdventureCard) { + Card creatureCard = card.getMainCard(); + Card spellCard = ((AdventureCard) card).getSpellCard(); + game.getState().setValue("PlayFromNotOwnHandZone" + creatureCard.getId(), null); + game.getState().setValue("PlayFromNotOwnHandZone" + spellCard.getId(), null); + } + // turn off effect on a normal card game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null); + return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/AsThoughEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/AsThoughEffectImpl.java index 6f9cb6d8346..a3cd1b1dc6e 100644 --- a/Mage/src/main/java/mage/abilities/effects/AsThoughEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/AsThoughEffectImpl.java @@ -10,6 +10,7 @@ import mage.game.Game; import mage.players.Player; import java.util.UUID; +import mage.cards.AdventureCard; /** * @author BetaSteward_at_googlemail.com @@ -69,12 +70,14 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements } /** - * Internal method to do the neccessary to allow the card from objectId to be cast or played (if it's a land) without paying any mana. - * Additional costs (like sacrificing or discarding) have still to be payed. - * Checks if the card is of the correct type or in the correct zone have to be done before. + * Internal method to do the necessary to allow the card from objectId to be + * cast or played (if it's a land) without paying any mana. Additional costs + * (like sacrificing or discarding) have still to be payed. Checks if the + * card is of the correct type or in the correct zone have to be done + * before. * - * @param objectId sourceId of the card to play - * @param source source ability that allows this effect + * @param objectId sourceId of the card to play + * @param source source ability that allows this effect * @param affectedControllerId player allowed to play the card * @param game * @return @@ -93,12 +96,21 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements player.setCastSourceIdWithAlternateMana(rightCard.getId(), null, rightCard.getSpellAbility().getCosts()); } else if (card instanceof ModalDoubleFacesCard) { Card leftCard = ((ModalDoubleFacesCard) card).getLeftHalfCard(); - player.setCastSourceIdWithAlternateMana(leftCard.getId(), null, leftCard.getSpellAbility().getCosts()); Card rightCard = ((ModalDoubleFacesCard) card).getRightHalfCard(); - player.setCastSourceIdWithAlternateMana(rightCard.getId(), null, rightCard.getSpellAbility().getCosts()); - } else { - player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); + // some MDFC's are land. IE: sea gate restoration + if (!leftCard.isLand(game)) { + player.setCastSourceIdWithAlternateMana(leftCard.getId(), null, leftCard.getSpellAbility().getCosts()); + } + if (!rightCard.isLand(game)) { + player.setCastSourceIdWithAlternateMana(rightCard.getId(), null, rightCard.getSpellAbility().getCosts()); + } + } else if (card instanceof AdventureCard) { + Card creatureCard = card.getMainCard(); + Card spellCard = ((AdventureCard) card).getSpellCard(); + player.setCastSourceIdWithAlternateMana(creatureCard.getId(), null, creatureCard.getSpellAbility().getCosts()); + player.setCastSourceIdWithAlternateMana(spellCard.getId(), null, spellCard.getSpellAbility().getCosts()); } + player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); } return true; } diff --git a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java index abd1b080544..efb4fa38886 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java @@ -231,21 +231,27 @@ public class ForetellAbility extends SpecialAction { } else if (card instanceof ModalDoubleFacesCard) { if (foretellCost != null) { ModalDoubleFacesCardHalf leftHalfCard = ((ModalDoubleFacesCard) card).getLeftHalfCard(); - ForetellCostAbility ability = new ForetellCostAbility(foretellCost); - ability.setSourceId(leftHalfCard.getId()); - ability.setControllerId(source.getControllerId()); - ability.setSpellAbilityType(leftHalfCard.getSpellAbility().getSpellAbilityType()); - ability.setAbilityName(leftHalfCard.getName()); - game.getState().addOtherAbility(leftHalfCard, ability); + // some MDFC's are land IE: sea gate restoration + if (!leftHalfCard.isLand(game)) { + ForetellCostAbility ability = new ForetellCostAbility(foretellCost); + ability.setSourceId(leftHalfCard.getId()); + ability.setControllerId(source.getControllerId()); + ability.setSpellAbilityType(leftHalfCard.getSpellAbility().getSpellAbilityType()); + ability.setAbilityName(leftHalfCard.getName()); + game.getState().addOtherAbility(leftHalfCard, ability); + } } if (foretellSplitCost != null) { ModalDoubleFacesCardHalf rightHalfCard = ((ModalDoubleFacesCard) card).getRightHalfCard(); - ForetellCostAbility ability = new ForetellCostAbility(foretellSplitCost); - ability.setSourceId(rightHalfCard.getId()); - ability.setControllerId(source.getControllerId()); - ability.setSpellAbilityType(rightHalfCard.getSpellAbility().getSpellAbilityType()); - ability.setAbilityName(rightHalfCard.getName()); - game.getState().addOtherAbility(rightHalfCard, ability); + // some MDFC's are land IE: sea gate restoration + if (!rightHalfCard.isLand(game)) { + ForetellCostAbility ability = new ForetellCostAbility(foretellSplitCost); + ability.setSourceId(rightHalfCard.getId()); + ability.setControllerId(source.getControllerId()); + ability.setSpellAbilityType(rightHalfCard.getSpellAbility().getSpellAbilityType()); + ability.setAbilityName(rightHalfCard.getName()); + game.getState().addOtherAbility(rightHalfCard, ability); + } } } else if (card instanceof AdventureCard) { if (foretellCost != null) {