- The AI will no longer sacrifice the sourcecard of a GainLife ability unless it has 5 or less life.

This commit is contained in:
Sloth
2012-09-16 12:29:43 +00:00
parent 237077eef7
commit 6bd356cb2c
2 changed files with 22 additions and 3 deletions

View File

@@ -326,7 +326,7 @@ public class AbilityFactoryAlterLife {
}
if (abCost != null && life > 5) {
if (!CostUtil.checkSacrificeCost(abCost, source)) {
if (!CostUtil.checkSacrificeCost(abCost, source, false)) {
return false;
}
@@ -348,7 +348,8 @@ public class AbilityFactoryAlterLife {
}
// Don't use lifegain before main 2 if possible
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
&& !params.containsKey("ActivationPhases")) {
return false;
}

View File

@@ -36,7 +36,7 @@ import forge.gui.GuiUtils;
*/
public class CostUtil {
private static Random r = new Random();
/**
* Check sacrifice cost.
*
@@ -47,6 +47,21 @@ public class CostUtil {
* @return true, if successful
*/
public static boolean checkSacrificeCost(final Cost cost, final Card source) {
return checkSacrificeCost(cost, source, true);
}
/**
* Check sacrifice cost.
*
* @param cost
* the cost
* @param source
* the source
* @param important
* is the gain important enough?
* @return true, if successful
*/
public static boolean checkSacrificeCost(final Cost cost, final Card source, final boolean important) {
if (cost == null) {
return true;
}
@@ -57,6 +72,9 @@ public class CostUtil {
final String type = sac.getType();
if (type.equals("CARDNAME")) {
if (!important) {
return false;
}
CardList auras = new CardList(source.getEnchantedBy());
if (!auras.getController(source.getController()).isEmpty()) {
return false;