* Optimized handling and call of player.choose choice to prevent problems if a player disconnects or left a game (#4263).

This commit is contained in:
LevelX2 2018-02-04 17:51:12 +01:00
parent b9ec919f06
commit b752eacfaa
152 changed files with 1224 additions and 1681 deletions

View file

@ -406,14 +406,14 @@ public class HumanPlayer extends PlayerImpl {
} }
} }
updateGameStatePriority("choose(3)", game); updateGameStatePriority("choose(3)", game);
while (!abort) { while (canRespond()) {
prepareForResponse(game); prepareForResponse(game);
if (!isExecutingMacro()) { if (!isExecutingMacro()) {
game.fireChooseChoiceEvent(playerId, choice); game.fireChooseChoiceEvent(playerId, choice);
} }
waitForResponse(game); waitForResponse(game);
String val = response.getString(); String val = response.getString();
if (val != null) { if (val != null && !val.isEmpty()) {
if (choice.isKeyChoice()) { if (choice.isKeyChoice()) {
choice.setChoiceByKey(val); choice.setChoiceByKey(val);
} else { } else {

View file

@ -87,18 +87,15 @@ class AddleEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if(controller != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(outcome, choice, game); if (controller != null && controller.choose(outcome, choice, game)) {
ObjectColor color = choice.getColor(); ObjectColor color = choice.getColor();
if(color != null) {
game.informPlayers(controller.getLogName() + " chooses " + color + '.'); game.informPlayers(controller.getLogName() + " chooses " + color + '.');
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(color)); filter.add(new ColorPredicate(color));
Effect effect = new DiscardCardYouChooseTargetEffect(filter); Effect effect = new DiscardCardYouChooseTargetEffect(filter);
return effect.apply(game, source); return effect.apply(game, source);
} }
}
return false; return false;
} }
} }

View file

@ -103,13 +103,8 @@ class AngelicSkirmisherEffect extends OneShotEffect {
abilityChoices.add("Vigilance"); abilityChoices.add("Vigilance");
abilityChoices.add("Lifelink"); abilityChoices.add("Lifelink");
abilityChoice.setChoices(abilityChoices); abilityChoice.setChoices(abilityChoices);
while (!controller.choose(outcome, abilityChoice, game)) { if (controller.choose(outcome, abilityChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
Ability ability = null; Ability ability = null;
if (abilityChoice.getChoice() != null) {
switch (abilityChoice.getChoice()) { switch (abilityChoice.getChoice()) {
case "First strike": case "First strike":
ability = FirstStrikeAbility.getInstance(); ability = FirstStrikeAbility.getInstance();

View file

@ -157,7 +157,7 @@ class AnimationModuleEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter"); choice.setMessage("Choose a counter");
controller.choose(Outcome.Benefit, choice, game); if (controller.choose(Outcome.Benefit, choice, game)) {
for (Counter counter : permanent.getCounters(game).values()) { for (Counter counter : permanent.getCounters(game).values()) {
if (counter.getName().equals(choice.getChoice())) { if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName()); Counter newCounter = new Counter(counter.getName());
@ -165,6 +165,9 @@ class AnimationModuleEffect extends OneShotEffect {
break; break;
} }
} }
} else {
return false;
}
} }
} }
} else { } else {
@ -184,7 +187,7 @@ class AnimationModuleEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter"); choice.setMessage("Choose a counter");
controller.choose(Outcome.Benefit, choice, game); if (controller.choose(Outcome.Benefit, choice, game)) {
for (Counter counter : player.getCounters().values()) { for (Counter counter : player.getCounters().values()) {
if (counter.getName().equals(choice.getChoice())) { if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName()); Counter newCounter = new Counter(counter.getName());
@ -192,6 +195,9 @@ class AnimationModuleEffect extends OneShotEffect {
break; break;
} }
} }
} else {
return false;
}
} }
} }
} }

View file

@ -64,15 +64,9 @@ public class AphettoDredging extends CardImpl {
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) { if (ability instanceof SpellAbility) {
Player controller = game.getPlayer(ability.getControllerId()); Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId()));
while (!controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) { if (controller != null && controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!controller.canRespond()) {
return;
}
}
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
FilterCreatureCard filter = new FilterCreatureCard(chosenType + " cards"); FilterCreatureCard filter = new FilterCreatureCard(chosenType + " cards");
filter.add(new SubtypePredicate(SubType.byDescription(chosenType))); filter.add(new SubtypePredicate(SubType.byDescription(chosenType)));
ability.addTarget(new TargetCardInYourGraveyard(0, 3, filter)); ability.addTarget(new TargetCardInYourGraveyard(0, 3, filter));

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.cards.a; package mage.cards.a;
import java.util.UUID; import java.util.UUID;
@ -53,6 +52,7 @@ import mage.target.common.TargetControlledPermanent;
* @author Loki * @author Loki
*/ */
public class ApostlesBlessing extends CardImpl { public class ApostlesBlessing extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature you control"); private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature you control");
static { static {
@ -102,13 +102,7 @@ class ApostlesBlessingEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact(); ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
while (!choice.isChosen()) { if (controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
FilterCard protectionFilter = new FilterCard(); FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) { if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));
@ -122,6 +116,7 @@ class ApostlesBlessingEffect extends OneShotEffect {
game.addEffect(effect, source); game.addEffect(effect, source);
return true; return true;
} }
}
return false; return false;
} }
} }

View file

@ -136,13 +136,11 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
choice.getChoices().add(choice15); choice.getChoices().add(choice15);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
while (!choice.isChosen()) { if (!controller.choose(Outcome.Neutral, choice, game)) {
controller.choose(Outcome.Neutral, choice, game); discard();
if (!controller.canRespond()) {
return false; return false;
} }
} }
}
int power = 0; int power = 0;
int toughness = 0; int toughness = 0;
switch (choice.getChoice()) { switch (choice.getChoice()) {

View file

@ -111,15 +111,9 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect {
choice.getChoices().add("war"); choice.getChoices().add("war");
choice.getChoices().add("peace"); choice.getChoices().add("peace");
while (!choice.isChosen()) { if (!player.choose(Outcome.Neutral, choice, game)) {
if (!player.canRespond()) { continue;
return false;
} }
player.choose(Outcome.Neutral, choice, game);
}
if (choice.isChosen()) {
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
} }
@ -127,7 +121,6 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect {
game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice()); game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice());
sourcePermanent.addInfo("_" + playerId + "_modeChoice", "<font color = 'blue'>" + player.getName() + " chose: " + choice.getChoice() + "</font>", game); sourcePermanent.addInfo("_" + playerId + "_modeChoice", "<font color = 'blue'>" + player.getName() + " chose: " + choice.getChoice() + "</font>", game);
} }
}
return true; return true;
} }
return false; return false;
@ -141,6 +134,7 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect {
} }
class ArchangelOfStrifeWarEffect extends BoostAllEffect { class ArchangelOfStrifeWarEffect extends BoostAllEffect {
private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose war"); private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose war");
public ArchangelOfStrifeWarEffect() { public ArchangelOfStrifeWarEffect() {
@ -171,6 +165,7 @@ class ArchangelOfStrifeWarEffect extends BoostAllEffect{
} }
class ArchangelOfStrifePeaceEffect extends BoostAllEffect { class ArchangelOfStrifePeaceEffect extends BoostAllEffect {
private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose peace"); private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose peace");
public ArchangelOfStrifePeaceEffect() { public ArchangelOfStrifePeaceEffect() {

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -101,7 +100,9 @@ class BatheInLightEffect extends OneShotEffect {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) { if (target != null) {
ChoiceColor colorChoice = new ChoiceColor(); ChoiceColor colorChoice = new ChoiceColor();
if (controller.choose(Outcome.Benefit, colorChoice, game)) { if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
return false;
}
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice()); game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(target.getId() + "_color", colorChoice.getColor()); game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
@ -117,7 +118,7 @@ class BatheInLightEffect extends OneShotEffect {
game.addEffect(effect, source); game.addEffect(effect, source);
} }
} }
}
} }
return true; return true;
} }

