mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- 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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user