* 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);
while (!abort) {
while (canRespond()) {
prepareForResponse(game);
if (!isExecutingMacro()) {
game.fireChooseChoiceEvent(playerId, choice);
}
waitForResponse(game);
String val = response.getString();
if (val != null) {
if (val != null && !val.isEmpty()) {
if (choice.isKeyChoice()) {
choice.setChoiceByKey(val);
} else {

View file

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

View file

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

View file

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

View file

@ -64,15 +64,9 @@ public class AphettoDredging extends CardImpl {
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId()));
while (!controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!controller.canRespond()) {
return;
}
}
if (controller != null && controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
String chosenType = typeChoice.getChoice();
FilterCreatureCard filter = new FilterCreatureCard(chosenType + " cards");
filter.add(new SubtypePredicate(SubType.byDescription(chosenType)));
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
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.a;
import java.util.UUID;
@ -53,6 +52,7 @@ import mage.target.common.TargetControlledPermanent;
* @author Loki
*/
public class ApostlesBlessing extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature you control");
static {
@ -102,13 +102,7 @@ class ApostlesBlessingEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
while (!choice.isChosen()) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
if (controller.choose(outcome, choice, game)) {
FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));
@ -122,6 +116,7 @@ class ApostlesBlessingEffect extends OneShotEffect {
game.addEffect(effect, source);
return true;
}
}
return false;
}
}

View file

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

View file

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

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -101,7 +100,9 @@ class BatheInLightEffect extends OneShotEffect {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
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.getState().setValue(target.getId() + "_color", colorChoice.getColor());
@ -117,7 +118,7 @@ class BatheInLightEffect extends OneShotEffect {
game.addEffect(effect, source);
}
}
}
}
return true;
}

View file

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

View file

