mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Improved Drain Life AI logic.
This commit is contained in:
@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.ai.*;
|
import forge.ai.*;
|
||||||
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.GameObject;
|
import forge.game.GameObject;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
@@ -742,8 +743,13 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
Player opponent = ai.getOpponents().min(PlayerPredicates.compareByLife());
|
Player opponent = ai.getOpponents().min(PlayerPredicates.compareByLife());
|
||||||
|
|
||||||
// TODO: somehow account for the possible cost reduction?
|
// TODO: somehow account for the possible cost reduction?
|
||||||
int xColorRemaining = ComputerUtilMana.determineLeftoverMana(sa, ai, saTgt.getParam("XColor"));
|
int dmg = ComputerUtilMana.determineLeftoverMana(sa, ai, saTgt.getParam("XColor"));
|
||||||
int dmg = xColorRemaining - saTgt.getPayCosts().getTotalMana().getCMC(); // otherwise AI incorrectly calculates mana it can afford
|
|
||||||
|
while (!ComputerUtilMana.canPayManaCost(sa, ai, dmg)) {
|
||||||
|
// TODO: ideally should never get here, currently put here as a precaution for complex mana base cases where the miscalculation might occur. Will remove later if it proves to never trigger.
|
||||||
|
System.out.println("Warning: AI could not pay mana cost for a XLifeDrain logic spell. Reducing X value to "+dmg);
|
||||||
|
dmg--;
|
||||||
|
}
|
||||||
|
|
||||||
// set the color map for black X for the purpose of Soul Burn
|
// set the color map for black X for the purpose of Soul Burn
|
||||||
// TODO: somehow generalize this calculation to allow other potential similar cards to function in the future
|
// TODO: somehow generalize this calculation to allow other potential similar cards to function in the future
|
||||||
|
|||||||
Reference in New Issue
Block a user