mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Fixing issue 8925 - AI has trouble casting spells that create X-toughness creatures. (#8972)
This commit is contained in:
@@ -69,17 +69,20 @@ public class TokenAi extends SpellAbilityAi {
|
||||
|
||||
Card actualToken = spawnToken(ai, sa);
|
||||
|
||||
if (actualToken == null || (actualToken.isCreature() && actualToken.getNetToughness() < 1)) {
|
||||
// planeswalker plus ability or sub-ability is useful
|
||||
return pwPlus || sa.getSubAbility() != null;
|
||||
}
|
||||
|
||||
String tokenAmount = sa.getParamOrDefault("TokenAmount", "1");
|
||||
String tokenPower = sa.getParamOrDefault("TokenPower", actualToken.getBasePowerString());
|
||||
String tokenToughness = sa.getParamOrDefault("TokenToughness", actualToken.getBaseToughnessString());
|
||||
|
||||
// Don't check toughness yet if token has variable P/T based on X
|
||||
boolean tokenHasX = "X".equals(tokenAmount) || "X".equals(tokenPower) || "X".equals(tokenToughness);
|
||||
|
||||
if (!tokenHasX && (actualToken == null || (actualToken.isCreature() && actualToken.getNetToughness() < 1))) {
|
||||
// planeswalker plus ability or sub-ability is useful
|
||||
return pwPlus || sa.getSubAbility() != null;
|
||||
}
|
||||
|
||||
// X-cost spells
|
||||
if ("X".equals(tokenAmount) || "X".equals(tokenPower) || "X".equals(tokenToughness)) {
|
||||
if (tokenHasX) {
|
||||
int x = AbilityUtils.calculateAmount(sa.getHostCard(), tokenAmount, sa);
|
||||
if (source.getSVar("X").equals("Count$Converge")) {
|
||||
x = ComputerUtilMana.getConvergeCount(sa, ai);
|
||||
|
||||
Reference in New Issue
Block a user