diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 0099a517261..c6d07918ec5 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -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; + } + } diff --git a/forge-gui/res/cardsfolder/p/pox.txt b/forge-gui/res/cardsfolder/p/pox.txt index 55316ae4415..599b0e8e0de 100644 --- a/forge-gui/res/cardsfolder/p/pox.txt +++ b/forge-gui/res/cardsfolder/p/pox.txt @@ -1,7 +1,7 @@ Name:Pox ManaCost:B B B Types:Sorcery -A:SP$ RepeatEach | Cost$ B B B | RepeatPlayers$ Player | RepeatSubAbility$ DBLoseLife | SpellDescription$ Each player loses a third of his or her life, then discards a third of the cards in his or her hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time. +A:SP$ RepeatEach | Cost$ B B B | RepeatPlayers$ Player | RepeatSubAbility$ DBLoseLife | AILifeThreshold$ 1 | SpellDescription$ Each player loses a third of his or her life, then discards a third of the cards in his or her hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time. SVar:DBLoseLife:DB$ LoseLife | LifeAmount$ A | References$ A | Defined$ Player.IsRemembered | SubAbility$ DBDiscard SVar:DBDiscard:DB$ Discard | NumCards$ C | References$ C | Defined$ Player.IsRemembered | Mode$ TgtChoose | SubAbility$ DBCreature SVar:DBCreature:DB$ Sacrifice | SacValid$ Creature | Amount$ E | References$ E | Defined$ Player.IsRemembered | SubAbility$ DBLand diff --git a/forge-gui/res/cardsfolder/s/smallpox.txt b/forge-gui/res/cardsfolder/s/smallpox.txt index e857fd34a2d..6dbd95e89a8 100644 --- a/forge-gui/res/cardsfolder/s/smallpox.txt +++ b/forge-gui/res/cardsfolder/s/smallpox.txt @@ -1,7 +1,7 @@ Name:Smallpox ManaCost:B B Types:Sorcery -A:SP$ LoseLife | Cost$ B B | Defined$ Player | LifeAmount$ 1 | SpellDescription$ Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land. | SubAbility$ DBDiscard +A:SP$ LoseLife | Cost$ B B | Defined$ Player | LifeAmount$ 1 | AILifeThreshold$ 1 | SpellDescription$ Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land. | SubAbility$ DBDiscard SVar:DBDiscard:DB$Discard | NumCards$ 1 | Mode$ TgtChoose | Defined$ Player | SubAbility$ DBSacCreature SVar:DBSacCreature:DB$Sacrifice | SacValid$ Creature | Defined$ Player | SubAbility$ DBSacLand SVar:DBSacLand:DB$Sacrifice | SacValid$ Land | Defined$ Player