mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Improvements in AiBlockController.
This commit is contained in:
@@ -622,18 +622,20 @@ public class AiBlockController {
|
||||
blockers.removeAll(combat.getBlockers(attacker));
|
||||
|
||||
// Try to use safe blockers first
|
||||
safeBlockers = getSafeBlockers(combat, attacker, blockers);
|
||||
for (final Card blocker : safeBlockers) {
|
||||
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
||||
// Add an additional blocker if the current blockers are not
|
||||
// enough and the new one would deal additional damage
|
||||
if (damageNeeded > ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker))
|
||||
&& ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker) > 0
|
||||
&& CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
}
|
||||
blockers.remove(blocker); // Don't check them again next
|
||||
if (blockers.size() > 1) {
|
||||
safeBlockers = getSafeBlockers(combat, attacker, blockers);
|
||||
for (final Card blocker : safeBlockers) {
|
||||
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
||||
// Add an additional blocker if the current blockers are not
|
||||
// enough and the new one would deal additional damage
|
||||
if (damageNeeded > ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker))
|
||||
&& ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker) > 0
|
||||
&& CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
}
|
||||
blockers.remove(blocker); // Don't check them again next
|
||||
}
|
||||
}
|
||||
|
||||
// Try to add blockers that could be destroyed, but are worth less than the attacker
|
||||
@@ -755,28 +757,32 @@ public class AiBlockController {
|
||||
|
||||
// When the AI holds some Fog effect, don't bother about lifeInDanger
|
||||
if (!ComputerUtil.hasAFogEffect(ai)) {
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
lifeInDanger = ComputerUtilCombat.lifeInDanger(ai, combat);
|
||||
if (lifeInDanger) {
|
||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||
}
|
||||
// if life is in danger
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
// if life is still in danger
|
||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
makeChumpBlocks(combat); // choose necessary chump blocks
|
||||
}
|
||||
} else {
|
||||
lifeInDanger = false;
|
||||
}
|
||||
// if life is still in danger
|
||||
// Reinforce blockers blocking attackers with trample if life is still
|
||||
// in danger
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
reinforceBlockersAgainstTrample(combat);
|
||||
}
|
||||
} else {
|
||||
lifeInDanger = false;
|
||||
}
|
||||
// Support blockers not destroying the attacker with more blockers to
|
||||
// try to kill the attacker
|
||||
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
if (!lifeInDanger) {
|
||||
reinforceBlockersToKill(combat);
|
||||
}
|
||||
|
||||
// == 2. If the AI life would still be in danger make a safer approach ==
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
lifeInDanger = true;
|
||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||
// if life is in danger
|
||||
@@ -784,11 +790,15 @@ public class AiBlockController {
|
||||
// choose necessary chump blocks if life is still in danger
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
makeChumpBlocks(combat);
|
||||
} else {
|
||||
lifeInDanger = false;
|
||||
}
|
||||
// Reinforce blockers blocking attackers with trample if life is
|
||||
// still in danger
|
||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||
reinforceBlockersAgainstTrample(combat);
|
||||
} else {
|
||||
lifeInDanger = false;
|
||||
}
|
||||
makeGangBlocks(combat);
|
||||
reinforceBlockersToKill(combat);
|
||||
|
||||
Reference in New Issue
Block a user