mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- A little bit better prediction in Lightmine Logic AI for creatures that are forced to attack.
This commit is contained in:
@@ -549,6 +549,7 @@ public class AiAttackController {
|
|||||||
playAggro = ((PlayerControllerAi) ai.getController()).getAi().getProperty(AiProps.PLAY_AGGRO).equals("true");
|
playAggro = ((PlayerControllerAi) ai.getController()).getAi().getProperty(AiProps.PLAY_AGGRO).equals("true");
|
||||||
}
|
}
|
||||||
final boolean bAssault = this.doAssault(ai);
|
final boolean bAssault = this.doAssault(ai);
|
||||||
|
// TODO: detect Lightmine Field by presence of a card with a specific trigger
|
||||||
final boolean lightmineField = ComputerUtilCard.isPresentOnBattlefield(ai.getGame(), "Lightmine Field");
|
final boolean lightmineField = ComputerUtilCard.isPresentOnBattlefield(ai.getGame(), "Lightmine Field");
|
||||||
|
|
||||||
// Determine who will be attacked
|
// Determine who will be attacked
|
||||||
@@ -565,6 +566,7 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attackers that don't really have a choice
|
// Attackers that don't really have a choice
|
||||||
|
int numForcedAttackers = 0;
|
||||||
for (final Card attacker : this.attackers) {
|
for (final Card attacker : this.attackers) {
|
||||||
if (!CombatUtil.canAttack(attacker, defender)) {
|
if (!CombatUtil.canAttack(attacker, defender)) {
|
||||||
attackersLeft.remove(attacker);
|
attackersLeft.remove(attacker);
|
||||||
@@ -591,6 +593,7 @@ public class AiAttackController {
|
|||||||
if (mustAttack || attacker.getController().getMustAttackEntity() != null) {
|
if (mustAttack || attacker.getController().getMustAttackEntity() != null) {
|
||||||
combat.addAttacker(attacker, defender);
|
combat.addAttacker(attacker, defender);
|
||||||
attackersLeft.remove(attacker);
|
attackersLeft.remove(attacker);
|
||||||
|
numForcedAttackers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attackersLeft.isEmpty()) {
|
if (attackersLeft.isEmpty()) {
|
||||||
@@ -603,7 +606,7 @@ public class AiAttackController {
|
|||||||
CardCollection attUnsafe = new CardCollection();
|
CardCollection attUnsafe = new CardCollection();
|
||||||
CardLists.sortByToughnessDesc(attSorted);
|
CardLists.sortByToughnessDesc(attSorted);
|
||||||
|
|
||||||
int i = 0;
|
int i = numForcedAttackers;
|
||||||
int refPowerValue = 0; // Aggro profiles do not account for the possible blockers' power, conservative profiles do.
|
int refPowerValue = 0; // Aggro profiles do not account for the possible blockers' power, conservative profiles do.
|
||||||
|
|
||||||
if (!playAggro && this.blockers.size() > 0) {
|
if (!playAggro && this.blockers.size() > 0) {
|
||||||
@@ -613,11 +616,12 @@ public class AiAttackController {
|
|||||||
// running simulations.
|
// running simulations.
|
||||||
CardCollection blkSorted = new CardCollection(this.blockers);
|
CardCollection blkSorted = new CardCollection(this.blockers);
|
||||||
CardLists.sortByPowerDesc(blkSorted);
|
CardLists.sortByPowerDesc(blkSorted);
|
||||||
refPowerValue = blkSorted.get(0).getCurrentPower();
|
refPowerValue += blkSorted.get(0).getCurrentPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card cre : attSorted) {
|
for (Card cre : attSorted) {
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i + refPowerValue >= cre.getCurrentToughness()) {
|
if (i + refPowerValue >= cre.getCurrentToughness()) {
|
||||||
attUnsafe.add(cre);
|
attUnsafe.add(cre);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class ComputerUtilCombat {
|
|||||||
|
|
||||||
if (!attacked.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
if (!attacked.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||||
// ask ReplacementDamage directly
|
// ask ReplacementDamage directly
|
||||||
if (ComputerUtilCombat.isCombatDamagePrevented(attacker, attacked, damage)) {
|
if (isCombatDamagePrevented(attacker, attacked, damage)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2407,7 +2407,7 @@ public class ComputerUtilCombat {
|
|||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static boolean isCombatDamagePrevented(final Card attacker, final GameEntity target, final int damage) {
|
public final static boolean isCombatDamagePrevented(final Card attacker, final GameEntity target, final int damage) {
|
||||||
final Game game = attacker.getGame();
|
final Game game = attacker.getGame();
|
||||||
|
|
||||||
// first try to replace the damage
|
// first try to replace the damage
|
||||||
|
|||||||
Reference in New Issue
Block a user