@ -27,6 +27,7 @@
*/
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -45,8 +46,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author fireshoes
@ -96,18 +95,9 @@ class BloodlineShamanEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null) {
// Choose a creature type.
Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
if (controller != null && controller.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCard filterSubtype = new FilterCard();
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++) {
Mana mana = new Mana();
while(!player.choose(Outcome.Benefit, manaChoice, game)) {
if(!player.canRespond()) {
if (!player.choose(Outcome.Benefit, manaChoice, game)) {
return false;
}
}
if (manaChoice.getChoice() == null) { //Can happen if player leaves game
return false;
}
@ -129,6 +127,7 @@ class BurntOfferingEffect extends OneShotEffect {
/**
* Helper method to determine the CMC of the sacrificed creature.
*
* @param sourceAbility
* @return
*/

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -106,8 +106,12 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
}
choice.setChoices(choices);
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();
} else {
return null;
}
} else {
for (Counter counter : permanent.getCounters(game).values()) {
if (counter.getCount() > 0) {
@ -134,8 +138,11 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
}
choice.setChoices(choices);
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();
} else {
return null;
}
} else {
for (Counter counter : card.getCounters(game).values()) {
if (counter.getCount() > 0) {

View file

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

View file

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

View file

@ -138,38 +138,35 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
}
if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
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 {
if (!player.choose(outcome, choice, game)) {
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;
}

View file

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

View file

@ -53,7 +53,6 @@ public class CreepingRenaissance extends CardImpl {
public CreepingRenaissance(UUID ownerId, CardSetInfo setInfo) {
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.
this.getSpellAbility().addEffect(new CreepingRenaissanceEffect());
@ -95,9 +94,7 @@ class CreepingRenaissanceEffect extends OneShotEffect {
typeChoice.getChoices().add(CardType.LAND.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();
CardType chosenType = null;
for (CardType cardType : CardType.values()) {
@ -114,6 +111,7 @@ class CreepingRenaissanceEffect extends OneShotEffect {
return true;
}
}
}
return false;
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -43,8 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -54,7 +53,7 @@ import mage.players.Player;
/**
*
* @author LoneFox
*
*/
public class CrosisThePurger extends CardImpl {
@ -104,7 +103,7 @@ class CrosisThePurgerEffect extends OneShotEffect {
if (player != null) {
ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game);
if(choice.getColor() != null) {
if (choice.isChosen()) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
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.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -98,16 +98,8 @@ class DarigaazTheIgniterEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(true);
while (!choice.isChosen()) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() != null) {
if (controller != null && controller.choose(outcome, choice, game)) {
game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (damagedPlayer != null) {
@ -119,9 +111,7 @@ class DarigaazTheIgniterEffect extends OneShotEffect {
damagedPlayer.damage(damage, source.getSourceId(), game, false, true);
}
}
}
return true;
}
return false;
}

View file

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

View file

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

View file

@ -27,6 +27,7 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
@ -43,8 +44,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author emerald000
@ -54,7 +53,6 @@ public class DistantMelody extends CardImpl {
public DistantMelody(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Choose a creature type. Draw a card for each permanent you control of that type.
this.getSpellAbility().addEffect(new DistantMelodyEffect());
}
@ -87,14 +85,9 @@ class DistantMelodyEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
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.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -102,11 +102,9 @@ public class DiviningWitch extends CardImpl {
// Name a card.
Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames());
while (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) {
if (!controller.choose(Outcome.Benefit, choice, game)) {
return false;
}
}
String name = choice.getChoice();
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.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -109,8 +109,7 @@ class BecomesColorOrColorsEnchantedEffect extends OneShotEffect {
}
}
ChoiceColor choiceColor = new ChoiceColor();
controller.choose(Outcome.Benefit, choiceColor, game);
if (!controller.canRespond()) {
if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
return false;
}
if (!game.isSimulation()) {

View file

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

View file

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

View file

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

View file

@ -94,11 +94,9 @@ class ElsewhereFlaskEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
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.addEffect(new ElsewhereFlaskContinuousEffect(), source);
return true;
}

View file

@ -95,13 +95,8 @@ class ElvishSoultillerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject);
while (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
if (!game.isSimulation()) {
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) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(outcome, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
if (player != null && player.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
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 (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) {
controller.choose(Outcome.Protect, choice, game);
if (!controller.canRespond()) {
if (!controller.choose(Outcome.Protect, choice, game)) {
return false;
}
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -99,12 +99,10 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl {
MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && mageObject != null) {
ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) {
player.choose(outcome, choice, game);
if (!player.canRespond()) {
if (!player.choose(outcome, choice, game)) {
discard();
return;
}
}
if (!game.isSimulation()) {
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)) {
Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
if (!player.canRespond()) {
if (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
continue PlayerIteration;
}
}
String chosenType = typeChoice.getChoice();
if (chosenType != null) {
game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,6 +27,7 @@
*/
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.ContinuousEffect;
@ -48,8 +49,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author emerald000
@ -92,17 +91,10 @@ class PeerPressureEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!controller.choose(Outcome.GainControl, choice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (controller != null && controller.choose(Outcome.GainControl, choice, game)) {
String chosenType = choice.getChoice();
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
}
UUID playerWithMost = null;
int maxControlled = 0;
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.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -126,12 +126,7 @@ class PemminsAuraBoostEnchantedEffect extends OneShotEffect {
choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2);
while (!choice.isChosen()) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
if (!controller.choose(outcome, choice, game)) {
if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
} else {
@ -139,6 +134,7 @@ class PemminsAuraBoostEnchantedEffect extends OneShotEffect {
}
return true;
}
}
return false;
}
}

View file

@ -89,17 +89,8 @@ class PersecuteEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && sourceObject != null && targetPlayer != null) {
ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() == null) {
return false;
}
if (controller != null && sourceObject != null && targetPlayer != null && controller.choose(outcome, choice, game)) {
Cards hand = targetPlayer.getHand();
targetPlayer.revealCards(sourceObject.getIdName(), hand, 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));
if (controller != null && sourceObject != null && player != null) {
if (player.getLibrary().hasCards()) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card");
while (!player.choose(Outcome.DrawCard, cardChoice, game)) {
if (!player.canRespond()) {
if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().removeFromTop(game);

View file

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

View file

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

View file

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

View file

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

View file

@ -50,7 +50,6 @@ public class ReverseTheSands extends CardImpl {
public ReverseTheSands(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}{W}");
// Redistribute any number of players' life totals.
this.getSpellAbility().addEffect(new ReverseTheSandsEffect());
}
@ -100,7 +99,9 @@ class ReverseTheSandsEffect extends OneShotEffect {
String selectedChoice;
if (choices.size() > 1) {
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();
} else {
selectedChoice = choices.iterator().next();

View file

@ -28,7 +28,6 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
@ -130,14 +129,9 @@ class RhysticCaveManaEffect extends ManaEffect {
@Override
public boolean apply(Game game, Ability source) {
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);
controller.choose(outcome, choice, game);
if (choice.getColor() != null) {
String color = choice.getColor().toString();
switch (color) {
if (controller != null && controller.choose(outcome, choice, game)) {
switch (choice.getColor().toString()) {
case "R":
chosenMana.setRed(1);
break;
@ -154,14 +148,10 @@ class RhysticCaveManaEffect extends ManaEffect {
chosenMana.setGreen(1);
break;
}
}
checkToFirePossibleEvents(chosenMana, game, source);
controller.getManaPool().addMana(chosenMana, game, source);
return true;
}
}
return false;
}

View file

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

View file

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

View file

@ -97,7 +97,10 @@ class RiteOfRuinEffect extends OneShotEffect {
choice.setMessage("Choose a card type");
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()));
choices.remove(choice.getChoice());
choice.clearChoice();

View file

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

View file

@ -90,11 +90,9 @@ class RoarOfTheCrowdEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.LoseLife, typeChoice, game)) {
if (!player.canRespond()) {
if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
return false;
}
}
FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
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.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -95,16 +95,13 @@ public class RootGreevil extends CardImpl {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.DestroyPermanent, choice, game);
if (choice.getColor() != null) {
if (controller != null && controller.choose(Outcome.DestroyPermanent, choice, game)) {
FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent();
filter.add(new ColorPredicate(choice.getColor()));
for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) {
enchantment.destroy(source.getSourceId(), game, false);
}
}
return true;
}
return false;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -41,8 +41,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -115,16 +115,14 @@ class SphinxAmbassadorEffect extends OneShotEffect {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(choices);
cardChoice.clearChoice();
while (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
if (!targetPlayer.canRespond()) {
if (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
return false;
}
}
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 (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);
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

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