mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'ai-exalted' into 'master'
Improve AI considerations for attacking in presence of Exalted Closes #1039 See merge request core-developers/forge!1796
This commit is contained in:
@@ -217,9 +217,22 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Player opp = this.defendingOpponent;
|
final Player opp = this.defendingOpponent;
|
||||||
if (ComputerUtilCombat.damageIfUnblocked(attacker, opp, combat, true) > 0) {
|
|
||||||
return true;
|
// Damage opponent if unblocked
|
||||||
|
final int dmgIfUnblocked = ComputerUtilCombat.damageIfUnblocked(attacker, opp, combat, true);
|
||||||
|
if (dmgIfUnblocked > 0) {
|
||||||
|
boolean onlyIfExalted = false;
|
||||||
|
if (combat.getAttackers().isEmpty() && ai.countExaltedBonus() > 0
|
||||||
|
&& dmgIfUnblocked - ai.countExaltedBonus() == 0) {
|
||||||
|
// Make sure we're not counting on the Exalted bonus when the AI is planning to attack with more than one creature
|
||||||
|
onlyIfExalted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!onlyIfExalted || this.attackers.size() == 1 || this.aiAggression == 6 /* 6 is Exalted attack */) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Poison opponent if unblocked
|
||||||
if (ComputerUtilCombat.poisonIfUnblocked(attacker, opp) > 0) {
|
if (ComputerUtilCombat.poisonIfUnblocked(attacker, opp) > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -234,7 +247,7 @@ public class AiAttackController {
|
|||||||
final CardCollectionView controlledByCompy = ai.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
|
final CardCollectionView controlledByCompy = ai.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
|
||||||
for (final Card c : controlledByCompy) {
|
for (final Card c : controlledByCompy) {
|
||||||
for (final Trigger trigger : c.getTriggers()) {
|
for (final Trigger trigger : c.getTriggers()) {
|
||||||
if (ComputerUtilCombat.combatTriggerWillTrigger(attacker, null, trigger, combat)) {
|
if (ComputerUtilCombat.combatTriggerWillTrigger(attacker, null, trigger, combat, this.attackers)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -769,6 +769,10 @@ public class ComputerUtilCombat {
|
|||||||
*/
|
*/
|
||||||
public static boolean combatTriggerWillTrigger(final Card attacker, final Card defender, final Trigger trigger,
|
public static boolean combatTriggerWillTrigger(final Card attacker, final Card defender, final Trigger trigger,
|
||||||
Combat combat) {
|
Combat combat) {
|
||||||
|
return combatTriggerWillTrigger(attacker, defender, trigger, combat, null);
|
||||||
|
}
|
||||||
|
public static boolean combatTriggerWillTrigger(final Card attacker, final Card defender, final Trigger trigger,
|
||||||
|
Combat combat, final List<Card> plannedAttackers) {
|
||||||
final Game game = attacker.getGame();
|
final Game game = attacker.getGame();
|
||||||
final Map<String, String> trigParams = trigger.getMapParams();
|
final Map<String, String> trigParams = trigger.getMapParams();
|
||||||
boolean willTrigger = false;
|
boolean willTrigger = false;
|
||||||
@@ -815,6 +819,9 @@ public class ComputerUtilCombat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (trigParams.containsKey("Alone") && plannedAttackers != null && plannedAttackers.size() != 1) {
|
||||||
|
return false; // won't trigger since the AI is planning to attack with more than one creature
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// defender == null means unblocked
|
// defender == null means unblocked
|
||||||
|
|||||||
Reference in New Issue
Block a user