tests: added automated tests to run all possible dialogs under AI (WIP, part of #13643, improved testable dialogs from #13638);

This commit is contained in:
Oleg Agafonov 2025-06-14 16:20:24 +04:00
parent 6ad2cdaa78
commit 361c320890
19 changed files with 555 additions and 107 deletions

View file

@ -32,7 +32,8 @@ class ChooseAmountTestableDialog extends BaseTestableDialog {
public ChooseAmountTestableDialog(boolean isYou, String name, int distributeAmount, int targetsMin, int targetsMax) {
super(String.format("player.chooseTarget(%s, amount)", isYou ? "you" : "AI"),
name,
String.format("%d between %d-%d targets", distributeAmount, targetsMin, targetsMax));
String.format("%d between %d-%d targets", distributeAmount, targetsMin, targetsMax),
new TargetTestableResult());
this.isYou = isYou;
this.distributeAmount = distributeAmount;
this.targetsMin = targetsMin;
@ -40,19 +41,20 @@ class ChooseAmountTestableDialog extends BaseTestableDialog {
}
@Override
public List<String> showDialog(Player player, Ability source, Game game, Player opponent) {
public void showDialog(Player player, Ability source, Game game, Player opponent) {
TargetAmount choosingTarget = new TargetAnyTargetAmount(this.distributeAmount, this.targetsMin, this.targetsMax);
Player choosingPlayer = this.isYou ? player : opponent;
// TODO: add "damage" word in ability text, so chooseTargetAmount an show diff dialog (due inner logic - distribute damage or 1/1)
boolean chooseRes = choosingPlayer.chooseTargetAmount(Outcome.Benefit, choosingTarget, source, game);
List<String> result = new ArrayList<>();
List<String> res = new ArrayList<>();
if (chooseRes) {
Targets.printDebugTargets(getGroup() + " - " + this.getName() + " - " + "TRUE", new Targets(choosingTarget), source, game, result);
Targets.printDebugTargets(getGroup() + " - " + this.getName() + " - " + "TRUE", new Targets(choosingTarget), source, game, res);
} else {
Targets.printDebugTargets(getGroup() + " - " + this.getName() + " - " + "FALSE", new Targets(choosingTarget), source, game, result);
Targets.printDebugTargets(getGroup() + " - " + this.getName() + " - " + "FALSE", new Targets(choosingTarget), source, game, res);
}
return result;
((TargetTestableResult) this.getResult()).save(chooseRes, res, choosingTarget);
}
static public void register(TestableDialogsRunner runner) {