mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- AI tweak to be a little more aggressive when a burn spell/ability is available.
This commit is contained in:
@@ -422,7 +422,7 @@ public class AiAttackController {
|
||||
}
|
||||
unblockedAttackers.addAll(remainingAttackers);
|
||||
|
||||
if ((ComputerUtilCombat.sumDamageIfUnblocked(remainingAttackers, opp) >= opp.getLife())
|
||||
if (ComputerUtilCombat.sumDamageIfUnblocked(remainingAttackers, opp) + ComputerUtil.possibleNonCombatDamage(ai) >= opp.getLife()
|
||||
&& !((opp.cantLoseForZeroOrLessLife() || ai.cantWin()) && (opp.getLife() < 1))) {
|
||||
return true;
|
||||
}
|
||||
@@ -620,14 +620,13 @@ public class AiAttackController {
|
||||
candidateUnblockedDamage += ComputerUtilCombat.damageIfUnblocked(pCard, opp, null);
|
||||
computerForces += 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// find the potential damage ratio the AI can cause
|
||||
double humanLifeToDamageRatio = 1000000;
|
||||
if (candidateUnblockedDamage > 0) {
|
||||
humanLifeToDamageRatio = (double) opp.getLife() / candidateUnblockedDamage;
|
||||
humanLifeToDamageRatio = (double) (opp.getLife() - ComputerUtil.possibleNonCombatDamage(ai)) / candidateUnblockedDamage;
|
||||
}
|
||||
|
||||
// determine if the ai outnumbers the player
|
||||
|
||||
@@ -1103,10 +1103,47 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} // hasACardGivingHaste
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param ai
|
||||
* @return
|
||||
*/
|
||||
public static int possibleNonCombatDamage(Player ai) {
|
||||
int damage = 0;
|
||||
final List<Card> all = new ArrayList<Card>(ai.getCardsIn(ZoneType.Battlefield));
|
||||
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(ai));
|
||||
all.addAll(ai.getCardsIn(ZoneType.Hand));
|
||||
|
||||
for (final Card c : all) {
|
||||
for (final SpellAbility sa : c.getSpellAbilities()) {
|
||||
if (sa.getApi() != ApiType.DealDamage) {
|
||||
continue;
|
||||
}
|
||||
final String numDam = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), numDam, sa);
|
||||
if (dmg <= damage) {
|
||||
continue;
|
||||
}
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt == null) {
|
||||
continue;
|
||||
}
|
||||
final Player enemy = ai.getOpponent();
|
||||
if (!sa.canTarget(enemy)) {
|
||||
continue;
|
||||
}
|
||||
if (!ComputerUtilCost.canPayCost(sa, ai)) {
|
||||
continue;
|
||||
}
|
||||
damage = dmg;
|
||||
}
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* predictThreatenedObjects.
|
||||
|
||||
Reference in New Issue
Block a user