View file

@ -106,8 +106,7 @@ class BloodOathEffect extends OneShotEffect {
if (player != null && opponent != null && sourceObject != null) { if (player != null && opponent != null && sourceObject != null) {
Choice choiceImpl = new ChoiceImpl(); Choice choiceImpl = new ChoiceImpl();
choiceImpl.setChoices(choice); choiceImpl.setChoices(choice);
while (player.canRespond() && !player.choose(Outcome.Neutral, choiceImpl, game)) { if (!player.choose(Outcome.Neutral, choiceImpl, game)) {
}
CardType type = null; CardType type = null;
String choosenType = choiceImpl.getChoice(); String choosenType = choiceImpl.getChoice();
@ -143,6 +142,7 @@ class BloodOathEffect extends OneShotEffect {
return true; return true;
} }
} }
}
return false; return false;
} }
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -45,8 +46,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author fireshoes * @author fireshoes
@ -96,18 +95,9 @@ class BloodlineShamanEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null) {
// Choose a creature type.
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(outcome, typeChoice, game)) { if (controller != null && controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCard filterSubtype = new FilterCard(); FilterCard filterSubtype = new FilterCard();
filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));

View file

@ -99,11 +99,9 @@ class BurntOfferingEffect extends OneShotEffect {
for (int i = 0; i < xValue; i++) { for (int i = 0; i < xValue; i++) {
Mana mana = new Mana(); Mana mana = new Mana();
while(!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if(!player.canRespond()) {
return false; return false;
} }
}
if (manaChoice.getChoice() == null) { //Can happen if player leaves game if (manaChoice.getChoice() == null) { //Can happen if player leaves game
return false; return false;
} }
@ -129,6 +127,7 @@ class BurntOfferingEffect extends OneShotEffect {
/** /**
* Helper method to determine the CMC of the sacrificed creature. * Helper method to determine the CMC of the sacrificed creature.
*
* @param sourceAbility * @param sourceAbility
* @return * @return
*/ */

View file

@ -107,13 +107,10 @@ class ButcherOfTheHordeEffect extends OneShotEffect {
abilities.add(LifelinkAbility.getInstance().getRule()); abilities.add(LifelinkAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule()); abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities); abilityChoice.setChoices(abilities);
while (!abilityChoice.isChosen()) {
controller.choose(Outcome.AddAbility, abilityChoice, game); controller.choose(Outcome.AddAbility, abilityChoice, game);
if (!controller.canRespond()) { if (!abilityChoice.isChosen()) {
return false; return false;
} }
}
String chosen = abilityChoice.getChoice(); String chosen = abilityChoice.getChoice();
Ability ability = null; Ability ability = null;
if (VigilanceAbility.getInstance().getRule().equals(chosen)) { if (VigilanceAbility.getInstance().getRule().equals(chosen)) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -46,8 +47,6 @@ import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
@ -128,13 +127,8 @@ class ChooseCreatureTypeEffect extends OneShotEffect { // code by LevelX2, but t
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject); Choice typeChoice = new ChoiceCreatureType(mageObject);
while (!controller.choose(outcome, typeChoice, game)) { if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
} }

View file

@ -27,9 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.LinkedHashSet;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -156,11 +154,9 @@ class CallousOppressorChooseCreatureTypeEffect extends OneShotEffect {
if (opponent != null && mageObject != null) { if (opponent != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject); Choice typeChoice = new ChoiceCreatureType(mageObject);
typeChoice.setMessage("Choose creature type"); typeChoice.setMessage("Choose creature type");
while (!opponent.choose(outcome, typeChoice, game)) { if (!opponent.choose(outcome, typeChoice, game)) {
if (!opponent.canRespond()) {
return false; return false;
} }
}
if (typeChoice.getChoice() == null) { if (typeChoice.getChoice() == null) {
return false; return false;
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
@ -47,8 +48,6 @@ import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import java.util.UUID;
/** /**
* *
* @author Plopman * @author Plopman
@ -152,14 +151,8 @@ class CarpetOfFlowersEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (controller != null && controller.choose(Outcome.Benefit, choice, game)) {
controller.choose(Outcome.Benefit, choice, game);
if (!controller.canRespond()) {
return false;
}
}
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game); int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
if (count > 0) { if (count > 0) {
Mana mana = new Mana(); Mana mana = new Mana();

View file

@ -182,12 +182,7 @@ class ChromeMoxManaEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
while (!player.choose(outcome, choice, game)) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (choice.getChoice() == null) {
return false; return false;
} }
} }

View file

@ -106,8 +106,12 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter type to add to " + permanent.getName()); choice.setMessage("Choose a counter type to add to " + permanent.getName());
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
counterName = choice.getChoice(); counterName = choice.getChoice();
} else {
return null;
}
} else { } else {
for (Counter counter : permanent.getCounters(game).values()) { for (Counter counter : permanent.getCounters(game).values()) {
if (counter.getCount() > 0) { if (counter.getCount() > 0) {
@ -134,8 +138,11 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter type to add to " + card.getName()); choice.setMessage("Choose a counter type to add to " + card.getName());
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
counterName = choice.getChoice(); counterName = choice.getChoice();
} else {
return null;
}
} else { } else {
for (Counter counter : card.getCounters(game).values()) { for (Counter counter : card.getCounters(game).values()) {
if (counter.getCount() > 0) { if (counter.getCount() > 0) {

View file

@ -101,12 +101,9 @@ class CoalitionRelicEffect extends OneShotEffect {
Mana mana = new Mana(); Mana mana = new Mana();
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
for (int i = 0; i < chargeCounters; i++) { for (int i = 0; i < chargeCounters; i++) {
while (!choice.isChosen()) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
player.choose(outcome, choice, game);
}
choice.increaseMana(mana); choice.increaseMana(mana);
choice.clearChoice(); choice.clearChoice();
} }

View file

@ -102,11 +102,9 @@ class ConundrumSphinxEffect extends OneShotEffect {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a card"); cardChoice.setMessage("Name a card");
while (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) { if (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) {
if (!player.canRespond()) {
continue Players; continue Players;
} }
}
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().removeFromTop(game); Card card = player.getLibrary().removeFromTop(game);

View file

@ -138,38 +138,35 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
} }
if (!choice.getChoices().isEmpty()) { if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
}
if (choice.getChoice() != null) {
Mana computedMana = new Mana();
switch (choice.getChoice()) {
case "Black":
computedMana.setBlack(1);
break;
case "Blue":
computedMana.setBlue(1);
break;
case "Red":
computedMana.setRed(1);
break;
case "Green":
computedMana.setGreen(1);
break;
case "White":
computedMana.setWhite(1);
break;
}
checkToFirePossibleEvents(computedMana, game, source);
player.getManaPool().addMana(computedMana, game, source);
} else {
return false; return false;
} }
} }
Mana computedManaHere = new Mana();
switch (choice.getChoice()) {
case "Black":
computedManaHere.setBlack(1);
break;
case "Blue":
computedManaHere.setBlue(1);
break;
case "Red":
computedManaHere.setRed(1);
break;
case "Green":
computedManaHere.setGreen(1);
break;
case "White":
computedManaHere.setWhite(1);
break;
}
checkToFirePossibleEvents(computedManaHere, game, source);
player.getManaPool().addMana(computedManaHere, game, source);
}
} }
return true; return true;
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
@ -43,8 +44,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -92,11 +91,9 @@ class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNam
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a nonland card"); cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) { if (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null) { if (sourceObject != null) {

View file

@ -53,7 +53,6 @@ public class CreepingRenaissance extends CardImpl {
public CreepingRenaissance(UUID ownerId, CardSetInfo setInfo) { public CreepingRenaissance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{G}");
// Choose a permanent type. Return all cards of the chosen type from your graveyard to your hand. // Choose a permanent type. Return all cards of the chosen type from your graveyard to your hand.
this.getSpellAbility().addEffect(new CreepingRenaissanceEffect()); this.getSpellAbility().addEffect(new CreepingRenaissanceEffect());
@ -95,9 +94,7 @@ class CreepingRenaissanceEffect extends OneShotEffect {
typeChoice.getChoices().add(CardType.LAND.toString()); typeChoice.getChoices().add(CardType.LAND.toString());
typeChoice.getChoices().add(CardType.PLANESWALKER.toString()); typeChoice.getChoices().add(CardType.PLANESWALKER.toString());
while (controller.canRespond() && !controller.choose(Outcome.ReturnToHand, typeChoice, game)) { if (controller.choose(Outcome.ReturnToHand, typeChoice, game)) {
}
String typeName = typeChoice.getChoice(); String typeName = typeChoice.getChoice();
CardType chosenType = null; CardType chosenType = null;
for (CardType cardType : CardType.values()) { for (CardType cardType : CardType.values()) {
@ -114,6 +111,7 @@ class CreepingRenaissanceEffect extends OneShotEffect {
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -27,7 +27,6 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -43,8 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -54,7 +53,7 @@ import mage.players.Player;
/** /**
* *
* @author LoneFox * @author LoneFox
*
*/ */
public class CrosisThePurger extends CardImpl { public class CrosisThePurger extends CardImpl {
@ -104,7 +103,7 @@ class CrosisThePurgerEffect extends OneShotEffect {
if (player != null) { if (player != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
if(choice.getColor() != null) { if (choice.isChosen()) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString()); game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);

View file

@ -39,8 +39,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -98,16 +98,8 @@ class DarigaazTheIgniterEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(true); ChoiceColor choice = new ChoiceColor(true);
while (!choice.isChosen()) { if (controller != null && controller.choose(outcome, choice, game)) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() != null) {
game.informPlayers(controller.getLogName() + " chooses " + choice.getColor()); game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (damagedPlayer != null) { if (damagedPlayer != null) {
@ -119,9 +111,7 @@ class DarigaazTheIgniterEffect extends OneShotEffect {
damagedPlayer.damage(damage, source.getSourceId(), game, false, true); damagedPlayer.damage(damage, source.getSourceId(), game, false, true);
} }
} }
}
return true; return true;
} }
return false; return false;
} }

View file

@ -38,8 +38,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -135,11 +135,9 @@ class DawnsReflectionManaEffect extends ManaEffect {
Mana mana = new Mana(); Mana mana = new Mana();
for (int i = 0; i < x; i++) { for (int i = 0; i < x; i++) {
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
while (!controller.choose(Outcome.Benefit, choiceColor, game)) { if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.isInGame()) {
return false; return false;
} }
}
choiceColor.increaseMana(mana); choiceColor.increaseMana(mana);
} }
controller.getManaPool().addMana(mana, game, source); controller.getManaPool().addMana(mana, game, source);

View file

@ -88,11 +88,9 @@ class DemonicConsultationEffect extends OneShotEffect {
// Name a card. // Name a card.
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String name = choice.getChoice(); String name = choice.getChoice();
game.informPlayers("Card named: " + name); game.informPlayers("Card named: " + name);

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.d; package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -43,8 +44,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -54,7 +53,6 @@ public class DistantMelody extends CardImpl {
public DistantMelody(UUID ownerId, CardSetInfo setInfo) { public DistantMelody(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Choose a creature type. Draw a card for each permanent you control of that type. // Choose a creature type. Draw a card for each permanent you control of that type.
this.getSpellAbility().addEffect(new DistantMelodyEffect()); this.getSpellAbility().addEffect(new DistantMelodyEffect());
} }
@ -87,14 +85,9 @@ class DistantMelodyEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source); return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);

View file

@ -41,8 +41,8 @@ import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -102,11 +102,9 @@ public class DiviningWitch extends CardImpl {
// Name a card. // Name a card.
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String name = choice.getChoice(); String name = choice.getChoice();
game.informPlayers("Card named: " + name); game.informPlayers("Card named: " + name);
@ -137,5 +135,3 @@ public class DiviningWitch extends CardImpl {
} }
} }
} }

