From e320bf241c380ec5f41612ea94a1e55e6374933c Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 17 May 2025 21:18:45 +0400 Subject: [PATCH] GUI, game: added source info in "choose number/amount" dialogs, added auto-choose for single possible value (part of #13638); --- .../src/main/java/mage/utils/SystemUtil.java | 2 +- .../ai/ComputerPlayerControllableProxy.java | 6 ++--- .../java/mage/player/ai/ComputerPlayer.java | 10 +++++-- .../mage/player/ai/SimulatedPlayerMCTS.java | 6 ++--- .../src/mage/player/human/HumanPlayer.java | 27 ++++++++++++------- .../src/mage/cards/a/AetherRefinery.java | 2 +- Mage.Sets/src/mage/cards/a/AetherSpike.java | 2 +- .../src/mage/cards/a/AetherbornMarauder.java | 2 +- Mage.Sets/src/mage/cards/b/Bioshift.java | 2 +- .../src/mage/cards/b/ByInvitationOnly.java | 2 +- .../src/mage/cards/c/CemeteryDesecrator.java | 2 +- .../src/mage/cards/c/ChoiceOfDamnations.java | 2 +- .../src/mage/cards/c/ClockworkAvian.java | 2 +- .../src/mage/cards/c/ClockworkBeast.java | 2 +- .../src/mage/cards/c/ClockworkSteed.java | 2 +- .../src/mage/cards/c/ClockworkSwarm.java | 2 +- Mage.Sets/src/mage/cards/c/CullingRitual.java | 2 +- Mage.Sets/src/mage/cards/d/DieYoung.java | 2 +- .../src/mage/cards/d/DiminishingReturns.java | 2 +- Mage.Sets/src/mage/cards/e/EsperTerra.java | 2 +- .../src/mage/cards/e/ExpelTheInterlopers.java | 2 +- .../src/mage/cards/e/ExpertLevelSafe.java | 4 +-- Mage.Sets/src/mage/cards/f/FadeAway.java | 2 +- Mage.Sets/src/mage/cards/f/FatalLore.java | 2 +- Mage.Sets/src/mage/cards/f/Flux.java | 2 +- .../src/mage/cards/f/ForgottenAncient.java | 2 +- .../src/mage/cards/g/GalvanicDischarge.java | 2 +- .../src/mage/cards/g/GlissaSunslayer.java | 2 +- Mage.Sets/src/mage/cards/g/GoblinGame.java | 2 +- .../src/mage/cards/h/HarnessedLightning.java | 2 +- Mage.Sets/src/mage/cards/h/HeartlessAct.java | 2 +- Mage.Sets/src/mage/cards/h/HexParasite.java | 2 +- Mage.Sets/src/mage/cards/h/Holochess.java | 2 +- .../src/mage/cards/i/IllicitAuction.java | 2 +- .../mage/cards/l/LocalizedDestruction.java | 2 +- Mage.Sets/src/mage/cards/m/MagesContest.java | 2 +- Mage.Sets/src/mage/cards/m/MenacingOgre.java | 2 +- .../src/mage/cards/m/MinionOfTheWastes.java | 2 +- Mage.Sets/src/mage/cards/n/NamelessRace.java | 2 +- .../src/mage/cards/n/Necrodominance.java | 2 +- .../src/mage/cards/n/NightshadeAssassin.java | 2 +- Mage.Sets/src/mage/cards/p/PainsReward.java | 8 +++--- .../src/mage/cards/p/PhyrexianProcessor.java | 2 +- .../mage/cards/p/PiaNalaarChiefMechanic.java | 2 +- .../src/mage/cards/p/PlagueOfVermin.java | 2 +- .../src/mage/cards/p/PriceOfBetrayal.java | 4 +-- .../src/mage/cards/r/RampagingAetherhood.java | 2 +- Mage.Sets/src/mage/cards/r/RenderInert.java | 2 +- .../src/mage/cards/r/RitesOfInitiation.java | 2 +- .../src/mage/cards/s/SanctumPrelate.java | 2 +- .../src/mage/cards/s/ScroungingBandar.java | 2 +- Mage.Sets/src/mage/cards/s/ScryingGlass.java | 2 +- .../src/mage/cards/s/ShahOfNaarIsle.java | 2 +- Mage.Sets/src/mage/cards/s/SixyBeast.java | 4 +-- .../src/mage/cards/s/SlipperyBogbonder.java | 2 +- Mage.Sets/src/mage/cards/s/SqueesRevenge.java | 2 +- .../src/mage/cards/s/SuppressionRay.java | 1 + .../src/mage/cards/t/TalionTheKindlyLord.java | 2 +- .../src/mage/cards/t/TemporaryTruce.java | 2 +- .../mage/cards/t/TerritorialAetherkite.java | 2 +- Mage.Sets/src/mage/cards/t/Tetravus.java | 2 +- .../src/mage/cards/t/ThornmantleStriker.java | 2 +- Mage.Sets/src/mage/cards/t/TradeSecrets.java | 4 +-- Mage.Sets/src/mage/cards/t/Truce.java | 2 +- .../cards/v/Vault112SadisticSimulation.java | 2 +- .../src/mage/cards/v/VizkopaConfessor.java | 2 +- Mage.Sets/src/mage/cards/v/Void.java | 2 +- .../src/mage/cards/v/VolcanoHellion.java | 2 +- .../src/mage/cards/w/WheelOfMisfortune.java | 2 +- .../src/mage/cards/w/WheelOfPotential.java | 2 +- .../src/mage/cards/w/WrathOfTheSkies.java | 2 +- .../src/mage/cards/x/XenagosTheReveler.java | 2 +- .../src/mage/cards/y/YusriFortunesFlame.java | 2 +- .../test/cards/control/WillbreakerTest.java | 2 +- .../test/cards/single/ltr/HELIOSOneTest.java | 9 ++++--- .../java/org/mage/test/player/TestPlayer.java | 16 +++++++++-- .../mage/abilities/common/SagaAbility.java | 2 +- .../costs/common/RemoveCounterCost.java | 3 ++- .../ExileCardsFromHandAdjuster.java | 2 +- .../effects/common/DrawCardTargetEffect.java | 2 +- .../java/mage/game/combat/CombatGroup.java | 2 +- Mage/src/main/java/mage/players/Player.java | 6 ++++- .../main/java/mage/players/StubPlayer.java | 4 +-- 83 files changed, 142 insertions(+), 106 deletions(-) diff --git a/Mage.Common/src/main/java/mage/utils/SystemUtil.java b/Mage.Common/src/main/java/mage/utils/SystemUtil.java index 6bb5d7d53d6..408e0b0de29 100644 --- a/Mage.Common/src/main/java/mage/utils/SystemUtil.java +++ b/Mage.Common/src/main/java/mage/utils/SystemUtil.java @@ -448,7 +448,7 @@ public final class SystemUtil { cardName = cardChoice.getChoice(); // amount - int cardAmount = feedbackPlayer.getAmount(1, 100, "How many [" + cardName + "] to add?", game); + int cardAmount = feedbackPlayer.getAmount(1, 100, "How many [" + cardName + "] to add?", null, game); if (cardAmount == 0) { break; } diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayerControllableProxy.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayerControllableProxy.java index ea9981f8264..57e1bc4205b 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayerControllableProxy.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayerControllableProxy.java @@ -276,11 +276,11 @@ public class ComputerPlayerControllableProxy extends ComputerPlayer7 { } @Override - public int getAmount(int min, int max, String message, Game game) { + public int getAmount(int min, int max, String message, Ability source, Game game) { if (isUnderMe(game)) { - return super.getAmount(min, max, message, game); + return super.getAmount(min, max, message, source, game); } else { - return getControllingPlayer(game).getAmount(min, max, message, game); + return getControllingPlayer(game).getAmount(min, max, message, source, game); } } diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 3fb11a77369..ace8620e6b2 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -2368,9 +2368,15 @@ public class ComputerPlayer extends PlayerImpl { @Override // TODO: add AI support with outcome and replace random with min/max - public int getAmount(int min, int max, String message, Game game) { + public int getAmount(int min, int max, String message, Ability source, Game game) { log.debug("getAmount"); - if (min < max && min == 0) { + + // fast calc on nothing to choose + if (min >= max) { + return min; + } + + if (min == 0) { return RandomUtil.nextInt(CardUtil.overflowInc(max, 1)); } return min; diff --git a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java index a7ac9164be1..944d9aa5135 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java +++ b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java @@ -375,11 +375,11 @@ public final class SimulatedPlayerMCTS extends MCTSPlayer { } @Override - public int getAmount(int min, int max, String message, Game game) { + public int getAmount(int min, int max, String message, Ability source, Game game) { if (this.isHuman()) { - return RandomUtil.nextInt(max - min) + min; + return RandomUtil.nextInt(max - min + 1) + min; } - return super.getAmount(min, max, message, game); + return super.getAmount(min, max, message, source, game); } } 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 c50062e7393..c0ab0e728db 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 @@ -2158,28 +2158,37 @@ public class HumanPlayer extends PlayerImpl { } @Override - public int getAmount(int min, int max, String message, Game game) { + public int getAmount(int min, int max, String message, Ability source, Game game) { if (!canCallFeedback(game)) { return min; } + // fast calc on nothing to choose + if (min >= max) { + return min; + } + + int xValue = min; while (canRespond()) { prepareForResponse(game); if (!isExecutingMacro()) { - game.fireGetAmountEvent(playerId, message, min, max); + game.fireGetAmountEvent(playerId, message + CardUtil.getSourceLogName(game, source), min, max); } waitForResponse(game); - if (response.getInteger() != null) { - break; + if (response.getInteger() == null) { + continue; } + + xValue = response.getInteger(); + if (xValue < min || xValue > max) { + continue; + } + + break; } - if (response.getInteger() != null) { - return response.getInteger(); - } else { - return 0; - } + return xValue; } @Override diff --git a/Mage.Sets/src/mage/cards/a/AetherRefinery.java b/Mage.Sets/src/mage/cards/a/AetherRefinery.java index 9cfde0c2518..626fc0e4416 100644 --- a/Mage.Sets/src/mage/cards/a/AetherRefinery.java +++ b/Mage.Sets/src/mage/cards/a/AetherRefinery.java @@ -119,7 +119,7 @@ class AetherRefineryTokenEffect extends OneShotEffect { return true; } int numberToPay = controller.getAmount(1, totalEnergy, - "Pay one or more {E}", game); + "Pay one or more {E}", source, game); Cost cost = new PayEnergyCost(numberToPay); if (cost.pay(source, game, source, source.getControllerId(), true)) { diff --git a/Mage.Sets/src/mage/cards/a/AetherSpike.java b/Mage.Sets/src/mage/cards/a/AetherSpike.java index c4866335ea6..37afa6d57b1 100644 --- a/Mage.Sets/src/mage/cards/a/AetherSpike.java +++ b/Mage.Sets/src/mage/cards/a/AetherSpike.java @@ -68,7 +68,7 @@ class AetherSpikeEffect extends OneShotEffect { } int numberToPay = controller.getAmount( 0, controller.getCountersCount(CounterType.ENERGY), - "How many {E} do you want to pay?", game + "How many {E} do you want to pay?", source, game ); Cost cost = new PayEnergyCost(numberToPay); int numberPaid = 0; diff --git a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java index 0427c19fc49..f3758b29fe7 100644 --- a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java +++ b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java @@ -89,7 +89,7 @@ class AetherbornMarauderEffect extends OneShotEffect { int numberOfCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); int numberToMove = 1; if (numberOfCounters > 1) { - numberToMove = controller.getAmount(0, numberOfCounters, "Choose how many +1/+1 counters to move", game); + numberToMove = controller.getAmount(0, numberOfCounters, "Choose how many +1/+1 counters to move", source, game); } if (numberToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(numberToMove), source, game); diff --git a/Mage.Sets/src/mage/cards/b/Bioshift.java b/Mage.Sets/src/mage/cards/b/Bioshift.java index b7b43ecc093..b9946b01b63 100644 --- a/Mage.Sets/src/mage/cards/b/Bioshift.java +++ b/Mage.Sets/src/mage/cards/b/Bioshift.java @@ -87,7 +87,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { } int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); if (amountCounters > 0) { - int amountToMove = controller.getAmount(0, amountCounters, "Choose how many counters to move", game); + int amountToMove = controller.getAmount(0, amountCounters, "Choose how many counters to move", source, game); if (amountToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), source, game); toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/b/ByInvitationOnly.java b/Mage.Sets/src/mage/cards/b/ByInvitationOnly.java index 6cd8c608653..40c58ee16b0 100644 --- a/Mage.Sets/src/mage/cards/b/ByInvitationOnly.java +++ b/Mage.Sets/src/mage/cards/b/ByInvitationOnly.java @@ -58,7 +58,7 @@ class ByInvitationOnlyEffect extends OneShotEffect { return false; } int number = player.getAmount( - 0, 13, "Choose a number between 0 and 13", game + 0, 13, "Choose a number between 0 and 13", source, game ); return new SacrificeAllEffect( number, StaticFilters.FILTER_PERMANENT_CREATURE diff --git a/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java b/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java index 5ceb53e7acf..8e5a1ada5a7 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java @@ -166,7 +166,7 @@ class CemeteryDesecratorRemoveCountersEffect extends OneShotEffect { remainingCounters -= numCounters; int min = Math.max(0, countersLeftToRemove - remainingCounters); int max = Math.min(countersLeftToRemove, numCounters); - int toRemove = controller.getAmount(min, max, counterName + " counters to remove", game); + int toRemove = controller.getAmount(min, max, counterName + " counters to remove", source, game); // Sanity check in case of GUI bugs/disconnects toRemove = Math.max(toRemove, min); toRemove = Math.min(toRemove, max); diff --git a/Mage.Sets/src/mage/cards/c/ChoiceOfDamnations.java b/Mage.Sets/src/mage/cards/c/ChoiceOfDamnations.java index f313f08d145..df299d2eb0e 100644 --- a/Mage.Sets/src/mage/cards/c/ChoiceOfDamnations.java +++ b/Mage.Sets/src/mage/cards/c/ChoiceOfDamnations.java @@ -74,7 +74,7 @@ class ChoiceOfDamnationsEffect extends OneShotEffect { amount = Math.min(numberPermanents, safeLifeToLost); } else { // Human must choose - amount = targetPlayer.getAmount(0, Integer.MAX_VALUE, "Chooses a number", game); + amount = targetPlayer.getAmount(0, Integer.MAX_VALUE, "Chooses a number", source, game); } Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/c/ClockworkAvian.java b/Mage.Sets/src/mage/cards/c/ClockworkAvian.java index d532799878f..77f3d5787aa 100644 --- a/Mage.Sets/src/mage/cards/c/ClockworkAvian.java +++ b/Mage.Sets/src/mage/cards/c/ClockworkAvian.java @@ -104,7 +104,7 @@ class ClockworkAvianEffect extends OneShotEffect { return false; } int toAdd = player.getAmount( - 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), game + 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), source, game ); return toAdd > 0 && permanent.addCounters( CounterType.P1P0.createInstance(toAdd), source.getControllerId(), diff --git a/Mage.Sets/src/mage/cards/c/ClockworkBeast.java b/Mage.Sets/src/mage/cards/c/ClockworkBeast.java index c091cf4ad66..499f38d6457 100644 --- a/Mage.Sets/src/mage/cards/c/ClockworkBeast.java +++ b/Mage.Sets/src/mage/cards/c/ClockworkBeast.java @@ -101,7 +101,7 @@ class ClockworkBeastEffect extends OneShotEffect { return false; } int toAdd = player.getAmount( - 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), game + 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), source, game ); return toAdd > 0 && permanent.addCounters( CounterType.P1P0.createInstance(toAdd), source.getControllerId(), diff --git a/Mage.Sets/src/mage/cards/c/ClockworkSteed.java b/Mage.Sets/src/mage/cards/c/ClockworkSteed.java index e3c2c117c13..d658e619f68 100644 --- a/Mage.Sets/src/mage/cards/c/ClockworkSteed.java +++ b/Mage.Sets/src/mage/cards/c/ClockworkSteed.java @@ -109,7 +109,7 @@ class ClockworkSteedEffect extends OneShotEffect { return false; } int toAdd = player.getAmount( - 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), game + 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), source, game ); return toAdd > 0 && permanent.addCounters( CounterType.P1P0.createInstance(toAdd), source.getControllerId(), diff --git a/Mage.Sets/src/mage/cards/c/ClockworkSwarm.java b/Mage.Sets/src/mage/cards/c/ClockworkSwarm.java index 8902726f6fb..002b971d144 100644 --- a/Mage.Sets/src/mage/cards/c/ClockworkSwarm.java +++ b/Mage.Sets/src/mage/cards/c/ClockworkSwarm.java @@ -113,7 +113,7 @@ class ClockworkSwarmEffect extends OneShotEffect { return false; } int toAdd = player.getAmount( - 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), game + 0, maxCounters, "Choose how many +1/+0 counters to put on " + permanent.getName(), source, game ); return toAdd > 0 && permanent.addCounters( CounterType.P1P0.createInstance(toAdd), source.getControllerId(), diff --git a/Mage.Sets/src/mage/cards/c/CullingRitual.java b/Mage.Sets/src/mage/cards/c/CullingRitual.java index d6bf290d208..1ba63fdf0da 100644 --- a/Mage.Sets/src/mage/cards/c/CullingRitual.java +++ b/Mage.Sets/src/mage/cards/c/CullingRitual.java @@ -80,7 +80,7 @@ class CullingRitualEffect extends OneShotEffect { } int black = player.getAmount( 0, counter, counter + " permanents were destroyed, " + - "choose the amount of black mana to produce (the rest will be green)", game + "choose the amount of black mana to produce (the rest will be green)", source, game ); Mana mana = new Mana(ManaType.BLACK, black); if (black < counter) { diff --git a/Mage.Sets/src/mage/cards/d/DieYoung.java b/Mage.Sets/src/mage/cards/d/DieYoung.java index 50567d87692..fedc892e9a0 100644 --- a/Mage.Sets/src/mage/cards/d/DieYoung.java +++ b/Mage.Sets/src/mage/cards/d/DieYoung.java @@ -67,7 +67,7 @@ class DieYoungEffect extends OneShotEffect { if (controller != null) { new GetEnergyCountersControllerEffect(2).apply(game, source); int max = controller.getCountersCount(CounterType.ENERGY); - int numberToPayed = controller.getAmount(0, max, "How many energy counters do you like to pay? (maximum = " + max + ')', game); + int numberToPayed = controller.getAmount(0, max, "How many energy counters do you like to pay? (maximum = " + max + ')', source, game); if (numberToPayed > 0) { Cost cost = new PayEnergyCost(numberToPayed); if (cost.pay(source, game, source, source.getControllerId(), true)) { diff --git a/Mage.Sets/src/mage/cards/d/DiminishingReturns.java b/Mage.Sets/src/mage/cards/d/DiminishingReturns.java index d7eb026335d..213a5864f6e 100644 --- a/Mage.Sets/src/mage/cards/d/DiminishingReturns.java +++ b/Mage.Sets/src/mage/cards/d/DiminishingReturns.java @@ -57,7 +57,7 @@ class DiminishingReturnsEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - int amount = player.getAmount(0, 7, "How many cards to draw (up to 7)?", game); + int amount = player.getAmount(0, 7, "How many cards to draw (up to 7)?", source, game); player.drawCards(amount, source, game); } } diff --git a/Mage.Sets/src/mage/cards/e/EsperTerra.java b/Mage.Sets/src/mage/cards/e/EsperTerra.java index bff25970fb1..9397c73f147 100644 --- a/Mage.Sets/src/mage/cards/e/EsperTerra.java +++ b/Mage.Sets/src/mage/cards/e/EsperTerra.java @@ -114,7 +114,7 @@ class EsperTerraEffect extends OneShotEffect { Optional.ofNullable(source.getControllerId()) .map(game::getPlayer) .map(player -> player.getAmount( - 0, 3, "Choose how many lore counters to put on " + token.getIdName(), game + 0, 3, "Choose how many lore counters to put on " + token.getIdName(), source, game )) .filter(amount -> amount > 0) .ifPresent(amount -> token.addCounters(CounterType.LORE.createInstance(amount), source, game)); diff --git a/Mage.Sets/src/mage/cards/e/ExpelTheInterlopers.java b/Mage.Sets/src/mage/cards/e/ExpelTheInterlopers.java index 562fd8d8fc2..6ca1c5a43f4 100644 --- a/Mage.Sets/src/mage/cards/e/ExpelTheInterlopers.java +++ b/Mage.Sets/src/mage/cards/e/ExpelTheInterlopers.java @@ -62,7 +62,7 @@ class ExpelTheInterlopersEffect extends OneShotEffect { } // Choose a number between 0 and 10. - int number = player.getAmount(0, 10, "Choose a number between 0 and 10", game); + int number = player.getAmount(0, 10, "Choose a number between 0 and 10", source, game); game.informPlayers(player.getLogName() + " has chosen the number " + number + "." + CardUtil.getSourceLogName(game, source)); // Destroy all creatures with power greater than or equal to the chosen number. diff --git a/Mage.Sets/src/mage/cards/e/ExpertLevelSafe.java b/Mage.Sets/src/mage/cards/e/ExpertLevelSafe.java index 629216547b3..37a2ff64722 100644 --- a/Mage.Sets/src/mage/cards/e/ExpertLevelSafe.java +++ b/Mage.Sets/src/mage/cards/e/ExpertLevelSafe.java @@ -72,8 +72,8 @@ class ExpertLevelSafeEffect extends OneShotEffect { return false; } - int controllerChoice = controller.getAmount(1, 3, "Choose a number", game); - int opponentChoice = opponent.getAmount(1, 3, "Choose a number", game); + int controllerChoice = controller.getAmount(1, 3, "Choose a number", source, game); + int opponentChoice = opponent.getAmount(1, 3, "Choose a number", source, game); game.informPlayers(controller.getLogName() + " chose " + controllerChoice); game.informPlayers(opponent.getLogName() + " chose " + opponentChoice); diff --git a/Mage.Sets/src/mage/cards/f/FadeAway.java b/Mage.Sets/src/mage/cards/f/FadeAway.java index c8fe2971b65..0299aae8f1e 100644 --- a/Mage.Sets/src/mage/cards/f/FadeAway.java +++ b/Mage.Sets/src/mage/cards/f/FadeAway.java @@ -64,7 +64,7 @@ class FadeAwayEffect extends OneShotEffect { int payAmount = 0; boolean paid = false; while (player.canRespond() && !paid) { - payAmount = player.getAmount(0, creaturesNumber, message, game); + payAmount = player.getAmount(0, creaturesNumber, message, source, game); ManaCostsImpl cost = new ManaCostsImpl<>(); cost.add(new GenericManaCost(payAmount)); cost.clearPaid(); diff --git a/Mage.Sets/src/mage/cards/f/FatalLore.java b/Mage.Sets/src/mage/cards/f/FatalLore.java index b0489701406..73de55ba270 100644 --- a/Mage.Sets/src/mage/cards/f/FatalLore.java +++ b/Mage.Sets/src/mage/cards/f/FatalLore.java @@ -98,7 +98,7 @@ class FatalLoreEffect extends OneShotEffect { if (player == null) { return false; } - int toDraw = player.getAmount(0, 3, "Choose how many cards to draw", game); + int toDraw = player.getAmount(0, 3, "Choose how many cards to draw", source, game); return player.drawCards(toDraw, source, game) > 0; } } diff --git a/Mage.Sets/src/mage/cards/f/Flux.java b/Mage.Sets/src/mage/cards/f/Flux.java index 018843af766..6b58a0ae6f4 100644 --- a/Mage.Sets/src/mage/cards/f/Flux.java +++ b/Mage.Sets/src/mage/cards/f/Flux.java @@ -59,7 +59,7 @@ class FluxEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards?", game); + int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards?", source, game); player.discard(numToDiscard, false, false, source, game); player.drawCards(numToDiscard, source, game); } diff --git a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java index e17e8b49ea1..748b0db0823 100644 --- a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java +++ b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java @@ -107,7 +107,7 @@ class ForgottenAncientEffect extends OneShotEffect { break; } - int amountToMove = controller.getAmount(0, numCounters, "Choose how many counters to move (" + numCounters + " counters remaining.)", game); + int amountToMove = controller.getAmount(0, numCounters, "Choose how many counters to move (" + numCounters + " counters remaining.)", source, game); if (amountToMove == 0) { break; } diff --git a/Mage.Sets/src/mage/cards/g/GalvanicDischarge.java b/Mage.Sets/src/mage/cards/g/GalvanicDischarge.java index 725f42f9893..2f91977e8f3 100644 --- a/Mage.Sets/src/mage/cards/g/GalvanicDischarge.java +++ b/Mage.Sets/src/mage/cards/g/GalvanicDischarge.java @@ -63,7 +63,7 @@ class GalvanicDischargeEffect extends OneShotEffect { return false; } new GetEnergyCountersControllerEffect(3).apply(game, source); - int numberToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), "How many {E} do you like to pay?", game); + int numberToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), "How many {E} do you like to pay?", source, game); if (numberToPay <= 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/g/GlissaSunslayer.java b/Mage.Sets/src/mage/cards/g/GlissaSunslayer.java index 5996a730353..13b5de6d9c4 100644 --- a/Mage.Sets/src/mage/cards/g/GlissaSunslayer.java +++ b/Mage.Sets/src/mage/cards/g/GlissaSunslayer.java @@ -104,7 +104,7 @@ class GlissaSunslayerEffect extends OneShotEffect { permanent.removeCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; permanent.removeCounters(counterName, amount, source, game); diff --git a/Mage.Sets/src/mage/cards/g/GoblinGame.java b/Mage.Sets/src/mage/cards/g/GoblinGame.java index 11586eef0ea..37711f5ff42 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinGame.java +++ b/Mage.Sets/src/mage/cards/g/GoblinGame.java @@ -68,7 +68,7 @@ class GoblinGameEffect extends OneShotEffect { .collect(Collectors.toList()); for (Player player : players) { // TODO: consider changing 1000 to another cap, or even Integer.MAX_VALUE if the Volcano Hellion binary wraparound gets addressed (although hiding over two billions of items would be rather difficult IRL) - numberChosen.put(player.getId(), player.getAmount(1, 1000, "Choose a number of objects to hide.", game)); + numberChosen.put(player.getId(), player.getAmount(1, 1000, "Choose a number of objects to hide.", source, game)); } // get lowest number diff --git a/Mage.Sets/src/mage/cards/h/HarnessedLightning.java b/Mage.Sets/src/mage/cards/h/HarnessedLightning.java index baf4f978f17..02967cf2df6 100644 --- a/Mage.Sets/src/mage/cards/h/HarnessedLightning.java +++ b/Mage.Sets/src/mage/cards/h/HarnessedLightning.java @@ -62,7 +62,7 @@ class HarnessedLightningEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { new GetEnergyCountersControllerEffect(3).apply(game, source); - int numberToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), "How many {E} do you like to pay?", game); + int numberToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), "How many {E} do you like to pay?", source, game); if (numberToPay > 0) { Cost cost = new PayEnergyCost(numberToPay); if (cost.pay(source, game, source, source.getControllerId(), true)) { diff --git a/Mage.Sets/src/mage/cards/h/HeartlessAct.java b/Mage.Sets/src/mage/cards/h/HeartlessAct.java index 8d487fd7fb8..7451941044b 100644 --- a/Mage.Sets/src/mage/cards/h/HeartlessAct.java +++ b/Mage.Sets/src/mage/cards/h/HeartlessAct.java @@ -90,7 +90,7 @@ class HeartlessActEffect extends OneShotEffect { permanent.removeCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; permanent.removeCounters(counterName, amount, source, game); diff --git a/Mage.Sets/src/mage/cards/h/HexParasite.java b/Mage.Sets/src/mage/cards/h/HexParasite.java index 3013430cfd8..6e85c817548 100644 --- a/Mage.Sets/src/mage/cards/h/HexParasite.java +++ b/Mage.Sets/src/mage/cards/h/HexParasite.java @@ -84,7 +84,7 @@ class HexParasiteEffect extends OneShotEffect { permanent.removeCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; permanent.removeCounters(counterName, amount, source, game); diff --git a/Mage.Sets/src/mage/cards/h/Holochess.java b/Mage.Sets/src/mage/cards/h/Holochess.java index 56b60a3f26d..d2199032d9c 100644 --- a/Mage.Sets/src/mage/cards/h/Holochess.java +++ b/Mage.Sets/src/mage/cards/h/Holochess.java @@ -67,7 +67,7 @@ class HolochessEffect extends OneShotEffect { if (player == null || opponent == null) { return false; } - int chosenNumber = player.getAmount(0, 3, "Choose a number between 0 and 3", game); + int chosenNumber = player.getAmount(0, 3, "Choose a number between 0 and 3", source, game); List creaturesControlledByOpponent = game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURES, opponent.getId(), game); if (chosenNumber < creaturesControlledByOpponent.size()) { diff --git a/Mage.Sets/src/mage/cards/i/IllicitAuction.java b/Mage.Sets/src/mage/cards/i/IllicitAuction.java index 454476ca0c8..55dc0df37d4 100644 --- a/Mage.Sets/src/mage/cards/i/IllicitAuction.java +++ b/Mage.Sets/src/mage/cards/i/IllicitAuction.java @@ -89,7 +89,7 @@ class IllicitAuctionEffect extends GainControlTargetEffect { newBid = Math.max(creatureValue % 2, computerLife - 100); } else { if (currentPlayer.canRespond()) { - newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game); + newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", source, game); } } if (newBid > highBid) { diff --git a/Mage.Sets/src/mage/cards/l/LocalizedDestruction.java b/Mage.Sets/src/mage/cards/l/LocalizedDestruction.java index 1c4ad664032..09f9f9c403e 100644 --- a/Mage.Sets/src/mage/cards/l/LocalizedDestruction.java +++ b/Mage.Sets/src/mage/cards/l/LocalizedDestruction.java @@ -88,7 +88,7 @@ class LocalizedDestructionEffect extends OneShotEffect { } int numberToPay = controller.getAmount(1, totalEnergy, - "Pay one or more {E}", game); + "Pay one or more {E}", source, game); Cost cost = new PayEnergyCost(numberToPay); diff --git a/Mage.Sets/src/mage/cards/m/MagesContest.java b/Mage.Sets/src/mage/cards/m/MagesContest.java index 51968f24497..bea7b9b6544 100644 --- a/Mage.Sets/src/mage/cards/m/MagesContest.java +++ b/Mage.Sets/src/mage/cards/m/MagesContest.java @@ -79,7 +79,7 @@ class MagesContestEffect extends OneShotEffect { } } else if (currentPlayer.chooseUse(Outcome.Benefit, winner.getLogName() + " has bet " + highBid + " life. Top the bid?", source, game)) { // Human choose - newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game); + newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", source, game); } if (newBid > highBid) { highBid = newBid; diff --git a/Mage.Sets/src/mage/cards/m/MenacingOgre.java b/Mage.Sets/src/mage/cards/m/MenacingOgre.java index cf3015dbba9..9dc2c800e89 100644 --- a/Mage.Sets/src/mage/cards/m/MenacingOgre.java +++ b/Mage.Sets/src/mage/cards/m/MenacingOgre.java @@ -81,7 +81,7 @@ class MenacingOgreEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - number = player.getAmount(0, 1000, message, game); + number = player.getAmount(0, 1000, message, source, game); numberChosen.put(player, number); } } diff --git a/Mage.Sets/src/mage/cards/m/MinionOfTheWastes.java b/Mage.Sets/src/mage/cards/m/MinionOfTheWastes.java index d0d0188faca..0d3dbdf0a3c 100644 --- a/Mage.Sets/src/mage/cards/m/MinionOfTheWastes.java +++ b/Mage.Sets/src/mage/cards/m/MinionOfTheWastes.java @@ -87,7 +87,7 @@ class MinionOfTheWastesEffect extends ReplacementEffectImpl { if (creature == null || controller == null) { return false; } - int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game); + int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", source, game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source, source.getControllerId(), true)) { return false; diff --git a/Mage.Sets/src/mage/cards/n/NamelessRace.java b/Mage.Sets/src/mage/cards/n/NamelessRace.java index 8f92effeaf1..e5be245a8b1 100644 --- a/Mage.Sets/src/mage/cards/n/NamelessRace.java +++ b/Mage.Sets/src/mage/cards/n/NamelessRace.java @@ -111,7 +111,7 @@ class NamelessRaceEffect extends ReplacementEffectImpl { int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null); int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null); int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife()); - int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game); + int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", source, game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source, source.getControllerId(), true)) { return false; diff --git a/Mage.Sets/src/mage/cards/n/Necrodominance.java b/Mage.Sets/src/mage/cards/n/Necrodominance.java index bd172ea7801..d1551da799c 100644 --- a/Mage.Sets/src/mage/cards/n/Necrodominance.java +++ b/Mage.Sets/src/mage/cards/n/Necrodominance.java @@ -81,7 +81,7 @@ class NecrodominanceEffect extends OneShotEffect { if (controller == null) { return false; } - int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game); + int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", source, game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source, source.getControllerId(), true)) { return false; diff --git a/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java b/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java index e79a9bbf471..e6d5dee8b26 100644 --- a/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java +++ b/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java @@ -88,7 +88,7 @@ class NightshadeAssassinEffect extends OneShotEffect { FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(ObjectColor.BLACK)); int blackCards = controller.getHand().count(filter, source.getControllerId(), source, game); - int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game); + int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", source, game); game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards."); if (cardsToReveal > 0) { TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter); diff --git a/Mage.Sets/src/mage/cards/p/PainsReward.java b/Mage.Sets/src/mage/cards/p/PainsReward.java index 3b8f2a94e65..544e62c6e82 100644 --- a/Mage.Sets/src/mage/cards/p/PainsReward.java +++ b/Mage.Sets/src/mage/cards/p/PainsReward.java @@ -60,7 +60,7 @@ class PainsRewardEffect extends OneShotEffect { playerList.setCurrent(controller.getId()); Player winner = game.getPlayer(controller.getId()); - int highBid = chooseLifeAmountToBid(controller, -1, game); // -1 for start with 0 min big + int highBid = chooseLifeAmountToBid(controller, -1, source, game); // -1 for start with 0 min big game.informPlayers(winner.getLogName() + " has bet " + highBid + " lifes"); Player currentPlayer = playerList.getNextInRange(controller, game); @@ -72,7 +72,7 @@ class PainsRewardEffect extends OneShotEffect { Outcome aiOutcome = (highBid + 1 <= safeLifeToLost) ? Outcome.Benefit : Outcome.Detriment; if (currentPlayer.chooseUse(aiOutcome, text, source, game)) { - int newBid = chooseLifeAmountToBid(currentPlayer, highBid, game); + int newBid = chooseLifeAmountToBid(currentPlayer, highBid, source, game); if (newBid > highBid) { highBid = newBid; winner = currentPlayer; @@ -90,14 +90,14 @@ class PainsRewardEffect extends OneShotEffect { return false; } - private int chooseLifeAmountToBid(Player player, int currentBig, Game game) { + private int chooseLifeAmountToBid(Player player, int currentBig, Ability source, Game game) { int newBid; if (player.isComputer()) { // AI choose newBid = currentBig + 1; } else { // Human choose - newBid = player.getAmount(currentBig + 1, Integer.MAX_VALUE, "Choose amount of life to bid", game); + newBid = player.getAmount(currentBig + 1, Integer.MAX_VALUE, "Choose amount of life to bid", source, game); } return newBid; } diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java b/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java index 011c55daf31..757ff74965b 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java @@ -74,7 +74,7 @@ class PhyrexianProcessorPayLifeEffect extends OneShotEffect { if (controller == null || permanent == null) { return false; } - int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game); + int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", source, game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source, source.getControllerId(), true)) { return false; diff --git a/Mage.Sets/src/mage/cards/p/PiaNalaarChiefMechanic.java b/Mage.Sets/src/mage/cards/p/PiaNalaarChiefMechanic.java index 02b816c6268..59f4a8d8b49 100644 --- a/Mage.Sets/src/mage/cards/p/PiaNalaarChiefMechanic.java +++ b/Mage.Sets/src/mage/cards/p/PiaNalaarChiefMechanic.java @@ -83,7 +83,7 @@ class PiaNalaarChiefMechanicEffect extends OneShotEffect { return false; } int energyToPay = controller.getAmount(1, controller.getCountersCount(CounterType.ENERGY), - "Pay 1 or more {E}", game); + "Pay 1 or more {E}", source, game); if (energyToPay == 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/p/PlagueOfVermin.java b/Mage.Sets/src/mage/cards/p/PlagueOfVermin.java index 267235cc9fd..bf5b72355bf 100644 --- a/Mage.Sets/src/mage/cards/p/PlagueOfVermin.java +++ b/Mage.Sets/src/mage/cards/p/PlagueOfVermin.java @@ -78,7 +78,7 @@ class PlagueOfVerminEffect extends OneShotEffect { currentLifePaid = 0; totalPaidLife = 0; if (currentPlayer.chooseUse(Outcome.AIDontUseIt, "Pay life?", source, game)) { - totalPaidLife = currentPlayer.getAmount(0, controller.getLife(), "Pay how many life?", game); + totalPaidLife = currentPlayer.getAmount(0, controller.getLife(), "Pay how many life?", source, game); if (totalPaidLife > 0) { currentPlayer.loseLife(totalPaidLife, game, source, false); if (payLife.get(currentPlayer.getId()) == null) { diff --git a/Mage.Sets/src/mage/cards/p/PriceOfBetrayal.java b/Mage.Sets/src/mage/cards/p/PriceOfBetrayal.java index bf0d5d6285f..8de18f96784 100644 --- a/Mage.Sets/src/mage/cards/p/PriceOfBetrayal.java +++ b/Mage.Sets/src/mage/cards/p/PriceOfBetrayal.java @@ -88,7 +88,7 @@ class PriceOfBetrayalEffect extends OneShotEffect { permanent.removeCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; permanent.removeCounters(counterName, amount, source, game); @@ -114,7 +114,7 @@ class PriceOfBetrayalEffect extends OneShotEffect { player.loseCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(player.getCountersCount(counterName), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(player.getCountersCount(counterName), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; player.loseCounters(counterName, amount, source, game); diff --git a/Mage.Sets/src/mage/cards/r/RampagingAetherhood.java b/Mage.Sets/src/mage/cards/r/RampagingAetherhood.java index d8c9f5710f7..8f08c10d92c 100644 --- a/Mage.Sets/src/mage/cards/r/RampagingAetherhood.java +++ b/Mage.Sets/src/mage/cards/r/RampagingAetherhood.java @@ -86,7 +86,7 @@ class RampagingAetherhoodEffect extends OneShotEffect { int totalEnergy = controller.getCountersCount(CounterType.ENERGY); if (totalEnergy > 0) { if (controller.chooseUse(Outcome.Benefit, "Pay one or more {E}? Put that many +1/+1 counters on this creature", source, game)) { - int energyToPay = controller.getAmount(1, totalEnergy, "Pay one or more {E}", game); + int energyToPay = controller.getAmount(1, totalEnergy, "Pay one or more {E}", source, game); Cost cost = new PayEnergyCost(energyToPay); if (cost.pay(source, game, source, controller.getId(), true)) { new AddCountersSourceEffect(CounterType.P1P1.createInstance(energyToPay), true).apply(game, source); diff --git a/Mage.Sets/src/mage/cards/r/RenderInert.java b/Mage.Sets/src/mage/cards/r/RenderInert.java index 7a366c9129c..eca89427255 100644 --- a/Mage.Sets/src/mage/cards/r/RenderInert.java +++ b/Mage.Sets/src/mage/cards/r/RenderInert.java @@ -72,7 +72,7 @@ class RenderInertEffect extends OneShotEffect { permanent.removeCounters(counterName, 1, source, game); removed++; } else { - int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", source, game); if (amount > 0) { removed += amount; permanent.removeCounters(counterName, amount, source, game); diff --git a/Mage.Sets/src/mage/cards/r/RitesOfInitiation.java b/Mage.Sets/src/mage/cards/r/RitesOfInitiation.java index 1aa6a77b0cd..f65979a5258 100644 --- a/Mage.Sets/src/mage/cards/r/RitesOfInitiation.java +++ b/Mage.Sets/src/mage/cards/r/RitesOfInitiation.java @@ -56,7 +56,7 @@ class RitesOfInitiationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards at random?", game); + int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards at random?", source, game); player.discard(numToDiscard, true, false, source, game); game.addEffect(new BoostControlledEffect(numToDiscard, 0, Duration.EndOfTurn), source); return true; diff --git a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java index b450095c96c..b98a522b910 100644 --- a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java +++ b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java @@ -62,7 +62,7 @@ class ChooseNumberEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int numberChoice = controller.getAmount(0, Integer.MAX_VALUE, "Choose a number (mana cost to restrict)", game); + int numberChoice = controller.getAmount(0, Integer.MAX_VALUE, "Choose a number (mana cost to restrict)", source, game); game.getState().setValue(source.getSourceId().toString(), numberChoice); Permanent permanent = game.getPermanentEntering(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/s/ScroungingBandar.java b/Mage.Sets/src/mage/cards/s/ScroungingBandar.java index 2f0a7a50c9d..6d9fb216110 100644 --- a/Mage.Sets/src/mage/cards/s/ScroungingBandar.java +++ b/Mage.Sets/src/mage/cards/s/ScroungingBandar.java @@ -78,7 +78,7 @@ class ScroungingBandarEffect extends OneShotEffect { if (fromPermanent != null && toPermanent != null) { int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); if (amountCounters > 0) { - int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game); + int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", source, game); if (amountToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), source, game); toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/s/ScryingGlass.java b/Mage.Sets/src/mage/cards/s/ScryingGlass.java index edd9daa8369..65b680f1f6e 100644 --- a/Mage.Sets/src/mage/cards/s/ScryingGlass.java +++ b/Mage.Sets/src/mage/cards/s/ScryingGlass.java @@ -64,7 +64,7 @@ class ScryingGlassEffect extends OneShotEffect { int amount = 0; if (controller != null && targetOpponent != null) { - amount = controller.getAmount(1, Integer.MAX_VALUE, "Choose a number", game); + amount = controller.getAmount(1, Integer.MAX_VALUE, "Choose a number", source, game); controller.choose(Outcome.Discard, color, game); FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(color.getColor())); diff --git a/Mage.Sets/src/mage/cards/s/ShahOfNaarIsle.java b/Mage.Sets/src/mage/cards/s/ShahOfNaarIsle.java index aab3657c0b0..e4f9acd7e57 100644 --- a/Mage.Sets/src/mage/cards/s/ShahOfNaarIsle.java +++ b/Mage.Sets/src/mage/cards/s/ShahOfNaarIsle.java @@ -101,7 +101,7 @@ class ShahOfNaarIsleEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { - int number = opponent.getAmount(0, 3, "Draw how many cards?", game); + int number = opponent.getAmount(0, 3, "Draw how many cards?", source, game); opponent.drawCards(number, source, game); } } diff --git a/Mage.Sets/src/mage/cards/s/SixyBeast.java b/Mage.Sets/src/mage/cards/s/SixyBeast.java index 8c5bc15a5af..5026543df75 100644 --- a/Mage.Sets/src/mage/cards/s/SixyBeast.java +++ b/Mage.Sets/src/mage/cards/s/SixyBeast.java @@ -67,7 +67,7 @@ class SixyBeastEffect extends OneShotEffect { Permanent permanent = game.getPermanentEntering(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (permanent != null && controller != null) { - int counterAmount = controller.getAmount(0, 6, "Secretly put up to six counters on " + permanent.getName(), game); + int counterAmount = controller.getAmount(0, 6, "Secretly put up to six counters on " + permanent.getName(), source, game); permanent.addCounters(CounterType.P1P1.createInstance(counterAmount), source.getControllerId(), source, game); Player opponent = null; Set opponents = game.getOpponents(source.getControllerId()); @@ -82,7 +82,7 @@ class SixyBeastEffect extends OneShotEffect { } } if (opponent != null) { - int guessedAmount = opponent.getAmount(0, 6, "Guess the number of counters on " + permanent.getName(), game); + int guessedAmount = opponent.getAmount(0, 6, "Guess the number of counters on " + permanent.getName(), source, game); game.informPlayers(opponent.getLogName() + " guessed " + guessedAmount + " as the number of counters on " + permanent.getLogName()); if (counterAmount == guessedAmount) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java b/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java index 09807275293..0dc8d5760ed 100644 --- a/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java +++ b/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java @@ -120,7 +120,7 @@ class SlipperyBogbonderEffect extends OneShotEffect { int num = player.getAmount( 0, entry.getValue().getCount(), "Choose how many " + entry.getKey() - + " counters to remove from " + permanent.getLogName(), game + + " counters to remove from " + permanent.getLogName(), source, game ); counterMap.computeIfAbsent( permanent.getId(), x -> new HashMap<>() diff --git a/Mage.Sets/src/mage/cards/s/SqueesRevenge.java b/Mage.Sets/src/mage/cards/s/SqueesRevenge.java index acdbf4d1fc7..16f731a58a3 100644 --- a/Mage.Sets/src/mage/cards/s/SqueesRevenge.java +++ b/Mage.Sets/src/mage/cards/s/SqueesRevenge.java @@ -53,7 +53,7 @@ class SqueesRevengeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if(player != null) { - int number = player.getAmount(0, Integer.MAX_VALUE, "Choose how many times to flip a coin", game); + int number = player.getAmount(0, Integer.MAX_VALUE, "Choose how many times to flip a coin", source, game); game.informPlayers(player.getLogName() + " chooses " + number + '.'); for(int i = 0; i < number; i++) { if(!player.flipCoin(source, game, true)) { diff --git a/Mage.Sets/src/mage/cards/s/SuppressionRay.java b/Mage.Sets/src/mage/cards/s/SuppressionRay.java index 476e96b6dd7..ddb25bec8de 100644 --- a/Mage.Sets/src/mage/cards/s/SuppressionRay.java +++ b/Mage.Sets/src/mage/cards/s/SuppressionRay.java @@ -114,6 +114,7 @@ class SuppressionRayTargetEffect extends OneShotEffect { int numberToPay = controller.getAmount( 0, maxEnergy, "How many {E} do you like to pay? (" + tappedThisWay.size() + " creature(s) were tapped)", + source, game ); if (numberToPay == 0) { diff --git a/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java b/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java index ba8037a083a..c6d438b3499 100644 --- a/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java +++ b/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java @@ -109,7 +109,7 @@ class TalionTheKindlyLordEffect extends OneShotEffect { if (controller == null) { return true; } - int numberChoice = controller.getAmount(1, 10, "Choose a number.", game); + int numberChoice = controller.getAmount(1, 10, "Choose a number.", source, game); game.getState().setValue("chosenNumber_" + source.getSourceId() + '_' + source.getSourceObjectZoneChangeCounter(), numberChoice); Permanent permanent = game.getPermanentEntering(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/t/TemporaryTruce.java b/Mage.Sets/src/mage/cards/t/TemporaryTruce.java index 10b6092c579..92f9a43e6c6 100644 --- a/Mage.Sets/src/mage/cards/t/TemporaryTruce.java +++ b/Mage.Sets/src/mage/cards/t/TemporaryTruce.java @@ -57,7 +57,7 @@ class TemporaryTruceEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", game); + int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", source, game); player.drawCards(cardsToDraw, source, game); player.gainLife((2 - cardsToDraw) * 2, game, source); } diff --git a/Mage.Sets/src/mage/cards/t/TerritorialAetherkite.java b/Mage.Sets/src/mage/cards/t/TerritorialAetherkite.java index d2fb3427d5a..e582f734ec3 100644 --- a/Mage.Sets/src/mage/cards/t/TerritorialAetherkite.java +++ b/Mage.Sets/src/mage/cards/t/TerritorialAetherkite.java @@ -83,7 +83,7 @@ class TerritorialAetherkiteEffect extends OneShotEffect { } new GetEnergyCountersControllerEffect(2).apply(game, source); int energyToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), - "Pay any amount of {E}", game); + "Pay any amount of {E}", source, game); if (energyToPay == 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/t/Tetravus.java b/Mage.Sets/src/mage/cards/t/Tetravus.java index ee741a58ccc..c7363423ee3 100644 --- a/Mage.Sets/src/mage/cards/t/Tetravus.java +++ b/Mage.Sets/src/mage/cards/t/Tetravus.java @@ -103,7 +103,7 @@ class TetravusCreateTokensEffect extends OneShotEffect { if (countersToRemove == 0) { return false; } - countersToRemove = player.getAmount(0, countersToRemove, "Choose an amount of counters to remove", game); + countersToRemove = player.getAmount(0, countersToRemove, "Choose an amount of counters to remove", source, game); Cost cost = new RemoveCountersSourceCost(CounterType.P1P1.createInstance(countersToRemove)); if (cost.pay(source, game, source, source.getControllerId(), true)) { CreateTokenEffect effect = new CreateTokenEffect(new TetraviteToken(), countersToRemove); diff --git a/Mage.Sets/src/mage/cards/t/ThornmantleStriker.java b/Mage.Sets/src/mage/cards/t/ThornmantleStriker.java index d3be8fdef03..8812ec8c512 100644 --- a/Mage.Sets/src/mage/cards/t/ThornmantleStriker.java +++ b/Mage.Sets/src/mage/cards/t/ThornmantleStriker.java @@ -127,7 +127,7 @@ class ThornmantleStrikerEffect extends OneShotEffect { remainingCounters -= numCounters; int min = Math.max(0, countersLeftToRemove - remainingCounters); int max = Math.min(countersLeftToRemove, numCounters); - int toRemove = controller.getAmount(min, max, counterName + " counters to remove", game); + int toRemove = controller.getAmount(min, max, counterName + " counters to remove", source, game); // Sanity check in case of GUI bugs/disconnects toRemove = Math.max(toRemove, min); toRemove = Math.min(toRemove, max); diff --git a/Mage.Sets/src/mage/cards/t/TradeSecrets.java b/Mage.Sets/src/mage/cards/t/TradeSecrets.java index 97972b6afff..9c08ff879f0 100644 --- a/Mage.Sets/src/mage/cards/t/TradeSecrets.java +++ b/Mage.Sets/src/mage/cards/t/TradeSecrets.java @@ -59,11 +59,11 @@ class TradeSecretsEffect extends OneShotEffect { if (controller != null && targetOpponent != null) { new DrawCardTargetEffect(2).apply(game, source);//The drawcard method would not work immediately - int amountOfCardsToDraw = controller.getAmount(0, 4, message2, game); + int amountOfCardsToDraw = controller.getAmount(0, 4, message2, source, game); new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source); while (targetOpponent.chooseUse(Outcome.AIDontUseIt, message, source, game)) { new DrawCardTargetEffect(2).apply(game, source); - amountOfCardsToDraw = controller.getAmount(0, 4, message2, game); + amountOfCardsToDraw = controller.getAmount(0, 4, message2, source, game); new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/t/Truce.java b/Mage.Sets/src/mage/cards/t/Truce.java index d0b4f90e7b4..7ecc0b5e213 100644 --- a/Mage.Sets/src/mage/cards/t/Truce.java +++ b/Mage.Sets/src/mage/cards/t/Truce.java @@ -57,7 +57,7 @@ class TruceEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", game); + int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", source, game); player.drawCards(cardsToDraw, source, game); player.gainLife((2 - cardsToDraw) * 2, game, source); } diff --git a/Mage.Sets/src/mage/cards/v/Vault112SadisticSimulation.java b/Mage.Sets/src/mage/cards/v/Vault112SadisticSimulation.java index 60292d91034..02267f60dbf 100644 --- a/Mage.Sets/src/mage/cards/v/Vault112SadisticSimulation.java +++ b/Mage.Sets/src/mage/cards/v/Vault112SadisticSimulation.java @@ -92,7 +92,7 @@ class Vault112SadisticSimulationChapterEffect extends OneShotEffect { } int numberToPay = controller.getAmount( 0, controller.getCountersCount(CounterType.ENERGY), - "How many {E} do you like to pay?", game + "How many {E} do you like to pay?", source, game ); if (numberToPay <= 0) { return true; diff --git a/Mage.Sets/src/mage/cards/v/VizkopaConfessor.java b/Mage.Sets/src/mage/cards/v/VizkopaConfessor.java index 698a105056d..a78fb030afc 100644 --- a/Mage.Sets/src/mage/cards/v/VizkopaConfessor.java +++ b/Mage.Sets/src/mage/cards/v/VizkopaConfessor.java @@ -79,7 +79,7 @@ class VizkopaConfessorEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(source.getFirstTarget()); Card sourceCard = game.getCard(source.getSourceId()); if (controller != null && targetPlayer != null && sourceCard != null) { - int payLife = controller.getAmount(0, controller.getLife(),"Pay how many life?", game); + int payLife = controller.getAmount(0, controller.getLife(),"Pay how many life?", source, game); if (payLife > 0) { controller.loseLife(payLife, game, source, false); game.informPlayers(sourceCard.getName() + ": " + controller.getLogName() + " pays " + payLife + " life"); diff --git a/Mage.Sets/src/mage/cards/v/Void.java b/Mage.Sets/src/mage/cards/v/Void.java index 20e380721ef..68aa4acdee2 100644 --- a/Mage.Sets/src/mage/cards/v/Void.java +++ b/Mage.Sets/src/mage/cards/v/Void.java @@ -64,7 +64,7 @@ class VoidEffect extends OneShotEffect { return false; } - int number = controller.getAmount(0, Integer.MAX_VALUE, "Choose a number (mana cost to destroy)", game); + int number = controller.getAmount(0, Integer.MAX_VALUE, "Choose a number (mana cost to destroy)", source, game); game.informPlayers(controller.getLogName() + " chooses " + number + '.'); for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/v/VolcanoHellion.java b/Mage.Sets/src/mage/cards/v/VolcanoHellion.java index c60f48ee61e..5928023abf8 100644 --- a/Mage.Sets/src/mage/cards/v/VolcanoHellion.java +++ b/Mage.Sets/src/mage/cards/v/VolcanoHellion.java @@ -82,7 +82,7 @@ class VolcanoHellionEffect extends OneShotEffect { } } else { //Human choose - amount = controller.getAmount(0, Integer.MAX_VALUE, "Choose the amount of damage to deliver to you and a target creature. The damage can't be prevented.", game); + amount = controller.getAmount(0, Integer.MAX_VALUE, "Choose the amount of damage to deliver to you and a target creature. The damage can't be prevented.", source, game); } if (amount > 0) { diff --git a/Mage.Sets/src/mage/cards/w/WheelOfMisfortune.java b/Mage.Sets/src/mage/cards/w/WheelOfMisfortune.java index 2633aae84db..f349c38ae35 100644 --- a/Mage.Sets/src/mage/cards/w/WheelOfMisfortune.java +++ b/Mage.Sets/src/mage/cards/w/WheelOfMisfortune.java @@ -63,7 +63,7 @@ class WheelOfMisfortuneEffect extends OneShotEffect { if (player == null) { continue; } - playerMap.put(playerId, player.getAmount(0, 1000, "Choose a number", game)); + playerMap.put(playerId, player.getAmount(0, 1000, "Choose a number", source, game)); } for (Map.Entry entry : playerMap.entrySet()) { Player player = game.getPlayer(entry.getKey()); diff --git a/Mage.Sets/src/mage/cards/w/WheelOfPotential.java b/Mage.Sets/src/mage/cards/w/WheelOfPotential.java index 5c32602230a..d4e776f3f76 100644 --- a/Mage.Sets/src/mage/cards/w/WheelOfPotential.java +++ b/Mage.Sets/src/mage/cards/w/WheelOfPotential.java @@ -67,7 +67,7 @@ class WheelOfPotentialEffect extends OneShotEffect { } int numberToPay = controller.getAmount( 0, controller.getCountersCount(CounterType.ENERGY), - "How many {E} do you want to pay?", game + "How many {E} do you want to pay?", source, game ); Cost cost = new PayEnergyCost(numberToPay); int numberPaid = 0; diff --git a/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java b/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java index c8fee5f8ad8..b1418341509 100644 --- a/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java +++ b/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java @@ -68,7 +68,7 @@ class WrathOfTheSkiesEffect extends OneShotEffect { } int numberToPay = controller.getAmount(0, controller.getCountersCount(CounterType.ENERGY), - "Pay any amount of {E}", game); + "Pay any amount of {E}", source, game); Cost cost = new PayEnergyCost(numberToPay); if (cost.pay(source, game, source, source.getControllerId(), true)) { game.getBattlefield() diff --git a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java index b4cbddf703b..dbdc230445c 100644 --- a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java +++ b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java @@ -81,7 +81,7 @@ class XenagosManaEffect extends OneShotEffect { } Mana mana = new Mana(); - int redCount = player.getAmount(0, x, "How much RED mana add to pool? (available: " + x + ", another mana goes to GREEN)?", game); + int redCount = player.getAmount(0, x, "How much RED mana add to pool? (available: " + x + ", another mana goes to GREEN)?", source, game); int greenCount = Math.max(0, x - redCount); mana.setRed(redCount); mana.setGreen(greenCount); diff --git a/Mage.Sets/src/mage/cards/y/YusriFortunesFlame.java b/Mage.Sets/src/mage/cards/y/YusriFortunesFlame.java index 84fe2942424..5b85ce922c9 100644 --- a/Mage.Sets/src/mage/cards/y/YusriFortunesFlame.java +++ b/Mage.Sets/src/mage/cards/y/YusriFortunesFlame.java @@ -69,7 +69,7 @@ class YusriFortunesFlameEffect extends OneShotEffect { if (player == null) { return false; } - int flips = player.getAmount(1, 5, "Choose a number between 1 and 5", game); + int flips = player.getAmount(1, 5, "Choose a number between 1 and 5", source, game); int wins = 0; int losses = 0; for (int i = 0; i < flips; i++) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/control/WillbreakerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/control/WillbreakerTest.java index 25116d90d8c..6fe3fd923c8 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/control/WillbreakerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/control/WillbreakerTest.java @@ -35,7 +35,7 @@ public class WillbreakerTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{B}, Remove", "Silvercoat Lion"); - setChoice(playerA, "X=0"); + //setChoice(playerA, "X=0"); // auto-choose X=0 setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/ltr/HELIOSOneTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/ltr/HELIOSOneTest.java index 61d6e137bba..366176c3c01 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/ltr/HELIOSOneTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/ltr/HELIOSOneTest.java @@ -29,7 +29,7 @@ public class HELIOSOneTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, "Plains", 3); addCard(Zone.BATTLEFIELD, playerA, "Memnite"); - setChoice(playerA, "X=0"); + //setChoice(playerA, "X=0"); // auto-choose X=0 activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{3}"); addTarget(playerA, "Memnite"); @@ -52,7 +52,10 @@ public class HELIOSOneTest extends CardTestPlayerBase { // TODO: So the test suite let's you activate the ability (as it does not go to adjust targets to check them.) // But X=0 is not a valid choice once targets are checked (no nonland card with that MV in play). - setChoice(playerA, "X=0"); + checkPlayableAbility("Pay X {E} ability is playable, but can't be activated", + 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{3}", true); + showAvailableAbilities("hmm", 1, PhaseStep.PRECOMBAT_MAIN, playerA); + //setChoice(playerA, "X=0"); // auto-choose X=0 waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{3}"); addTarget(playerA, "Elite Vanguard"); // not a valid target for X=0 energy payment @@ -65,7 +68,7 @@ public class HELIOSOneTest extends CardTestPlayerBase { } catch (AssertionError e) { Assert.assertTrue( "X=0 is not a valid choice. Error message:\n" + e.getMessage(), - e.getMessage().contains("Message: Announce the value for {X}") + e.getMessage().contains("Can't find ability to activate command: {3}") ); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index f3983b39d03..e79cc0bc719 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -2917,6 +2917,12 @@ public class TestPlayer implements Player { @Override public int announceX(int min, int max, String message, Game game, Ability source, boolean isManaPay) { assertAliasSupportInChoices(false); + + // fast calc on nothing to choose + if (min >= max) { + return min; + } + if (!choices.isEmpty()) { if (choices.get(0).startsWith("X=")) { int xValue = Integer.parseInt(choices.get(0).substring(2)); @@ -2949,8 +2955,14 @@ public class TestPlayer implements Player { } @Override - public int getAmount(int min, int max, String message, Game game) { + public int getAmount(int min, int max, String message, Ability source, Game game) { assertAliasSupportInChoices(false); + + // fast calc on nothing to choose + if (min >= max) { + return min; + } + if (!choices.isEmpty()) { if (choices.get(0).startsWith("X=")) { int xValue = Integer.parseInt(choices.get(0).substring(2)); @@ -2960,7 +2972,7 @@ public class TestPlayer implements Player { } this.chooseStrictModeFailed("choice", game, message); - return computerPlayer.getAmount(min, max, message, game); + return computerPlayer.getAmount(min, max, message, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/SagaAbility.java b/Mage/src/main/java/mage/abilities/common/SagaAbility.java index 72c06a7be6c..803556ae727 100644 --- a/Mage/src/main/java/mage/abilities/common/SagaAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SagaAbility.java @@ -204,7 +204,7 @@ class SagaLoreCountersEffect extends OneShotEffect { } int counters = player.getAmount( 1, maxChapter.getNumber(), - "Choose the number of lore counters to enter with", game + "Choose the number of lore counters to enter with", source, game ); return permanent.addCounters(CounterType.LORE.createInstance(counters), source, game); } 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 15f52b824ad..03c1607a1fb 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java @@ -136,7 +136,8 @@ public class RemoveCounterCost extends CostImpl { int numberOfCountersSelected = 1; if (countersLeft > 1 && countersOnPermanent > 1) { numberOfCountersSelected = controller.getAmount(1, Math.min(countersLeft, countersOnPermanent), - "Choose how many counters (" + counterName + ") to remove from " + targetObject.getLogName() + " as payment", game); + "Choose how many counters (" + counterName + ") to remove from " + targetObject.getLogName() + " as payment", + source, game); } targetObject.removeCounters(counterName, numberOfCountersSelected, source, game); countersRemoved += numberOfCountersSelected; diff --git a/Mage/src/main/java/mage/abilities/costs/costadjusters/ExileCardsFromHandAdjuster.java b/Mage/src/main/java/mage/abilities/costs/costadjusters/ExileCardsFromHandAdjuster.java index 9d9d287eae2..f438ed65c45 100644 --- a/Mage/src/main/java/mage/abilities/costs/costadjusters/ExileCardsFromHandAdjuster.java +++ b/Mage/src/main/java/mage/abilities/costs/costadjusters/ExileCardsFromHandAdjuster.java @@ -40,7 +40,7 @@ public class ExileCardsFromHandAdjuster implements CostAdjuster { // real - need to choose // TODO: need early target cost instead dialog here int toExile = cardCount == 0 ? 0 : player.getAmount( - 0, cardCount, "Choose how many " + filter.getMessage() + " to exile", game + 0, cardCount, "Choose how many " + filter.getMessage() + " to exile", ability, game ); reduceCount = 2 * toExile; if (toExile > 0) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DrawCardTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DrawCardTargetEffect.java index baa6602d9de..210b127ae01 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DrawCardTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DrawCardTargetEffect.java @@ -64,7 +64,7 @@ public class DrawCardTargetEffect extends OneShotEffect { && player.canRespond()) { int cardsToDraw = amount.calculate(game, source, this); if (upTo) { - cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", game); + cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", source, game); } if (!optional || player.chooseUse(outcome, "Use draw effect?", source, game)) { diff --git a/Mage/src/main/java/mage/game/combat/CombatGroup.java b/Mage/src/main/java/mage/game/combat/CombatGroup.java index f7f82fd5377..9940f345875 100644 --- a/Mage/src/main/java/mage/game/combat/CombatGroup.java +++ b/Mage/src/main/java/mage/game/combat/CombatGroup.java @@ -382,7 +382,7 @@ public class CombatGroup implements Serializable, Copyable { break; } int damageAssigned = 0; - damageAssigned = player.getAmount(0, damage, "Assign damage to " + defendingCreature.getName(), game); + damageAssigned = player.getAmount(0, damage, "Assign damage to " + defendingCreature.getName(), null, game); assigned.put(defendingCreature.getId(), damageAssigned); damage -= damageAssigned; } diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index f614a215990..a0bc38d90ff 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -763,7 +763,11 @@ public interface Player extends MageItem, Copyable { void selectBlockers(Ability source, Game game, UUID defendingPlayerId); - int getAmount(int min, int max, String message, Game game); + /** + * + * @param source can be null for system actions like define damage + */ + int getAmount(int min, int max, String message, Ability source, Game game); /** * Player distributes amount among multiple options diff --git a/Mage/src/main/java/mage/players/StubPlayer.java b/Mage/src/main/java/mage/players/StubPlayer.java index da47009b213..d39f65a1444 100644 --- a/Mage/src/main/java/mage/players/StubPlayer.java +++ b/Mage/src/main/java/mage/players/StubPlayer.java @@ -186,8 +186,8 @@ public class StubPlayer extends PlayerImpl { } @Override - public int getAmount(int min, int max, String message, Game game) { - return 0; + public int getAmount(int min, int max, String message, Ability source, Game game) { + return min; } @Override