mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
checkETBeffects: be a bit less greedy when facing death
This commit is contained in:
@@ -321,7 +321,7 @@ public class AiController {
|
|||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
String pres = cons.getIsPresent();
|
String pres = cons.getIsPresent();
|
||||||
if (pres != null && pres.matches("Card\\.(Strictly)?Self")) {
|
if (pres != null && pres.matches("Card\\.(Strictly)?Self")) {
|
||||||
cons.setIsPresent(null);
|
cons.setIsPresent(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +329,10 @@ public class AiController {
|
|||||||
// These checks only work if the Executing SpellAbility is an Ability_Sub.
|
// These checks only work if the Executing SpellAbility is an Ability_Sub.
|
||||||
if (exSA instanceof AbilitySub && !doTrigger(exSA, false)) {
|
if (exSA instanceof AbilitySub && !doTrigger(exSA, false)) {
|
||||||
// AI would not run this trigger if given the chance
|
// AI would not run this trigger if given the chance
|
||||||
|
if (api == null && card.isCreature() && exSA.usesTargeting() && !exSA.getTargetRestrictions().hasCandidates(exSA) && ComputerUtil.aiLifeInDanger(activatingPlayer, true, 0)) {
|
||||||
|
// trigger will not run due to lack of targets and we desperately need a creature
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3015,6 +3015,7 @@ public class ComputerUtil {
|
|||||||
// call this to determine if it's safe to use a life payment spell
|
// call this to determine if it's safe to use a life payment spell
|
||||||
// or trigger "emergency" strategies such as holding mana for Spike Weaver of Counterspell.
|
// or trigger "emergency" strategies such as holding mana for Spike Weaver of Counterspell.
|
||||||
public static boolean aiLifeInDanger(Player ai, boolean serious, int payment) {
|
public static boolean aiLifeInDanger(Player ai, boolean serious, int payment) {
|
||||||
|
// TODO should also consider them as teams
|
||||||
for (Player opponent: ai.getOpponents()) {
|
for (Player opponent: ai.getOpponents()) {
|
||||||
// test whether the human can kill the ai next turn
|
// test whether the human can kill the ai next turn
|
||||||
Combat combat = new Combat(opponent);
|
Combat combat = new Combat(opponent);
|
||||||
@@ -3035,10 +3036,10 @@ public class ComputerUtil {
|
|||||||
// examples : Black Vise, The Rack, known direct damage spells in enemy hand, etc
|
// examples : Black Vise, The Rack, known direct damage spells in enemy hand, etc
|
||||||
// If added, might need a parameter to define whether we want to check all threats or combat threats.
|
// If added, might need a parameter to define whether we want to check all threats or combat threats.
|
||||||
|
|
||||||
if ((serious) && (ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment))) {
|
if (serious && ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment))) {
|
if (!serious && ComputerUtilCombat.lifeInDanger(ai, combat, payment)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ public class Cost implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends CostPart> T getCostPartByType(Class<T> costType) {
|
public <T extends CostPart> T getCostPartByType(Class<T> costType) {
|
||||||
for (CostPart p : getCostParts()) {
|
for (CostPart p : getCostParts()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user