mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Implemented AI for more Converge cards
This commit is contained in:
@@ -667,10 +667,26 @@ public class AiController {
|
|||||||
if (mana.countX() > 0) {
|
if (mana.countX() > 0) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player);
|
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player);
|
||||||
if (xPay <= 0) {
|
final Card source = sa.getHostCard();
|
||||||
return AiPlayDecision.CantAffordX;
|
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
|
// Check for valid targets before casting
|
||||||
|
|||||||
@@ -58,6 +58,18 @@ public class ComputerUtilMana {
|
|||||||
public static boolean canPayManaCost(final SpellAbility sa, final Player ai, final int extraMana) {
|
public static boolean canPayManaCost(final SpellAbility sa, final Player ai, final int extraMana) {
|
||||||
return payManaCost(sa, ai, true, extraMana, true);
|
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.
|
// 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) {
|
public static boolean hasEnoughManaSourcesToCast(final SpellAbility sa, final Player ai) {
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ public class DamageAllAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
final String damage = sa.getParam("NumDmg");
|
final String damage = sa.getParam("NumDmg");
|
||||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
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")) {
|
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
if (this.tokenAmount.equals("X") || this.tokenPower.equals("X") || this.tokenToughness.equals("X")) {
|
if (this.tokenAmount.equals("X") || this.tokenPower.equals("X") || this.tokenToughness.equals("X")) {
|
||||||
int x = AbilityUtils.calculateAmount(sa.getHostCard(), this.tokenAmount, sa);
|
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")) {
|
if (source.getSVar("X").equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
x = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
x = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ ManaCost:2 R
|
|||||||
Types:Sorcery
|
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.
|
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:X:Count$Converge
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/radiant_flames.jpg
|
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.
|
Oracle:Converge — Radiant Flames deals X damage to each creature, where X is the number of colors of mana spent to cast Radiant Flames.
|
||||||
|
|||||||
@@ -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.
|
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:X:Count$xPaid
|
||||||
SVar:Y:Count$Converge
|
SVar:Y:Count$Converge
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/skyrider_elf.jpg
|
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.
|
Oracle:Flying\nConverge — Skyrider Elf enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ ManaCost:3 W
|
|||||||
Types:Sorcery
|
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.
|
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:X:Count$Converge
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/unified_front.jpg
|
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.
|
Oracle:Converge — Put a 1/1 white Kor Ally creature token onto the battlefield for each color of mana spent to cast Unified Front.
|
||||||
|
|||||||
Reference in New Issue
Block a user