other: reworked target selection: (#13638)

- WIP: AI and multi targets, human and X=0 use cases, human and impossible targets use cases;
- improved stability and shared logic (related to #13606, #11134, #11666, continue from a53eb66b58, close #13617, close #13613);
- improved test logs and debug info to show more target info on errors;
- improved test framework to support multiple addTarget calls;
- improved test framework to find bad commands order for targets (related to #11666);
- fixed game freezes on auto-choice usages with disconnected or under control players (related to #11285);
- gui, game: fixed that player doesn't mark avatar as selected/green in "up to" targeting;
- gui, game: fixed small font in some popup messages on big screens (related to #969);
- gui, game: added min targets info for target selection dialog;
- for devs: added new cheat option to call and test any game dialog (define own dialogs, targets, etc in HumanDialogsTester);
- for devs: now tests require complete an any or up to target selection by addTarget + TestPlayer.TARGET_SKIP or setChoice + TestPlayer.CHOICE_SKIP (if not all max/possible targets used);
- for devs: added detail targets info for activate/trigger/cast, can be useful to debug unit tests, auto-choose or AI (see DebugUtil.GAME_SHOW_CHOOSE_TARGET_LOGS)
This commit is contained in:
Oleg Agafonov 2025-05-16 13:55:54 +04:00 committed by GitHub
parent 80d62727e1
commit 133e4fe425
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 2737 additions and 743 deletions

View file

@ -24,12 +24,13 @@ public interface Target extends Copyable<Target>, Serializable {
* All targets selected by a player
* <p>
* Warning, for "up to" targets it will return true all the time, so make sure your dialog
* use do-while logic and call "choose" one time min or use doneChoosing
* use do-while logic and call "choose" one time min or use isChoiceCompleted
*/
boolean isChosen(Game game);
// TODO: combine code or research usages (doneChoosing must be in while cycles, isChosen in other places, see #13606)
boolean doneChoosing(Game game);
boolean isChoiceCompleted(Game game);
boolean isChoiceCompleted(UUID abilityControllerId, Ability source, Game game);
void clearChosen();
@ -63,6 +64,9 @@ public interface Target extends Copyable<Target>, Serializable {
*/
Set<UUID> possibleTargets(UUID sourceControllerId, Ability source, Game game);
/**
* Priority method to make a choice from cards and other places, not a player.chooseXXX
*/
boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game);
/**
@ -101,10 +105,19 @@ public interface Target extends Copyable<Target>, Serializable {
Set<UUID> possibleTargets(UUID sourceControllerId, Game game);
@Deprecated // TODO: need replace to source only version?
boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Ability source, Game game);
/**
* Priority method to make a choice from cards and other places, not a player.chooseXXX
*/
default boolean choose(Outcome outcome, UUID playerId, Ability source, Game game) {
return choose(outcome, playerId, source == null ? null : source.getSourceId(), source, game);
}
/**
* Add target from non targeting methods like choose
* TODO: need usage research, looks like there are wrong usage of addTarget, e.g. in choose method (must be add)
*/
void add(UUID id, Game game);