mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
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:
parent
06242496d7
commit
e320bf241c
83 changed files with 142 additions and 106 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue