AI: improved target amount targeting (part of #13638, #13766):

- refactor: migrated AI's target amount code to shared selection logic;
- ai: fixed game freezes on some use cases;
- tests: added AI's testable dialogs for target amount;
- tests: improved load tests result table, added game cycles stats;
- Dwarven Catapult - fixed game error on usage;
This commit is contained in:
Oleg Agafonov 2025-06-20 18:20:50 +04:00
parent 8e7a7e9fc6
commit f3e18e245f
23 changed files with 502 additions and 390 deletions

View file

@ -690,12 +690,8 @@ public class HumanPlayer extends PlayerImpl {
return false;
}
// choose one or multiple permanents
UUID abilityControllerId = playerId;
if (target.getTargetController() != null
&& target.getAbilityController() != null) {
abilityControllerId = target.getAbilityController();
}
// choose one or multiple targets
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
if (options == null) {
options = new HashMap<>();
}
@ -782,11 +778,7 @@ public class HumanPlayer extends PlayerImpl {
}
// choose one or multiple targets
UUID abilityControllerId = playerId;
if (target.getAbilityController() != null) {
abilityControllerId = target.getAbilityController();
}
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
Map<String, Serializable> options = new HashMap<>();
while (canRespond()) {
@ -869,13 +861,7 @@ public class HumanPlayer extends PlayerImpl {
return false;
}
UUID abilityControllerId;
if (target.getTargetController() != null
&& target.getAbilityController() != null) {
abilityControllerId = target.getAbilityController();
} else {
abilityControllerId = playerId;
}
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
while (canRespond()) {
@ -966,13 +952,7 @@ public class HumanPlayer extends PlayerImpl {
return false;
}
UUID abilityControllerId;
if (target.getTargetController() != null
&& target.getAbilityController() != null) {
abilityControllerId = target.getAbilityController();
} else {
abilityControllerId = playerId;
}
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
while (canRespond()) {
boolean required = target.isRequiredExplicitlySet() ? target.isRequired() : target.isRequired(source);
@ -1042,18 +1022,20 @@ public class HumanPlayer extends PlayerImpl {
return false;
}
// nothing to choose
target.prepareAmount(source, game);
if (target.getAmountRemaining() <= 0) {
return false;
}
if (target.getMaxNumberOfTargets() == 0 && target.getMinNumberOfTargets() == 0) {
return false;
}
if (source == null) {
return false;
}
UUID abilityControllerId = playerId;
if (target.getAbilityController() != null) {
abilityControllerId = target.getAbilityController();
}
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
int amountTotal = target.getAmountTotal(game, source);
if (amountTotal == 0) {