mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Fixed a bug of AI target selection that caused endless loops during build of test project.
This commit is contained in:
parent
96f08cad9c
commit
80d3e6bd9a
3 changed files with 18 additions and 12 deletions
|
|
@ -75,6 +75,8 @@ import java.io.IOException;
|
|||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -1947,10 +1949,14 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
protected List<Permanent> threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List<UUID> targets) {
|
||||
List<Permanent> threats = (playerId == null || sourceId ==null) ?
|
||||
game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game) : // all permanents within the range of the player
|
||||
game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game);
|
||||
|
||||
List<Permanent> threats;
|
||||
if (playerId == null) {
|
||||
threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game); // all permanents within the range of the player
|
||||
} else {
|
||||
FilterPermanent filterCopy = filter.copy();
|
||||
filterCopy.add(new PlayerIdPredicate(playerId));
|
||||
threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game);
|
||||
}
|
||||
Iterator<Permanent> it = threats.iterator();
|
||||
while (it.hasNext()) { // remove permanents already targeted
|
||||
Permanent test = it.next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue