- Implemented AI for more Converge cards

This commit is contained in:
excessum
2015-10-11 09:31:41 +00:00
parent 94b6f67815
commit 71e417dd8a
7 changed files with 37 additions and 7 deletions

View File

@@ -667,10 +667,26 @@ public class AiController {
if (mana.countX() > 0) {
// Set PayX here to maximum value.
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player);
if (xPay <= 0) {
return AiPlayDecision.CantAffordX;
final Card source = sa.getHostCard();
if (source.hasConverge()) {
card.setSVar("PayX", Integer.toString(0));
int nColors = ComputerUtilMana.getConvergeCount(sa, player);
for (int i = 1; i <= xPay; i++) {
card.setSVar("PayX", Integer.toString(i));
int newColors = ComputerUtilMana.getConvergeCount(sa, player);
if (newColors > nColors) {
nColors = newColors;
} else {
card.setSVar("PayX", Integer.toString(i - 1));
break;
}
}
} else {
if (xPay <= 0) {
return AiPlayDecision.CantAffordX;
}
card.setSVar("PayX", Integer.toString(xPay));
}
card.setSVar("PayX", Integer.toString(xPay));
}
// Check for valid targets before casting

View File

@@ -59,6 +59,18 @@ public class ComputerUtilMana {
return payManaCost(sa, ai, true, extraMana, true);
}
/**
* Return the number of colors used for payment for Converge
*/
public static int getConvergeCount(final SpellAbility sa, final Player ai) {
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, true, 0);
if (payManaCost(cost, sa, ai, true, true)) {
return cost.getSunburst();
} else {
return 0;
}
}
// Does not check if mana sources can be used right now, just checks for potential chance.
public static boolean hasEnoughManaSourcesToCast(final SpellAbility sa, final Player ai) {
sa.setActivatingPlayer(ai);

View File

@@ -29,7 +29,9 @@ public class DamageAllAi extends SpellAbilityAi {
final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
if (damage.equals("X") && sa.getSVar(damage).equals("Count$Converge")) {
dmg = ComputerUtilMana.getConvergeCount(sa, ai);
}
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
// Set PayX here to maximum value.
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);

View File

@@ -235,6 +235,9 @@ public class TokenAi extends SpellAbilityAi {
if (this.tokenAmount.equals("X") || this.tokenPower.equals("X") || this.tokenToughness.equals("X")) {
int x = AbilityUtils.calculateAmount(sa.getHostCard(), this.tokenAmount, sa);
if (source.getSVar("X").equals("Count$Converge")) {
x = ComputerUtilMana.getConvergeCount(sa, ai);
}
if (source.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value.
x = ComputerUtilMana.determineLeftoverMana(sa, ai);

View File

@@ -3,6 +3,5 @@ ManaCost:2 R
Types:Sorcery
A:SP$ DamageAll | Cost$ 2 R | NumDmg$ X | ValidCards$ Creature | ValidDescription$ each creature. | References$ X | SpellDescription$ Converge — CARDNAME deals X damage to each creature, where X is the number of colors of mana spent to cast CARDNAME.
SVar:X:Count$Converge
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/radiant_flames.jpg
Oracle:Converge — Radiant Flames deals X damage to each creature, where X is the number of colors of mana spent to cast Radiant Flames.

View File

@@ -6,6 +6,5 @@ K:Flying
K:etbCounter:P1P1:Y:no Condition:Converge — CARDNAME enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.
SVar:X:Count$xPaid
SVar:Y:Count$Converge
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/skyrider_elf.jpg
Oracle:Flying\nConverge — Skyrider Elf enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.

View File

@@ -3,6 +3,5 @@ ManaCost:3 W
Types:Sorcery
A:SP$ Token | Cost$ 3 W | TokenAmount$ X | References$ X | TokenName$ Kor Ally | TokenTypes$ Creature,Kor,Ally | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | SpellDescription$ Converge — Put a 1/1 white Kor Ally creature token onto the battlefield for each color of mana spent to cast CARDNAME.
SVar:X:Count$Converge
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/unified_front.jpg
Oracle:Converge — Put a 1/1 white Kor Ally creature token onto the battlefield for each color of mana spent to cast Unified Front.