- Added the new AI function "hasAFogEffect".

This commit is contained in:
Sloth
2014-10-26 15:24:42 +00:00
parent 3da6b32a7b
commit baf0af3a24
2 changed files with 83 additions and 59 deletions

View File

@@ -754,6 +754,9 @@ public class AiBlockController {
// == 1. choose best blocks first ==
makeGoodBlocks(combat);
makeGangBlocks(combat);
// When the AI holds some Fog effect, don't bother about lifeInDanger
if (!ComputerUtil.hasAFogEffect(ai)) {
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
makeTradeBlocks(combat); // choose necessary trade blocks
}
@@ -814,6 +817,7 @@ public class AiBlockController {
// to try to kill the attacker
reinforceBlockersToKill(combat);
}
}
// assign blockers that have to block
chumpBlockers = CardLists.getKeyword(blockersLeft, "CARDNAME blocks each turn if able.");

View File

@@ -999,6 +999,26 @@ public class ComputerUtil {
return false;
}
public static boolean hasAFogEffect(final Player ai) {
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
all.addAll(ai.getCardsActivableInExternalZones(true));
all.addAll(ai.getCardsIn(ZoneType.Hand));
for (final Card c : all) {
for (final SpellAbility sa : c.getSpellAbilities()) {
if (sa.getApi() != ApiType.Fog) {
continue;
}
if (!ComputerUtilCost.canPayCost(sa, ai)) {
continue;
}
return true;
}
}
return false;
}
public static int possibleNonCombatDamage(Player ai) {
int damage = 0;
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));