mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Fixed AI game freeze on random targets selection (#5023);
This commit is contained in:
parent
b3fb6f047a
commit
688a3fa516
1 changed files with 4 additions and 9 deletions
|
@ -293,22 +293,17 @@ public abstract class TargetImpl implements Target {
|
|||
return false;
|
||||
}
|
||||
|
||||
List<UUID> possibleTargets = new ArrayList<>(possibleTargets(source.getSourceId(), playerId, game));
|
||||
while (!isChosen() && !doneChosing()) {
|
||||
if (!player.canRespond()) {
|
||||
return chosen = targets.size() >= getNumberOfTargets();
|
||||
}
|
||||
chosen = targets.size() >= getNumberOfTargets();
|
||||
if (isRandom()) {
|
||||
Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), playerId, game);
|
||||
if (!possibleTargets.isEmpty()) {
|
||||
int i = 0;
|
||||
int rnd = RandomUtil.nextInt(possibleTargets.size());
|
||||
Iterator it = possibleTargets.iterator();
|
||||
while (i < rnd) {
|
||||
it.next();
|
||||
i++;
|
||||
}
|
||||
this.addTarget(((UUID) it.next()), source, game);
|
||||
int index = RandomUtil.nextInt(possibleTargets.size());
|
||||
this.addTarget(possibleTargets.get(index), source, game);
|
||||
possibleTargets.remove(index);
|
||||
} else {
|
||||
return chosen;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue