- Added a way to specify AILifeThreshold for cards which do not have a life cost but which deal damage or make the player lose life.

- Added AI life activation threshold to Smallpox and Pox to prevent the AI from killing itself with them.
This commit is contained in:
Agetian
2017-01-24 10:38:56 +00:00
parent 6000083a60
commit f292d63c68
3 changed files with 19 additions and 2 deletions

View File

@@ -626,6 +626,9 @@ public class AiController {
public AiPlayDecision canPlaySa(SpellAbility sa) {
final Card card = sa.getHostCard();
if (!checkAiSpecificRestrictions(player, sa)) {
return AiPlayDecision.CantPlayAi;
}
if (sa instanceof WrappedAbility) {
return canPlaySa(((WrappedAbility) sa).getWrappedAbility());
}
@@ -1612,5 +1615,19 @@ public class AiController {
}
return ComputerUtil.chooseSacrificeType(player, type, ability, ability.getTargetCard(), amount);
}
private boolean checkAiSpecificRestrictions(final Player ai, final SpellAbility sa) {
// AI-specific restrictions specified as activation parameters in spell abilities
if (sa.hasParam("AILifeThreshold")) {
System.out.println("threshold");
if (ai.getLife() <= Integer.parseInt(sa.getParam("AILifeThreshold"))) {
return false;
}
}
return true;
}
}