mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- The AI will no longer sacrifice the sourcecard of a GainLife ability unless it has 5 or less life.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user