View file

@ -41,9 +41,9 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -109,8 +109,7 @@ class BecomesColorOrColorsEnchantedEffect extends OneShotEffect {
} }
} }
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
controller.choose(Outcome.Benefit, choiceColor, game); if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
if (!game.isSimulation()) { if (!game.isSimulation()) {

View file

@ -40,8 +40,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -100,8 +100,7 @@ class DromarTheBanisherEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game); if (player.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
game.informPlayers(player.getLogName() + " chooses " + choice.getChoice()); game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.d; package mage.cards.d;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,8 +44,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -51,10 +54,6 @@ import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -115,16 +114,13 @@ class DwarvenArmorerEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose type of counter to add"); choice.setMessage("Choose type of counter to add");
choice.setChoices(choices); choice.setChoices(choices);
while(!controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
if(controller.canRespond()) {
return false;
}
}
Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance(); Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance();
Effect effect = new AddCountersTargetEffect(counter); Effect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source))); effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source)));
return effect.apply(game, source); return effect.apply(game, source);
} }
}
return false; return false;
} }
} }

View file

@ -31,23 +31,23 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.constants.SubType;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent;
/** /**
* *
@ -125,13 +125,10 @@ class ElementalResonanceEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Choose a mana combination"); choice.setMessage("Choose a mana combination");
choice.getChoices().addAll(manaOptions); choice.getChoices().addAll(manaOptions);
while (!choice.isChosen()) { if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
controller.choose(Outcome.PutManaInPool, choice, game);
if (!controller.canRespond()) {
return false; return false;
} }
manaToAdd = choice.getChoice(); manaToAdd = choice.getChoice();
}
} else if (manaOptions.size() == 1) { } else if (manaOptions.size() == 1) {
manaToAdd = manaOptions.get(0); manaToAdd = manaOptions.get(0);
} }

View file

@ -94,11 +94,9 @@ class ElsewhereFlaskEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice choice = new ChoiceBasicLandType(); Choice choice = new ChoiceBasicLandType();
if (player.choose(Outcome.Neutral, choice, game)) { if (player != null && player.choose(Outcome.Neutral, choice, game)) {
game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice()); game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice());
}
game.addEffect(new ElsewhereFlaskContinuousEffect(), source); game.addEffect(new ElsewhereFlaskContinuousEffect(), source);
return true; return true;
} }

View file

@ -95,13 +95,8 @@ class ElvishSoultillerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject); Choice typeChoice = new ChoiceCreatureType(mageObject);
while (!controller.choose(outcome, typeChoice, game)) { if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
} }

View file

@ -82,16 +82,9 @@ class ExtinctionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(outcome, typeChoice, game)) { if (player != null && player.choose(outcome, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {

View file

@ -92,12 +92,9 @@ class FaithsShieldEffect extends OneShotEffect {
if (controller != null && mageObject != null) { if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) { if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (!controller.choose(Outcome.Protect, choice, game)) {
controller.choose(Outcome.Protect, choice, game);
if (!controller.canRespond()) {
return false; return false;
} }
}
if (choice.getColor() != null) { if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.f; package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -42,10 +45,6 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -105,11 +104,9 @@ class FatespinnerChooseEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose phase or step to skip"); choice.setMessage("Choose phase or step to skip");
choice.setChoices(choices); choice.setChoices(choices);
while (!player.choose(outcome, choice, game)) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
String chosenPhase = choice.getChoice(); String chosenPhase = choice.getChoice();
game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase() + '.'); game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase() + '.');
game.addEffect(new FatespinnerSkipEffect(chosenPhase), source); game.addEffect(new FatespinnerSkipEffect(chosenPhase), source);

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.f; package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -43,18 +46,14 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -115,17 +114,14 @@ class FlowstoneSculptureEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while(!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if(controller.canRespond()) {
return false; return false;
} }
}
String chosen = choice.getChoice(); String chosen = choice.getChoice();
if (chosen.equals("+1/+1 counter")) { if (chosen.equals("+1/+1 counter")) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source); return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
} } else {
else {
Ability gainedAbility; Ability gainedAbility;
switch (chosen) { switch (chosen) {
case "Flying": case "Flying":

View file

@ -112,7 +112,8 @@ class FluctuatorEffect extends CostModificationEffectImpl {
if (controller.choose(Outcome.Benefit, choice, game)) { if (controller.choose(Outcome.Benefit, choice, game)) {
reduce = Integer.parseInt(choice.getChoice()); reduce = Integer.parseInt(choice.getChoice());
} else {
return false;
} }
} }
CardUtil.reduceCost(abilityToModify, reduce); CardUtil.reduceCost(abilityToModify, reduce);

View file

@ -114,8 +114,7 @@ class FoodChainManaEffect extends ManaEffect {
} }
} }
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PutManaInPool, choice, game); if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
if (choice.getColor() == null) {
return false; return false;
} }
Mana chosen = choice.getMana(manaCostExiled + 1); Mana chosen = choice.getMana(manaCostExiled + 1);

View file

@ -112,6 +112,7 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
return false; return false;
} }
@Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
@ -121,9 +122,6 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
choice.setChoices(choices); choice.setChoices(choices);
if (controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
switch (choice.getChoice()) { switch (choice.getChoice()) {
// case "Flying":
// ability = FlyingAbility.getInstance();
// break;
case "First strike": case "First strike":
ability = FirstStrikeAbility.getInstance(); ability = FirstStrikeAbility.getInstance();
break; break;
@ -137,6 +135,8 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
ability = FlyingAbility.getInstance(); ability = FlyingAbility.getInstance();
break; break;
} }
} else {
discard();
} }
} }
} }

View file

@ -85,7 +85,6 @@ public class GoblinClearcutter extends CardImpl {
} }
} }
class GoblinClearCutterEffect extends OneShotEffect { class GoblinClearCutterEffect extends OneShotEffect {
public GoblinClearCutterEffect() { public GoblinClearCutterEffect() {
@ -115,12 +114,7 @@ class GoblinClearCutterEffect extends OneShotEffect {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Mana mana = new Mana(); Mana mana = new Mana();
while (!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (manaChoice.getChoice() == null) { // can happen if player leaves game
return false; return false;
} }
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {

View file

@ -46,9 +46,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
@ -114,7 +114,9 @@ class GolemArtisanEffect extends OneShotEffect {
abilities.add(TrampleAbility.getInstance().getRule()); abilities.add(TrampleAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule()); abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities); abilityChoice.setChoices(abilities);
playerControls.choose(Outcome.AddAbility, abilityChoice, game); if (!playerControls.choose(Outcome.AddAbility, abilityChoice, game)) {
return false;
}
String chosen = abilityChoice.getChoice(); String chosen = abilityChoice.getChoice();
Ability ability = null; Ability ability = null;

View file

@ -110,20 +110,17 @@ class GremlinMineEffect extends OneShotEffect {
if (player != null && permanent != null) { if (player != null && permanent != null) {
int existingCount = permanent.getCounters(game).getCount(CounterType.CHARGE); int existingCount = permanent.getCounters(game).getCount(CounterType.CHARGE);
if (existingCount > 0) { if (existingCount > 0) {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Select number of charge counters to remove:"); choice.setMessage("Select number of charge counters to remove:");
for (Integer i = 0; i <= existingCount; i++) { for (Integer i = 0; i <= existingCount; i++) {
choice.getChoices().add(i.toString()); choice.getChoices().add(i.toString());
} }
int amount = 0;
if (player.choose(Outcome.Detriment, choice, game)) { if (player.choose(Outcome.Detriment, choice, game)) {
amount = Integer.parseInt(choice.getChoice()); permanent.removeCounters(CounterType.CHARGE.getName(), Integer.parseInt(choice.getChoice()), game);
return true;
} }
return false;
permanent.removeCounters(CounterType.CHARGE.getName(), amount, game);
} }
return true; return true;
} }

View file

@ -99,12 +99,10 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl {
MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && mageObject != null) { if (player != null && mageObject != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (!player.choose(outcome, choice, game)) {
player.choose(outcome, choice, game); discard();
if (!player.canRespond()) {
return; return;
} }
}
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
} }

View file

@ -97,11 +97,9 @@ class HarshMercyEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) { if (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
if (!player.canRespond()) {
continue PlayerIteration; continue PlayerIteration;
} }
}
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
if (chosenType != null) { if (chosenType != null) {
game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType); game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);

View file

@ -88,11 +88,9 @@ class InfiniteObliterationEffect extends SearchTargetGraveyardHandLibraryForCard
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a creature card"); cardChoice.setMessage("Name a creature card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) { if (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String cardName; String cardName;
cardName = cardChoice.getChoice(); cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());

View file

@ -41,9 +41,9 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColorOrArtifact; import mage.choices.ChoiceColorOrArtifact;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
@ -102,15 +102,8 @@ class JeweledSpiritEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact(); ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
while (!choice.isChosen()) { if (controller != null && controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
FilterCard protectionFilter = new FilterCard(); FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) { if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.j; package mage.cards.j;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -47,10 +50,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -127,6 +126,8 @@ class JodahsAvengerEffect extends ContinuousEffectImpl {
gainedAbility = ProtectionAbility.from(ObjectColor.RED); gainedAbility = ProtectionAbility.from(ObjectColor.RED);
break; break;
} }
} else {
discard();
} }
} }
} }

View file

@ -153,11 +153,9 @@ class KaronaFalseGodEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(Outcome.BoostCreature, typeChoice, game)) { if (!controller.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String typeChosen = typeChoice.getChoice(); String typeChosen = typeChoice.getChoice();
if (!typeChosen.isEmpty()) { if (!typeChosen.isEmpty()) {
game.informPlayers(controller.getLogName() + " has chosen " + typeChosen); game.informPlayers(controller.getLogName() + " has chosen " + typeChosen);

View file

@ -73,7 +73,6 @@ public class LiarsPendulum extends CardImpl {
} }
} }
class LiarsPendulumEffect extends OneShotEffect { class LiarsPendulumEffect extends OneShotEffect {
public LiarsPendulumEffect() { public LiarsPendulumEffect() {
@ -99,11 +98,9 @@ class LiarsPendulumEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
choice.setMessage("Choose a card name"); choice.setMessage("Choose a card name");
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String cardName = choice.getChoice(); String cardName = choice.getChoice();
game.informPlayers("Card named: " + cardName); game.informPlayers("Card named: " + cardName);
boolean opponentGuess = false; boolean opponentGuess = false;
@ -118,8 +115,7 @@ class LiarsPendulumEffect extends OneShotEffect {
SplitCard splitCard = (SplitCard) card; SplitCard splitCard = (SplitCard) card;
if (splitCard.getLeftHalfCard().getName().equals(cardName)) { if (splitCard.getLeftHalfCard().getName().equals(cardName)) {
rightGuess = opponentGuess; rightGuess = opponentGuess;
} } else if (splitCard.getRightHalfCard().getName().equals(cardName)) {
else if (splitCard.getRightHalfCard().getName().equals(cardName)){
rightGuess = opponentGuess; rightGuess = opponentGuess;
} }
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.l; package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -43,8 +44,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author michael.napoleon@gmail.com * @author michael.napoleon@gmail.com
@ -87,13 +86,8 @@ class LuminescentRainEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledPermanent filter = new FilterControlledPermanent(); FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source); return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source);

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.l; package mage.cards.l;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -42,18 +45,14 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -114,12 +113,9 @@ class LunarAvengerEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
Ability gainedAbility; Ability gainedAbility;
String chosen = choice.getChoice(); String chosen = choice.getChoice();
switch (chosen) { switch (chosen) {

View file

@ -27,7 +27,6 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -109,15 +108,12 @@ class MadScienceFairManaEffect extends ManaEffect {
controller.getManaPool().addMana(Mana.ColorlessMana(1), game, source); controller.getManaPool().addMana(Mana.ColorlessMana(1), game, source);
} else { } else {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PutManaInPool, choice, game); if (controller.choose(Outcome.PutManaInPool, choice, game)) {
if (choice.getColor() == null) {
return false;
}
Mana chosen = choice.getMana(1); Mana chosen = choice.getMana(1);
if (chosen != null) {
checkToFirePossibleEvents(chosen, game, source); checkToFirePossibleEvents(chosen, game, source);
controller.getManaPool().addMana(chosen, game, source); controller.getManaPool().addMana(chosen, game, source);
return true; } else {
return false;
} }
} }
return true; return true;

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -40,8 +43,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -50,10 +53,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -121,11 +120,9 @@ class MaintenanceDroidEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose mode"); choice.setMessage("Choose mode");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
String chosen = choice.getChoice(); String chosen = choice.getChoice();
switch (chosen) { switch (chosen) {

View file

@ -41,8 +41,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -75,8 +75,6 @@ public class ManaforgeCinder extends CardImpl {
} }
} }
class ManaforgeCinderManaEffect extends OneShotEffect { class ManaforgeCinderManaEffect extends OneShotEffect {
public ManaforgeCinderManaEffect() { public ManaforgeCinderManaEffect() {
@ -104,11 +102,9 @@ class ManaforgeCinderManaEffect extends OneShotEffect {
manaChoice.setChoices(choices); manaChoice.setChoices(choices);
manaChoice.setMessage("Select black or red mana to add to your mana pool"); manaChoice.setMessage("Select black or red mana to add to your mana pool");
Mana mana = new Mana(); Mana mana = new Mana();
while (!controller.choose(Outcome.Benefit, manaChoice, game)) { if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
if (manaChoice.getChoice() == null) { if (manaChoice.getChoice() == null) {
return false; return false;
} }

View file

@ -144,11 +144,9 @@ class MarketFestivalManaEffect extends ManaEffect {
} else { } else {
choiceColor.setMessage("Second mana color for " + sourceObject.getLogName()); choiceColor.setMessage("Second mana color for " + sourceObject.getLogName());
} }
while (!controller.choose(Outcome.Benefit, choiceColor, game)) { if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
if (choiceColor.getChoice() == null) { // Possible after reconnect? if (choiceColor.getChoice() == null) { // Possible after reconnect?
return false; return false;
} }

View file

@ -27,6 +27,10 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -44,10 +48,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Loki * @author Loki
@ -91,7 +91,8 @@ class MindblazeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player playerControls = game.getPlayer(source.getControllerId()); Player playerControls = game.getPlayer(source.getControllerId());
if (player != null && playerControls != null) { MageObject sourceObject = source.getSourceObject(game);
if (player != null && playerControls != null && sourceObject != null) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames()); cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice(); cardChoice.clearChoice();
@ -103,20 +104,14 @@ class MindblazeEffect extends OneShotEffect {
} }
numberChoice.setChoices(numbers); numberChoice.setChoices(numbers);
while (!playerControls.choose(Outcome.Neutral, cardChoice, game)) { if (!playerControls.choose(Outcome.Neutral, cardChoice, game)) {
if (!playerControls.canRespond()) {
return false; return false;
} }
} if (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
if (!playerControls.canRespond()) {
return false; return false;
} }
}
game.informPlayers("Mindblaze, named card: [" + cardChoice.getChoice() + ']'); game.informPlayers(sourceObject.getIdName() + " - Named card: [" + cardChoice.getChoice() + "] - Chosen number: [" + numberChoice.getChoice() + ']');
game.informPlayers("Mindblaze, chosen number: [" + numberChoice.getChoice() + ']');
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.addAll(player.getLibrary().getCards(game)); cards.addAll(player.getLibrary().getCards(game));
@ -128,6 +123,7 @@ class MindblazeEffect extends OneShotEffect {
player.damage(8, source.getSourceId(), game.copy(), false, true); player.damage(8, source.getSourceId(), game.copy(), false, true);
} }
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
return true;
} }
return false; return false;
} }

View file

@ -93,11 +93,9 @@ class MistformSliverEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) { if (player != null && permanent != null) {
Choice typeChoice = new ChoiceCreatureType(permanent); Choice typeChoice = new ChoiceCreatureType(permanent);
while (!player.choose(Outcome.Detriment, typeChoice, game)) { if (!player.choose(Outcome.Detriment, typeChoice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn); ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId())); effect.setTargetPointer(new FixedTarget(permanent.getId()));

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -49,10 +52,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -116,11 +115,9 @@ class MultiformWonderEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
Ability gainedAbility; Ability gainedAbility;
String chosen = choice.getChoice(); String chosen = choice.getChoice();

View file

@ -27,6 +27,10 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -47,11 +51,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerList; import mage.players.PlayerList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -120,12 +119,6 @@ class MysticBarrierChooseEffect extends OneShotEffect {
static final String[] SET_VALUES = new String[]{MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT}; static final String[] SET_VALUES = new String[]{MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT};
static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES)); static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES));
final static Choice DIRECTION_CHOICE = new ChoiceImpl(true);
static {
DIRECTION_CHOICE.setChoices(CHOICES);
DIRECTION_CHOICE.setMessage("Direction each player may only attack to");
DIRECTION_CHOICE.isRequired();
}
public MysticBarrierChooseEffect() { public MysticBarrierChooseEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
@ -145,15 +138,14 @@ class MysticBarrierChooseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
DIRECTION_CHOICE.clearChoice(); Choice directionChoice = new ChoiceImpl(true);
while (!DIRECTION_CHOICE.isChosen() && controller.canRespond()) { directionChoice.setChoices(CHOICES);
controller.choose(outcome, DIRECTION_CHOICE, game); directionChoice.setMessage("Direction each player may only attack to");
} directionChoice.isRequired();
if (!DIRECTION_CHOICE.getChoice().isEmpty()) { if (!controller.choose(outcome, directionChoice, game)) {
game.getState().setValue(new StringBuilder("attack_direction_").append(source.getSourceId()).toString(), DIRECTION_CHOICE.getChoice()); game.getState().setValue("attack_direction_" + source.getSourceId(), directionChoice.getChoice());
return true; return true;
} }
} }
return false; return false;
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.n; package mage.cards.n;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -44,8 +45,6 @@ import mage.game.events.ManaEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -120,8 +119,11 @@ class NakedSingularityEffect extends ReplacementEffectImpl {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next(); chosenColor = choice.getChoices().iterator().next();
} else { } else {
controller.choose(Outcome.PutManaInPool, choice, game); if (controller.choose(Outcome.PutManaInPool, choice, game)) {
chosenColor = choice.getChoice(); chosenColor = choice.getChoice();
} else {
return false;
}
} }
ManaEvent manaEvent = (ManaEvent) event; ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana(); Mana mana = manaEvent.getMana();

View file

@ -144,12 +144,7 @@ class ChangeCreatureTypeTargetEffect extends ContinuousEffectImpl {
if (fromSubType == null) { if (fromSubType == null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to change to Vampire"); typeChoice.setMessage("Choose creature type to change to Vampire");
while (!controller.choose(outcome, typeChoice, game)) { if (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return;
}
}
if (typeChoice.getChoice() == null) {
discard(); discard();
return; return;
} }

View file

@ -38,10 +38,12 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
@ -102,29 +104,24 @@ class OonaQueenOfTheFaeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller == null || opponent == null) { ChoiceColor choice = new ChoiceColor();
if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) {
return false; return false;
} }
ChoiceColor choice = new ChoiceColor();
controller.choose(outcome, choice, game);
if (choice.getColor() != null) {
int cardsWithColor = 0; int cardsWithColor = 0;
int cardsToExile = Math.min(opponent.getLibrary().size(), source.getManaCostsToPay().getX()); Cards cardsToExile = new CardsImpl();
for (int i = 0; i < cardsToExile; i++) { cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
Card card = opponent.getLibrary().removeFromTop(game);
if (card != null) { for (Card card : cardsToExile.getCards(game)) {
if (card.getColor(game).contains(choice.getColor())) { if (card != null && card.getColor(game).contains(choice.getColor())) {
cardsWithColor++; cardsWithColor++;
} }
card.moveToExile(null, null, source.getSourceId(), game);
}
} }
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (cardsWithColor > 0) { if (cardsWithColor > 0) {
new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source); new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source);
} }
game.informPlayers(new StringBuilder("Oona: ").append(cardsWithColor).append(" Token").append(cardsWithColor != 1 ? "s" : "").append(" created").toString()); game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created");
return true; return true;
} }
return false;
}
} }

View file

@ -116,11 +116,9 @@ class OrcishLumberjackManaEffect extends ManaEffect {
Mana mana = new Mana(); Mana mana = new Mana();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
while (!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {
case "Green": case "Green":
mana.increaseGreen(); mana.increaseGreen();
@ -143,5 +141,4 @@ class OrcishLumberjackManaEffect extends ManaEffect {
return null; return null;
} }
} }

View file

@ -96,8 +96,10 @@ class OrderOfSuccessionEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Map<UUID, UUID> playerCreature = new HashMap<>(2); Map<UUID, UUID> playerCreature = new HashMap<>(2);
Choice choice = new ChoiceLeftOrRight(); Choice choice = new ChoiceLeftOrRight();
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
boolean left = choice == null || choice.getChoice().equals("Left"); // to prevent npe return false;
}
boolean left = choice.getChoice().equals("Left");
PlayerList playerList = game.getState().getPlayerList().copy(); PlayerList playerList = game.getState().getPlayerList().copy();
// set playerlist to controller // set playerlist to controller
while (!playerList.get().equals(source.getControllerId()) && controller.canRespond()) { while (!playerList.get().equals(source.getControllerId()) && controller.canRespond()) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.o; package mage.cards.o;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.DiscardTargetCost; import mage.abilities.costs.common.DiscardTargetCost;
@ -48,8 +49,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import java.util.UUID;
/** /**
* @author fireshoes * @author fireshoes
*/ */
@ -95,20 +94,14 @@ class OutbreakEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(outcome, typeChoice, game)) { if (player != null && player.choose(outcome, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice());
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type"); FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type");
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
ContinuousEffect effect = new BoostAllEffect(-1, -1, Duration.WhileOnBattlefield, filter, false); ContinuousEffect effect = new BoostAllEffect(-1, -1, Duration.WhileOnBattlefield, filter, false);
game.addEffect(effect, source); game.addEffect(effect, source);
return true;
} }
return false; return false;
} }

