From b752eacfaad06505aa6751c7c935f9bf50f0ba3a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 4 Feb 2018 17:51:12 +0100 Subject: [PATCH] * Optimized handling and call of player.choose choice to prevent problems if a player disconnects or left a game (#4263). --- .../src/mage/player/human/HumanPlayer.java | 6 +- Mage.Sets/src/mage/cards/a/Addle.java | 19 +- .../src/mage/cards/a/AngelicSkirmisher.java | 11 +- .../src/mage/cards/a/AnimationModule.java | 30 ++- .../src/mage/cards/a/AphettoDredging.java | 12 +- .../src/mage/cards/a/ApostlesBlessing.java | 45 ++-- .../src/mage/cards/a/AquamorphEntity.java | 10 +- .../src/mage/cards/a/ArchangelOfStrife.java | 85 +++---- Mage.Sets/src/mage/cards/b/BatheInLight.java | 35 +-- Mage.Sets/src/mage/cards/b/BloodOath.java | 66 ++--- .../src/mage/cards/b/BloodlineShaman.java | 40 ++- Mage.Sets/src/mage/cards/b/BurntOffering.java | 45 ++-- .../src/mage/cards/b/ButcherOfTheHorde.java | 9 +- .../src/mage/cards/c/CallerOfTheHunt.java | 12 +- .../src/mage/cards/c/CallousOppressor.java | 20 +- .../src/mage/cards/c/CarpetOfFlowers.java | 13 +- Mage.Sets/src/mage/cards/c/ChromeMox.java | 7 +- Mage.Sets/src/mage/cards/c/Clockspinning.java | 17 +- .../src/mage/cards/c/CoalitionRelic.java | 9 +- .../src/mage/cards/c/ConundrumSphinx.java | 6 +- .../src/mage/cards/c/CorruptedGrafstone.java | 47 ++-- .../src/mage/cards/c/CranialExtraction.java | 11 +- .../src/mage/cards/c/CreepingRenaissance.java | 34 ++- .../src/mage/cards/c/CrosisThePurger.java | 19 +- .../src/mage/cards/d/DarigaazTheIgniter.java | 36 +-- .../src/mage/cards/d/DawnsReflection.java | 8 +- .../src/mage/cards/d/DemonicConsultation.java | 8 +- Mage.Sets/src/mage/cards/d/DistantMelody.java | 25 +- Mage.Sets/src/mage/cards/d/DiviningWitch.java | 14 +- Mage.Sets/src/mage/cards/d/DreamCoat.java | 5 +- .../src/mage/cards/d/DromarTheBanisher.java | 7 +- .../src/mage/cards/d/DwarvenArmorer.java | 30 +-- .../src/mage/cards/e/ElementalResonance.java | 15 +- .../src/mage/cards/e/ElsewhereFlask.java | 10 +- .../src/mage/cards/e/ElvishSoultiller.java | 11 +- Mage.Sets/src/mage/cards/e/Extinction.java | 15 +- Mage.Sets/src/mage/cards/f/FaithsShield.java | 7 +- Mage.Sets/src/mage/cards/f/Fatespinner.java | 15 +- .../src/mage/cards/f/FlowstoneSculpture.java | 62 +++-- Mage.Sets/src/mage/cards/f/Fluctuator.java | 5 +- Mage.Sets/src/mage/cards/f/FoodChain.java | 5 +- .../src/mage/cards/g/GabrielAngelfire.java | 8 +- .../src/mage/cards/g/GoblinClearcutter.java | 24 +- Mage.Sets/src/mage/cards/g/GolemArtisan.java | 6 +- Mage.Sets/src/mage/cards/g/GremlinMine.java | 11 +- .../src/mage/cards/h/HallOfGemstone.java | 8 +- Mage.Sets/src/mage/cards/h/HarshMercy.java | 8 +- .../mage/cards/i/InfiniteObliteration.java | 8 +- Mage.Sets/src/mage/cards/j/JeweledSpirit.java | 31 +-- Mage.Sets/src/mage/cards/j/JodahsAvenger.java | 9 +- .../src/mage/cards/k/KaronaFalseGod.java | 6 +- Mage.Sets/src/mage/cards/l/LiarsPendulum.java | 24 +- .../src/mage/cards/l/LuminescentRain.java | 48 ++-- Mage.Sets/src/mage/cards/l/LunarAvenger.java | 18 +- .../mage/cards/m/MadScienceFairProject.java | 12 +- .../src/mage/cards/m/MaintenanceDroid.java | 17 +- .../src/mage/cards/m/ManaforgeCinder.java | 14 +- .../src/mage/cards/m/MarketFestival.java | 6 +- Mage.Sets/src/mage/cards/m/Mindblaze.java | 30 +-- .../src/mage/cards/m/MistformSliver.java | 6 +- .../src/mage/cards/m/MultiformWonder.java | 15 +- Mage.Sets/src/mage/cards/m/MysticBarrier.java | 44 ++-- .../src/mage/cards/n/NakedSingularity.java | 10 +- Mage.Sets/src/mage/cards/n/NewBlood.java | 7 +- .../src/mage/cards/o/OonaQueenOfTheFae.java | 39 ++- .../src/mage/cards/o/OrcishLumberjack.java | 17 +- .../src/mage/cards/o/OrderOfSuccession.java | 6 +- Mage.Sets/src/mage/cards/o/Outbreak.java | 17 +- Mage.Sets/src/mage/cards/p/PacksDisdain.java | 11 +- Mage.Sets/src/mage/cards/p/PaleWayfarer.java | 9 +- .../src/mage/cards/p/PatriarchsBidding.java | 17 +- Mage.Sets/src/mage/cards/p/PeerPressure.java | 18 +- Mage.Sets/src/mage/cards/p/PemminsAura.java | 20 +- Mage.Sets/src/mage/cards/p/Persecute.java | 15 +- Mage.Sets/src/mage/cards/p/PetraSphinx.java | 7 +- Mage.Sets/src/mage/cards/p/PlasmCapture.java | 10 +- Mage.Sets/src/mage/cards/p/PrimalClay.java | 13 +- Mage.Sets/src/mage/cards/p/PrimalPlasma.java | 19 +- .../src/mage/cards/p/PrismaticStrands.java | 2 +- Mage.Sets/src/mage/cards/r/RealityTwist.java | 7 +- .../src/mage/cards/r/ReverseTheSands.java | 7 +- Mage.Sets/src/mage/cards/r/RhysticCave.java | 52 ++-- .../src/mage/cards/r/RiptideChronologist.java | 16 +- .../src/mage/cards/r/RiptideShapeshifter.java | 11 +- Mage.Sets/src/mage/cards/r/RiteOfRuin.java | 5 +- .../src/mage/cards/r/RithTheAwakener.java | 19 +- .../src/mage/cards/r/RoarOfTheCrowd.java | 8 +- Mage.Sets/src/mage/cards/r/RootGreevil.java | 19 +- .../src/mage/cards/s/SarkhanUnbroken.java | 8 +- .../mage/cards/s/SasayaOrochiAscendant.java | 10 +- .../src/mage/cards/s/SealOfTheGuildpact.java | 33 +-- Mage.Sets/src/mage/cards/s/SehtsTiger.java | 27 +- Mage.Sets/src/mage/cards/s/Shapeshifter.java | 57 ++--- .../mage/cards/s/ShorecrasherElemental.java | 26 +- Mage.Sets/src/mage/cards/s/SithEvoker.java | 16 +- .../src/mage/cards/s/SphinxAmbassador.java | 14 +- .../src/mage/cards/s/SquanderedResources.java | 53 ++-- Mage.Sets/src/mage/cards/s/Standardize.java | 6 +- Mage.Sets/src/mage/cards/s/StarCompass.java | 4 +- Mage.Sets/src/mage/cards/s/StorageMatrix.java | 16 +- Mage.Sets/src/mage/cards/s/SuddenDemise.java | 19 +- .../src/mage/cards/t/TabletOfTheGuilds.java | 14 +- Mage.Sets/src/mage/cards/t/TeferisRealm.java | 18 +- .../src/mage/cards/t/TrainingGrounds.java | 8 +- .../src/mage/cards/t/TrevaTheRenewer.java | 19 +- Mage.Sets/src/mage/cards/t/TribalUnity.java | 23 +- Mage.Sets/src/mage/cards/t/TsabosDecree.java | 24 +- Mage.Sets/src/mage/cards/t/TundraKavu.java | 16 +- Mage.Sets/src/mage/cards/t/Turnabout.java | 21 +- .../src/mage/cards/v/VedalkenEngineer.java | 26 +- .../src/mage/cards/v/VeteranWarleader.java | 7 +- Mage.Sets/src/mage/cards/v/VexingArcanix.java | 7 +- Mage.Sets/src/mage/cards/v/VisionCharm.java | 10 +- Mage.Sets/src/mage/cards/v/Void.java | 4 +- .../src/mage/cards/w/WalkingDesecration.java | 15 +- Mage.Sets/src/mage/cards/w/WalkingSponge.java | 22 +- Mage.Sets/src/mage/cards/w/WashOut.java | 19 +- Mage.Sets/src/mage/cards/w/Wishmonger.java | 29 +-- Mage.Sets/src/mage/cards/w/WoodSage.java | 8 +- Mage.Sets/src/mage/cards/w/WorldQueller.java | 32 +-- .../src/mage/cards/x/XenagosTheReveler.java | 8 +- .../cards/abilities/keywords/BestowTest.java | 2 +- .../main/java/mage/abilities/AbilityImpl.java | 18 +- .../costs/common/RemoveCounterCost.java | 6 +- .../decorator/ConditionalManaEffect.java | 4 - .../AddConditionalManaOfAnyColorEffect.java | 8 +- ...dManaAnyColorAttachedControllerEffect.java | 18 +- .../common/AddManaOfAnyColorEffect.java | 15 +- ...fAnyColorToManaPoolTargetPlayerEffect.java | 23 +- .../AddManaOfAnyTypeProducedEffect.java | 7 +- .../effects/common/ChooseColorEffect.java | 10 +- .../common/ChooseCreatureTypeEffect.java | 21 +- .../common/ChooseExpansionSetEffect.java | 25 +- .../effects/common/ChooseLandTypeEffect.java | 21 +- .../effects/common/ChooseModeEffect.java | 17 +- .../effects/common/DynamicManaEffect.java | 6 +- .../abilities/effects/common/MeldEffect.java | 239 +++++++++--------- .../effects/common/NameACardEffect.java | 21 +- .../BecomesBasicLandTargetEffect.java | 16 +- ...BecomesChosenCreatureTypeTargetEffect.java | 15 +- .../BecomesColorOrColorsTargetEffect.java | 3 +- .../continuous/BecomesColorSourceEffect.java | 12 +- .../continuous/BecomesColorTargetEffect.java | 16 +- .../GainProtectionFromColorAllEffect.java | 13 +- .../GainProtectionFromColorSourceEffect.java | 36 ++- .../GainProtectionFromColorTargetEffect.java | 14 +- ...seAbilityOrAnotherAbilityTargetEffect.java | 12 +- .../cost/SpellsCostReductionAllEffect.java | 3 +- .../common/counter/ProliferateEffect.java | 31 ++- .../counter/RemoveCounterTargetEffect.java | 19 +- .../abilities/keyword/ConvokeAbility.java | 11 +- .../mana/AnyColorLandsProduceManaAbility.java | 4 +- 152 files changed, 1224 insertions(+), 1681 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index ad9961c87f..349d39a859 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -153,7 +153,7 @@ public class HumanPlayer extends PlayerImpl { // wait response open for answer process int numTimesWaiting = 0; while (!responseOpenedForAnswer && canRespond()) { - numTimesWaiting ++; + numTimesWaiting++; if (numTimesWaiting >= 300) { // game freezed -- need to report about error and continue to execute String s = "Game freezed in waitResponseOpen for user " + getName(); @@ -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 { diff --git a/Mage.Sets/src/mage/cards/a/Addle.java b/Mage.Sets/src/mage/cards/a/Addle.java index afd3f43a09..359dbe4c1b 100644 --- a/Mage.Sets/src/mage/cards/a/Addle.java +++ b/Mage.Sets/src/mage/cards/a/Addle.java @@ -51,7 +51,7 @@ import mage.target.TargetPlayer; public class Addle extends CardImpl { public Addle(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}"); // Choose a color. Target player reveals his or her hand and you choose a card of that color from it. That player discards that card. this.getSpellAbility().addEffect(new AddleEffect()); @@ -87,17 +87,14 @@ 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); + ChoiceColor choice = new ChoiceColor(); + 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); - } + 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; } diff --git a/Mage.Sets/src/mage/cards/a/AngelicSkirmisher.java b/Mage.Sets/src/mage/cards/a/AngelicSkirmisher.java index f70cda40c0..8252259cc0 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicSkirmisher.java +++ b/Mage.Sets/src/mage/cards/a/AngelicSkirmisher.java @@ -56,7 +56,7 @@ import mage.players.Player; public class AngelicSkirmisher extends CardImpl { public AngelicSkirmisher(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}"); this.subtype.add(SubType.ANGEL); this.power = new MageInt(4); @@ -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; - } - } - Ability ability = null; - if (abilityChoice.getChoice() != null) { + if (controller.choose(outcome, abilityChoice, game)) { + Ability ability = null; switch (abilityChoice.getChoice()) { case "First strike": ability = FirstStrikeAbility.getInstance(); diff --git a/Mage.Sets/src/mage/cards/a/AnimationModule.java b/Mage.Sets/src/mage/cards/a/AnimationModule.java index 9b3e661d72..2c154badff 100644 --- a/Mage.Sets/src/mage/cards/a/AnimationModule.java +++ b/Mage.Sets/src/mage/cards/a/AnimationModule.java @@ -157,13 +157,16 @@ class AnimationModuleEffect extends OneShotEffect { } choice.setChoices(choices); choice.setMessage("Choose a counter"); - 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()); - permanent.addCounters(newCounter, source, game); - break; + 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()); + permanent.addCounters(newCounter, source, game); + break; + } } + } else { + return false; } } } @@ -184,13 +187,16 @@ class AnimationModuleEffect extends OneShotEffect { } choice.setChoices(choices); choice.setMessage("Choose a counter"); - controller.choose(Outcome.Benefit, choice, game); - for (Counter counter : player.getCounters().values()) { - if (counter.getName().equals(choice.getChoice())) { - Counter newCounter = new Counter(counter.getName()); - player.addCounters(newCounter, game); - break; + 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()); + player.addCounters(newCounter, game); + break; + } } + } else { + return false; } } } diff --git a/Mage.Sets/src/mage/cards/a/AphettoDredging.java b/Mage.Sets/src/mage/cards/a/AphettoDredging.java index 74df66d983..a95c0acc84 100644 --- a/Mage.Sets/src/mage/cards/a/AphettoDredging.java +++ b/Mage.Sets/src/mage/cards/a/AphettoDredging.java @@ -52,7 +52,7 @@ import mage.target.common.TargetCardInYourGraveyard; public class AphettoDredging extends CardImpl { public AphettoDredging(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}"); // Return up to three target creature cards of the creature type of your choice from your graveyard to your hand. Effect effect = new ReturnFromGraveyardToHandTargetEffect(); @@ -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; - } - } + Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId())); + 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)); diff --git a/Mage.Sets/src/mage/cards/a/ApostlesBlessing.java b/Mage.Sets/src/mage/cards/a/ApostlesBlessing.java index 6cbac2f44e..5de768c4a9 100644 --- a/Mage.Sets/src/mage/cards/a/ApostlesBlessing.java +++ b/Mage.Sets/src/mage/cards/a/ApostlesBlessing.java @@ -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 { @@ -62,8 +62,8 @@ public class ApostlesBlessing extends CardImpl { } public ApostlesBlessing(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W/P}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W/P}"); + // ({W/P} can be paid with either {W} or 2 life.) // Target artifact or creature you control gains protection from artifacts or from the color of your choice until end of turn. this.getSpellAbility().addEffect(new ApostlesBlessingEffect()); @@ -82,46 +82,41 @@ public class ApostlesBlessing extends CardImpl { } class ApostlesBlessingEffect extends OneShotEffect { - + public ApostlesBlessingEffect() { super(Outcome.AddAbility); this.staticText = "Target artifact or creature you control gains protection from artifacts or from the color of your choice until end of turn"; } - + public ApostlesBlessingEffect(final ApostlesBlessingEffect effect) { super(effect); } - + @Override public ApostlesBlessingEffect copy() { return new ApostlesBlessingEffect(this); } - + @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; + if (controller.choose(outcome, choice, game)) { + FilterCard protectionFilter = new FilterCard(); + if (choice.isArtifactSelected()) { + protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); + } else { + protectionFilter.add(new ColorPredicate(choice.getColor())); } - controller.choose(outcome, choice, game); + protectionFilter.setMessage(choice.getChoice()); + ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter); + ContinuousEffect effect = new GainAbilityTargetEffect(protectionAbility, Duration.EndOfTurn); + effect.setTargetPointer(getTargetPointer()); + game.addEffect(effect, source); + return true; } - - FilterCard protectionFilter = new FilterCard(); - if (choice.isArtifactSelected()) { - protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); - } else { - protectionFilter.add(new ColorPredicate(choice.getColor())); - } - protectionFilter.setMessage(choice.getChoice()); - ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter); - ContinuousEffect effect = new GainAbilityTargetEffect(protectionAbility, Duration.EndOfTurn); - effect.setTargetPointer(getTargetPointer()); - game.addEffect(effect, source); - return true; - } + } return false; } } diff --git a/Mage.Sets/src/mage/cards/a/AquamorphEntity.java b/Mage.Sets/src/mage/cards/a/AquamorphEntity.java index f3f0d0efa1..2dac1191fe 100644 --- a/Mage.Sets/src/mage/cards/a/AquamorphEntity.java +++ b/Mage.Sets/src/mage/cards/a/AquamorphEntity.java @@ -54,7 +54,7 @@ import mage.players.Player; public class AquamorphEntity extends CardImpl { public AquamorphEntity(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(0); this.toughness = new MageInt(0); @@ -136,11 +136,9 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Neutral, choice, game)) { + discard(); + return false; } } int power = 0; diff --git a/Mage.Sets/src/mage/cards/a/ArchangelOfStrife.java b/Mage.Sets/src/mage/cards/a/ArchangelOfStrife.java index 77d35c7a08..bb7b398a07 100644 --- a/Mage.Sets/src/mage/cards/a/ArchangelOfStrife.java +++ b/Mage.Sets/src/mage/cards/a/ArchangelOfStrife.java @@ -53,20 +53,20 @@ import mage.players.Player; public class ArchangelOfStrife extends CardImpl { public ArchangelOfStrife(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}"); this.subtype.add(SubType.ANGEL); this.power = new MageInt(6); this.toughness = new MageInt(6); // Flying this.addAbility(FlyingAbility.getInstance()); - + // As Archangel of Strife enters the battlefield, each player chooses war or peace. this.addAbility(new EntersBattlefieldAbility(new ArchangelOfStrifeChooseEffect(), "As Archangel of Strife enters the battlefield, each player chooses war or peace.")); - + // Creatures controlled by players who chose war get +3/+0. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ArchangelOfStrifeWarEffect())); - + // Creatures controlled by players who chose peace get +0/+3. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ArchangelOfStrifePeaceEffect())); } @@ -83,50 +83,43 @@ public class ArchangelOfStrife extends CardImpl { class ArchangelOfStrifeChooseEffect extends OneShotEffect { - public ArchangelOfStrifeChooseEffect(){ + public ArchangelOfStrifeChooseEffect() { super(Outcome.Neutral); - + this.staticText = "each player chooses war or peace."; } - - public ArchangelOfStrifeChooseEffect(ArchangelOfStrifeChooseEffect effect){ + + public ArchangelOfStrifeChooseEffect(ArchangelOfStrifeChooseEffect effect) { super(effect); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - + if (sourcePermanent == null) { sourcePermanent = game.getPermanentEntering(source.getSourceId()); } - + if (controller != null && sourcePermanent != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); - + Choice choice = new ChoiceImpl(true); choice.setMessage("Select war or peace"); choice.getChoices().add("war"); choice.getChoices().add("peace"); - - while (!choice.isChosen()) { - if (!player.canRespond()) { - return false; - } - - player.choose(Outcome.Neutral, choice, game); + + if (!player.choose(Outcome.Neutral, choice, game)) { + continue; } - - if (choice.isChosen()) { - if (!game.isSimulation()) { - game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); - } - - game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice()); - sourcePermanent.addInfo("_" + playerId +"_modeChoice", "" + player.getName() + " chose: " + choice.getChoice() + "", game); + if (!game.isSimulation()) { + game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); } + + game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice()); + sourcePermanent.addInfo("_" + playerId + "_modeChoice", "" + player.getName() + " chose: " + choice.getChoice() + "", game); } return true; } @@ -137,29 +130,30 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect { public Effect copy() { return new ArchangelOfStrifeChooseEffect(this); } - + } -class ArchangelOfStrifeWarEffect extends BoostAllEffect{ +class ArchangelOfStrifeWarEffect extends BoostAllEffect { + private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose war"); - - public ArchangelOfStrifeWarEffect(){ + + public ArchangelOfStrifeWarEffect() { super(3, 0, Duration.WhileOnBattlefield, creaturefilter, false); } - + @Override protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { - if (permanent != null){ + if (permanent != null) { UUID controllerId = permanent.getControllerId(); String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice"); - return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("war"); + return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("war"); } - + return false; } - + public ArchangelOfStrifeWarEffect(ArchangelOfStrifeWarEffect effect) { super(effect); } @@ -170,26 +164,27 @@ 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"); - - public ArchangelOfStrifePeaceEffect(){ + + public ArchangelOfStrifePeaceEffect() { super(0, 3, Duration.WhileOnBattlefield, creaturefilter, false); } - + @Override protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { - if (permanent != null){ + if (permanent != null) { UUID controllerId = permanent.getControllerId(); String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice"); - return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("peace"); + return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("peace"); } - + return false; } - + public ArchangelOfStrifePeaceEffect(ArchangelOfStrifePeaceEffect effect) { super(effect); } @@ -198,4 +193,4 @@ class ArchangelOfStrifePeaceEffect extends BoostAllEffect{ public ArchangelOfStrifePeaceEffect copy() { return new ArchangelOfStrifePeaceEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/b/BatheInLight.java b/Mage.Sets/src/mage/cards/b/BatheInLight.java index 396666f53d..15ee51eb88 100644 --- a/Mage.Sets/src/mage/cards/b/BatheInLight.java +++ b/Mage.Sets/src/mage/cards/b/BatheInLight.java @@ -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,25 +100,27 @@ 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)) { - game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice()); - game.getState().setValue(target.getId() + "_color", colorChoice.getColor()); - - ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color"); - if (protectColor != null) { - ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); - game.addEffect(effect, source); - ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { - if (permanent != target && permanent.getColor(game).shares(color)) { - game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor()); - effect.setTargetPointer(new FixedTarget(permanent, game)); - game.addEffect(effect, source); - } + 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()); + + ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color"); + if (protectColor != null) { + ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); + game.addEffect(effect, source); + ObjectColor color = target.getColor(game); + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + if (permanent != target && permanent.getColor(game).shares(color)) { + game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor()); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); } } + } - return true; + return true; } } return false; diff --git a/Mage.Sets/src/mage/cards/b/BloodOath.java b/Mage.Sets/src/mage/cards/b/BloodOath.java index 8557e046d6..d1d56b9b54 100644 --- a/Mage.Sets/src/mage/cards/b/BloodOath.java +++ b/Mage.Sets/src/mage/cards/b/BloodOath.java @@ -106,41 +106,41 @@ 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)) { - } - CardType type = null; - String choosenType = choiceImpl.getChoice(); + if (!player.choose(Outcome.Neutral, choiceImpl, game)) { + CardType type = null; + String choosenType = choiceImpl.getChoice(); - if (choosenType.equals(CardType.ARTIFACT.toString())) { - type = CardType.ARTIFACT; - } else if (choosenType.equals(CardType.LAND.toString())) { - type = CardType.LAND; - } else if (choosenType.equals(CardType.CREATURE.toString())) { - type = CardType.CREATURE; - } else if (choosenType.equals(CardType.ENCHANTMENT.toString())) { - type = CardType.ENCHANTMENT; - } else if (choosenType.equals(CardType.INSTANT.toString())) { - type = CardType.INSTANT; - } else if (choosenType.equals(CardType.SORCERY.toString())) { - type = CardType.SORCERY; - } else if (choosenType.equals(CardType.PLANESWALKER.toString())) { - type = CardType.PLANESWALKER; - } else if (choosenType.equals(CardType.TRIBAL.toString())) { - type = CardType.TRIBAL; - } - if (type != null) { - Cards hand = opponent.getHand(); - opponent.revealCards(sourceObject.getIdName(), hand, game); - Set cards = hand.getCards(game); - int damageToDeal = 0; - for (Card card : cards) { - if (card != null && card.getCardType().contains(type)) { - damageToDeal += 3; - } + if (choosenType.equals(CardType.ARTIFACT.toString())) { + type = CardType.ARTIFACT; + } else if (choosenType.equals(CardType.LAND.toString())) { + type = CardType.LAND; + } else if (choosenType.equals(CardType.CREATURE.toString())) { + type = CardType.CREATURE; + } else if (choosenType.equals(CardType.ENCHANTMENT.toString())) { + type = CardType.ENCHANTMENT; + } else if (choosenType.equals(CardType.INSTANT.toString())) { + type = CardType.INSTANT; + } else if (choosenType.equals(CardType.SORCERY.toString())) { + type = CardType.SORCERY; + } else if (choosenType.equals(CardType.PLANESWALKER.toString())) { + type = CardType.PLANESWALKER; + } else if (choosenType.equals(CardType.TRIBAL.toString())) { + type = CardType.TRIBAL; + } + if (type != null) { + Cards hand = opponent.getHand(); + opponent.revealCards(sourceObject.getIdName(), hand, game); + Set cards = hand.getCards(game); + int damageToDeal = 0; + for (Card card : cards) { + if (card != null && card.getCardType().contains(type)) { + damageToDeal += 3; + } + } + game.informPlayers(sourceObject.getLogName() + " deals " + (damageToDeal == 0 ? "no" : "" + damageToDeal) + " damage to " + opponent.getLogName()); + opponent.damage(damageToDeal, source.getSourceId(), game, false, true); + return true; } - game.informPlayers(sourceObject.getLogName() + " deals " + (damageToDeal == 0 ? "no" : "" + damageToDeal) + " damage to " + opponent.getLogName()); - opponent.damage(damageToDeal, source.getSourceId(), game, false, true); - return true; } } return false; diff --git a/Mage.Sets/src/mage/cards/b/BloodlineShaman.java b/Mage.Sets/src/mage/cards/b/BloodlineShaman.java index 4e9867eaa1..183e7ea969 100644 --- a/Mage.Sets/src/mage/cards/b/BloodlineShaman.java +++ b/Mage.Sets/src/mage/cards/b/BloodlineShaman.java @@ -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,37 +95,28 @@ 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) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); - } - + Choice typeChoice = new ChoiceCreatureType(sourceObject); + 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()))); // Reveal the top card of your library. if (controller.getLibrary().hasCards()) { - Card card = controller.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(card); - controller.revealCards(sourceObject.getIdName(), cards, game); + Card card = controller.getLibrary().getFromTop(game); + Cards cards = new CardsImpl(card); + controller.revealCards(sourceObject.getIdName(), cards, game); - if (card != null) { - // If that card is a creature card of the chosen type, put it into your hand. - if (filterSubtype.match(card, game)) { - controller.moveCards(card, Zone.HAND, source, game); - // Otherwise, put it into your graveyard. - } else { - controller.moveCards(card, Zone.GRAVEYARD, source, game); + if (card != null) { + // If that card is a creature card of the chosen type, put it into your hand. + if (filterSubtype.match(card, game)) { + controller.moveCards(card, Zone.HAND, source, game); + // Otherwise, put it into your graveyard. + } else { + controller.moveCards(card, Zone.GRAVEYARD, source, game); + } } } - } return true; } return false; diff --git a/Mage.Sets/src/mage/cards/b/BurntOffering.java b/Mage.Sets/src/mage/cards/b/BurntOffering.java index 01b24b260c..0626baa62c 100644 --- a/Mage.Sets/src/mage/cards/b/BurntOffering.java +++ b/Mage.Sets/src/mage/cards/b/BurntOffering.java @@ -52,20 +52,20 @@ import mage.target.common.TargetControlledCreaturePermanent; * @author Topher */ public class BurntOffering extends CardImpl { - + public BurntOffering(UUID ownerID, CardSetInfo setInfo) { - super(ownerID, setInfo, new CardType[]{CardType.INSTANT},"{B}"); - + super(ownerID, setInfo, new CardType[]{CardType.INSTANT}, "{B}"); + //As an additional cost to cast Burnt Offering, sacrifice a creature. this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent())); //Add to your mana pool an amount of {B} and/or {R} equal to the sacrificed creature's converted mana cost. this.getSpellAbility().addEffect(new BurntOfferingEffect()); } - + public BurntOffering(final BurntOffering card) { super(card); } - + @Override public BurntOffering copy() { return new BurntOffering(this); @@ -73,17 +73,17 @@ public class BurntOffering extends CardImpl { } class BurntOfferingEffect extends OneShotEffect { - + public BurntOfferingEffect() { super(Outcome.PutManaInPool); this.staticText = "Add X mana in any combination of {B} and/or {R} to your mana pool," + " where X is the sacrificed creature's converted mana cost"; } - + public BurntOfferingEffect(final BurntOfferingEffect effect) { super(effect); } - + @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); @@ -94,20 +94,18 @@ class BurntOfferingEffect extends OneShotEffect { choices.add("Black"); manaChoice.setChoices(choices); manaChoice.setMessage("Select color of mana to add"); - + int xValue = getCost(source); - - for(int i = 0; i < xValue; i++) { + + for (int i = 0; i < xValue; 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()) { + if (manaChoice.getChoice() == null) { //Can happen if player leaves game + return false; + } + switch (manaChoice.getChoice()) { case "Red": mana.increaseRed(); break; @@ -126,18 +124,19 @@ class BurntOfferingEffect extends OneShotEffect { public Effect copy() { return new BurntOfferingEffect(this); } - + /** * Helper method to determine the CMC of the sacrificed creature. + * * @param sourceAbility - * @return + * @return */ private int getCost(Ability sourceAbility) { - for(Cost cost : sourceAbility.getCosts()) { - if(cost instanceof SacrificeTargetCost) { + for (Cost cost : sourceAbility.getCosts()) { + if (cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; int totalCMC = 0; - for(Permanent permanent : sacrificeCost.getPermanents()) { + for (Permanent permanent : sacrificeCost.getPermanents()) { totalCMC += permanent.getConvertedManaCost(); } return totalCMC; diff --git a/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java b/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java index 9ee59e2c1b..b61402b9f3 100644 --- a/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java +++ b/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java @@ -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()) { - return false; - } + controller.choose(Outcome.AddAbility, abilityChoice, game); + if (!abilityChoice.isChosen()) { + return false; } - String chosen = abilityChoice.getChoice(); Ability ability = null; if (VigilanceAbility.getInstance().getRule().equals(chosen)) { diff --git a/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java b/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java index 4e440094aa..b2d6968e4d 100644 --- a/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java +++ b/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java @@ -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; - } - } + Choice typeChoice = new ChoiceCreatureType(mageObject); + if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) { if (!game.isSimulation()) { game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } diff --git a/Mage.Sets/src/mage/cards/c/CallousOppressor.java b/Mage.Sets/src/mage/cards/c/CallousOppressor.java index f5b9d78b01..a7868ae8c6 100644 --- a/Mage.Sets/src/mage/cards/c/CallousOppressor.java +++ b/Mage.Sets/src/mage/cards/c/CallousOppressor.java @@ -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; @@ -65,7 +63,7 @@ import mage.util.CardUtil; public class CallousOppressor extends CardImpl { public CallousOppressor(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); this.subtype.add(SubType.CEPHALID); this.power = new MageInt(1); this.toughness = new MageInt(2); @@ -97,20 +95,20 @@ public class CallousOppressor extends CardImpl { } class CallousOppressorFilter extends FilterCreaturePermanent { - + public CallousOppressorFilter() { super("creature that isn't of the chosen type"); } - + public CallousOppressorFilter(final CallousOppressorFilter filter) { super(filter); } - + @Override public CallousOppressorFilter copy() { return new CallousOppressorFilter(this); } - + @Override public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (super.match(permanent, sourceId, playerId, game)) { @@ -122,7 +120,7 @@ class CallousOppressorFilter extends FilterCreaturePermanent { } return false; } - + } class CallousOppressorChooseCreatureTypeEffect extends OneShotEffect { @@ -156,10 +154,8 @@ 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()) { - return false; - } + if (!opponent.choose(outcome, typeChoice, game)) { + return false; } if (typeChoice.getChoice() == null) { return false; diff --git a/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java b/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java index ac2aa41969..dbb09c5698 100644 --- a/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java +++ b/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java @@ -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; - } - } + ChoiceColor choice = new ChoiceColor(); + 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(); diff --git a/Mage.Sets/src/mage/cards/c/ChromeMox.java b/Mage.Sets/src/mage/cards/c/ChromeMox.java index 8358706f9b..9abb1f8c8f 100644 --- a/Mage.Sets/src/mage/cards/c/ChromeMox.java +++ b/Mage.Sets/src/mage/cards/c/ChromeMox.java @@ -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; } } diff --git a/Mage.Sets/src/mage/cards/c/Clockspinning.java b/Mage.Sets/src/mage/cards/c/Clockspinning.java index e8aab7e550..11834748f4 100644 --- a/Mage.Sets/src/mage/cards/c/Clockspinning.java +++ b/Mage.Sets/src/mage/cards/c/Clockspinning.java @@ -56,7 +56,7 @@ import mage.target.targetpointer.FixedTarget; public class Clockspinning extends CardImpl { public Clockspinning(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}"); // Buyback {3} this.addAbility(new BuybackAbility("{3}")); @@ -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); - counterName = choice.getChoice(); + 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); - counterName = choice.getChoice(); + 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) { diff --git a/Mage.Sets/src/mage/cards/c/CoalitionRelic.java b/Mage.Sets/src/mage/cards/c/CoalitionRelic.java index b9ae158113..e67b91c4d0 100644 --- a/Mage.Sets/src/mage/cards/c/CoalitionRelic.java +++ b/Mage.Sets/src/mage/cards/c/CoalitionRelic.java @@ -55,7 +55,7 @@ import mage.players.Player; public class CoalitionRelic extends CardImpl { public CoalitionRelic(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // {tap}: Add one mana of any color to your mana pool. this.addAbility(new AnyColorManaAbility()); @@ -101,11 +101,8 @@ 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()) { - return false; - } - player.choose(outcome, choice, game); + if (!player.choose(outcome, choice, game)) { + return false; } choice.increaseMana(mana); choice.clearChoice(); diff --git a/Mage.Sets/src/mage/cards/c/ConundrumSphinx.java b/Mage.Sets/src/mage/cards/c/ConundrumSphinx.java index 5b1080aba7..f42d2be742 100644 --- a/Mage.Sets/src/mage/cards/c/ConundrumSphinx.java +++ b/Mage.Sets/src/mage/cards/c/ConundrumSphinx.java @@ -102,10 +102,8 @@ 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()) { - continue Players; - } + if (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) { + continue Players; } String cardName = cardChoice.getChoice(); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); diff --git a/Mage.Sets/src/mage/cards/c/CorruptedGrafstone.java b/Mage.Sets/src/mage/cards/c/CorruptedGrafstone.java index 5d2668e8f0..064326fb57 100644 --- a/Mage.Sets/src/mage/cards/c/CorruptedGrafstone.java +++ b/Mage.Sets/src/mage/cards/c/CorruptedGrafstone.java @@ -138,37 +138,34 @@ 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; + if (!player.choose(outcome, choice, game)) { + return false; } - checkToFirePossibleEvents(computedMana, game, source); - player.getManaPool().addMana(computedMana, game, source); - } else { - 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; diff --git a/Mage.Sets/src/mage/cards/c/CranialExtraction.java b/Mage.Sets/src/mage/cards/c/CranialExtraction.java index 7a214b77fd..fb8f930d0d 100644 --- a/Mage.Sets/src/mage/cards/c/CranialExtraction.java +++ b/Mage.Sets/src/mage/cards/c/CranialExtraction.java @@ -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 @@ -52,7 +51,7 @@ import java.util.UUID; public class CranialExtraction extends CardImpl { public CranialExtraction(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}"); this.subtype.add(SubType.ARCANE); /* Name a nonland card. Search target player's graveyard, hand, and library for @@ -92,10 +91,8 @@ class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNam cardChoice.clearChoice(); cardChoice.setMessage("Name a nonland card"); - while (!controller.choose(Outcome.Exile, cardChoice, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Exile, cardChoice, game)) { + return false; } String cardName = cardChoice.getChoice(); MageObject sourceObject = game.getObject(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java b/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java index dee52edc67..674b94d0d5 100644 --- a/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java +++ b/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java @@ -51,8 +51,7 @@ import mage.players.Player; public class CreepingRenaissance extends CardImpl { 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. this.getSpellAbility().addEffect(new CreepingRenaissanceEffect()); @@ -95,25 +94,24 @@ 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)) { - } - - String typeName = typeChoice.getChoice(); - CardType chosenType = null; - for (CardType cardType : CardType.values()) { - if (cardType.toString().equals(typeName)) { - chosenType = cardType; - } - } - if (chosenType != null) { - for (Card card : controller.getGraveyard().getCards(game)) { - if (card.getCardType().contains(chosenType)) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); + if (controller.choose(Outcome.ReturnToHand, typeChoice, game)) { + String typeName = typeChoice.getChoice(); + CardType chosenType = null; + for (CardType cardType : CardType.values()) { + if (cardType.toString().equals(typeName)) { + chosenType = cardType; } } - return true; + if (chosenType != null) { + for (Card card : controller.getGraveyard().getCards(game)) { + if (card.getCardType().contains(chosenType)) { + card.moveToZone(Zone.HAND, source.getSourceId(), game, false); + } + } + return true; + } } - } + } return false; } diff --git a/Mage.Sets/src/mage/cards/c/CrosisThePurger.java b/Mage.Sets/src/mage/cards/c/CrosisThePurger.java index a3675c0bdc..c7d38c5d14 100644 --- a/Mage.Sets/src/mage/cards/c/CrosisThePurger.java +++ b/Mage.Sets/src/mage/cards/c/CrosisThePurger.java @@ -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,12 +53,12 @@ import mage.players.Player; /** * * @author LoneFox - + * */ public class CrosisThePurger extends CardImpl { public CrosisThePurger(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{B}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{B}{R}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); @@ -69,7 +68,7 @@ public class CrosisThePurger extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Whenever Crosis, the Purger deals combat damage to a player, you may pay {2}{B}. If you do, choose a color, then that player reveals his or her hand and discards all cards of that color. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DoIfCostPaid(new CrosisThePurgerEffect(), - new ManaCostsImpl("{2}{B}")), false, true)); + new ManaCostsImpl("{2}{B}")), false, true)); } public CrosisThePurger(final CrosisThePurger card) { @@ -101,23 +100,23 @@ class CrosisThePurgerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if(player != null) { + 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); FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(choice.getColor())); List toDiscard = new ArrayList<>(); - for(UUID cardId : damagedPlayer.getHand()) { + for (UUID cardId : damagedPlayer.getHand()) { Card card = game.getCard(cardId); - if(filter.match(card, game)) { + if (filter.match(card, game)) { toDiscard.add(card); } } - for(Card card: toDiscard) { + for (Card card : toDiscard) { damagedPlayer.discard(card, source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java b/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java index 567f0177e4..9bb78334e5 100644 --- a/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java +++ b/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java @@ -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; @@ -54,7 +54,7 @@ import mage.players.Player; public class DarigaazTheIgniter extends CardImpl { public DarigaazTheIgniter(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{R}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); @@ -98,30 +98,20 @@ 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) { - game.informPlayers(controller.getLogName() + " chooses " + choice.getColor()); - Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - if (damagedPlayer != null) { - damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); - FilterCard filter = new FilterCard(); - filter.add(new ColorPredicate(choice.getColor())); - int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game); - if (damage > 0) { - damagedPlayer.damage(damage, source.getSourceId(), game, false, true); - } + ChoiceColor choice = new ChoiceColor(true); + 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) { + damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); + FilterCard filter = new FilterCard(); + filter.add(new ColorPredicate(choice.getColor())); + int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game); + if (damage > 0) { + damagedPlayer.damage(damage, source.getSourceId(), game, false, true); } } return true; - } return false; } diff --git a/Mage.Sets/src/mage/cards/d/DawnsReflection.java b/Mage.Sets/src/mage/cards/d/DawnsReflection.java index f008b699bb..01295644fb 100644 --- a/Mage.Sets/src/mage/cards/d/DawnsReflection.java +++ b/Mage.Sets/src/mage/cards/d/DawnsReflection.java @@ -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,10 +135,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choiceColor, game)) { + return false; } choiceColor.increaseMana(mana); } diff --git a/Mage.Sets/src/mage/cards/d/DemonicConsultation.java b/Mage.Sets/src/mage/cards/d/DemonicConsultation.java index 27da4a8c8a..1be6c39d27 100644 --- a/Mage.Sets/src/mage/cards/d/DemonicConsultation.java +++ b/Mage.Sets/src/mage/cards/d/DemonicConsultation.java @@ -48,7 +48,7 @@ import mage.players.Player; public class DemonicConsultation extends CardImpl { public DemonicConsultation(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}"); // Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way. this.getSpellAbility().addEffect(new DemonicConsultationEffect()); @@ -88,10 +88,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choice, game)) { + return false; } String name = choice.getChoice(); game.informPlayers("Card named: " + name); diff --git a/Mage.Sets/src/mage/cards/d/DistantMelody.java b/Mage.Sets/src/mage/cards/d/DistantMelody.java index 5502cf2232..a4085eafb0 100644 --- a/Mage.Sets/src/mage/cards/d/DistantMelody.java +++ b/Mage.Sets/src/mage/cards/d/DistantMelody.java @@ -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 @@ -52,8 +51,7 @@ import java.util.UUID; public class DistantMelody extends CardImpl { 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. this.getSpellAbility().addEffect(new DistantMelodyEffect()); @@ -70,31 +68,26 @@ public class DistantMelody extends CardImpl { } class DistantMelodyEffect extends OneShotEffect { - + DistantMelodyEffect() { super(Outcome.DrawCard); this.staticText = "Choose a creature type. Draw a card for each permanent you control of that type"; } - + DistantMelodyEffect(final DistantMelodyEffect effect) { super(effect); } - + @Override public DistantMelodyEffect copy() { return new DistantMelodyEffect(this); } - + @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; - } - } + Player controller = game.getPlayer(source.getControllerId()); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + 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); diff --git a/Mage.Sets/src/mage/cards/d/DiviningWitch.java b/Mage.Sets/src/mage/cards/d/DiviningWitch.java index cd9f02de23..bf003028bb 100644 --- a/Mage.Sets/src/mage/cards/d/DiviningWitch.java +++ b/Mage.Sets/src/mage/cards/d/DiviningWitch.java @@ -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; @@ -56,7 +56,7 @@ public class DiviningWitch extends CardImpl { public DiviningWitch(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); - + this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.SPELLSHAPER); this.power = new MageInt(1); @@ -78,7 +78,7 @@ public class DiviningWitch extends CardImpl { return new DiviningWitch(this); } - private static class DiviningWitchEffect extends OneShotEffect { + private static class DiviningWitchEffect extends OneShotEffect { DiviningWitchEffect() { super(Outcome.Benefit); @@ -102,10 +102,8 @@ 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()) { - return false; - } + 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 { } } } - - diff --git a/Mage.Sets/src/mage/cards/d/DreamCoat.java b/Mage.Sets/src/mage/cards/d/DreamCoat.java index da541eeb5e..893d4efd38 100644 --- a/Mage.Sets/src/mage/cards/d/DreamCoat.java +++ b/Mage.Sets/src/mage/cards/d/DreamCoat.java @@ -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()) { diff --git a/Mage.Sets/src/mage/cards/d/DromarTheBanisher.java b/Mage.Sets/src/mage/cards/d/DromarTheBanisher.java index 5c23250372..c0d52b690d 100644 --- a/Mage.Sets/src/mage/cards/d/DromarTheBanisher.java +++ b/Mage.Sets/src/mage/cards/d/DromarTheBanisher.java @@ -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; @@ -55,7 +55,7 @@ import mage.players.Player; public class DromarTheBanisher extends CardImpl { public DromarTheBanisher(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{U}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{U}{B}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); @@ -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())); diff --git a/Mage.Sets/src/mage/cards/d/DwarvenArmorer.java b/Mage.Sets/src/mage/cards/d/DwarvenArmorer.java index 1b0eafc30a..d3b8111f98 100644 --- a/Mage.Sets/src/mage/cards/d/DwarvenArmorer.java +++ b/Mage.Sets/src/mage/cards/d/DwarvenArmorer.java @@ -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 @@ -62,7 +61,7 @@ import java.util.UUID; public class DwarvenArmorer extends CardImpl { public DwarvenArmorer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); this.subtype.add(SubType.DWARF); this.power = new MageInt(0); this.toughness = new MageInt(2); @@ -95,8 +94,8 @@ class DwarvenArmorerEffect extends OneShotEffect { } public DwarvenArmorerEffect() { - super(Outcome.Benefit); - staticText = "Put a +0/+1 counter or a +1/+0 counter on target creature."; + super(Outcome.Benefit); + staticText = "Put a +0/+1 counter or a +1/+0 counter on target creature."; } public DwarvenArmorerEffect(final DwarvenArmorerEffect effect) { @@ -111,19 +110,16 @@ class DwarvenArmorerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if(controller != null) { + if (controller != null) { 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); } - 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; } diff --git a/Mage.Sets/src/mage/cards/e/ElementalResonance.java b/Mage.Sets/src/mage/cards/e/ElementalResonance.java index ff2cb56235..81b89fc12f 100644 --- a/Mage.Sets/src/mage/cards/e/ElementalResonance.java +++ b/Mage.Sets/src/mage/cards/e/ElementalResonance.java @@ -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()) { - return false; - } - manaToAdd = choice.getChoice(); + if (!controller.choose(Outcome.PutManaInPool, choice, game)) { + return false; } + manaToAdd = choice.getChoice(); } else if (manaOptions.size() == 1) { manaToAdd = manaOptions.get(0); } diff --git a/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java b/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java index 7637054ca7..d831f55a85 100644 --- a/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java +++ b/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java @@ -79,7 +79,7 @@ class ElsewhereFlaskEffect extends OneShotEffect { public ElsewhereFlaskEffect() { super(Outcome.Neutral); - this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn"; + this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn"; } public ElsewhereFlaskEffect(final ElsewhereFlaskEffect effect) { @@ -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)) { - game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice()); - } + Choice choice = new ChoiceBasicLandType(); + 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; } diff --git a/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java b/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java index 51047e5053..c2e99d4315 100644 --- a/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java +++ b/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java @@ -54,7 +54,7 @@ import mage.players.Player; public class ElvishSoultiller extends CardImpl { public ElvishSoultiller(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}"); this.subtype.add(SubType.ELF); this.subtype.add(SubType.MUTANT); this.power = new MageInt(5); @@ -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; - } - } + Choice typeChoice = new ChoiceCreatureType(mageObject); + if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) { if (!game.isSimulation()) { game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } diff --git a/Mage.Sets/src/mage/cards/e/Extinction.java b/Mage.Sets/src/mage/cards/e/Extinction.java index 0310e86933..949a8a575d 100644 --- a/Mage.Sets/src/mage/cards/e/Extinction.java +++ b/Mage.Sets/src/mage/cards/e/Extinction.java @@ -51,7 +51,7 @@ import mage.players.Player; public class Extinction extends CardImpl { public Extinction(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}"); // Destroy all creatures of the creature type of your choice. this.getSpellAbility().addEffect(new ExtinctionEffect()); @@ -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) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); - } + Choice typeChoice = new ChoiceCreatureType(sourceObject); + 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)) { diff --git a/Mage.Sets/src/mage/cards/f/FaithsShield.java b/Mage.Sets/src/mage/cards/f/FaithsShield.java index f1465e3820..c126094461 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsShield.java +++ b/Mage.Sets/src/mage/cards/f/FaithsShield.java @@ -92,11 +92,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Protect, choice, game)) { + return false; } if (choice.getColor() != null) { game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); diff --git a/Mage.Sets/src/mage/cards/f/Fatespinner.java b/Mage.Sets/src/mage/cards/f/Fatespinner.java index 7eed6c6fb6..8fe538a37f 100644 --- a/Mage.Sets/src/mage/cards/f/Fatespinner.java +++ b/Mage.Sets/src/mage/cards/f/Fatespinner.java @@ -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 @@ -53,7 +52,7 @@ import java.util.UUID; public class Fatespinner extends CardImpl { public Fatespinner(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WIZARD); this.power = new MageInt(1); @@ -105,10 +104,8 @@ 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()) { - return false; - } + if (!player.choose(outcome, choice, game)) { + return false; } String chosenPhase = choice.getChoice(); game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase() + '.'); diff --git a/Mage.Sets/src/mage/cards/f/FlowstoneSculpture.java b/Mage.Sets/src/mage/cards/f/FlowstoneSculpture.java index aec33e5ae7..9bf7c47123 100644 --- a/Mage.Sets/src/mage/cards/f/FlowstoneSculpture.java +++ b/Mage.Sets/src/mage/cards/f/FlowstoneSculpture.java @@ -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 @@ -62,7 +61,7 @@ import java.util.UUID; public class FlowstoneSculpture extends CardImpl { public FlowstoneSculpture(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(4); this.toughness = new MageInt(4); @@ -100,7 +99,7 @@ class FlowstoneSculptureEffect extends OneShotEffect { } public FlowstoneSculptureEffect(final FlowstoneSculptureEffect effect) { - super(effect); + super(effect); } @Override @@ -111,36 +110,33 @@ class FlowstoneSculptureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if(controller != null) { + if (controller != null) { Choice choice = new ChoiceImpl(true); choice.setMessage("Choose ability to add"); choice.setChoices(choices); - while(!controller.choose(outcome, choice, game)) { - if(controller.canRespond()) { - return false; - } - } + 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 { - Ability gainedAbility; - switch (chosen) { - case "Flying": - gainedAbility = FlyingAbility.getInstance(); - break; - case "First strike": - gainedAbility = FirstStrikeAbility.getInstance(); - break; - default: - gainedAbility = TrampleAbility.getInstance(); - break; - } - game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source); - return true; - } + String chosen = choice.getChoice(); + if (chosen.equals("+1/+1 counter")) { + return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source); + } else { + Ability gainedAbility; + switch (chosen) { + case "Flying": + gainedAbility = FlyingAbility.getInstance(); + break; + case "First strike": + gainedAbility = FirstStrikeAbility.getInstance(); + break; + default: + gainedAbility = TrampleAbility.getInstance(); + break; + } + game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source); + return true; + } } return false; diff --git a/Mage.Sets/src/mage/cards/f/Fluctuator.java b/Mage.Sets/src/mage/cards/f/Fluctuator.java index c09d64994f..47b34027e9 100644 --- a/Mage.Sets/src/mage/cards/f/Fluctuator.java +++ b/Mage.Sets/src/mage/cards/f/Fluctuator.java @@ -51,7 +51,7 @@ import mage.util.CardUtil; public class Fluctuator extends CardImpl { public Fluctuator(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); // Cycling abilities you activate cost you up to {2} less to activate. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new FluctuatorEffect())); @@ -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); diff --git a/Mage.Sets/src/mage/cards/f/FoodChain.java b/Mage.Sets/src/mage/cards/f/FoodChain.java index 3a001b430d..c9d3550414 100644 --- a/Mage.Sets/src/mage/cards/f/FoodChain.java +++ b/Mage.Sets/src/mage/cards/f/FoodChain.java @@ -56,7 +56,7 @@ import mage.target.common.TargetControlledCreaturePermanent; public class FoodChain extends CardImpl { public FoodChain(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); // Exile a creature you control: Add X mana of any one color to your mana pool, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells. Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new FoodChainManaEffect(), new ExileTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature you control"), true))); @@ -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); diff --git a/Mage.Sets/src/mage/cards/g/GabrielAngelfire.java b/Mage.Sets/src/mage/cards/g/GabrielAngelfire.java index b7a41426a2..af64d89d01 100644 --- a/Mage.Sets/src/mage/cards/g/GabrielAngelfire.java +++ b/Mage.Sets/src/mage/cards/g/GabrielAngelfire.java @@ -74,7 +74,7 @@ public class GabrielAngelfire extends CardImpl { } class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect { - + private static final Set choices = new LinkedHashSet<>(); private boolean sameStep = true; @@ -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(); } } } diff --git a/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java b/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java index 0c4b014354..df27a7f688 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java +++ b/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java @@ -57,20 +57,20 @@ import mage.target.common.TargetControlledPermanent; public class GoblinClearcutter extends CardImpl { private static final FilterControlledPermanent filter = new FilterControlledPermanent("Forest"); - - static { + + static { filter.add(new SubtypePredicate(SubType.FOREST)); } - + public GoblinClearcutter(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); this.subtype.add(SubType.GOBLIN); - + this.power = new MageInt(3); this.toughness = new MageInt(3); // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinClearCutterEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinClearCutterEffect(), new TapSourceCost()); ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); this.addAbility(ability); } @@ -85,7 +85,6 @@ public class GoblinClearcutter extends CardImpl { } } - class GoblinClearCutterEffect extends OneShotEffect { public GoblinClearCutterEffect() { @@ -105,7 +104,7 @@ class GoblinClearCutterEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (player != null){ + if (player != null) { Choice manaChoice = new ChoiceImpl(); Set choices = new LinkedHashSet<>(); choices.add("Red"); @@ -113,14 +112,9 @@ class GoblinClearCutterEffect extends OneShotEffect { manaChoice.setChoices(choices); manaChoice.setMessage("Select color of mana to add"); - for (int i = 0; i < 3; i++){ + 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()) { diff --git a/Mage.Sets/src/mage/cards/g/GolemArtisan.java b/Mage.Sets/src/mage/cards/g/GolemArtisan.java index 8647d6ede6..132bcba0b4 100644 --- a/Mage.Sets/src/mage/cards/g/GolemArtisan.java +++ b/Mage.Sets/src/mage/cards/g/GolemArtisan.java @@ -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; diff --git a/Mage.Sets/src/mage/cards/g/GremlinMine.java b/Mage.Sets/src/mage/cards/g/GremlinMine.java index 27abe58fc6..2857fad92e 100644 --- a/Mage.Sets/src/mage/cards/g/GremlinMine.java +++ b/Mage.Sets/src/mage/cards/g/GremlinMine.java @@ -66,7 +66,7 @@ public class GremlinMine extends CardImpl { } public GremlinMine(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); // {1}, {tap}, Sacrifice Gremlin Mine: Gremlin Mine deals 4 damage to target artifact creature. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(4), new ManaCostsImpl("{1}")); @@ -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; } diff --git a/Mage.Sets/src/mage/cards/h/HallOfGemstone.java b/Mage.Sets/src/mage/cards/h/HallOfGemstone.java index 578a776668..dfcc7953c8 100644 --- a/Mage.Sets/src/mage/cards/h/HallOfGemstone.java +++ b/Mage.Sets/src/mage/cards/h/HallOfGemstone.java @@ -99,11 +99,9 @@ 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()) { - return; - } + if (!player.choose(outcome, choice, game)) { + discard(); + return; } if (!game.isSimulation()) { game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); diff --git a/Mage.Sets/src/mage/cards/h/HarshMercy.java b/Mage.Sets/src/mage/cards/h/HarshMercy.java index 72f42fb3b7..3c3a2ba95c 100644 --- a/Mage.Sets/src/mage/cards/h/HarshMercy.java +++ b/Mage.Sets/src/mage/cards/h/HarshMercy.java @@ -55,7 +55,7 @@ import mage.players.Player; public class HarshMercy extends CardImpl { public HarshMercy(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}"); // Each player chooses a creature type. Destroy all creatures that aren't of a type chosen this way. They can't be regenerated. this.getSpellAbility().addEffect(new HarshMercyEffect()); @@ -97,10 +97,8 @@ 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()) { - continue PlayerIteration; - } + if (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) { + continue PlayerIteration; } String chosenType = typeChoice.getChoice(); if (chosenType != null) { diff --git a/Mage.Sets/src/mage/cards/i/InfiniteObliteration.java b/Mage.Sets/src/mage/cards/i/InfiniteObliteration.java index ecd3f9cce6..151b89f6ff 100644 --- a/Mage.Sets/src/mage/cards/i/InfiniteObliteration.java +++ b/Mage.Sets/src/mage/cards/i/InfiniteObliteration.java @@ -50,7 +50,7 @@ import mage.target.common.TargetOpponent; public class InfiniteObliteration extends CardImpl { public InfiniteObliteration(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}"); // Name a creature card. Search target opponent's graveyard, hand, and library // for any number of cards with that name and exile them. Then that player shuffles his or her library. @@ -88,10 +88,8 @@ class InfiniteObliterationEffect extends SearchTargetGraveyardHandLibraryForCard cardChoice.clearChoice(); cardChoice.setMessage("Name a creature card"); - while (!controller.choose(Outcome.Exile, cardChoice, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Exile, cardChoice, game)) { + return false; } String cardName; cardName = cardChoice.getChoice(); diff --git a/Mage.Sets/src/mage/cards/j/JeweledSpirit.java b/Mage.Sets/src/mage/cards/j/JeweledSpirit.java index 08b98eca1a..0ba8cce9c5 100644 --- a/Mage.Sets/src/mage/cards/j/JeweledSpirit.java +++ b/Mage.Sets/src/mage/cards/j/JeweledSpirit.java @@ -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; @@ -60,16 +60,16 @@ import mage.target.common.TargetControlledPermanent; public class JeweledSpirit extends CardImpl { public JeweledSpirit(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); this.subtype.add(SubType.SPIRIT); this.power = new MageInt(3); this.toughness = new MageInt(3); // Flying this.addAbility(FlyingAbility.getInstance()); - + // Sacrifice two lands: Jeweled Spirit gains protection from artifacts or from the color of your choice until end of turn. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new JeweledSpiritEffect(), + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new JeweledSpiritEffect(), new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterControlledLandPermanent("two lands"), true)))); } @@ -84,34 +84,27 @@ public class JeweledSpirit extends CardImpl { } class JeweledSpiritEffect extends OneShotEffect { - + public JeweledSpiritEffect() { super(Outcome.AddAbility); this.staticText = "{this} gains protection from artifacts or from the color of your choice until end of turn"; } - + public JeweledSpiritEffect(final JeweledSpiritEffect effect) { super(effect); } - + @Override public JeweledSpiritEffect copy() { return new JeweledSpiritEffect(this); } - + @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); - } - - FilterCard protectionFilter = new FilterCard(); + ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact(); + if (controller != null && controller.choose(outcome, choice, game)) { + FilterCard protectionFilter = new FilterCard(); if (choice.isArtifactSelected()) { protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); } else { @@ -122,7 +115,7 @@ class JeweledSpiritEffect extends OneShotEffect { ContinuousEffect effect = new GainAbilitySourceEffect(protectionAbility, Duration.EndOfTurn); game.addEffect(effect, source); return true; - } + } return false; } } diff --git a/Mage.Sets/src/mage/cards/j/JodahsAvenger.java b/Mage.Sets/src/mage/cards/j/JodahsAvenger.java index 80e2299360..59e6b65c82 100644 --- a/Mage.Sets/src/mage/cards/j/JodahsAvenger.java +++ b/Mage.Sets/src/mage/cards/j/JodahsAvenger.java @@ -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(); } } } diff --git a/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java b/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java index b287a99d53..37068eeda6 100644 --- a/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java +++ b/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java @@ -153,10 +153,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.BoostCreature, typeChoice, game)) { + return false; } String typeChosen = typeChoice.getChoice(); if (!typeChosen.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/l/LiarsPendulum.java b/Mage.Sets/src/mage/cards/l/LiarsPendulum.java index d0117ed33f..f3280ad7d4 100644 --- a/Mage.Sets/src/mage/cards/l/LiarsPendulum.java +++ b/Mage.Sets/src/mage/cards/l/LiarsPendulum.java @@ -54,8 +54,8 @@ import mage.target.common.TargetOpponent; public class LiarsPendulum extends CardImpl { public LiarsPendulum(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); - + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + // {2}, {T}: Choose a card name. Target opponent guesses whether a card with that name is in your hand. You may reveal your hand. If you do and your opponent guessed wrong, draw a card. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LiarsPendulumEffect(), new GenericManaCost(2)); ability.addCost(new TapSourceCost()); @@ -73,7 +73,6 @@ public class LiarsPendulum extends CardImpl { } } - class LiarsPendulumEffect extends OneShotEffect { public LiarsPendulumEffect() { @@ -99,27 +98,24 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choice, game)) { + return false; } String cardName = choice.getChoice(); game.informPlayers("Card named: " + cardName); boolean opponentGuess = false; - + if (opponent.chooseUse(Outcome.Neutral, "Is the chosen card (" + cardName + ") in " + controller.getLogName() + "'s hand?", source, game)) { opponentGuess = true; } boolean rightGuess = !opponentGuess; - + for (Card card : controller.getHand().getCards(game)) { - if (card.isSplitCard()){ + if (card.isSplitCard()) { SplitCard splitCard = (SplitCard) card; - if (splitCard.getLeftHalfCard().getName().equals(cardName)){ + if (splitCard.getLeftHalfCard().getName().equals(cardName)) { rightGuess = opponentGuess; - } - else if (splitCard.getRightHalfCard().getName().equals(cardName)){ + } else if (splitCard.getRightHalfCard().getName().equals(cardName)) { rightGuess = opponentGuess; } } @@ -128,7 +124,7 @@ class LiarsPendulumEffect extends OneShotEffect { } } game.informPlayers(opponent.getLogName() + " guesses that " + cardName + " is " + (opponentGuess ? "" : "not") + " in " + controller.getLogName() + "'s hand"); - + if (controller.chooseUse(outcome, "Reveal your hand?", source, game)) { controller.revealCards("hand of " + controller.getName(), controller.getHand(), game); if (!rightGuess) { diff --git a/Mage.Sets/src/mage/cards/l/LuminescentRain.java b/Mage.Sets/src/mage/cards/l/LuminescentRain.java index cb881e2b5e..eae4bce676 100644 --- a/Mage.Sets/src/mage/cards/l/LuminescentRain.java +++ b/Mage.Sets/src/mage/cards/l/LuminescentRain.java @@ -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 @@ -52,8 +51,8 @@ import java.util.UUID; public class LuminescentRain extends CardImpl { public LuminescentRain(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}"); + // Choose a creature type. You gain 2 life for each permanent you control of that type. this.getSpellAbility().addEffect(new LuminescentRainEffect()); } @@ -68,36 +67,31 @@ public class LuminescentRain extends CardImpl { } } -class LuminescentRainEffect extends OneShotEffect { +class LuminescentRainEffect extends OneShotEffect { - LuminescentRainEffect() { - super(Outcome.GainLife); - this.staticText = "Choose a creature type. You gain 2 life for each permanent you control of that type."; - } + LuminescentRainEffect() { + super(Outcome.GainLife); + this.staticText = "Choose a creature type. You gain 2 life for each permanent you control of that type."; + } - LuminescentRainEffect(final LuminescentRainEffect effect) { - super(effect); - } - - @Override - public LuminescentRainEffect copy() { - return new LuminescentRainEffect(this); - } + LuminescentRainEffect(final LuminescentRainEffect effect) { + super(effect); + } - @Override - public boolean apply(Game game, Ability source) { + @Override + public LuminescentRainEffect copy() { + return new LuminescentRainEffect(this); + } + + @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; - } - } + Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + 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); } return false; - } + } } diff --git a/Mage.Sets/src/mage/cards/l/LunarAvenger.java b/Mage.Sets/src/mage/cards/l/LunarAvenger.java index 03efc35ea2..6fdd9c75e9 100644 --- a/Mage.Sets/src/mage/cards/l/LunarAvenger.java +++ b/Mage.Sets/src/mage/cards/l/LunarAvenger.java @@ -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 @@ -61,7 +60,7 @@ import java.util.UUID; public class LunarAvenger extends CardImpl { public LunarAvenger(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{7}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{7}"); this.subtype.add(SubType.GOLEM); this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -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()) { - return false; - } + if (!controller.choose(outcome, choice, game)) { + return false; } - Ability gainedAbility; String chosen = choice.getChoice(); switch (chosen) { diff --git a/Mage.Sets/src/mage/cards/m/MadScienceFairProject.java b/Mage.Sets/src/mage/cards/m/MadScienceFairProject.java index 3b503600c3..0f56b423bc 100644 --- a/Mage.Sets/src/mage/cards/m/MadScienceFairProject.java +++ b/Mage.Sets/src/mage/cards/m/MadScienceFairProject.java @@ -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; - } - Mana chosen = choice.getMana(1); - if (chosen != null) { + if (controller.choose(Outcome.PutManaInPool, choice, game)) { + Mana chosen = choice.getMana(1); checkToFirePossibleEvents(chosen, game, source); controller.getManaPool().addMana(chosen, game, source); - return true; + } else { + return false; } } return true; diff --git a/Mage.Sets/src/mage/cards/m/MaintenanceDroid.java b/Mage.Sets/src/mage/cards/m/MaintenanceDroid.java index 04685f33c5..f582734bcb 100644 --- a/Mage.Sets/src/mage/cards/m/MaintenanceDroid.java +++ b/Mage.Sets/src/mage/cards/m/MaintenanceDroid.java @@ -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 @@ -67,7 +66,7 @@ public class MaintenanceDroid extends CardImpl { } public MaintenanceDroid(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{W}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{W}{U}"); this.subtype.add(SubType.DROID); this.power = new MageInt(1); this.toughness = new MageInt(2); @@ -121,10 +120,8 @@ 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()) { - return false; - } + if (!controller.choose(outcome, choice, game)) { + return false; } String chosen = choice.getChoice(); diff --git a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java index 4157248aa0..20e5e93516 100644 --- a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java +++ b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java @@ -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; @@ -54,7 +54,7 @@ import mage.players.Player; public class ManaforgeCinder extends CardImpl { public ManaforgeCinder(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B/R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B/R}"); this.subtype.add(SubType.ELEMENTAL); this.subtype.add(SubType.SHAMAN); this.power = new MageInt(1); @@ -62,7 +62,7 @@ public class ManaforgeCinder extends CardImpl { // {1}: Add {B} or {R} to your mana pool. Activate this ability no more than three times each turn. this.addAbility(new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new ManaforgeCinderManaEffect(), new ManaCostsImpl("{1}"), 3)); - + } public ManaforgeCinder(final ManaforgeCinder card) { @@ -75,8 +75,6 @@ public class ManaforgeCinder extends CardImpl { } } - - class ManaforgeCinderManaEffect extends OneShotEffect { public ManaforgeCinderManaEffect() { @@ -104,10 +102,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.Benefit, manaChoice, game)) { + return false; } if (manaChoice.getChoice() == null) { return false; diff --git a/Mage.Sets/src/mage/cards/m/MarketFestival.java b/Mage.Sets/src/mage/cards/m/MarketFestival.java index 930a9adb43..d025298f16 100644 --- a/Mage.Sets/src/mage/cards/m/MarketFestival.java +++ b/Mage.Sets/src/mage/cards/m/MarketFestival.java @@ -144,10 +144,8 @@ class MarketFestivalManaEffect extends ManaEffect { } else { choiceColor.setMessage("Second mana color for " + sourceObject.getLogName()); } - while (!controller.choose(Outcome.Benefit, choiceColor, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choiceColor, game)) { + return false; } if (choiceColor.getChoice() == null) { // Possible after reconnect? return false; diff --git a/Mage.Sets/src/mage/cards/m/Mindblaze.java b/Mage.Sets/src/mage/cards/m/Mindblaze.java index 4745590f11..a44c95cbe6 100644 --- a/Mage.Sets/src/mage/cards/m/Mindblaze.java +++ b/Mage.Sets/src/mage/cards/m/Mindblaze.java @@ -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()) { - return false; - } + if (!playerControls.choose(Outcome.Neutral, cardChoice, game)) { + return false; + } + if (!playerControls.choose(Outcome.Neutral, numberChoice, game)) { + return false; } - while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) { - if (!playerControls.canRespond()) { - 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; } diff --git a/Mage.Sets/src/mage/cards/m/MistformSliver.java b/Mage.Sets/src/mage/cards/m/MistformSliver.java index 2364d2cd9c..2e66d7d160 100644 --- a/Mage.Sets/src/mage/cards/m/MistformSliver.java +++ b/Mage.Sets/src/mage/cards/m/MistformSliver.java @@ -93,10 +93,8 @@ 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()) { - return false; - } + 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); diff --git a/Mage.Sets/src/mage/cards/m/MultiformWonder.java b/Mage.Sets/src/mage/cards/m/MultiformWonder.java index 1c4efc97cc..6e663d1491 100644 --- a/Mage.Sets/src/mage/cards/m/MultiformWonder.java +++ b/Mage.Sets/src/mage/cards/m/MultiformWonder.java @@ -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 @@ -60,7 +59,7 @@ import java.util.UUID; public class MultiformWonder extends CardImpl { public MultiformWonder(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}"); this.subtype.add(SubType.CONSTRUCT); this.power = new MageInt(3); this.toughness = new MageInt(3); @@ -116,10 +115,8 @@ 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()) { - return false; - } + if (!controller.choose(outcome, choice, game)) { + return false; } Ability gainedAbility; diff --git a/Mage.Sets/src/mage/cards/m/MysticBarrier.java b/Mage.Sets/src/mage/cards/m/MysticBarrier.java index 88e8efb52f..6abe083ef7 100644 --- a/Mage.Sets/src/mage/cards/m/MysticBarrier.java +++ b/Mage.Sets/src/mage/cards/m/MysticBarrier.java @@ -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 @@ -62,7 +61,7 @@ public class MysticBarrier extends CardImpl { static final String ALLOW_ATTACKING_RIGHT = "Allow attacking right"; public MysticBarrier(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{4}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}"); // When Mystic Barrier enters the battlefield or at the beginning of your upkeep, choose left or right. this.addAbility(new MysticBarrierTriggeredAbility()); @@ -95,12 +94,12 @@ class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl { public MysticBarrierTriggeredAbility copy() { return new MysticBarrierTriggeredAbility(this); } - + @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == EventType.ENTERS_THE_BATTLEFIELD || event.getType() == EventType.UPKEEP_STEP_PRE; } - + @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) { @@ -118,14 +117,8 @@ class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl { 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 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; } @@ -161,12 +153,12 @@ class MysticBarrierChooseEffect extends OneShotEffect { class MysticBarrierReplacementEffect extends ReplacementEffectImpl { - MysticBarrierReplacementEffect ( ) { + MysticBarrierReplacementEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); staticText = "Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player"; } - MysticBarrierReplacementEffect ( MysticBarrierReplacementEffect effect ) { + MysticBarrierReplacementEffect(MysticBarrierReplacementEffect effect) { super(effect); } @@ -179,7 +171,7 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl { public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DECLARE_ATTACKER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getPlayers().size() > 2) { @@ -217,7 +209,7 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl { return true; } } - } + } } } } diff --git a/Mage.Sets/src/mage/cards/n/NakedSingularity.java b/Mage.Sets/src/mage/cards/n/NakedSingularity.java index 730207b099..e845fe6181 100644 --- a/Mage.Sets/src/mage/cards/n/NakedSingularity.java +++ b/Mage.Sets/src/mage/cards/n/NakedSingularity.java @@ -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); - chosenColor = choice.getChoice(); + if (controller.choose(Outcome.PutManaInPool, choice, game)) { + chosenColor = choice.getChoice(); + } else { + return false; + } } ManaEvent manaEvent = (ManaEvent) event; Mana mana = manaEvent.getMana(); diff --git a/Mage.Sets/src/mage/cards/n/NewBlood.java b/Mage.Sets/src/mage/cards/n/NewBlood.java index e65704f83e..7093594edf 100644 --- a/Mage.Sets/src/mage/cards/n/NewBlood.java +++ b/Mage.Sets/src/mage/cards/n/NewBlood.java @@ -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; } diff --git a/Mage.Sets/src/mage/cards/o/OonaQueenOfTheFae.java b/Mage.Sets/src/mage/cards/o/OonaQueenOfTheFae.java index ad4e21ef1b..722a4a4695 100644 --- a/Mage.Sets/src/mage/cards/o/OonaQueenOfTheFae.java +++ b/Mage.Sets/src/mage/cards/o/OonaQueenOfTheFae.java @@ -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())) { - cardsWithColor++; - } - card.moveToExile(null, null, source.getSourceId(), game); - } + int cardsWithColor = 0; + 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++; } - 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()); - return true; } - return false; + controller.moveCards(cardsToExile, Zone.EXILED, source, game); + if (cardsWithColor > 0) { + new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source); + } + game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created"); + return true; } } diff --git a/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java b/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java index d3c7c30485..3df748909c 100644 --- a/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java +++ b/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java @@ -64,14 +64,14 @@ public class OrcishLumberjack extends CardImpl { } public OrcishLumberjack(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); this.subtype.add(SubType.ORC); this.power = new MageInt(1); this.toughness = new MageInt(1); // {tap}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new OrcishLumberjackManaEffect(), new TapSourceCost()); + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new OrcishLumberjackManaEffect(), new TapSourceCost()); ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); this.addAbility(ability); @@ -106,7 +106,7 @@ class OrcishLumberjackManaEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if(player != null){ + if (player != null) { Choice manaChoice = new ChoiceImpl(); Set choices = new LinkedHashSet<>(); choices.add("Red"); @@ -115,11 +115,9 @@ class OrcishLumberjackManaEffect extends ManaEffect { manaChoice.setMessage("Select color of mana to add"); Mana mana = new Mana(); - for(int i = 0; i < 3; i++){ - while (!player.choose(Outcome.Benefit, manaChoice, game)) { - if (!player.canRespond()) { - return false; - } + for (int i = 0; i < 3; i++) { + if (!player.choose(Outcome.Benefit, manaChoice, game)) { + return false; } switch (manaChoice.getChoice()) { case "Green": @@ -129,7 +127,7 @@ class OrcishLumberjackManaEffect extends ManaEffect { mana.increaseRed(); break; } - + } checkToFirePossibleEvents(mana, game, source); player.getManaPool().addMana(mana, game, source); @@ -143,5 +141,4 @@ class OrcishLumberjackManaEffect extends ManaEffect { return null; } - } diff --git a/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java b/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java index fa5a5d8d06..9a0b89c5d4 100644 --- a/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java +++ b/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java @@ -96,8 +96,10 @@ class OrderOfSuccessionEffect extends OneShotEffect { if (controller != null) { Map 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()) { diff --git a/Mage.Sets/src/mage/cards/o/Outbreak.java b/Mage.Sets/src/mage/cards/o/Outbreak.java index 4de53cd115..fdc3916df2 100644 --- a/Mage.Sets/src/mage/cards/o/Outbreak.java +++ b/Mage.Sets/src/mage/cards/o/Outbreak.java @@ -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) { - game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice()); - } + Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + 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; } diff --git a/Mage.Sets/src/mage/cards/p/PacksDisdain.java b/Mage.Sets/src/mage/cards/p/PacksDisdain.java index 88c1951e0b..0114364c87 100644 --- a/Mage.Sets/src/mage/cards/p/PacksDisdain.java +++ b/Mage.Sets/src/mage/cards/p/PacksDisdain.java @@ -56,7 +56,7 @@ import mage.target.targetpointer.FixedTarget; public class PacksDisdain extends CardImpl { public PacksDisdain(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}"); // Choose a creature type. Target creature gets -1/-1 until end of turn for each permanent of the chosen type you control. this.getSpellAbility().addEffect(new PacksDisdainEffect()); @@ -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; - } - } + Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + 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); diff --git a/Mage.Sets/src/mage/cards/p/PaleWayfarer.java b/Mage.Sets/src/mage/cards/p/PaleWayfarer.java index 39227fe6a7..658a55291f 100644 --- a/Mage.Sets/src/mage/cards/p/PaleWayfarer.java +++ b/Mage.Sets/src/mage/cards/p/PaleWayfarer.java @@ -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; @@ -63,7 +63,7 @@ import mage.target.targetpointer.FixedTarget; public class PaleWayfarer extends CardImpl { public PaleWayfarer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}"); this.subtype.add(SubType.SPIRIT); this.subtype.add(SubType.GIANT); @@ -109,15 +109,15 @@ class PaleWayfarerEffect extends OneShotEffect { if (player.choose(Outcome.Neutral, colorChoice, game)) { game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice()); game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor()); - + ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color"); if (protectColor != null) { ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); effect.setTargetPointer(new FixedTarget(targetCreature, game)); game.addEffect(effect, source); } + return true; } - return true; } } return false; @@ -129,7 +129,6 @@ class PaleWayfarerEffect extends OneShotEffect { } } - class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl { protected ObjectColor chosenColor; diff --git a/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java b/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java index e450078385..123c26d563 100644 --- a/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java +++ b/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java @@ -27,6 +27,7 @@ */ package mage.cards.p; +import java.util.*; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -45,15 +46,13 @@ import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.players.Player; -import java.util.*; - /** * @author duncant */ public class PatriarchsBidding extends CardImpl { public PatriarchsBidding(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); // Each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield. this.getSpellAbility().addEffect(new PatriarchsBiddingEffect()); @@ -94,16 +93,12 @@ 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); - } + game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType); + chosenTypes.add(chosenType); } List predicates = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/p/PeerPressure.java b/Mage.Sets/src/mage/cards/p/PeerPressure.java index 4ea1cfe77c..169d74746f 100644 --- a/Mage.Sets/src/mage/cards/p/PeerPressure.java +++ b/Mage.Sets/src/mage/cards/p/PeerPressure.java @@ -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 @@ -57,7 +56,7 @@ import java.util.UUID; public class PeerPressure extends CardImpl { public PeerPressure(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. If you control more creatures of that type than each other player, you gain control of all creatures of that type. this.getSpellAbility().addEffect(new PeerPressureEffect()); @@ -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; - } - } + Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + if (controller != null && controller.choose(Outcome.GainControl, choice, game)) { String chosenType = choice.getChoice(); - if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " has chosen " + chosenType); - } + game.informPlayers(controller.getLogName() + " has chosen " + chosenType); UUID playerWithMost = null; int maxControlled = 0; for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/p/PemminsAura.java b/Mage.Sets/src/mage/cards/p/PemminsAura.java index 8f635ac3fa..83f8178b58 100644 --- a/Mage.Sets/src/mage/cards/p/PemminsAura.java +++ b/Mage.Sets/src/mage/cards/p/PemminsAura.java @@ -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; @@ -62,7 +62,7 @@ import mage.target.common.TargetCreaturePermanent; public class PemminsAura extends CardImpl { public PemminsAura(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}{U}"); this.subtype.add(SubType.AURA); // Enchant creature @@ -126,18 +126,14 @@ 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; + if (!controller.choose(outcome, choice, game)) { + if (choice.getChoice().equals(CHOICE_1)) { + game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source); + } else { + game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source); } - controller.choose(outcome, choice, game); + return true; } - if (choice.getChoice().equals(CHOICE_1)) { - game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source); - } else { - game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source); - } - return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/p/Persecute.java b/Mage.Sets/src/mage/cards/p/Persecute.java index 6630aa958f..b13cd5158a 100644 --- a/Mage.Sets/src/mage/cards/p/Persecute.java +++ b/Mage.Sets/src/mage/cards/p/Persecute.java @@ -50,7 +50,7 @@ import mage.target.TargetPlayer; public class Persecute extends CardImpl { public Persecute(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{B}"); // Choose a color. Target player reveals his or her hand and discards all cards of that color. this.getSpellAbility().addEffect(new PersecuteEffect()); @@ -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; - } + ChoiceColor choice = new ChoiceColor(); + if (controller != null && sourceObject != null && targetPlayer != null && controller.choose(outcome, choice, game)) { Cards hand = targetPlayer.getHand(); targetPlayer.revealCards(sourceObject.getIdName(), hand, game); Set cards = hand.getCards(game); diff --git a/Mage.Sets/src/mage/cards/p/PetraSphinx.java b/Mage.Sets/src/mage/cards/p/PetraSphinx.java index a1292fd7d0..f2a9737758 100644 --- a/Mage.Sets/src/mage/cards/p/PetraSphinx.java +++ b/Mage.Sets/src/mage/cards/p/PetraSphinx.java @@ -94,15 +94,12 @@ 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()) { - return false; - } + if (!player.choose(Outcome.DrawCard, cardChoice, game)) { + return false; } String cardName = cardChoice.getChoice(); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); diff --git a/Mage.Sets/src/mage/cards/p/PlasmCapture.java b/Mage.Sets/src/mage/cards/p/PlasmCapture.java index 99fa7e161b..05c1391a7b 100644 --- a/Mage.Sets/src/mage/cards/p/PlasmCapture.java +++ b/Mage.Sets/src/mage/cards/p/PlasmCapture.java @@ -52,7 +52,7 @@ import mage.target.TargetSpell; public class PlasmCapture extends CardImpl { public PlasmCapture(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}{G}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{G}{U}{U}"); // Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. this.getSpellAbility().addTarget(new TargetSpell()); @@ -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()) { - return false; - } + if (!player.choose(Outcome.Benefit, choiceColor, game)) { + return false; } - choiceColor.increaseMana(mana); } - player.getManaPool().addMana(mana, game, source); return true; diff --git a/Mage.Sets/src/mage/cards/p/PrimalClay.java b/Mage.Sets/src/mage/cards/p/PrimalClay.java index 0a0647dcbe..2c4b5f532f 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalClay.java +++ b/Mage.Sets/src/mage/cards/p/PrimalClay.java @@ -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; @@ -58,7 +58,7 @@ import mage.players.Player; public class PrimalClay extends CardImpl { public PrimalClay(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{4}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(0); @@ -123,13 +123,8 @@ 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()) { - return false; - } - } + if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) { + return false; } int power = 0; int toughness = 0; diff --git a/Mage.Sets/src/mage/cards/p/PrimalPlasma.java b/Mage.Sets/src/mage/cards/p/PrimalPlasma.java index b53b28b63a..591679f5e4 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalPlasma.java +++ b/Mage.Sets/src/mage/cards/p/PrimalPlasma.java @@ -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; @@ -58,7 +58,7 @@ import mage.players.Player; public class PrimalPlasma extends CardImpl { public PrimalPlasma(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}"); this.subtype.add(SubType.ELEMENTAL); this.subtype.add(SubType.SHAPESHIFTER); @@ -117,20 +117,15 @@ 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()) { - return false; - } - } + if (!controller.choose(Outcome.Neutral, choice, game)) { + return false; } int power = 0; int toughness = 0; @@ -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; diff --git a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java index 0255cc370e..741267c07a 100644 --- a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java +++ b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java @@ -65,7 +65,7 @@ public class PrismaticStrands extends CardImpl { } public PrismaticStrands(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}"); // Prevent all damage that sources of the color of your choice would deal this turn. this.getSpellAbility().addEffect(new PrismaticStrandsEffect()); diff --git a/Mage.Sets/src/mage/cards/r/RealityTwist.java b/Mage.Sets/src/mage/cards/r/RealityTwist.java index ce44c138fb..92aefb5d14 100644 --- a/Mage.Sets/src/mage/cards/r/RealityTwist.java +++ b/Mage.Sets/src/mage/cards/r/RealityTwist.java @@ -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; diff --git a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java index e01acda4f5..8c1a2a1ddf 100644 --- a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java +++ b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java @@ -48,8 +48,7 @@ import mage.players.Player; public class ReverseTheSands extends CardImpl { 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. 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(); diff --git a/Mage.Sets/src/mage/cards/r/RhysticCave.java b/Mage.Sets/src/mage/cards/r/RhysticCave.java index 6ce08e5651..170ac58e0a 100644 --- a/Mage.Sets/src/mage/cards/r/RhysticCave.java +++ b/Mage.Sets/src/mage/cards/r/RhysticCave.java @@ -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,38 +129,29 @@ 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) { - case "R": - chosenMana.setRed(1); - break; - case "U": - chosenMana.setBlue(1); - break; - case "W": - chosenMana.setWhite(1); - break; - case "B": - chosenMana.setBlack(1); - break; - case "G": - chosenMana.setGreen(1); - break; - } - } - checkToFirePossibleEvents(chosenMana, game, source); - controller.getManaPool().addMana(chosenMana, game, source); - return true; + ChoiceColor choice = new ChoiceColor(true); + if (controller != null && controller.choose(outcome, choice, game)) { + switch (choice.getColor().toString()) { + case "R": + chosenMana.setRed(1); + break; + case "U": + chosenMana.setBlue(1); + break; + case "W": + chosenMana.setWhite(1); + break; + case "B": + chosenMana.setBlack(1); + break; + case "G": + chosenMana.setGreen(1); + break; } - + checkToFirePossibleEvents(chosenMana, game, source); + controller.getManaPool().addMana(chosenMana, game, source); + return true; } - return false; } diff --git a/Mage.Sets/src/mage/cards/r/RiptideChronologist.java b/Mage.Sets/src/mage/cards/r/RiptideChronologist.java index c4d0b45ad6..569782107b 100644 --- a/Mage.Sets/src/mage/cards/r/RiptideChronologist.java +++ b/Mage.Sets/src/mage/cards/r/RiptideChronologist.java @@ -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) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); - } + Choice typeChoice = new ChoiceCreatureType(sourceObject); + 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)) { diff --git a/Mage.Sets/src/mage/cards/r/RiptideShapeshifter.java b/Mage.Sets/src/mage/cards/r/RiptideShapeshifter.java index ec5ee0e304..ff278dab8c 100644 --- a/Mage.Sets/src/mage/cards/r/RiptideShapeshifter.java +++ b/Mage.Sets/src/mage/cards/r/RiptideShapeshifter.java @@ -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,10 +96,8 @@ 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()) { - return false; - } + if (!controller.choose(Outcome.BoostCreature, choice, game)) { + return false; } Cards revealedCards = new CardsImpl(); while (controller.getLibrary().hasCards()) { diff --git a/Mage.Sets/src/mage/cards/r/RiteOfRuin.java b/Mage.Sets/src/mage/cards/r/RiteOfRuin.java index 9086a1ece0..8510fa902d 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfRuin.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfRuin.java @@ -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(); diff --git a/Mage.Sets/src/mage/cards/r/RithTheAwakener.java b/Mage.Sets/src/mage/cards/r/RithTheAwakener.java index 178fe052f3..a655d9123d 100644 --- a/Mage.Sets/src/mage/cards/r/RithTheAwakener.java +++ b/Mage.Sets/src/mage/cards/r/RithTheAwakener.java @@ -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; @@ -56,7 +56,7 @@ import mage.players.Player; public class RithTheAwakener extends CardImpl { public RithTheAwakener(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}{G}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{G}{W}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); @@ -67,7 +67,7 @@ public class RithTheAwakener extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Whenever Rith, the Awakener deals combat damage to a player, you may pay {2}{G}. If you do, choose a color, then create a 1/1 green Saproling creature token for each permanent of that color. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( - new DoIfCostPaid(new RithTheAwakenerEffect(), new ManaCostsImpl("{2}{G}")), false)); + new DoIfCostPaid(new RithTheAwakenerEffect(), new ManaCostsImpl("{2}{G}")), false)); } public RithTheAwakener(final RithTheAwakener card) { @@ -81,30 +81,29 @@ public class RithTheAwakener extends CardImpl { } class RithTheAwakenerEffect extends OneShotEffect { - + public RithTheAwakenerEffect() { super(Outcome.Benefit); this.staticText = "choose a color, then create a 1/1 green Saproling creature token for each permanent of that color"; } - + public RithTheAwakenerEffect(final RithTheAwakenerEffect effect) { super(effect); } - + @Override public RithTheAwakenerEffect copy() { return new RithTheAwakenerEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { 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())); diff --git a/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java b/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java index 213b919807..180d2fff81 100644 --- a/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java +++ b/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java @@ -90,10 +90,8 @@ 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()) { - return false; - } + if (!player.choose(Outcome.LoseLife, typeChoice, game)) { + return false; } FilterControlledPermanent filter = new FilterControlledPermanent(); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); @@ -101,4 +99,4 @@ class RoarOfTheCrowdEffect extends OneShotEffect { } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/r/RootGreevil.java b/Mage.Sets/src/mage/cards/r/RootGreevil.java index 3818f4f50f..6fc91c02c2 100644 --- a/Mage.Sets/src/mage/cards/r/RootGreevil.java +++ b/Mage.Sets/src/mage/cards/r/RootGreevil.java @@ -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; @@ -55,7 +55,7 @@ import mage.players.Player; public class RootGreevil extends CardImpl { public RootGreevil(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); this.subtype.add(SubType.BEAST); this.power = new MageInt(2); this.toughness = new MageInt(3); @@ -95,15 +95,12 @@ 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) { - FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); - filter.add(new ColorPredicate(choice.getColor())); - for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) { - enchantment.destroy(source.getSourceId(), game, false); - } + ChoiceColor choice = new ChoiceColor(); + 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; } diff --git a/Mage.Sets/src/mage/cards/s/SarkhanUnbroken.java b/Mage.Sets/src/mage/cards/s/SarkhanUnbroken.java index 48a642f9b1..04adea4f79 100644 --- a/Mage.Sets/src/mage/cards/s/SarkhanUnbroken.java +++ b/Mage.Sets/src/mage/cards/s/SarkhanUnbroken.java @@ -65,7 +65,7 @@ public class SarkhanUnbroken extends CardImpl { } public SarkhanUnbroken(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{G}{U}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{G}{U}{R}"); this.addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.SARKHAN); @@ -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(); diff --git a/Mage.Sets/src/mage/cards/s/SasayaOrochiAscendant.java b/Mage.Sets/src/mage/cards/s/SasayaOrochiAscendant.java index b381856d82..87d5e655d0 100644 --- a/Mage.Sets/src/mage/cards/s/SasayaOrochiAscendant.java +++ b/Mage.Sets/src/mage/cards/s/SasayaOrochiAscendant.java @@ -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()) { - return false; - } + if (!controller.choose(outcome, choice, game)) { + return false; } } - if (choice.getChoice() == null) { - return false; - } switch (choice.getChoice()) { case "Black": newMana.increaseBlack(); diff --git a/Mage.Sets/src/mage/cards/s/SealOfTheGuildpact.java b/Mage.Sets/src/mage/cards/s/SealOfTheGuildpact.java index e9e815b992..03583be581 100644 --- a/Mage.Sets/src/mage/cards/s/SealOfTheGuildpact.java +++ b/Mage.Sets/src/mage/cards/s/SealOfTheGuildpact.java @@ -58,11 +58,11 @@ import mage.util.CardUtil; public class SealOfTheGuildpact extends CardImpl { public SealOfTheGuildpact(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}"); // As Seal of the Guildpact enters the battlefield, choose two colors. this.addAbility(new EntersBattlefieldAbility(new SealOfTheGuildpactChooseColorEffect())); - + // Each spell you cast costs {1} less to cast for each of the chosen colors it is. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SealOfTheGuildpactCostReductionEffect())); } @@ -78,33 +78,27 @@ public class SealOfTheGuildpact extends CardImpl { } class SealOfTheGuildpactChooseColorEffect extends OneShotEffect { - + SealOfTheGuildpactChooseColorEffect() { super(Outcome.Benefit); this.staticText = "choose two colors"; } - + SealOfTheGuildpactChooseColorEffect(final SealOfTheGuildpactChooseColorEffect effect) { super(effect); } - + @Override public SealOfTheGuildpactChooseColorEffect copy() { return new SealOfTheGuildpactChooseColorEffect(this); } - + @Override 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; - } - } + ChoiceColor choice1 = new ChoiceColor(); + if (controller != null && mageObject != null && controller.choose(Outcome.Benefit, choice1, game)) { String color1 = choice1.getChoice(); Set choices2 = new HashSet<>(); if (!color1.equals("White")) { @@ -124,11 +118,8 @@ class SealOfTheGuildpactChooseColorEffect extends OneShotEffect { } ChoiceColor choice2 = new ChoiceColor(); choice2.setChoices(choices2); - while (!choice2.isChosen()) { - controller.choose(Outcome.Benefit, choice2, game); - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choice2, game)) { + return false; } String color2 = choice2.getChoice(); if (!game.isSimulation()) { @@ -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 diff --git a/Mage.Sets/src/mage/cards/s/SehtsTiger.java b/Mage.Sets/src/mage/cards/s/SehtsTiger.java index c04c8ebbb8..26dc8196ae 100644 --- a/Mage.Sets/src/mage/cards/s/SehtsTiger.java +++ b/Mage.Sets/src/mage/cards/s/SehtsTiger.java @@ -95,24 +95,15 @@ 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) { - game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); - FilterCard filter = new FilterCard(); - filter.add(new ColorPredicate(choice.getColor())); - filter.setMessage(choice.getChoice()); - Ability ability = new ProtectionAbility(filter); - game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source); - return true; - } - + ChoiceColor choice = new ChoiceColor(); + 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())); + filter.setMessage(choice.getChoice()); + Ability ability = new ProtectionAbility(filter); + game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source); + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/s/Shapeshifter.java b/Mage.Sets/src/mage/cards/s/Shapeshifter.java index ef6d8049e1..ff730738f3 100644 --- a/Mage.Sets/src/mage/cards/s/Shapeshifter.java +++ b/Mage.Sets/src/mage/cards/s/Shapeshifter.java @@ -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 @@ -57,7 +56,7 @@ public class Shapeshifter extends CardImpl { public Shapeshifter(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); - + this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(0); this.toughness = new MageInt(7); @@ -65,7 +64,7 @@ public class Shapeshifter extends CardImpl { // As Shapeshifter enters the battlefield, choose a number between 0 and 7. this.addAbility(new AsEntersBattlefieldAbility(new ShapeshifterEffect())); // At the beginning of your upkeep, you may choose a number between 0 and 7. - this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ShapeshifterEffect(), TargetController.YOU, true)); + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ShapeshifterEffect(), TargetController.YOU, true)); // Shapeshifter's power is equal to the last chosen number and its toughness is equal to 7 minus that number. this.addAbility(new SimpleStaticAbility(Zone.ALL, new ShapeshifterContinuousEffect())); } @@ -79,22 +78,23 @@ public class Shapeshifter extends CardImpl { return new Shapeshifter(this); } } + class ShapeshifterEffect extends OneShotEffect { - + public ShapeshifterEffect() { super(Outcome.Benefit); this.staticText = "Choose a number between 0 and 7."; } - + public ShapeshifterEffect(final ShapeshifterEffect effect) { super(effect); } - + @Override public ShapeshifterEffect copy() { return new ShapeshifterEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -110,46 +110,45 @@ class ShapeshifterEffect extends OneShotEffect { numbers.add(Integer.toString(i)); } numberChoice.setChoices(numbers); - while (!controller.choose(Outcome.Neutral, numberChoice, game)) { - if (!controller.canRespond()) { - return false; - } + 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) { - ((Permanent) mageObject).addInfo("lastChosenNumber", CardUtil.addToolTipMarkTags("Last chosen number: " + numberChoice.getChoice()), game); - } + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo("lastChosenNumber", CardUtil.addToolTipMarkTags("Last chosen number: " + numberChoice.getChoice()), game); + } } return false; } } + class ShapeshifterContinuousEffect extends ContinuousEffectImpl { - + public ShapeshifterContinuousEffect() { super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature); staticText = "{this}'s power is equal to the last chosen number and its toughness is equal to 7 minus that number."; } - + public ShapeshifterContinuousEffect(final ShapeshifterContinuousEffect effect) { super(effect); } - + @Override public ShapeshifterContinuousEffect copy() { return new ShapeshifterContinuousEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - if(permanent!=null){ - String lastChosen = (String) game.getState().getValue(source.getSourceId().toString() + "_Shapeshifter"); - int lastChosenNumber = Integer.parseInt(lastChosen); - permanent.getPower().modifyBaseValue(lastChosenNumber); - permanent.getToughness().modifyBaseValue(7 - lastChosenNumber); - return true; - } + if (permanent != null) { + String lastChosen = (String) game.getState().getValue(source.getSourceId().toString() + "_Shapeshifter"); + int lastChosenNumber = Integer.parseInt(lastChosen); + permanent.getPower().modifyBaseValue(lastChosenNumber); + permanent.getToughness().modifyBaseValue(7 - lastChosenNumber); + return true; + } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/s/ShorecrasherElemental.java b/Mage.Sets/src/mage/cards/s/ShorecrasherElemental.java index ba4d8c79a0..e05c34fd25 100644 --- a/Mage.Sets/src/mage/cards/s/ShorecrasherElemental.java +++ b/Mage.Sets/src/mage/cards/s/ShorecrasherElemental.java @@ -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; @@ -60,7 +60,7 @@ import mage.players.Player; public class ShorecrasherElemental extends CardImpl { public ShorecrasherElemental(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}{U}"); this.subtype.add(SubType.ELEMENTAL); this.power = new MageInt(3); this.toughness = new MageInt(3); @@ -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,18 +149,14 @@ 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; + if (controller.choose(outcome, choice, game)) { + if (choice.getChoice().equals(CHOICE_1)) { + game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source); + } else { + game.addEffect(new BoostSourceEffect(-1, +1, Duration.EndOfTurn), source); } - controller.choose(outcome, choice, game); + return true; } - if (choice.getChoice().equals(CHOICE_1)) { - game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source); - } else { - game.addEffect(new BoostSourceEffect(-1, +1, Duration.EndOfTurn), source); - } - return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SithEvoker.java b/Mage.Sets/src/mage/cards/s/SithEvoker.java index 9d45740615..0afb176e76 100644 --- a/Mage.Sets/src/mage/cards/s/SithEvoker.java +++ b/Mage.Sets/src/mage/cards/s/SithEvoker.java @@ -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()) { - return false; - } + if (!controller.choose(outcome, choice, game)) { + return false; } - Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard != null) { for (Object cost : source.getCosts()) { diff --git a/Mage.Sets/src/mage/cards/s/SphinxAmbassador.java b/Mage.Sets/src/mage/cards/s/SphinxAmbassador.java index 07b21241e1..b9305dbc47 100644 --- a/Mage.Sets/src/mage/cards/s/SphinxAmbassador.java +++ b/Mage.Sets/src/mage/cards/s/SphinxAmbassador.java @@ -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; @@ -56,7 +56,7 @@ import mage.target.common.TargetCardInLibrary; public class SphinxAmbassador extends CardImpl { public SphinxAmbassador(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}"); this.subtype.add(SubType.SPHINX); this.power = new MageInt(5); @@ -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()) { - return false; - } + 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); } } diff --git a/Mage.Sets/src/mage/cards/s/SquanderedResources.java b/Mage.Sets/src/mage/cards/s/SquanderedResources.java index d495b71e0f..1c3f968219 100644 --- a/Mage.Sets/src/mage/cards/s/SquanderedResources.java +++ b/Mage.Sets/src/mage/cards/s/SquanderedResources.java @@ -134,35 +134,34 @@ class SquanderedResourcesEffect extends ManaEffect { if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { - player.choose(outcome, choice, game); - } - if (choice.getChoice() != null) { - Mana mana = new Mana(); - switch (choice.getChoice()) { - case "Black": - mana.setBlack(1); - break; - case "Blue": - mana.setBlue(1); - break; - case "Red": - mana.setRed(1); - break; - case "Green": - mana.setGreen(1); - break; - case "White": - mana.setWhite(1); - break; - case "Colorless": - mana.setColorless(1); - break; + if (!player.choose(outcome, choice, game)) { + return false; } - checkToFirePossibleEvents(mana, game, source); - player.getManaPool().addMana(mana, game, source); - return true; } - return false; + Mana mana = new Mana(); + switch (choice.getChoice()) { + case "Black": + mana.setBlack(1); + break; + case "Blue": + mana.setBlue(1); + break; + case "Red": + mana.setRed(1); + break; + case "Green": + mana.setGreen(1); + break; + case "White": + mana.setWhite(1); + break; + case "Colorless": + mana.setColorless(1); + break; + } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); + } return true; } diff --git a/Mage.Sets/src/mage/cards/s/Standardize.java b/Mage.Sets/src/mage/cards/s/Standardize.java index 6a1adee518..cc47640a75 100644 --- a/Mage.Sets/src/mage/cards/s/Standardize.java +++ b/Mage.Sets/src/mage/cards/s/Standardize.java @@ -88,10 +88,8 @@ 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()) { - return false; - } + if (!player.choose(Outcome.BoostCreature, typeChoice, game)) { + return false; } game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); chosenType = typeChoice.getChoice(); diff --git a/Mage.Sets/src/mage/cards/s/StarCompass.java b/Mage.Sets/src/mage/cards/s/StarCompass.java index 2f87dd194b..2a68d148c3 100644 --- a/Mage.Sets/src/mage/cards/s/StarCompass.java +++ b/Mage.Sets/src/mage/cards/s/StarCompass.java @@ -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(); diff --git a/Mage.Sets/src/mage/cards/s/StorageMatrix.java b/Mage.Sets/src/mage/cards/s/StorageMatrix.java index 45c40eb7ee..ed64b3ed34 100644 --- a/Mage.Sets/src/mage/cards/s/StorageMatrix.java +++ b/Mage.Sets/src/mage/cards/s/StorageMatrix.java @@ -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 @@ -53,7 +52,7 @@ import java.util.UUID; public class StorageMatrix extends CardImpl { public StorageMatrix(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // As long as Storage Matrix is untapped, each player chooses artifact, creature, or land during his or her untap step. That player can untap only permanents of the chosen type this step. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StorageMatrixRestrictionEffect())); @@ -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); diff --git a/Mage.Sets/src/mage/cards/s/SuddenDemise.java b/Mage.Sets/src/mage/cards/s/SuddenDemise.java index e0607a9321..4475bd7a7e 100644 --- a/Mage.Sets/src/mage/cards/s/SuddenDemise.java +++ b/Mage.Sets/src/mage/cards/s/SuddenDemise.java @@ -85,18 +85,15 @@ 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) { - final int damage = source.getManaCostsToPay().getX(); - FilterPermanent filter = new FilterCreaturePermanent(); - filter.add(new ColorPredicate(choice.getColor())); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - permanent.damage(damage, source.getSourceId(), game, false, true); - } - return true; + ChoiceColor choice = new ChoiceColor(); + if (controller != null && controller.choose(outcome, choice, game)) { + final int damage = source.getManaCostsToPay().getX(); + FilterPermanent filter = new FilterCreaturePermanent(); + filter.add(new ColorPredicate(choice.getColor())); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + permanent.damage(damage, source.getSourceId(), game, false, true); } + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/t/TabletOfTheGuilds.java b/Mage.Sets/src/mage/cards/t/TabletOfTheGuilds.java index 8a8e4ef3a4..3120df514c 100644 --- a/Mage.Sets/src/mage/cards/t/TabletOfTheGuilds.java +++ b/Mage.Sets/src/mage/cards/t/TabletOfTheGuilds.java @@ -51,7 +51,7 @@ import mage.players.Player; public class TabletOfTheGuilds extends CardImpl { public TabletOfTheGuilds(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); // As Tablet of the Guilds enters the battlefield, choose two colors. this.addAbility(new AsEntersBattlefieldAbility(new TabletOfTheGuildsEntersBattlefieldEffect())); @@ -89,22 +89,20 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect { String colors; ChoiceColor colorChoice = new ChoiceColor(); colorChoice.setMessage("Choose the first color"); - while (!player.choose(Outcome.GainLife, colorChoice, game)) { - if (!player.canRespond()) { - return false; - } + if (!player.choose(Outcome.GainLife, colorChoice, game)) { + return false; } game.getState().setValue(permanent.getId() + "_color1", colorChoice.getColor().toString()); colors = colorChoice.getChoice().toLowerCase() + " and "; - colorChoice.getChoices().remove(colorChoice.getChoice()); colorChoice.setMessage("Choose the second color"); - while (!player.choose(Outcome.GainLife, colorChoice, game) && player.canRespond()) { - game.debugMessage("player canceled choosing type. retrying."); + if (!player.choose(Outcome.GainLife, colorChoice, game) && player.canRespond()) { + return false; } game.getState().setValue(permanent.getId() + "_color2", colorChoice.getColor().toString()); colors = colors + colorChoice.getChoice().toLowerCase(); game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + colors); + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/t/TeferisRealm.java b/Mage.Sets/src/mage/cards/t/TeferisRealm.java index da7adaa853..199f382ed0 100644 --- a/Mage.Sets/src/mage/cards/t/TeferisRealm.java +++ b/Mage.Sets/src/mage/cards/t/TeferisRealm.java @@ -28,9 +28,14 @@ package mage.cards.t; import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PhaseOutAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.choices.Choice; @@ -45,13 +50,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import mage.abilities.effects.common.PhaseOutAllEffect; -import mage.filter.common.FilterControlledLandPermanent; - /** * * @author LevelX2 @@ -113,10 +111,8 @@ class TeferisRealmEffect extends OneShotEffect { Choice choiceImpl = new ChoiceImpl(true); choiceImpl.setMessage("Phase out which kind of permanents?"); choiceImpl.setChoices(choices); - while (!player.choose(outcome, choiceImpl, game)) { - if (!player.canRespond()) { - return false; - } + if (!player.choose(outcome, choiceImpl, game)) { + return false; } String choosenType = choiceImpl.getChoice(); FilterPermanent filter = new FilterPermanent(); diff --git a/Mage.Sets/src/mage/cards/t/TrainingGrounds.java b/Mage.Sets/src/mage/cards/t/TrainingGrounds.java index 391f27ddbc..4ab8559aff 100644 --- a/Mage.Sets/src/mage/cards/t/TrainingGrounds.java +++ b/Mage.Sets/src/mage/cards/t/TrainingGrounds.java @@ -108,17 +108,15 @@ class TrainingGroundsEffect extends CostModificationEffectImpl { } choice.setChoices(set); choice.setMessage("Reduce ability cost"); - while (!choice.isChosen()) { - controller.choose(Outcome.Benefit, choice, game); - if (!controller.isInGame()) { - return false; - } + if (!controller.choose(Outcome.Benefit, choice, game)) { + return false; } int reduce = Integer.parseInt(choice.getChoice()); CardUtil.reduceCost(abilityToModify, reduce); } return true; } + return false; } diff --git a/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java b/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java index 70884572c6..33115371c7 100644 --- a/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java +++ b/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java @@ -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; @@ -55,7 +55,7 @@ import mage.players.Player; public class TrevaTheRenewer extends CardImpl { public TrevaTheRenewer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{W}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{W}{U}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); @@ -78,30 +78,29 @@ public class TrevaTheRenewer extends CardImpl { } class TrevaTheRenewerEffect extends OneShotEffect { - + public TrevaTheRenewerEffect() { super(Outcome.Benefit); this.staticText = "choose a color, then you gain 1 life for each permanent of that color."; } - + public TrevaTheRenewerEffect(final TrevaTheRenewerEffect effect) { super(effect); } - + @Override public TrevaTheRenewerEffect copy() { return new TrevaTheRenewerEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { 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())); @@ -113,4 +112,4 @@ class TrevaTheRenewerEffect extends OneShotEffect { } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/t/TribalUnity.java b/Mage.Sets/src/mage/cards/t/TribalUnity.java index fc9653ce1f..6d9be2b1be 100644 --- a/Mage.Sets/src/mage/cards/t/TribalUnity.java +++ b/Mage.Sets/src/mage/cards/t/TribalUnity.java @@ -27,6 +27,7 @@ */ package mage.cards.t; +import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; @@ -46,8 +47,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.players.Player; -import java.util.UUID; - /** * @author anonymous */ @@ -70,8 +69,8 @@ public class TribalUnity extends CardImpl { } } - class TribalUnityEffect extends OneShotEffect { + protected DynamicValue amount; public TribalUnityEffect(DynamicValue amount) { @@ -87,16 +86,14 @@ class TribalUnityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); - int boost = amount.calculate(game, source, this); - if (player != null) { - Choice typeChoice = new ChoiceCreatureType(sourceObject); - while (!player.choose(outcome, typeChoice, game)) { - if (!player.canRespond()) { - return false; - } - } + if (sourceObject == null) { + return false; + } + Player player = game.getPlayer(source.getControllerId()); + Choice typeChoice = new ChoiceCreatureType(sourceObject); + if (player != null && player.choose(outcome, typeChoice, game)) { + int boost = amount.calculate(game, source, this); if (typeChoice.getChoice() != null) { game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); } @@ -113,4 +110,4 @@ class TribalUnityEffect extends OneShotEffect { public TribalUnityEffect copy() { return new TribalUnityEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/t/TsabosDecree.java b/Mage.Sets/src/mage/cards/t/TsabosDecree.java index b455b45505..8975b2e9a2 100644 --- a/Mage.Sets/src/mage/cards/t/TsabosDecree.java +++ b/Mage.Sets/src/mage/cards/t/TsabosDecree.java @@ -56,7 +56,7 @@ import mage.target.TargetPlayer; public class TsabosDecree extends CardImpl { public TsabosDecree(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{5}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{5}{B}"); // Choose a creature type. Target player reveals his or her hand and discards all creature cards of that type. Then destroy all creatures of that type that player controls. They can't be regenerated. this.getSpellAbility().addEffect(new TsabosDecreeEffect()); @@ -91,31 +91,27 @@ class TsabosDecreeEffect extends OneShotEffect { 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) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); + if (!player.choose(outcome, typeChoice, game)) { + return false; } + game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game); FilterCard filterCard = new FilterCard(); filterCard.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); List toDiscard = new ArrayList<>(); for (Card card : targetPlayer.getHand().getCards(game)) { - if(filterCard.match(card, game)) { - toDiscard.add(card); + if (filterCard.match(card, game)) { + toDiscard.add(card); } } - for(Card card: toDiscard) { - targetPlayer.discard(card, source, game); - } + for (Card card : toDiscard) { + targetPlayer.discard(card, source, game); + } FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) { if (creature.getControllerId().equals(targetPlayer.getId())) { - creature.destroy(source.getSourceId(), game, true); + creature.destroy(source.getSourceId(), game, true); } } return true; diff --git a/Mage.Sets/src/mage/cards/t/TundraKavu.java b/Mage.Sets/src/mage/cards/t/TundraKavu.java index dbb3f5b62a..8805beac81 100644 --- a/Mage.Sets/src/mage/cards/t/TundraKavu.java +++ b/Mage.Sets/src/mage/cards/t/TundraKavu.java @@ -27,6 +27,9 @@ */ package mage.cards.t; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -43,10 +46,6 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetLandPermanent; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; - /** * * @author LoneFox @@ -54,7 +53,7 @@ import java.util.UUID; public class TundraKavu extends CardImpl { public TundraKavu(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); this.subtype.add(SubType.KAVU); this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -102,10 +101,9 @@ class TundraKavuEffect extends BecomesBasicLandTargetEffect { ChoiceImpl choice = new ChoiceImpl(true); choice.setChoices(choiceSet); choice.setMessage("Choose a basic land type"); - while (!controller.choose(outcome, choice, game)) { - if (!controller.canRespond()) { - return; - } + if (!controller.choose(outcome, choice, game)) { + discard(); + return; } landTypes.add(SubType.byDescription(choice.getChoice())); } else { diff --git a/Mage.Sets/src/mage/cards/t/Turnabout.java b/Mage.Sets/src/mage/cards/t/Turnabout.java index e15011b9e4..17bc7babdc 100644 --- a/Mage.Sets/src/mage/cards/t/Turnabout.java +++ b/Mage.Sets/src/mage/cards/t/Turnabout.java @@ -27,6 +27,9 @@ */ package mage.cards.t; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -44,10 +47,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPlayer; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - /** * * @author Plopman @@ -55,7 +54,7 @@ import java.util.UUID; public class Turnabout extends CardImpl { public Turnabout(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); // Choose artifact, creature, or land. Tap all untapped permanents of the chosen type target player controls, or untap all tapped permanents of that type that player controls. this.getSpellAbility().addTarget(new TargetPlayer()); @@ -112,10 +111,8 @@ class TurnaboutEffect extends OneShotEffect { Choice choiceImpl = new ChoiceImpl(); choiceImpl.setMessage("Choose card type to tap or untap"); choiceImpl.setChoices(choice); - while (!controller.choose(Outcome.Neutral, choiceImpl, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Neutral, choiceImpl, game)) { + return false; } CardType type; String choosenType = choiceImpl.getChoice(); @@ -131,10 +128,8 @@ class TurnaboutEffect extends OneShotEffect { choiceImpl = new ChoiceImpl(); choiceImpl.setMessage("Choose to tap or untap"); choiceImpl.setChoices(choice2); - while (!controller.choose(Outcome.Neutral, choiceImpl, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Neutral, choiceImpl, game)) { + return false; } FilterPermanent filter = new FilterPermanent(); diff --git a/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java b/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java index 5ddaa3305a..34c50f8b79 100644 --- a/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java +++ b/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java @@ -43,8 +43,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.players.Player; @@ -56,7 +56,7 @@ import mage.players.Player; public class VedalkenEngineer extends CardImpl { public VedalkenEngineer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add(SubType.VEDALKEN); this.subtype.add(SubType.ARTIFICER); @@ -114,7 +114,7 @@ class VedalkenEngineerAbility extends ActivatedManaAbilityImpl { public VedalkenEngineerAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) { super(Zone.BATTLEFIELD, new VedalkenEngineerEffect(amount, manaBuilder), cost); - this.netMana.add(new Mana(0,0,0,0,0,0, amount, 0)); + this.netMana.add(new Mana(0, 0, 0, 0, 0, 0, amount, 0)); } public VedalkenEngineerAbility(final VedalkenEngineerAbility ability) { @@ -153,21 +153,15 @@ class VedalkenEngineerEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { - return false; - } - ChoiceColor choiceColor = new ChoiceColor(true); - while (!controller.choose(Outcome.Benefit, choiceColor, game)) { - if (!controller.canRespond()) { - return false; - } + if (controller != null && controller.choose(Outcome.Benefit, choiceColor, game)) { + Mana mana = choiceColor.getMana(amount); + Mana condMana = manaBuilder.setMana(mana, source, game).build(); + checkToFirePossibleEvents(condMana, game, source); + controller.getManaPool().addMana(condMana, game, source); + return true; } - Mana mana = choiceColor.getMana(amount); - Mana condMana = manaBuilder.setMana(mana, source, game).build(); - checkToFirePossibleEvents(condMana, game, source); - controller.getManaPool().addMana(condMana, game, source); - return true; + return false; } @Override diff --git a/Mage.Sets/src/mage/cards/v/VeteranWarleader.java b/Mage.Sets/src/mage/cards/v/VeteranWarleader.java index 83aa9c70d4..5f304d3d1e 100644 --- a/Mage.Sets/src/mage/cards/v/VeteranWarleader.java +++ b/Mage.Sets/src/mage/cards/v/VeteranWarleader.java @@ -124,11 +124,8 @@ class VeteranWarleaderEffect extends OneShotEffect { abilities.add(VigilanceAbility.getInstance().getRule()); abilities.add(TrampleAbility.getInstance().getRule()); abilityChoice.setChoices(abilities); - while (!abilityChoice.isChosen()) { - controller.choose(Outcome.AddAbility, abilityChoice, game); - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.AddAbility, abilityChoice, game)) { + return false; } String chosen = abilityChoice.getChoice(); diff --git a/Mage.Sets/src/mage/cards/v/VexingArcanix.java b/Mage.Sets/src/mage/cards/v/VexingArcanix.java index 5278c1626b..add38ad870 100644 --- a/Mage.Sets/src/mage/cards/v/VexingArcanix.java +++ b/Mage.Sets/src/mage/cards/v/VexingArcanix.java @@ -90,15 +90,12 @@ class VexingArcanixEffect 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()) { - return false; - } + if (!player.choose(Outcome.DrawCard, cardChoice, game)) { + return false; } String cardName = cardChoice.getChoice(); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); diff --git a/Mage.Sets/src/mage/cards/v/VisionCharm.java b/Mage.Sets/src/mage/cards/v/VisionCharm.java index 52d0254810..5b5faaada3 100644 --- a/Mage.Sets/src/mage/cards/v/VisionCharm.java +++ b/Mage.Sets/src/mage/cards/v/VisionCharm.java @@ -117,10 +117,16 @@ class VisionCharmEffect extends ContinuousEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Choice choice = new ChoiceLandType(); - controller.choose(outcome, choice, game); + if (!controller.choose(outcome, choice, game)) { + discard(); + return; + } targetLandType = choice.getChoice(); choice = new ChoiceBasicLandType(); - controller.choose(outcome, choice, game); + if (!controller.choose(outcome, choice, game)) { + discard(); + return; + } targetBasicLandType = SubType.byDescription(choice.getChoice()); if (targetLandType == null || targetBasicLandType == null) { this.discard(); diff --git a/Mage.Sets/src/mage/cards/v/Void.java b/Mage.Sets/src/mage/cards/v/Void.java index 3ea8ac6aa3..3565fb85f9 100644 --- a/Mage.Sets/src/mage/cards/v/Void.java +++ b/Mage.Sets/src/mage/cards/v/Void.java @@ -100,7 +100,9 @@ class VoidEffect extends OneShotEffect { } numberChoice.setChoices(numbers); numberChoice.setMessage("Choose a number"); - controller.choose(Outcome.DestroyPermanent, numberChoice, game); + if (!controller.choose(Outcome.DestroyPermanent, numberChoice, game)) { + return false; + } int number = Integer.parseInt(numberChoice.getChoice()); for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { if ((permanent.isArtifact() || permanent.isCreature()) diff --git a/Mage.Sets/src/mage/cards/w/WalkingDesecration.java b/Mage.Sets/src/mage/cards/w/WalkingDesecration.java index f23339c4e2..bc234db818 100644 --- a/Mage.Sets/src/mage/cards/w/WalkingDesecration.java +++ b/Mage.Sets/src/mage/cards/w/WalkingDesecration.java @@ -54,7 +54,7 @@ import mage.players.Player; public class WalkingDesecration extends CardImpl { public WalkingDesecration(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(1); this.toughness = new MageInt(1); @@ -90,16 +90,9 @@ class WalkingDesecrationEffect 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) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); - } + Choice typeChoice = new ChoiceCreatureType(sourceObject); + if (player != null && player.choose(outcome, typeChoice, game)) { + game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn); diff --git a/Mage.Sets/src/mage/cards/w/WalkingSponge.java b/Mage.Sets/src/mage/cards/w/WalkingSponge.java index 0bc3b9fbba..fb0bb0f4bc 100644 --- a/Mage.Sets/src/mage/cards/w/WalkingSponge.java +++ b/Mage.Sets/src/mage/cards/w/WalkingSponge.java @@ -44,9 +44,9 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; 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; @@ -60,7 +60,7 @@ import mage.target.common.TargetCreaturePermanent; public class WalkingSponge extends CardImpl { public WalkingSponge(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add(SubType.SPONGE); this.power = new MageInt(1); this.toughness = new MageInt(1); @@ -99,9 +99,9 @@ class WalkingSpongeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); - if (player != null || permanent != null) { + if (controller != null && permanent != null) { ChoiceImpl chooseAbility = new ChoiceImpl(); chooseAbility.setMessage("What ability do you wish to remove? (default is Flying)"); Set choice = new LinkedHashSet<>(); @@ -111,20 +111,18 @@ class WalkingSpongeEffect extends OneShotEffect { chooseAbility.setChoices(choice); // since the player can't pick "no ability", let's default to the first option Ability ability = FlyingAbility.getInstance(); - - if (player.choose(Outcome.UnboostCreature, chooseAbility, game)) { + + if (controller.choose(Outcome.UnboostCreature, chooseAbility, game)) { String chosenAbility = chooseAbility.getChoice(); - // if (chosenAbility.equals("Flying")) { - // ability = FlyingAbility.getInstance(); - // } if (chosenAbility.equals("First strike")) { ability = FirstStrikeAbility.getInstance(); - } - else if (chosenAbility.equals("Trample")) { + } else if (chosenAbility.equals("Trample")) { ability = TrampleAbility.getInstance(); } + } else { + return false; } - game.informPlayers(player.getLogName() + " has chosen " + ability.getRule()); + game.informPlayers(controller.getLogName() + " has chosen " + ability.getRule()); ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn); game.addEffect(effect, source); return true; diff --git a/Mage.Sets/src/mage/cards/w/WashOut.java b/Mage.Sets/src/mage/cards/w/WashOut.java index 9fab715687..82597cc3f6 100644 --- a/Mage.Sets/src/mage/cards/w/WashOut.java +++ b/Mage.Sets/src/mage/cards/w/WashOut.java @@ -59,7 +59,7 @@ public class WashOut extends CardImpl { } public WashOut(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); // Return all permanents of the color of your choice to their owners' hands. this.getSpellAbility().addEffect(new WashOutEffect()); @@ -90,18 +90,15 @@ class WashOutEffect 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.ReturnToHand, choice, game); + ChoiceColor choice = new ChoiceColor(); + if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) { ObjectColor color = choice.getColor(); - if (color != null) { - FilterPermanent filter = new FilterPermanent(); - filter.add(new ColorPredicate(color)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return true; + FilterPermanent filter = new FilterPermanent(); + filter.add(new ColorPredicate(color)); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true); } + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/w/Wishmonger.java b/Mage.Sets/src/mage/cards/w/Wishmonger.java index 46659aab0e..faa5539c4e 100644 --- a/Mage.Sets/src/mage/cards/w/Wishmonger.java +++ b/Mage.Sets/src/mage/cards/w/Wishmonger.java @@ -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.TargetController; import mage.constants.Zone; import mage.filter.FilterObject; @@ -64,7 +64,7 @@ import mage.target.targetpointer.FixedTarget; public class Wishmonger extends CardImpl { public Wishmonger(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}"); this.subtype.add(SubType.UNICORN); this.subtype.add(SubType.MONGER); this.power = new MageInt(3); @@ -104,32 +104,31 @@ class WishmongerEffect extends OneShotEffect { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { Player player = game.getPlayer(targetCreature.getControllerId()); - if (player != null) { - ChoiceColor colorChoice = new ChoiceColor(); - if (player.choose(Outcome.Neutral, colorChoice, game)) { - game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice()); - game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor()); - - ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color"); - if (protectColor != null) { - ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); - effect.setTargetPointer(new FixedTarget(targetCreature, game)); - game.addEffect(effect, source); - } + ChoiceColor colorChoice = new ChoiceColor(); + if (player != null && player.choose(Outcome.Neutral, colorChoice, game)) { + game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice()); + game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor()); + + ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color"); + if (protectColor != null) { + ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); + effect.setTargetPointer(new FixedTarget(targetCreature, game)); + game.addEffect(effect, source); } return true; } } + return false; } @Override public WishmongerEffect copy() { return new WishmongerEffect(this); + } } - class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl { protected ObjectColor chosenColor; diff --git a/Mage.Sets/src/mage/cards/w/WoodSage.java b/Mage.Sets/src/mage/cards/w/WoodSage.java index 12f79ba6d5..18acd9f169 100644 --- a/Mage.Sets/src/mage/cards/w/WoodSage.java +++ b/Mage.Sets/src/mage/cards/w/WoodSage.java @@ -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.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.NamePredicate; @@ -101,10 +101,8 @@ class WoodSageEffect extends OneShotEffect { Choice cardChoice = new ChoiceImpl(); cardChoice.setChoices(CardRepository.instance.getCreatureNames()); cardChoice.setMessage("Name a creature card"); - while (!controller.choose(Outcome.Detriment, cardChoice, game)) { - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Detriment, cardChoice, game)) { + return false; } String cardName = cardChoice.getChoice(); if (!game.isSimulation()) { diff --git a/Mage.Sets/src/mage/cards/w/WorldQueller.java b/Mage.Sets/src/mage/cards/w/WorldQueller.java index 9b52e7df2e..27a98266d1 100644 --- a/Mage.Sets/src/mage/cards/w/WorldQueller.java +++ b/Mage.Sets/src/mage/cards/w/WorldQueller.java @@ -27,6 +27,7 @@ */ package mage.cards.w; +import java.util.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -37,8 +38,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.TargetController; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; @@ -48,8 +49,6 @@ import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetControlledPermanent; -import java.util.*; - /** * * @author jeffwadsworth @@ -57,7 +56,7 @@ import java.util.*; public class WorldQueller extends CardImpl { public WorldQueller(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); this.subtype.add(SubType.AVATAR); this.power = new MageInt(4); @@ -115,10 +114,11 @@ class WorldQuellerEffect extends OneShotEffect { if (player != null && sourceCreature != null) { Choice choiceImpl = new ChoiceImpl(); choiceImpl.setChoices(choice); - while (player.canRespond() && !player.choose(Outcome.Neutral, choiceImpl, game)) {} + if (!player.choose(Outcome.Neutral, choiceImpl, game)) { + return false; + } CardType type = null; String choosenType = choiceImpl.getChoice(); - if (choosenType.equals(CardType.ARTIFACT.toString())) { type = CardType.ARTIFACT; } else if (choosenType.equals(CardType.LAND.toString())) { @@ -144,17 +144,17 @@ class WorldQuellerEffect extends OneShotEffect { target.setNotTarget(true); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player2 = game.getPlayer(playerId); - if (target.canChoose(playerId, game)) { - while (player2.canRespond() && !target.isChosen() && target.canChoose(playerId, game)) { - player2.chooseTarget(Outcome.Sacrifice, target, source, game); - } - Permanent permanent = game.getPermanent(target.getFirstTarget()); - if (permanent != null) { - chosen.add(permanent); - } - target.clearChosen(); + Player player2 = game.getPlayer(playerId); + if (target.canChoose(playerId, game)) { + while (player2.canRespond() && !target.isChosen() && target.canChoose(playerId, game)) { + player2.chooseTarget(Outcome.Sacrifice, target, source, game); } + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + chosen.add(permanent); + } + target.clearChosen(); + } } // all chosen permanents are sacrificed together diff --git a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java index aa0367a1f1..61fd0e37d0 100644 --- a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java +++ b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java @@ -43,8 +43,8 @@ import mage.cards.CardsImpl; 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.SuperType; import mage.constants.Zone; import mage.filter.FilterCard; @@ -120,10 +120,8 @@ class XenagosManaEffect extends OneShotEffect { for (int i = 0; i < x; i++) { Mana mana = new Mana(); - while (!player.choose(Outcome.Benefit, manaChoice, game)) { - if (!player.canRespond()) { - return false; - } + if (!player.choose(Outcome.Benefit, manaChoice, game)) { + return false; } if (manaChoice.getChoice() == null) { // can happen if player leaves game return false; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java index 06737b8415..8677ddbfa6 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java @@ -68,7 +68,7 @@ public class BestowTest extends CardTestPlayerBase { @Test public void bestowEnchantmentToCreature() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); - addCard(Zone.BATTLEFIELD, playerA, "Silent Artisan"); + addCard(Zone.BATTLEFIELD, playerA, "Silent Artisan"); // 3/5 addCard(Zone.HAND, playerA, "Hopeful Eidolon"); addCard(Zone.HAND, playerA, "Gods Willing"); diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index e2ded9987d..8caf2db48c 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -342,7 +342,7 @@ public abstract class AbilityImpl implements Ability { && !getTargets().isEmpty()) { Outcome outcome = getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome(); if (getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game) == false) { - if ((variableManaCost != null || announceString != null) && !game.isSimulation()) { + if ((variableManaCost != null || announceString != null)) { game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName() : "") + ": no valid targets"); } return false; // when activation of ability is canceled during target selection @@ -405,15 +405,13 @@ public abstract class AbilityImpl implements Ability { logger.debug("activate failed - non mana costs"); return false; } - if (!game.isSimulation()) { - // inform about x costs now, so canceled announcements are not shown in the log - if ((announceString != null) && (!announceString.equals(""))) { - game.informPlayers(announceString); - } - if (variableManaCost != null) { - int xValue = getManaCostsToPay().getX(); - game.informPlayers(controller.getLogName() + " announces a value of " + xValue + " for " + variableManaCost.getText()); - } + // inform about x costs now, so canceled announcements are not shown in the log + if ((announceString != null) && (!announceString.equals(""))) { + game.informPlayers(announceString); + } + if (variableManaCost != null) { + int xValue = getManaCostsToPay().getX(); + game.informPlayers(controller.getLogName() + " announces a value of " + xValue + " for " + variableManaCost.getText()); } activated = true; // fire if tapped for mana (may only fire now because else costs of ability itself can be payed with mana of abilities that trigger for that event diff --git a/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java b/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java index 3e7c557e8e..c3b55e4747 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java @@ -108,7 +108,9 @@ public class RemoveCounterCost extends CostImpl { } choice.setChoices(choices); choice.setMessage("Choose a counter to remove from " + permanent.getLogName()); - controller.choose(Outcome.UnboostCreature, choice, game); + if (!controller.choose(Outcome.UnboostCreature, choice, game)) { + return false; + } counterName = choice.getChoice(); } else { for (Counter counter : permanent.getCounters(game).values()) { @@ -117,7 +119,7 @@ public class RemoveCounterCost extends CostImpl { } } } - if (counterName != null) { + if (counterName != null && !counterName.isEmpty()) { int countersLeft = countersToRemove - countersRemoved; int countersOnPermanent = permanent.getCounters(game).getCount(counterName); int numberOfCountersSelected = 1; diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java index e297e429fa..ba692a491d 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java @@ -88,10 +88,6 @@ public class ConditionalManaEffect extends ManaEffect { ChoiceColor choice = new ChoiceColor(true); Mana createdMana = null; if (controller.choose(outcome, choice, game)) { - if (choice.getColor() == null) { - return false; // it happens, don't know how - } - createdMana = choice.getMana(amount); } if (createdMana == null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java index 633d8a0bd3..2bf737ab41 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java @@ -93,11 +93,9 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect { ChoiceColor choice = new ChoiceColor(true); for (int i = 0; i < value; i++) { - while (!choice.isChosen()) { - controller.choose(outcome, choice, game); - if (!controller.isInGame()) { - return false; - } + controller.choose(outcome, choice, game); + if (choice.getChoice() == null) { + return false; } Mana mana = choice.getMana(1); if (mana != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddManaAnyColorAttachedControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddManaAnyColorAttachedControllerEffect.java index fa2847daee..aac3866254 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddManaAnyColorAttachedControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddManaAnyColorAttachedControllerEffect.java @@ -38,7 +38,6 @@ import mage.players.Player; * * @author LevelX2 */ - public class AddManaAnyColorAttachedControllerEffect extends ManaEffect { public AddManaAnyColorAttachedControllerEffect() { @@ -57,19 +56,12 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect { Permanent land = game.getPermanent(enchantment.getAttachedTo()); if (land != null) { Player player = game.getPlayer(land.getControllerId()); - if (player != null) { - ChoiceColor choice = new ChoiceColor(); - while (!player.choose(outcome, choice, game)) { - if (!player.canRespond()) { - return false; - } - } + ChoiceColor choice = new ChoiceColor(); + if (player != null && player.choose(outcome, choice, game)) { Mana mana = choice.getMana(1); - if (mana != null) { - checkToFirePossibleEvents(mana, game, source); - player.getManaPool().addMana(mana, game, source); - return true; - } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); + return true; } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorEffect.java index 52e3a0fb3b..4ccd4fcc5c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. @@ -71,12 +71,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect { if (controller != null) { String mes = String.format("Select color of %d mana to add it to your mana pool", this.amount); ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId())); - if (controller.choose(outcome, choice, game)) { - if (choice.getColor() == null) { - // on user's reconnect choice dialog close and return null even with required settings - return false; - } Mana createdMana = choice.getMana(amount); if (createdMana != null) { checkToFirePossibleEvents(createdMana, game, source); diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorToManaPoolTargetPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorToManaPoolTargetPlayerEffect.java index 072484d19c..b087354cfb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorToManaPoolTargetPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyColorToManaPoolTargetPlayerEffect.java @@ -1,13 +1,12 @@ package mage.abilities.effects.common; +import java.util.UUID; import mage.Mana; import mage.abilities.Ability; import mage.choices.ChoiceColor; import mage.game.Game; import mage.players.Player; -import java.util.UUID; - /** * * Created by Galatolol @@ -16,7 +15,7 @@ public class AddManaOfAnyColorToManaPoolTargetPlayerEffect extends ManaEffect { public AddManaOfAnyColorToManaPoolTargetPlayerEffect(String textManaPoolOwner) { super(); - this.staticText = (textManaPoolOwner.equals("his or her")?"that player adds ":"add ") + "one mana of any color" + " to " + textManaPoolOwner + " mana pool"; + this.staticText = (textManaPoolOwner.equals("his or her") ? "that player adds " : "add ") + "one mana of any color" + " to " + textManaPoolOwner + " mana pool"; } public AddManaOfAnyColorToManaPoolTargetPlayerEffect(final AddManaOfAnyColorToManaPoolTargetPlayerEffect effect) { @@ -27,19 +26,12 @@ public class AddManaOfAnyColorToManaPoolTargetPlayerEffect extends ManaEffect { public boolean apply(Game game, Ability source) { UUID playerId = (UUID) game.getState().getValue(source.getSourceId() + "_player"); Player player = game.getPlayer(playerId); - if (player != null) { - ChoiceColor choice = new ChoiceColor(); - while (!player.choose(outcome, choice, game)) { - if (!player.canRespond()) { - return false; - } - } + ChoiceColor choice = new ChoiceColor(); + if (player != null && player.choose(outcome, choice, game)) { Mana mana = choice.getMana(1); - if (mana != null) { - checkToFirePossibleEvents(mana, game, source); - player.getManaPool().addMana(mana, game, source); - return true; - } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); + return true; } return false; } @@ -55,4 +47,3 @@ public class AddManaOfAnyColorToManaPoolTargetPlayerEffect extends ManaEffect { } } - diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyTypeProducedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyTypeProducedEffect.java index a07f02e8d8..28617232df 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyTypeProducedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddManaOfAnyTypeProducedEffect.java @@ -84,10 +84,9 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect { if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { - targetController.choose(outcome, choice, game); - } - if (choice.getChoice() == null) { - return false; + if (!targetController.choose(outcome, choice, game)) { + return false; + } } Mana newMana = new Mana(); switch (choice.getChoice()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java index 161dec6767..b23c7f849b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java @@ -59,14 +59,8 @@ public class ChooseColorEffect extends OneShotEffect { if (mageObject == null) { mageObject = game.getObject(source.getSourceId()); } - if (controller != null && mageObject != null) { - ChoiceColor choice = new ChoiceColor(); - while (!choice.isChosen()) { - controller.choose(outcome, choice, game); - if (!controller.canRespond()) { - return false; - } - } + ChoiceColor choice = new ChoiceColor(); + if (controller != null && mageObject != null && controller.choose(outcome, choice, game)) { if (!game.isSimulation()) { game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index 28bcb457c5..a14e1fd635 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -63,20 +63,15 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { } if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCreatureType(mageObject); - while (!controller.choose(outcome, typeChoice, game)) { - if (!controller.canRespond()) { - return false; + if (controller.choose(outcome, typeChoice, game)) { + if (!game.isSimulation()) { + game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } - } - if (typeChoice.getChoice() == null) { - return false; - } - if (!game.isSimulation()) { - game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); - } - game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice())); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game); + game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice())); + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game); + } + return true; } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java index ba2a223a87..66b2b683a1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java @@ -37,7 +37,6 @@ import mage.cards.repository.ExpansionRepository; import mage.choices.Choice; import mage.choices.ChoiceImpl; import mage.constants.Outcome; -import mage.constants.SubType; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -73,22 +72,16 @@ public class ChooseExpansionSetEffect extends OneShotEffect { Set sets = new HashSet(setCodes); setChoice.setChoices(sets); - - while (!controller.choose(outcome, setChoice, game)) { - if (!controller.canRespond()) { - return false; + if (controller.choose(outcome, setChoice, game)) { + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " has chosen set " + setChoice.getChoice()); } - } - if (setChoice.getChoice() == null) { - return false; - } - if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " has chosen set " + setChoice.getChoice()); - } - game.getState().setValue(mageObject.getId() + "_set", setChoice.getChoice()); - this.setValue("setchosen", setChoice.getChoice()); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen set", CardUtil.addToolTipMarkTags("Chosen set: " + setChoice.getChoice()), game); + game.getState().setValue(mageObject.getId() + "_set", setChoice.getChoice()); + this.setValue("setchosen", setChoice.getChoice()); + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo("chosen set", CardUtil.addToolTipMarkTags("Chosen set: " + setChoice.getChoice()), game); + } + return true; } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java index d3777a79ed..7964752d8c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java @@ -5,6 +5,7 @@ */ package mage.abilities.effects.common; +import java.util.stream.Collectors; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -17,8 +18,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; -import java.util.stream.Collectors; - /** * * @author fireshoes @@ -45,17 +44,15 @@ public class ChooseLandTypeEffect extends OneShotEffect { Choice typeChoice = new ChoiceImpl(true); typeChoice.setMessage("Choose land type"); typeChoice.setChoices(SubType.getLandTypes(false).stream().map(SubType::toString).collect(Collectors.toSet())); - while (!controller.choose(outcome, typeChoice, game)) { - if (!controller.canRespond()) { - return false; + if (controller.choose(outcome, typeChoice, game)) { + if (!game.isSimulation()) { + game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } - } - if (!game.isSimulation()) { - game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); - } - game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice())); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game); + game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice())); + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game); + } + return true; } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java index 55fb38058d..d4577a45e0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java @@ -27,6 +27,9 @@ */ package mage.abilities.effects.common; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.choices.Choice; @@ -36,10 +39,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * * @author LevelX2 @@ -78,20 +77,14 @@ public class ChooseModeEffect extends OneShotEffect { Choice choice = new ChoiceImpl(true); choice.setMessage(choiceMessage); choice.getChoices().addAll(modes); - while (!choice.isChosen()) { - if (!controller.canRespond()) { - return false; - } - controller.choose(Outcome.Neutral, choice, game); - } - if (choice.isChosen()) { + if (controller.choose(Outcome.Neutral, choice, game)) { if (!game.isSimulation()) { game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); } game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice()); sourcePermanent.addInfo("_modeChoice", "Chosen mode: " + choice.getChoice() + "", game); + return true; } - return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DynamicManaEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DynamicManaEffect.java index 1c510e7d04..4ce3ece908 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DynamicManaEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DynamicManaEffect.java @@ -146,10 +146,8 @@ public class DynamicManaEffect extends BasicManaEffect { ChoiceColor choiceColor = new ChoiceColor(true); for (int i = 0; i < count; i++) { if (!choiceColor.isChosen()) { - while (!controller.choose(Outcome.Benefit, choiceColor, game)) { - if (!controller.canRespond()) { - return computedMana; - } + if (!controller.choose(Outcome.Benefit, choiceColor, game)) { + return computedMana; } } choiceColor.increaseMana(computedMana); diff --git a/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java index 127957787f..d976cea63d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java @@ -1,119 +1,120 @@ -/* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ -package mage.abilities.effects.common; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.MeldCard; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.predicate.mageobject.NamePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.TargetPermanent; -import mage.target.common.TargetControlledCreaturePermanent; - -/** - * - * @author emerald000 - */ -public class MeldEffect extends OneShotEffect { - - private final String meldWithName; - private final MeldCard meldCard; - - public MeldEffect(String meldWithName, MeldCard meldCard) { - super(Outcome.Benefit); - this.meldWithName = meldWithName; - this.meldCard = meldCard; - } - - public MeldEffect(final MeldEffect effect) { - super(effect); - this.meldWithName = effect.meldWithName; - this.meldCard = effect.meldCard; - } - - @Override - public MeldEffect copy() { - return new MeldEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - // Find the two permanents to meld. - UUID sourceId = source.getSourceId(); - FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature named " + meldWithName); - filter.add(new NamePredicate(meldWithName)); - TargetPermanent target = new TargetControlledCreaturePermanent(filter); - Set meldWithList = target.possibleTargets(sourceId, source.getControllerId(), game); - if (meldWithList.isEmpty()) { - return false; // possible permanent has left the battlefield meanwhile - } - UUID meldWithId; - if (meldWithList.size() == 1) { - meldWithId = meldWithList.iterator().next(); - } else { - controller.choose(Outcome.BoostCreature, target, sourceId, game); - meldWithId = target.getFirstTarget(); - } - // Exile the two permanents to meld. - Permanent sourcePermanent = game.getPermanent(sourceId); - Permanent meldWithPermanent = game.getPermanent(meldWithId); - if (sourcePermanent != null && meldWithPermanent != null) { - Set toExile = new HashSet<>(); - toExile.add(sourcePermanent); - toExile.add(meldWithPermanent); - controller.moveCards(toExile, Zone.EXILED, source, game); - // Create the meld card and move it to the battlefield. - Card sourceCard = game.getExile().getCard(sourceId, game); - Card meldWithCard = game.getExile().getCard(meldWithId, game); - if (sourceCard != null && !sourceCard.isCopy() && meldWithCard != null && !meldWithCard.isCopy()) { - meldCard.setOwnerId(controller.getId()); - meldCard.setTopHalfCard(meldWithCard, game); - meldCard.setBottomHalfCard(sourceCard, game); - meldCard.setMelded(true); - game.addMeldCard(meldCard.getId(), meldCard); - game.getState().addCard(meldCard); - meldCard.setZone(Zone.EXILED, game); - controller.moveCards(meldCard, Zone.BATTLEFIELD, source, game); - } - return true; - } - } - return false; - } -} +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.MeldCard; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.mageobject.NamePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author emerald000 + */ +public class MeldEffect extends OneShotEffect { + + private final String meldWithName; + private final MeldCard meldCard; + + public MeldEffect(String meldWithName, MeldCard meldCard) { + super(Outcome.Benefit); + this.meldWithName = meldWithName; + this.meldCard = meldCard; + } + + public MeldEffect(final MeldEffect effect) { + super(effect); + this.meldWithName = effect.meldWithName; + this.meldCard = effect.meldCard; + } + + @Override + public MeldEffect copy() { + return new MeldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + // Find the two permanents to meld. + UUID sourceId = source.getSourceId(); + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature named " + meldWithName); + filter.add(new NamePredicate(meldWithName)); + TargetPermanent target = new TargetControlledCreaturePermanent(filter); + Set meldWithList = target.possibleTargets(sourceId, source.getControllerId(), game); + if (meldWithList.isEmpty()) { + return false; // possible permanent has left the battlefield meanwhile + } + UUID meldWithId = null; + if (meldWithList.size() == 1) { + meldWithId = meldWithList.iterator().next(); + } else { + if (controller.choose(Outcome.BoostCreature, target, sourceId, game)) { + meldWithId = target.getFirstTarget(); + } + } + // Exile the two permanents to meld. + Permanent sourcePermanent = game.getPermanent(sourceId); + Permanent meldWithPermanent = game.getPermanent(meldWithId); + if (sourcePermanent != null && meldWithPermanent != null) { + Set toExile = new HashSet<>(); + toExile.add(sourcePermanent); + toExile.add(meldWithPermanent); + controller.moveCards(toExile, Zone.EXILED, source, game); + // Create the meld card and move it to the battlefield. + Card sourceCard = game.getExile().getCard(sourceId, game); + Card meldWithCard = game.getExile().getCard(meldWithId, game); + if (sourceCard != null && !sourceCard.isCopy() && meldWithCard != null && !meldWithCard.isCopy()) { + meldCard.setOwnerId(controller.getId()); + meldCard.setTopHalfCard(meldWithCard, game); + meldCard.setBottomHalfCard(sourceCard, game); + meldCard.setMelded(true); + game.addMeldCard(meldCard.getId(), meldCard); + game.getState().addCard(meldCard); + meldCard.setZone(Zone.EXILED, game); + controller.moveCards(meldCard, Zone.BATTLEFIELD, source, game); + } + return true; + } + } + return false; + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/NameACardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/NameACardEffect.java index 8c0d69c78c..e038bc42ac 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/NameACardEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/NameACardEffect.java @@ -106,20 +106,17 @@ public class NameACardEffect extends OneShotEffect { break; } cardChoice.clearChoice(); - while (!controller.choose(Outcome.Detriment, cardChoice, game)) { - if (!controller.canRespond()) { - return false; + if (controller.choose(Outcome.Detriment, cardChoice, game)) { + String cardName = cardChoice.getChoice(); + if (!game.isSimulation()) { + game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + ']'); } + game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName); + if (sourceObject instanceof Permanent) { + ((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName), game); + } + return true; } - String cardName = cardChoice.getChoice(); - if (!game.isSimulation()) { - game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + ']'); - } - game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName); - if (sourceObject instanceof Permanent) { - ((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName), game); - } - return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesBasicLandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesBasicLandTargetEffect.java index 4d0bb0703e..72b32fa2c4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesBasicLandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesBasicLandTargetEffect.java @@ -27,6 +27,10 @@ */ package mage.abilities.effects.common.continuous; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.mana.*; @@ -37,11 +41,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - /** * http://mtgsalvation.gamepedia.com/Land_changers * @@ -114,15 +113,14 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl { // choose land type if (chooseLandType) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Choice choice = new ChoiceBasicLandType(); - controller.choose(outcome, choice, game); + Choice choice = new ChoiceBasicLandType(); + if (controller != null && controller.choose(outcome, choice, game)) { landTypes.add(SubType.byDescription(choice.getChoice())); } else { this.discard(); + return; } } - if (loseOther) { landTypesToAdd.addAll(landTypes); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java index dde5970a68..982f160fb6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java @@ -25,10 +25,9 @@ public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect { public BecomesChosenCreatureTypeTargetEffect(boolean nonWall) { super(Outcome.BoostCreature); this.nonWall = nonWall; - if(nonWall) { + if (nonWall) { staticText = "choose a creature type other than Wall. Target creature becomes that type until end of turn"; - } - else { + } else { staticText = "target creature becomes the creature type of your choice until end of turn"; } @@ -47,17 +46,15 @@ public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect { if (player != null && card != null) { Choice typeChoice = new ChoiceCreatureType(); String msg = "Choose a creature type"; - if(nonWall) { + if (nonWall) { msg += " other than Wall"; } typeChoice.setMessage(msg); - if(nonWall) { + if (nonWall) { typeChoice.getChoices().remove(SubType.WALL.getDescription()); } - while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { - if (!player.canRespond()) { - return false; - } + if (!player.choose(Outcome.BoostCreature, typeChoice, game)) { + return false; } game.informPlayers(card.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); chosenType = typeChoice.getChoice(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorOrColorsTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorOrColorsTargetEffect.java index 670ae3da06..aac1a5db03 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorOrColorsTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorOrColorsTargetEffect.java @@ -79,8 +79,7 @@ public class BecomesColorOrColorsTargetEffect 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()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java index b7ba3d680c..948ee55a5c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java @@ -77,17 +77,11 @@ public class BecomesColorSourceEffect extends ContinuousEffectImpl { } if (setColor == null) { ChoiceColor choice = new ChoiceColor(); - while (!choice.isChosen()) { - controller.choose(Outcome.PutManaInPool, choice, game); - if (!controller.canRespond()) { - return; - } - } - if (choice.getColor() != null) { - setColor = choice.getColor(); - } else { + if (!controller.choose(Outcome.PutManaInPool, choice, game)) { + discard(); return; } + setColor = choice.getColor(); if (!game.isSimulation()) { game.informPlayers(controller.getLogName() + " has chosen the color: " + setColor.toString()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java index c437a9404f..94b66f0b86 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are @@ -25,7 +25,7 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. - * + * */ package mage.abilities.effects.common.continuous; @@ -82,17 +82,11 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl { } if (setColor == null) { ChoiceColor choice = new ChoiceColor(); - while (!choice.isChosen()) { - controller.choose(Outcome.PutManaInPool, choice, game); - if (!controller.canRespond()) { - return; - } - } - if (choice.getColor() != null) { - setColor = choice.getColor(); - } else { + if (!controller.choose(Outcome.PutManaInPool, choice, game)) { + discard(); return; } + setColor = choice.getColor(); if (!game.isSimulation()) { game.informPlayers(controller.getLogName() + " has chosen the color: " + setColor.toString()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java index bce7d96590..d08a999b6e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java @@ -78,16 +78,11 @@ public class GainProtectionFromColorAllEffect extends GainAbilityAllEffect { MageObject sourceObject = game.getObject(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (sourceObject != null && controller != null) { - choice.clearChoice(); - while (!choice.isChosen()) { - controller.choose(Outcome.Protect, choice, game); - if (!controller.canRespond()) { - return; - } - } - if (choice.isChosen() && !game.isSimulation()) { - game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice()); + if (!controller.choose(Outcome.Protect, choice, game)) { + discard(); + return; } + game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice()); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorSourceEffect.java index ca3a5a7664..f2addf2ca4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorSourceEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. @@ -43,14 +43,13 @@ import mage.players.Player; * * @author LevelX2 */ - public class GainProtectionFromColorSourceEffect extends GainAbilitySourceEffect { FilterCard protectionFilter; public GainProtectionFromColorSourceEffect(Duration duration) { super(new ProtectionAbility(new FilterCard()), duration); - protectionFilter = (FilterCard)((ProtectionAbility)ability).getFilter(); + protectionFilter = (FilterCard) ((ProtectionAbility) ability).getFilter(); } public GainProtectionFromColorSourceEffect(final GainProtectionFromColorSourceEffect effect) { @@ -65,23 +64,18 @@ public class GainProtectionFromColorSourceEffect extends GainAbilitySourceEffect @Override public void init(Ability source, Game game) { - super.init(source, game); + super.init(source, game); Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + if (controller != null) { ChoiceColor colorChoice = new ChoiceColor(true); colorChoice.setMessage("Choose color for protection ability"); - while (!colorChoice.isChosen()) { - controller.choose(outcome, colorChoice, game); - if (!controller.canRespond()) { - discard(); - return; - } + if (controller.choose(outcome, colorChoice, game)) { + game.informPlayers("Choosen color: " + colorChoice.getColor()); + protectionFilter.add(new ColorPredicate(colorChoice.getColor())); + protectionFilter.setMessage(colorChoice.getChoice()); + ((ProtectionAbility) ability).setFilter(protectionFilter); + return; } - game.informPlayers("Choosen color: " + colorChoice.getColor()); - protectionFilter.add(new ColorPredicate(colorChoice.getColor())); - protectionFilter.setMessage(colorChoice.getChoice()); - ((ProtectionAbility)ability).setFilter(protectionFilter); - return; } discard(); } @@ -102,4 +96,4 @@ public class GainProtectionFromColorSourceEffect extends GainAbilitySourceEffect public String getText(Mode mode) { return "{this} gains protection from the color of your choice " + duration.toString(); } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java index d96a4ed463..140afdbaba 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java @@ -77,18 +77,12 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect MageObject sourceObject = game.getObject(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (sourceObject != null && controller != null) { - if (!choice.isChosen()) { - while (!choice.isChosen()) { - controller.choose(Outcome.Protect, choice, game); - if (!controller.canRespond()) { - return; - } - } - if (choice.isChosen() && !game.isSimulation()) { - game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice()); - } + if (controller.choose(Outcome.Protect, choice, game)) { + game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice()); + return; } } + discard(); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java index 1a19d10848..3036a063d2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java @@ -27,6 +27,8 @@ */ package mage.abilities.effects.common.continuous; +import java.util.HashSet; +import java.util.Set; import mage.abilities.Ability; import mage.abilities.Mode; import mage.choices.ChoiceImpl; @@ -36,9 +38,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.Target; -import java.util.HashSet; -import java.util.Set; - /** * * @author a @@ -88,19 +87,18 @@ public class LoseAbilityOrAnotherAbilityTargetEffect extends LoseAbilityTargetEf Player player = game.getPlayer(source.getControllerId()); if (player.choose(outcome, chooseAbility, game)) { - String chosenAbility = chooseAbility.getChoice(); - if (chosenAbility.equals(ability.getRule())) { while (permanent.getAbilities().contains(ability)) { permanent.getAbilities().remove(ability); } - } - else if (chosenAbility.equals(ability2.getRule())) { + } else if (chosenAbility.equals(ability2.getRule())) { while (permanent.getAbilities().contains(ability2)) { permanent.getAbilities().remove(ability2); } } + } else { + return false; } } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java index dd47a9e0e7..54bc9bbd81 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java @@ -112,10 +112,11 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl { if (controller.choose(Outcome.Benefit, choice, game)) { int reduce = Integer.parseInt(choice.getChoice()); CardUtil.reduceCost(abilityToModify, reduce); + } else { + return false; } } } else { - CardUtil.reduceCost(abilityToModify, this.amount); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java index b50b5adbbb..2a3019a34a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java @@ -45,7 +45,6 @@ import mage.players.Player; import mage.target.Target; import mage.target.common.TargetPermanentOrPlayerWithCounter; - /** * @author nantuko */ @@ -88,13 +87,16 @@ public class ProliferateEffect extends OneShotEffect { } choice.setChoices(choices); choice.setMessage("Choose a counter to proliferate (" + permanent.getIdName() + ')'); - 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()); - permanent.addCounters(newCounter, source, game); - break; + 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()); + permanent.addCounters(newCounter, source, game); + break; + } } + } else { + return false; } } } @@ -115,13 +117,16 @@ public class ProliferateEffect extends OneShotEffect { } choice.setChoices(choices); choice.setMessage("Choose a counter to proliferate (" + player.getLogName() + ')'); - controller.choose(Outcome.Benefit, choice, game); - for (Counter counter : player.getCounters().values()) { - if (counter.getName().equals(choice.getChoice())) { - Counter newCounter = new Counter(counter.getName()); - player.addCounters(newCounter, game); - break; + 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()); + player.addCounters(newCounter, game); + break; + } } + } else { + return false; } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterTargetEffect.java index 458546cf30..0f14f1ef86 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterTargetEffect.java @@ -98,19 +98,22 @@ public class RemoveCounterTargetEffect extends OneShotEffect { if (permanent.getCounters(game).size() > 1) { Choice choice = new ChoiceImpl(true); Set choices = new HashSet<>(); - for (Counter counter : permanent.getCounters(game).values()) { - if (permanent.getCounters(game).getCount(counter.getName()) > 0) { - choices.add(counter.getName()); + for (Counter counterOnPermanent : permanent.getCounters(game).values()) { + if (permanent.getCounters(game).getCount(counterOnPermanent.getName()) > 0) { + choices.add(counterOnPermanent.getName()); } } choice.setChoices(choices); choice.setMessage("Choose a counter type to remove from " + permanent.getName()); - controller.choose(Outcome.Detriment, choice, game); - counterName = choice.getChoice(); + if (controller.choose(Outcome.Detriment, choice, game)) { + counterName = choice.getChoice(); + } else { + return null; + } } else { - for (Counter counter : permanent.getCounters(game).values()) { - if (counter.getCount() > 0) { - counterName = counter.getName(); + for (Counter counterOnPermanent : permanent.getCounters(game).values()) { + if (counterOnPermanent.getCount() > 0) { + counterName = counterOnPermanent.getName(); } } } diff --git a/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java b/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java index ceb9e90a7d..70f7f53400 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java @@ -212,11 +212,8 @@ class ConvokeEffect extends OneShotEffect { if (chooseManaType.getChoices().size() > 1) { chooseManaType.getChoices().add("Colorless"); chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName()); - while (!chooseManaType.isChosen()) { - controller.choose(Outcome.Benefit, chooseManaType, game); - if (!controller.canRespond()) { - return false; - } + if (!controller.choose(Outcome.Benefit, chooseManaType, game)) { + return false; } } else { chooseManaType.setChoice(chooseManaType.getChoices().iterator().next()); @@ -251,9 +248,7 @@ class ConvokeEffect extends OneShotEffect { manaPool.unlockManaType(ManaType.COLORLESS); manaName = "colorless"; } - if (!game.isSimulation()) { - game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana"); - } + game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana"); } } diff --git a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java index 2447bd0c50..5c9f9d2394 100644 --- a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java @@ -143,7 +143,9 @@ class AnyColorLandsProduceManaEffect 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();