mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
add logic to make ManaNeededToAvoidNegativeEffect mana a mandatory part of the cost for the AI
This commit is contained in:
@@ -612,17 +612,25 @@ public class ComputerUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cost = manapool.subtractMana(sa, cost);
|
cost = manapool.subtractMana(sa, cost);
|
||||||
//ManaCost testCost = new ManaCost(cost.toString()); // temp variable for testing only
|
|
||||||
if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
||||||
String[] negEffects = card.getSVar("ManaNeededToAvoidNegativeEffect").split(",");
|
String[] negEffects = card.getSVar("ManaNeededToAvoidNegativeEffect").split(",");
|
||||||
|
int amountAdded = 0;
|
||||||
for (int nStr = 0; nStr < negEffects.length; nStr++) {
|
for (int nStr = 0; nStr < negEffects.length; nStr++) {
|
||||||
// convert long color strings to short color strings
|
// convert long color strings to short color strings
|
||||||
if (negEffects[nStr].length() > 1) {
|
if (negEffects[nStr].length() > 1) {
|
||||||
negEffects[nStr] = InputPayManaCostUtil.getShortColorString(negEffects[nStr]);
|
negEffects[nStr] = InputPayManaCostUtil.getShortColorString(negEffects[nStr]);
|
||||||
}
|
}
|
||||||
|
// make mana mandatory for AI
|
||||||
|
if (!cost.isColor(negEffects[nStr])) {
|
||||||
|
cost.combineManaCost(negEffects[nStr]);
|
||||||
|
amountAdded++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cost.setManaNeededToAvoidNegativeEffect(negEffects);
|
cost.setManaNeededToAvoidNegativeEffect(negEffects);
|
||||||
//testCost.setManaNeededToAvoidNegativeEffect(negEffects);
|
//TODO: should it be an error condition if amountAdded is greater than the colorless
|
||||||
|
// in the original cost? (ArsenalNut - 120102)
|
||||||
|
// adjust colorless amount to account for added mana
|
||||||
|
cost.decreaseColorlessMana(amountAdded);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get map of mana abilities
|
// get map of mana abilities
|
||||||
@@ -637,8 +645,6 @@ public class ComputerUtil {
|
|||||||
foundAllSources = false;
|
foundAllSources = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//TODO: Sort colorless sources based on ManaNeededToAvoidNegativeEffect
|
|
||||||
// (ArsenalNut - 111230)
|
|
||||||
String[] shortColors = {"W", "U", "B" , "R", "G"};
|
String[] shortColors = {"W", "U", "B" , "R", "G"};
|
||||||
// loop over cost parts
|
// loop over cost parts
|
||||||
for (int nPart = 0; nPart < costParts.length; nPart++) {
|
for (int nPart = 0; nPart < costParts.length; nPart++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user