View file

@ -92,13 +92,8 @@ class PacksDisdainEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.UnboostCreature, typeChoice, game)) { if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1); DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);

View file

@ -42,11 +42,11 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer; import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterObject; import mage.filter.FilterObject;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -116,10 +116,10 @@ class PaleWayfarerEffect extends OneShotEffect {
effect.setTargetPointer(new FixedTarget(targetCreature, game)); effect.setTargetPointer(new FixedTarget(targetCreature, game));
game.addEffect(effect, source); game.addEffect(effect, source);
} }
}
return true; return true;
} }
} }
}
return false; return false;
} }
@ -129,7 +129,6 @@ class PaleWayfarerEffect extends OneShotEffect {
} }
} }
class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl { class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl {
protected ObjectColor chosenColor; protected ObjectColor chosenColor;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.p; package mage.cards.p;
import java.util.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -45,8 +46,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.*;
/** /**
* @author duncant * @author duncant
*/ */
@ -94,17 +93,13 @@ class PatriarchsBiddingEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) { if (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!player.canRespond()) { continue;
break;
}
} }
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
if (chosenType != null) {
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType); game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType);
chosenTypes.add(chosenType); chosenTypes.add(chosenType);
} }
}
List<SubtypePredicate> predicates = new ArrayList<>(); List<SubtypePredicate> predicates = new ArrayList<>();
for (String type : chosenTypes) { for (String type : chosenTypes) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.p; package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -48,8 +49,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -92,17 +91,10 @@ class PeerPressureEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!controller.choose(Outcome.GainControl, choice, game)) { if (controller != null && controller.choose(Outcome.GainControl, choice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String chosenType = choice.getChoice(); String chosenType = choice.getChoice();
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " has chosen " + chosenType); game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
}
UUID playerWithMost = null; UUID playerWithMost = null;
int maxControlled = 0; int maxControlled = 0;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -45,9 +45,9 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.AttachmentType; import mage.constants.AttachmentType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -126,12 +126,7 @@ class PemminsAuraBoostEnchantedEffect extends OneShotEffect {
choice.setMessage("Select how to boost"); choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1); choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2); choice.getChoices().add(CHOICE_2);
while (!choice.isChosen()) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
if (choice.getChoice().equals(CHOICE_1)) { if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source); game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
} else { } else {
@ -139,6 +134,7 @@ class PemminsAuraBoostEnchantedEffect extends OneShotEffect {
} }
return true; return true;
} }
}
return false; return false;
} }
} }

