* Cast without paying its mana cost - fixed that some cards can freeze the game on disconnected player or non castable cards (Mizzix's Mastery and other);

This commit is contained in:
Oleg Agafonov 2020-01-17 20:54:56 +04:00
parent e92081b7ea
commit 1ac9502748
13 changed files with 113 additions and 150 deletions

View file

@ -1,6 +1,5 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount;
@ -20,8 +19,9 @@ import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import org.apache.log4j.Logger;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class BringToLight extends CardImpl {
@ -86,8 +86,7 @@ class BringToLightEffect extends OneShotEffect {
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) {
} else {
if (!cardWasCast) {
Logger.getLogger(BringToLightEffect.class).error("Bring to Light: spellAbility == null " + card.getName());
}
}

View file

@ -1,17 +1,12 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -19,8 +14,9 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class ChaosWand extends CardImpl {
@ -79,7 +75,7 @@ class ChaosWandEffect extends OneShotEffect {
return false;
}
Cards cardsToShuffle = new CardsImpl();
while (opponent.getLibrary().hasCards()) {
while (opponent.canRespond() && opponent.getLibrary().hasCards()) {
Card card = opponent.getLibrary().getFromTop(game);
if (card == null) {
break;

View file

@ -79,21 +79,22 @@ class CollectedConjuringEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null
if (controller == null
|| sourceObject == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 6));
Cards cardsToChoose = new CardsImpl(cards);
controller.moveCards(cards, Zone.EXILED, source, game);
int cardsCast = 0;
while (!cards.getCards(filter, source.getSourceId(), source.getControllerId(), game).isEmpty()
while (!cardsToChoose.getCards(filter, source.getSourceId(), source.getControllerId(), game).isEmpty()
&& cardsCast < 2) {
if (!controller.chooseUse(Outcome.PlayForFree, "Cast a card exiled with "
+ sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
break;
}
TargetCard targetCard = new TargetCard(1, Zone.EXILED, filter2);
if (!controller.choose(Outcome.PlayForFree, cards, targetCard, game)) {
if (!controller.choose(Outcome.PlayForFree, cardsToChoose, targetCard, game)) {
continue;
}
Card card = game.getCard(targetCard.getFirstTarget());
@ -104,11 +105,12 @@ class CollectedConjuringEffect extends OneShotEffect {
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
cardsToChoose.remove(card); // remove on non cast too (infinite freeze fix)
if (cardWasCast) {
cards.remove(card);
cardsCast++;
} else {
game.informPlayer(controller, "You're not able to cast "
game.informPlayer(controller, "You're not able to cast "
+ card.getIdName() + " or you canceled the casting.");
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -18,8 +17,9 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class EpicExperiment extends CardImpl {
@ -79,7 +79,7 @@ class EpicExperimentEffect extends OneShotEffect {
}
cardsToCast.addAll(epicExperimentExileZone.getCards(filter, source.getSourceId(),
source.getControllerId(), game));
while (!cardsToCast.isEmpty()) {
while (controller.canRespond() && !cardsToCast.isEmpty()) {
if (!controller.chooseUse(Outcome.PlayForFree, "Cast (another) a card exiled with "
+ sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
break;
@ -94,7 +94,7 @@ class EpicExperimentEffect extends OneShotEffect {
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
if (!cardWasCast) {
game.informPlayer(controller, "You're not able to cast "
game.informPlayer(controller, "You're not able to cast "
+ card.getIdName() + " or you canceled the casting.");
}
cardsToCast.remove(card);

View file

@ -1,32 +1,24 @@
package mage.cards.e;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterNonlandCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author ciaccona007 & L_J
*/
public final class EtaliPrimalStorm extends CardImpl {
@ -99,7 +91,7 @@ class EtaliPrimalStormEffect extends OneShotEffect {
Cards cardsToCast = new CardsImpl();
cardsToCast.addAll(currentExiledCards);
boolean alreadyCast = false;
while (!cardsToCast.isEmpty()) {
while (controller.canRespond() && !cardsToCast.isEmpty()) {
if (!controller.chooseUse(Outcome.PlayForFree, "Cast a"
+ (alreadyCast ? "nother" : "") + " card exiled with "
+ sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
@ -119,7 +111,7 @@ class EtaliPrimalStormEffect extends OneShotEffect {
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
if (!cardWasCast) {
game.informPlayer(controller, "You're not able to cast "
game.informPlayer(controller, "You're not able to cast "
+ card.getIdName() + " or you canceled the casting.");
}
cardsToCast.remove(card);

View file

@ -1,22 +1,12 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DontUntapInControllersUntapStepAllEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.Predicates;
@ -26,8 +16,9 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.UUID;
/**
*
* @author ciaccona007
*/
public final class HazoretsUndyingFury extends CardImpl {
@ -87,7 +78,7 @@ class HazoretsUndyingFuryEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null
if (controller != null
&& sourceObject != null) {
controller.shuffleLibrary(source, game);
// move cards from library to exile
@ -101,13 +92,13 @@ class HazoretsUndyingFuryEffect extends OneShotEffect {
}
cardsToCast.addAll(hazoretsUndyingFuryExileZone.getCards(filter,
source.getSourceId(), source.getControllerId(), game));
while (!cardsToCast.isEmpty()) {
while (controller.canRespond() && !cardsToCast.isEmpty()) {
if (!controller.chooseUse(Outcome.PlayForFree,
"Cast (another) a card exiled with "
+ sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
+ sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
break;
}
TargetCard targetCard = new TargetCard(1, Zone.EXILED,
TargetCard targetCard = new TargetCard(1, Zone.EXILED,
new FilterCard("nonland card to cast for free"));
if (controller.choose(Outcome.PlayForFree, cardsToCast, targetCard, game)) {
Card card = game.getCard(targetCard.getFirstTarget());
@ -116,10 +107,9 @@ class HazoretsUndyingFuryEffect extends OneShotEffect {
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) {
cardsToCast.remove(card);
} else {
game.informPlayer(controller, "You're not able to cast "
cardsToCast.remove(card);
if (!cardWasCast) {
game.informPlayer(controller, "You're not able to cast "
+ card.getIdName() + " or you canceled the casting.");
}
}

View file

@ -1,20 +1,12 @@
package mage.cards.h;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
@ -25,8 +17,12 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
/**
*
* @author jeffwadsworth & L_J
*/
public final class HellcarverDemon extends CardImpl {
@ -86,21 +82,20 @@ class HellcarverDemonEffect extends OneShotEffect {
// move cards from library to exile
Set<Card> currentExiledCards = new HashSet<>();
currentExiledCards.addAll(controller.getLibrary().getTopCards(game, 6));
controller.moveCardsToExile(currentExiledCards, source, game, true,
controller.moveCardsToExile(currentExiledCards, source, game, true,
source.getSourceId(), sourceObject.getIdName());
// cast the possible cards without paying the mana
Cards cardsToCast = new CardsImpl();
cardsToCast.addAll(currentExiledCards);
boolean alreadyCast = false;
while (!cardsToCast.isEmpty()
&& controller.canRespond()) {
while (controller.canRespond() && !cardsToCast.isEmpty()) {
if (!controller.chooseUse(outcome, "Cast a" + (alreadyCast ? "another" : "")
+ " card exiled with " + sourceObject.getLogName()
+ " card exiled with " + sourceObject.getLogName()
+ " without paying its mana cost?", source, game)) {
break;
}
TargetCard targetCard = new TargetCard(1, Zone.EXILED,
TargetCard targetCard = new TargetCard(1, Zone.EXILED,
new FilterNonlandCard("nonland card to cast for free"));
if (controller.choose(Outcome.PlayForFree, cardsToCast, targetCard, game)) {
alreadyCast = true;
@ -110,10 +105,9 @@ class HellcarverDemonEffect extends OneShotEffect {
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) {
cardsToCast.remove(card);
} else {
game.informPlayer(controller, "You're not able to cast "
cardsToCast.remove(card);
if (!cardWasCast) {
game.informPlayer(controller, "You're not able to cast "
+ card.getIdName() + " or you canceled the casting.");
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -11,11 +10,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
@ -29,8 +24,9 @@ import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInExile;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class IzzetChemister extends CardImpl {
@ -115,17 +111,16 @@ class IzzetChemisterCastFromExileEffect extends OneShotEffect {
}
TargetCardInExile target = new TargetCardInExile(0, 1, filter, exileId, false);
target.setNotTarget(true);
while (cardsToExile.count(filter, game) > 0
while (controller.canRespond()
&& cardsToExile.count(filter, game) > 0
&& controller.choose(Outcome.PlayForFree, cardsToExile, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true,
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true,
new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
if (cardWasCast) {
cardsToExile.remove(card);
}
cardsToExile.remove(card);
} else {
break OuterLoop;
}

View file

@ -1,10 +1,5 @@
package mage.cards.j;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
@ -12,17 +7,8 @@ import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.FilterPlayer;
import mage.filter.common.FilterNonlandCard;
@ -42,9 +28,9 @@ import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.*;
/**
*
*
* @author LevelX2
*/
public final class JaceArchitectOfThought extends CardImpl {
@ -141,7 +127,7 @@ class JaceArchitectOfThoughtDelayedTriggeredAbility extends DelayedTriggeredAbil
@Override
public boolean isInactive(Game game) {
return game.isActivePlayer(getControllerId())
return game.isActivePlayer(getControllerId())
&& game.getTurnNum() != startingTurn;
}
@ -304,15 +290,18 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
}
FilterCard filter = new FilterCard("card to cast without mana costs");
TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId());
while (jaceExileZone.count(filter, game) > 0
Cards cardsToChoose = new CardsImpl(jaceExileZone.getCards(game));
while (controller.canRespond()
&& cardsToChoose.count(filter, game) > 0
&& controller.chooseUse(Outcome.Benefit, "Cast another spell from exile zone for free?", source, game)) {
controller.choose(Outcome.PlayForFree, jaceExileZone, target, game);
controller.choose(Outcome.PlayForFree, cardsToChoose, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
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);
cardsToChoose.remove(card);
if (cardWasCast) {
game.getExile().removeCard(card, game);
}

View file

@ -81,7 +81,7 @@ class MizzixsMasteryEffect extends OneShotEffect {
Card cardCopy = game.copyCard(card, source, source.getControllerId());
if (cardCopy.getSpellAbility().canChooseTarget(game)
&& controller.chooseUse(outcome, "Cast copy of "
+ card.getName() + " without paying its mana cost?", source, game)) {
+ card.getName() + " without paying its mana cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + cardCopy.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(cardCopy, game, true),
game, true, new MageObjectReference(source.getSourceObject(game), game));
@ -126,8 +126,8 @@ class MizzixsMasteryOverloadEffect extends OneShotEffect {
copiedCards.add(game.copyCard(card, source, source.getControllerId()));
}
boolean continueCasting = true;
while (continueCasting
&& controller.isInGame()
while (controller.canRespond()
&& continueCasting
&& !copiedCards.isEmpty()) {
TargetCard targetCard = new TargetCard(0, 1, Zone.OUTSIDE,
new FilterCard("copied card to cast without paying its mana cost?"));
@ -137,13 +137,11 @@ class MizzixsMasteryOverloadEffect extends OneShotEffect {
if (selectedCard != null
&& selectedCard.getSpellAbility().canChooseTarget(game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + selectedCard.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(selectedCard, game, true),
controller.cast(controller.chooseAbilityForCast(selectedCard, game, true),
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + selectedCard.getId(), null);
if (cardWasCast) {
copiedCards.remove(selectedCard);
}
}
copiedCards.remove(selectedCard);
}
continueCasting = !copiedCards.isEmpty()
&& controller.chooseUse(Outcome.Benefit, "Continue to choose copies and cast?", source, game);

View file

@ -1,6 +1,5 @@
package mage.cards.o;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -9,20 +8,23 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.common.FilterInstantOrSorceryCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInHand;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class OmnispellAdept extends CardImpl {
@ -80,29 +82,36 @@ class OmnispellAdeptEffect extends OneShotEffect {
if (controller == null) {
return false;
}
Target target = new TargetCardInHand(filter);
FilterCard realFilter = filter.copy();
Target target = new TargetCardInHand(realFilter);
// choose one card until it possible to cast
if (target.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.chooseUse(Outcome.PlayForFree, "Cast an instant or sorcery "
+ "card from your hand without paying its mana cost?", source, game)) {
Card cardToCast = null;
boolean cancel = false;
+ "card from your hand without paying its mana cost?", source, game)) {
Card cardToCast;
while (controller.canRespond()
&& !cancel) {
if (controller.chooseTarget(Outcome.PlayForFree, target, source, game)) {
cardToCast = game.getCard(target.getFirstTarget());
if (cardToCast != null
&& cardToCast.getSpellAbility().canChooseTarget(game)) {
cancel = true;
}
} else {
cancel = true;
&& controller.chooseTarget(Outcome.PlayForFree, target, source, game)) {
cardToCast = game.getCard(target.getFirstTarget());
if (cardToCast == null) {
break;
}
}
if (cardToCast != null) {
realFilter.add(Predicates.not(new CardIdPredicate(cardToCast.getId()))); // remove card from choose dialog (infinite fix)
if (!cardToCast.getSpellAbility().canChooseTarget(game)) {
continue;
}
game.getState().setValue("PlayFromNotOwnHandZone" + cardToCast.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(cardToCast, game, true),
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(cardToCast, game, true),
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + cardToCast.getId(), null);
if (cardWasCast) {
break;
} else {
game.informPlayer(controller, "You're not able to cast "
+ cardToCast.getIdName() + " or you canceled the casting.");
}
}
}
return true;

View file

@ -1,17 +1,11 @@
package mage.cards.t;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.condition.common.SpellMasteryCondition;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -22,8 +16,10 @@ import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetOpponent;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class TalentOfTheTelepath extends CardImpl {
@ -98,13 +94,13 @@ class TalentOfTheTelepathEffect extends OneShotEffect {
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCard target = new TargetCard(Zone.LIBRARY, filter); // zone should be ignored here
target.setNotTarget(true);
while (numberOfSpells > 0
while (controller.canRespond()
&& numberOfSpells > 0
&& !cardsToCast.isEmpty()
&& controller.chooseUse(outcome, "Cast an instant or sorcery card "
+ "from among them for free?", source, game)
+ "from among them for free?", source, game)
&& controller.choose(Outcome.PlayForFree, cardsToCast, target, game)) {
Card card = cardsToCast.get(target.getFirstTarget(), game);
if (card != null) {
@ -112,11 +108,13 @@ class TalentOfTheTelepathEffect extends OneShotEffect {
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
game, true, new MageObjectReference(source.getSourceObject(game), game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
cardsToCast.remove(card);
if (cardWasCast) {
numberOfSpells--;
cardsToCast.remove(card);
allCards.remove(card);
}
} else {
break;
}
if (!controller.canRespond()) {
return false;

View file

@ -1,6 +1,5 @@
package mage.cards.v;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -19,8 +18,9 @@ import mage.target.common.TargetCardInExile;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class VillainousWealth extends CardImpl {
@ -85,7 +85,8 @@ class VillainousWealthEffect extends OneShotEffect {
}
TargetCardInExile target = new TargetCardInExile(0, 1, filter, exileId, false);
target.setNotTarget(true);
while (cardsToExile.count(filter, game) > 0
while (controller.canRespond()
&& cardsToExile.count(filter, game) > 0
&& controller.choose(Outcome.PlayForFree, cardsToExile, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {