mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
AI, combat: fixed that computer blocking an attacker by biggest creature instead optimal;
refactor: fixed that Defiant Vanguard depends on debug data;
This commit is contained in:
parent
138788659a
commit
f4572faf8b
5 changed files with 48 additions and 30 deletions
|
|
@ -909,6 +909,7 @@ public class ComputerPlayer6 extends ComputerPlayer {
|
|||
List<Permanent> blockers = entry.getValue();
|
||||
if (blockers != null) {
|
||||
for (Permanent blocker : blockers) {
|
||||
// TODO: buggy or miss on multi blocker requirements?!
|
||||
player.declareBlocker(player.getId(), blocker.getId(), attackerId, game);
|
||||
blocked = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,28 +83,17 @@ public final class CombatUtil {
|
|||
}
|
||||
|
||||
public static void sortByPower(List<Permanent> permanents, final boolean ascending) {
|
||||
Collections.sort(permanents, new Comparator<Permanent>() {
|
||||
@Override
|
||||
public int compare(Permanent o1, Permanent o2) {
|
||||
if (ascending) {
|
||||
return o1.getPower().getValue() - o2.getPower().getValue();
|
||||
} else {
|
||||
return o2.getPower().getValue() - o1.getPower().getValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
permanents.sort(Comparator.comparingInt(p -> p.getPower().getValue()));
|
||||
if (!ascending) {
|
||||
Collections.reverse(permanents);
|
||||
}
|
||||
}
|
||||
|
||||
public static Permanent getWorstCreature(List<Permanent> creatures) {
|
||||
if (creatures.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Collections.sort(creatures, new Comparator<Permanent>() {
|
||||
@Override
|
||||
public int compare(Permanent o1, Permanent o2) {
|
||||
return o2.getPower().getValue() - o1.getPower().getValue();
|
||||
}
|
||||
});
|
||||
creatures.sort(Comparator.comparingInt(p -> p.getPower().getValue()));
|
||||
return creatures.get(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue