- Little improvements in AttachAi.

This commit is contained in:
Sloth
2014-11-05 23:12:53 +00:00
parent c0073f61cf
commit b46c4292b6

View File

@@ -263,7 +263,7 @@ public class AttachAi extends SpellAbilityAi {
targetable.removeAll(aiPlayer.getAllies()); targetable.removeAll(aiPlayer.getAllies());
targetable.remove(aiPlayer); targetable.remove(aiPlayer);
} }
if (targetable.size() > 0) { if (!targetable.isEmpty()) {
// first try get weakest opponent to reduce opponents faster // first try get weakest opponent to reduce opponents faster
if (targetable.contains(aiPlayer.getWeakestOpponent())) { if (targetable.contains(aiPlayer.getWeakestOpponent())) {
return aiPlayer.getWeakestOpponent(); return aiPlayer.getWeakestOpponent();
@@ -282,7 +282,7 @@ public class AttachAi extends SpellAbilityAi {
if (!mandatory) { if (!mandatory) {
targetable.removeAll(aiPlayer.getOpponents()); targetable.removeAll(aiPlayer.getOpponents());
} }
if (targetable.size() > 0) { if (!targetable.isEmpty()) {
// first try self // first try self
if (targetable.contains(aiPlayer)) { if (targetable.contains(aiPlayer)) {
return aiPlayer; return aiPlayer;
@@ -827,13 +827,15 @@ public class AttachAi extends SpellAbilityAi {
// Probably want to "weight" the list by amount of Enchantments and // Probably want to "weight" the list by amount of Enchantments and
// choose the "lightest" // choose the "lightest"
magnetList = CardLists.filter(magnetList, new Predicate<Card>() { List<Card> betterList = CardLists.filter(magnetList, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return CombatUtil.canAttack(c, ai.getWeakestOpponent()); return CombatUtil.canAttack(c, ai.getWeakestOpponent());
} }
}); });
if (!betterList.isEmpty()) {
return ComputerUtilCard.getBestAI(betterList);
}
return ComputerUtilCard.getBestAI(magnetList); return ComputerUtilCard.getBestAI(magnetList);
} }
} }
@@ -1104,7 +1106,7 @@ public class AttachAi extends SpellAbilityAi {
} }
// If there are no preferred cards, and not mandatory bail out // If there are no preferred cards, and not mandatory bail out
if (prefList.size() == 0) { if (prefList.isEmpty()) {
return chooseUnpreferred(mandatory, list); return chooseUnpreferred(mandatory, list);
} }
@@ -1210,7 +1212,8 @@ public class AttachAi extends SpellAbilityAi {
return false; return false;
} }
} else if (keyword.equals("First Strike")) { } else if (keyword.equals("First Strike")) {
if (card.getNetCombatDamage() + powerBonus <= 0 || card.hasKeyword("Double Strike")) { if (card.getNetCombatDamage() + powerBonus <= 0 || card.hasKeyword("Double Strike")
|| (!ComputerUtilCombat.canAttackNextTurn(card) && !CombatUtil.canBlock(card, true))) {
return false; return false;
} }
} else if (keyword.startsWith("Flanking")) { } else if (keyword.startsWith("Flanking")) {