View file

@ -89,17 +89,8 @@ class PersecuteEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && sourceObject != null && targetPlayer != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (controller != null && sourceObject != null && targetPlayer != null && controller.choose(outcome, choice, game)) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() == null) {
return false;
}
Cards hand = targetPlayer.getHand(); Cards hand = targetPlayer.getHand();
targetPlayer.revealCards(sourceObject.getIdName(), hand, game); targetPlayer.revealCards(sourceObject.getIdName(), hand, game);
Set<Card> cards = hand.getCards(game); Set<Card> cards = hand.getCards(game);

View file

@ -94,16 +94,13 @@ class PetraSphinxEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && sourceObject != null && player != null) { if (controller != null && sourceObject != null && player != null) {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames()); cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card"); cardChoice.setMessage("Name a card");
while (!player.choose(Outcome.DrawCard, cardChoice, game)) { if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().removeFromTop(game); Card card = player.getLibrary().removeFromTop(game);

View file

@ -128,15 +128,11 @@ class PlasmCaptureManaEffect extends ManaEffect {
Mana mana = new Mana(); Mana mana = new Mana();
for (int i = 0; i < amountOfMana; i++) { for (int i = 0; i < amountOfMana; i++) {
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
while (!player.choose(Outcome.Benefit, choiceColor, game)) { if (!player.choose(Outcome.Benefit, choiceColor, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
choiceColor.increaseMana(mana); choiceColor.increaseMana(mana);
} }
player.getManaPool().addMana(mana, game, source); player.getManaPool().addMana(mana, game, source);
return true; return true;

View file

@ -40,9 +40,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
@ -123,14 +123,9 @@ public class PrimalClay extends CardImpl {
choice.getChoices().add(choice22); choice.getChoices().add(choice22);
choice.getChoices().add(choice16); choice.getChoices().add(choice16);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) {
while (!choice.isChosen()) {
controller.choose(Outcome.Neutral, choice, game);
if (!controller.canRespond()) {
return false; return false;
} }
}
}
int power = 0; int power = 0;
int toughness = 0; int toughness = 0;
switch (choice.getChoice()) { switch (choice.getChoice()) {

View file

@ -40,9 +40,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
@ -117,21 +117,16 @@ public class PrimalPlasma extends CardImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what " + permanent.getIdName() + " becomes to"); choice.setMessage("Choose what " + permanent.getIdName() + " becomes to");
choice.getChoices().add(choice33); choice.getChoices().add(choice33);
choice.getChoices().add(choice22); choice.getChoices().add(choice22);
choice.getChoices().add(choice16); choice.getChoices().add(choice16);
Player controller = game.getPlayer(source.getControllerId()); if (!controller.choose(Outcome.Neutral, choice, game)) {
if (controller != null) {
while (!choice.isChosen()) {
controller.choose(Outcome.Neutral, choice, game);
if (!controller.canRespond()) {
return false; return false;
} }
}
}
int power = 0; int power = 0;
int toughness = 0; int toughness = 0;
switch (choice.getChoice()) { switch (choice.getChoice()) {
@ -152,8 +147,6 @@ public class PrimalPlasma extends CardImpl {
} }
permanent.getPower().modifyBaseValue(power); permanent.getPower().modifyBaseValue(power);
permanent.getToughness().modifyBaseValue(toughness); permanent.getToughness().modifyBaseValue(toughness);
// game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
} }
return false; return false;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -44,8 +45,6 @@ import mage.game.events.ManaEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 & L_J * @author emerald000 & L_J
@ -117,7 +116,9 @@ class RealityTwistEffect extends ReplacementEffectImpl {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next(); chosenColor = choice.getChoices().iterator().next();
} else { } else {
controller.choose(Outcome.PutManaInPool, choice, game); if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
return false;
}
chosenColor = choice.getChoice(); chosenColor = choice.getChoice();
} }
ManaEvent manaEvent = (ManaEvent) event; ManaEvent manaEvent = (ManaEvent) event;

View file

@ -50,7 +50,6 @@ public class ReverseTheSands extends CardImpl {
public ReverseTheSands(UUID ownerId, CardSetInfo setInfo) { public ReverseTheSands(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}{W}");
// Redistribute any number of players' life totals. // Redistribute any number of players' life totals.
this.getSpellAbility().addEffect(new ReverseTheSandsEffect()); this.getSpellAbility().addEffect(new ReverseTheSandsEffect());
} }
@ -100,7 +99,9 @@ class ReverseTheSandsEffect extends OneShotEffect {
String selectedChoice; String selectedChoice;
if (choices.size() > 1) { if (choices.size() > 1) {
lifeChoice.setMessage("Which players life should get player " + player.getLogName()); lifeChoice.setMessage("Which players life should get player " + player.getLogName());
controller.choose(Outcome.Detriment, lifeChoice, game); if (!controller.choose(Outcome.Detriment, lifeChoice, game)) {
return false;
}
selectedChoice = lifeChoice.getChoice(); selectedChoice = lifeChoice.getChoice();
} else { } else {
selectedChoice = choices.iterator().next(); selectedChoice = choices.iterator().next();

View file

@ -28,7 +28,6 @@
package mage.cards.r; package mage.cards.r;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
@ -130,14 +129,9 @@ class RhysticCaveManaEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); //get obj reference to Rhystic Cave
if (controller != null) {
if (mageObject != null) {
ChoiceColor choice = new ChoiceColor(true); ChoiceColor choice = new ChoiceColor(true);
controller.choose(outcome, choice, game); if (controller != null && controller.choose(outcome, choice, game)) {
if (choice.getColor() != null) { switch (choice.getColor().toString()) {
String color = choice.getColor().toString();
switch (color) {
case "R": case "R":
chosenMana.setRed(1); chosenMana.setRed(1);
break; break;
@ -154,14 +148,10 @@ class RhysticCaveManaEffect extends ManaEffect {
chosenMana.setGreen(1); chosenMana.setGreen(1);
break; break;
} }
}
checkToFirePossibleEvents(chosenMana, game, source); checkToFirePossibleEvents(chosenMana, game, source);
controller.getManaPool().addMana(chosenMana, game, source); controller.getManaPool().addMana(chosenMana, game, source);
return true; return true;
} }
}
return false; return false;
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -48,8 +49,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* @author fireshoes * @author fireshoes
*/ */
@ -93,16 +92,9 @@ class RiptideChronologistEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(outcome, typeChoice, game)) { if (player != null && player.choose(outcome, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -38,14 +39,12 @@ import mage.cards.*;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceCreatureType; import mage.choices.ChoiceCreatureType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -97,11 +96,9 @@ class RiptideShapeshifterEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Choice choice = new ChoiceCreatureType(sourceObject); Choice choice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(Outcome.BoostCreature, choice, game)) { if (!controller.choose(Outcome.BoostCreature, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
Cards revealedCards = new CardsImpl(); Cards revealedCards = new CardsImpl();
while (controller.getLibrary().hasCards()) { while (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);

View file

@ -97,7 +97,10 @@ class RiteOfRuinEffect extends OneShotEffect {
choice.setMessage("Choose a card type"); choice.setMessage("Choose a card type");
choice.setChoices(choices); choice.setChoices(choices);
while (controller.canRespond() && controller.choose(Outcome.Sacrifice, choice, game) && choices.size() > 1) { while (choices.size() > 1) {
if (!controller.choose(Outcome.Sacrifice, choice, game)) {
return false;
}
order.add(getCardType(choice.getChoice())); order.add(getCardType(choice.getChoice()));
choices.remove(choice.getChoice()); choices.remove(choice.getChoice());
choice.clearChoice(); choice.clearChoice();

View file

@ -40,8 +40,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -103,8 +103,7 @@ class RithTheAwakenerEffect extends OneShotEffect {
return false; return false;
} }
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(outcome, choice, game); if (controller.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(" chooses ").append(choice.getColor()).toString()); game.informPlayers(new StringBuilder(controller.getLogName()).append(" chooses ").append(choice.getColor()).toString());
FilterPermanent filter = new FilterPermanent(); FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));

View file

@ -90,11 +90,9 @@ class RoarOfTheCrowdEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.LoseLife, typeChoice, game)) { if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
FilterControlledPermanent filter = new FilterControlledPermanent(); FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
return new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source); return new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);

View file

@ -39,8 +39,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterEnchantmentPermanent; import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -95,16 +95,13 @@ public class RootGreevil extends CardImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.DestroyPermanent, choice, game); if (controller != null && controller.choose(Outcome.DestroyPermanent, choice, game)) {
if (choice.getColor() != null) {
FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));
for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) { for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) {
enchantment.destroy(source.getSourceId(), game, false); enchantment.destroy(source.getSourceId(), game, false);
} }
}
return true; return true;
} }
return false; return false;

View file

@ -125,13 +125,9 @@ class SarkhanUnbrokenAbility1 extends OneShotEffect {
manaChoice.setMessage("Select color of mana to add"); manaChoice.setMessage("Select color of mana to add");
Mana mana = new Mana(); Mana mana = new Mana();
if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
controller.choose(Outcome.Benefit, manaChoice, game);
if (manaChoice.getChoice() == null) {
return false; return false;
} }
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {
case "White": case "White":
mana.increaseWhite(); mana.increaseWhite();

View file

@ -187,16 +187,10 @@ class SasayasEssenceManaEffectEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
while (!choice.isChosen()) { if (!controller.choose(outcome, choice, game)) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false; return false;
} }
} }
}
if (choice.getChoice() == null) {
return false;
}
switch (choice.getChoice()) { switch (choice.getChoice()) {
case "Black": case "Black":
newMana.increaseBlack(); newMana.increaseBlack();

View file

@ -97,14 +97,8 @@ class SealOfTheGuildpactChooseColorEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (controller != null && mageObject != null) {
ChoiceColor choice1 = new ChoiceColor(); ChoiceColor choice1 = new ChoiceColor();
while (!choice1.isChosen()) { if (controller != null && mageObject != null && controller.choose(Outcome.Benefit, choice1, game)) {
controller.choose(Outcome.Benefit, choice1, game);
if (!controller.canRespond()) {
return false;
}
}
String color1 = choice1.getChoice(); String color1 = choice1.getChoice();
Set<String> choices2 = new HashSet<>(); Set<String> choices2 = new HashSet<>();
if (!color1.equals("White")) { if (!color1.equals("White")) {
@ -124,12 +118,9 @@ class SealOfTheGuildpactChooseColorEffect extends OneShotEffect {
} }
ChoiceColor choice2 = new ChoiceColor(); ChoiceColor choice2 = new ChoiceColor();
choice2.setChoices(choices2); choice2.setChoices(choices2);
while (!choice2.isChosen()) { if (!controller.choose(Outcome.Benefit, choice2, game)) {
controller.choose(Outcome.Benefit, choice2, game);
if (!controller.canRespond()) {
return false; return false;
} }
}
String color2 = choice2.getChoice(); String color2 = choice2.getChoice();
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + color1 + " and " + color2 + '.'); game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + color1 + " and " + color2 + '.');
@ -178,8 +169,8 @@ class SealOfTheGuildpactCostReductionEffect extends CostModificationEffectImpl {
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getControllerId().equals(source.getControllerId()) && return abilityToModify.getControllerId().equals(source.getControllerId())
abilityToModify instanceof SpellAbility; && abilityToModify instanceof SpellAbility;
} }
@Override @Override

View file

@ -95,15 +95,8 @@ class SehtsTigerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
controller.choose(Outcome.Protect, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));
@ -112,8 +105,6 @@ class SehtsTigerEffect extends OneShotEffect {
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source); game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true; return true;
} }
}
return false; return false;
} }

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -45,10 +48,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author MarcoMarin / HCrescent * @author MarcoMarin / HCrescent
@ -79,6 +78,7 @@ public class Shapeshifter extends CardImpl {
return new Shapeshifter(this); return new Shapeshifter(this);
} }
} }
class ShapeshifterEffect extends OneShotEffect { class ShapeshifterEffect extends OneShotEffect {
public ShapeshifterEffect() { public ShapeshifterEffect() {
@ -110,11 +110,9 @@ class ShapeshifterEffect extends OneShotEffect {
numbers.add(Integer.toString(i)); numbers.add(Integer.toString(i));
} }
numberChoice.setChoices(numbers); numberChoice.setChoices(numbers);
while (!controller.choose(Outcome.Neutral, numberChoice, game)) { if (!controller.choose(Outcome.Neutral, numberChoice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + ']'); game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + ']');
game.getState().setValue(source.getSourceId().toString() + "_Shapeshifter", numberChoice.getChoice()); game.getState().setValue(source.getSourceId().toString() + "_Shapeshifter", numberChoice.getChoice());
if (mageObject instanceof Permanent) { if (mageObject instanceof Permanent) {
@ -124,6 +122,7 @@ class ShapeshifterEffect extends OneShotEffect {
return false; return false;
} }
} }
class ShapeshifterContinuousEffect extends ContinuousEffectImpl { class ShapeshifterContinuousEffect extends ContinuousEffectImpl {
public ShapeshifterContinuousEffect() { public ShapeshifterContinuousEffect() {

View file

@ -45,9 +45,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -106,9 +106,9 @@ class ShorecrasherElementalEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent shorecrasherElemental = game.getPermanent(source.getSourceId()); Permanent shorecrasherElemental = game.getPermanent(source.getSourceId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (shorecrasherElemental != null && if (shorecrasherElemental != null
sourceObject != null && && sourceObject != null
new MageObjectReference(sourceObject, game).refersTo(shorecrasherElemental, game)) { && new MageObjectReference(sourceObject, game).refersTo(shorecrasherElemental, game)) {
if (shorecrasherElemental.moveToExile(source.getSourceId(), sourceObject.getName(), source.getSourceId(), game)) { if (shorecrasherElemental.moveToExile(source.getSourceId(), sourceObject.getName(), source.getSourceId(), game)) {
Card card = game.getExile().getCard(source.getSourceId(), game); Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) { if (card != null) {
@ -149,12 +149,7 @@ class ShorecrasherElementalBoostEffect extends OneShotEffect {
choice.setMessage("Select how to boost"); choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1); choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2); choice.getChoices().add(CHOICE_2);
while (!choice.isChosen()) { if (controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
if (choice.getChoice().equals(CHOICE_1)) { if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source); game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source);
} else { } else {
@ -162,6 +157,7 @@ class ShorecrasherElementalBoostEffect extends OneShotEffect {
} }
return true; return true;
} }
}
return false; return false;
} }
} }

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,8 +44,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game; import mage.game.Game;
@ -50,10 +53,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -115,12 +114,9 @@ class SithEvokerEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose mode"); choice.setMessage("Choose mode");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
}
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) { if (sourceCard != null) {
for (Object cost : source.getCosts()) { for (Object cost : source.getCosts()) {

View file

@ -41,8 +41,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -115,16 +115,14 @@ class SphinxAmbassadorEffect extends OneShotEffect {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(choices); cardChoice.setChoices(choices);
cardChoice.clearChoice(); cardChoice.clearChoice();
while (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) { if (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
if (!targetPlayer.canRespond()) {
return false; return false;
} }
}
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append(']').toString()); game.informPlayers(sourcePermanent.getName() + ", named card: [" + cardName + ']');
if (!card.getName().equals(cardName) && card.isCreature()) { if (!card.getName().equals(cardName) && card.isCreature()) {
if (controller.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) { if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game); controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} }
} }

View file

@ -134,9 +134,10 @@ class SquanderedResourcesEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
return false;
}
} }
if (choice.getChoice() != null) {
Mana mana = new Mana(); Mana mana = new Mana();
switch (choice.getChoice()) { switch (choice.getChoice()) {
case "Black": case "Black":
@ -160,9 +161,7 @@ class SquanderedResourcesEffect extends ManaEffect {
} }
checkToFirePossibleEvents(mana, game, source); checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source); player.getManaPool().addMana(mana, game, source);
return true;
}
return false;
} }
return true; return true;
} }

