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

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