GUI, game: added source info in "choose number/amount" dialogs, added auto-choose for single possible value (part of #13638);

This commit is contained in:
Oleg Agafonov 2025-05-17 21:18:45 +04:00
parent 06242496d7
commit e320bf241c
83 changed files with 142 additions and 106 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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) {

View file

@ -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)) {

View file

@ -382,7 +382,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
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;
}

View file

@ -763,7 +763,11 @@ public interface Player extends MageItem, Copyable<Player> {
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

View file

@ -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