View file

@ -88,11 +88,9 @@ class StandardizeEffect extends OneShotEffect {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
typeChoice.setMessage("Choose a creature type other than Wall"); typeChoice.setMessage("Choose a creature type other than Wall");
typeChoice.getChoices().remove("Wall"); typeChoice.getChoices().remove("Wall");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { if (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false; return false;
} }
}
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
chosenType = typeChoice.getChoice(); chosenType = typeChoice.getChoice();
if (chosenType != null && !chosenType.isEmpty()) { if (chosenType != null && !chosenType.isEmpty()) {

View file

@ -152,7 +152,9 @@ class StarCompassManaEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
return false;
}
} }
if (choice.getChoice() != null) { if (choice.getChoice() != null) {
Mana mana = new Mana(); Mana mana = new Mana();

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.RestrictionEffect;
@ -42,10 +45,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -106,12 +105,7 @@ class StorageMatrixRestrictionEffect extends RestrictionEffect {
choiceImpl.setMessage("Untap which kind of permanent?"); choiceImpl.setMessage("Untap which kind of permanent?");
choiceImpl.setChoices(choice); choiceImpl.setChoices(choice);
Player player = game.getPlayer(game.getActivePlayerId()); Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) { if (player != null && player.choose(outcome, choiceImpl, game)) {
while (!player.choose(outcome, choiceImpl, game)) {
if (!player.canRespond()) {
return false;
}
}
String choosenType = choiceImpl.getChoice(); String choosenType = choiceImpl.getChoice();
if (choosenType != null) { if (choosenType != null) {
game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType); game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType);

View file

@ -85,10 +85,8 @@ class SuddenDemiseDamageEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(outcome, choice, game); if (controller != null && controller.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
final int damage = source.getManaCostsToPay().getX(); final int damage = source.getManaCostsToPay().getX();
FilterPermanent filter = new FilterCreaturePermanent(); FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));
@ -97,7 +95,6 @@ class SuddenDemiseDamageEffect extends OneShotEffect {
} }
return true; return true;
} }
}
return false; return false;
} }
} }

Some files were not shown because too many files have changed in this diff Show more