- The AI will now pay Phyrexian mana with life if it can't be payed otherwise and life is above 8.

This commit is contained in:
Sloth
2012-08-29 21:50:21 +00:00
parent 7752d23e2f
commit 5ea0c31e3c

View File

@@ -653,13 +653,12 @@ public class ComputerUtil {
// initialize ArrayList list for mana needed
final ArrayList<ArrayList<AbilityMana>> partSources = new ArrayList<ArrayList<AbilityMana>>();
final ArrayList<Integer> partPriority = new ArrayList<Integer>();
final String[] costParts = cost.toString().replace("X ", "").replace("P", "").split(" ");
final String[] costParts = cost.toString().replace("X ", "").split(" ");
Boolean foundAllSources = findManaSources(manaAbilityMap, partSources, partPriority, costParts);
if (!foundAllSources) {
if (!test) {
// real payment should not arrive here
throw new RuntimeException("ComputerUtil : payManaCost() cost was not paid for "
+ sa.getSourceCard().getName());
throw new RuntimeException("ComputerUtil : payManaCost() cost was not paid for " + sa.getSourceCard());
}
manapool.clearManaPaid(sa, test); // refund any mana taken from mana pool
return false;
@@ -771,14 +770,22 @@ public class ComputerUtil {
break;
}
} // end of mana ability loop
if (!costPart.isPaid() || cost.isPaid()) {
break;
} else {
nPriority++;
}
} // end of cost parts loop
//check for phyrexian mana
if (!cost.isPaid() && cost.containsPhyrexianMana() && AllZone.getComputerPlayer().getLife() > 8) {
cost.payPhyrexian();
if (!test) {
AllZone.getComputerPlayer().payLife(2, sa.getSourceCard());
}
}
manapool.clearManaPaid(sa, test);
// check if paid
if (cost.isPaid()) {
@@ -842,6 +849,14 @@ public class ComputerUtil {
}
}
}
} else if (costParts[nPart].contains("P")) { // Phyrexian
String newPart = costParts[nPart].replace("/P", "");
if (manaAbilityMap.containsKey(newPart)) {
srcFound.addAll(manaAbilityMap.get(newPart));
} else if (AllZone.getComputerPlayer().getLife() > 8) { //Pay with life
partSources.add(nPart, srcFound);
continue;
}
} else if (costParts[nPart].length() > 1) { // Hybrid
final String firstColor = costParts[nPart].substring(0, 1);
final String secondColor = costParts[nPart].substring(2);