mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Improvements and cleanup in AiBlockController.
This commit is contained in:
@@ -199,8 +199,8 @@ public class AiBlockController {
|
|||||||
boolean doNotBlock = false;
|
boolean doNotBlock = false;
|
||||||
for (Card other : attackersLeft) {
|
for (Card other : attackersLeft) {
|
||||||
if (other.equals(attacker) || !CombatUtil.canBlock(other, blocker)
|
if (other.equals(attacker) || !CombatUtil.canBlock(other, blocker)
|
||||||
|| ComputerUtilCombat.canDestroyBlocker(ai, blocker, other, combat, false)
|
|
||||||
|| other.hasKeyword("Trample")
|
|| other.hasKeyword("Trample")
|
||||||
|
|| ComputerUtilCombat.canDestroyBlocker(ai, blocker, other, combat, false)
|
||||||
|| other.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
|
|| other.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -234,6 +234,9 @@ public class AiBlockController {
|
|||||||
for (Card b : blockers) {
|
for (Card b : blockers) {
|
||||||
if (b.hasSVar("SacMe") && Integer.parseInt(b.getSVar("SacMe")) > 3) {
|
if (b.hasSVar("SacMe") && Integer.parseInt(b.getSVar("SacMe")) > 3) {
|
||||||
blocker = b;
|
blocker = b;
|
||||||
|
if (!ComputerUtilCombat.canDestroyAttacker(ai, attacker, blocker, combat, false)) {
|
||||||
|
blockedButUnkilled.add(attacker);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,6 +297,9 @@ public class AiBlockController {
|
|||||||
|| (b.hasStartOfKeyword("Fading") && b.getCounters(CounterType.FADE) == 0)
|
|| (b.hasStartOfKeyword("Fading") && b.getCounters(CounterType.FADE) == 0)
|
||||||
|| b.hasSVar("EndOfTurnLeavePlay")) {
|
|| b.hasSVar("EndOfTurnLeavePlay")) {
|
||||||
blocker = b;
|
blocker = b;
|
||||||
|
if (!ComputerUtilCombat.canDestroyAttacker(ai, attacker, blocker, combat, false)) {
|
||||||
|
blockedButUnkilled.add(attacker);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,7 +389,7 @@ public class AiBlockController {
|
|||||||
&& !ComputerUtilCombat.dealsFirstStrikeDamage(c, false, combat)) {
|
&& !ComputerUtilCombat.dealsFirstStrikeDamage(c, false, combat)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return lifeInDanger || (ComputerUtilCard.evaluateCreature(c) + diff) < ComputerUtilCard.evaluateCreature(attacker);
|
return lifeInDanger || ComputerUtilCard.evaluateCreature(c) + diff < ComputerUtilCard.evaluateCreature(attacker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (usableBlockers.size() < 2) {
|
if (usableBlockers.size() < 2) {
|
||||||
@@ -616,7 +622,7 @@ public class AiBlockController {
|
|||||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
||||||
// Add an additional blocker if the current blockers are not
|
// Add an additional blocker if the current blockers are not
|
||||||
// enough and the new one would deal additional damage
|
// enough and the new one would deal additional damage
|
||||||
if ((damageNeeded > ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker)))
|
if (damageNeeded > ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker))
|
||||||
&& ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker) > 0
|
&& ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker) > 0
|
||||||
&& CombatUtil.canBlock(attacker, blocker, combat)) {
|
&& CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||||
combat.addBlocker(attacker, blocker);
|
combat.addBlocker(attacker, blocker);
|
||||||
@@ -624,10 +630,8 @@ public class AiBlockController {
|
|||||||
blockers.remove(blocker); // Don't check them again next
|
blockers.remove(blocker); // Don't check them again next
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to add blockers that could be destroyed, but are worth less
|
// Try to add blockers that could be destroyed, but are worth less than the attacker
|
||||||
// than the attacker
|
// Don't use blockers without First Strike or Double Strike if attacker has it
|
||||||
// Don't use blockers without First Strike or Double Strike if
|
|
||||||
// attacker has it
|
|
||||||
if (ComputerUtilCombat.dealsFirstStrikeDamage(attacker, false, combat)) {
|
if (ComputerUtilCombat.dealsFirstStrikeDamage(attacker, false, combat)) {
|
||||||
safeBlockers = CardLists.getKeyword(blockers, "First Strike");
|
safeBlockers = CardLists.getKeyword(blockers, "First Strike");
|
||||||
safeBlockers.addAll(CardLists.getKeyword(blockers, "Double Strike"));
|
safeBlockers.addAll(CardLists.getKeyword(blockers, "Double Strike"));
|
||||||
@@ -642,10 +646,10 @@ public class AiBlockController {
|
|||||||
// enough and the new one would deal the remaining damage
|
// enough and the new one would deal the remaining damage
|
||||||
final int currentDamage = ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker));
|
final int currentDamage = ComputerUtilCombat.totalDamageOfBlockers(attacker, combat.getBlockers(attacker));
|
||||||
final int additionalDamage = ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker);
|
final int additionalDamage = ComputerUtilCombat.dealsDamageAsBlocker(attacker, blocker);
|
||||||
if ((damageNeeded > currentDamage)
|
if (damageNeeded > currentDamage
|
||||||
&& !(damageNeeded > (currentDamage + additionalDamage))
|
&& damageNeeded <= currentDamage + additionalDamage
|
||||||
&& ((ComputerUtilCard.evaluateCreature(blocker) + diff) < ComputerUtilCard
|
&& ComputerUtilCard.evaluateCreature(blocker) + diff < ComputerUtilCard.evaluateCreature(attacker)
|
||||||
.evaluateCreature(attacker)) && CombatUtil.canBlock(attacker, blocker, combat)) {
|
&& CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||||
combat.addBlocker(attacker, blocker);
|
combat.addBlocker(attacker, blocker);
|
||||||
blockersLeft.remove(blocker);
|
blockersLeft.remove(blocker);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user