server: fixed game freeze on leaving player before finish target selection (example: Nethergoyf, close #13567, related to #11285)

This commit is contained in:
Oleg Agafonov 2025-05-07 17:27:26 +04:00
parent 99ca1e6029
commit 62aa310a4f
2 changed files with 26 additions and 13 deletions

View file

@ -52,11 +52,17 @@ public class Targets extends ArrayList<Target> implements Copyable<Targets> {
}
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Ability source, Game game) {
if (this.size() > 0) {
if (!canChoose(playerId, source, game)) {
return false;
}
while (!isChosen(game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
return false;
}
if (this.size() > 0 && !this.doneChoosing(game)) {
do {
if (!player.canRespond() || !canChoose(playerId, source, game)) {
return false;
}
Target target = this.getUnchosen(game).get(0);
if (!target.choose(outcome, playerId, sourceId, source, game)) {
return false;
@ -67,13 +73,17 @@ public class Targets extends ArrayList<Target> implements Copyable<Targets> {
}
public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, boolean noMana, Game game, boolean canCancel) {
if (this.size() > 0) {
if (!canChoose(playerId, source, game)) {
return false;
}
Player player = game.getPlayer(playerId);
if (player == null) {
return false;
}
if (this.size() > 0 && !this.doneChoosing(game)) {
do {
if (!player.canRespond() || !canChoose(playerId, source, game)) {
return false;
}
//int state = game.bookmarkState();
while (!isChosen(game)) {
Target target = this.getUnchosen(game).get(0);
UUID targetController = playerId;