From 6d00a26530cec429df565a658b1f37acaa0c06b0 Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Fri, 26 Mar 2021 14:38:10 +0300 Subject: [PATCH] - Basic logic for Professor Onyx. --- forge-ai/src/main/java/forge/ai/AiController.java | 13 ++++++++++--- .../res/cardsfolder/upcoming/professor_onyx.txt | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 124a4a8e9c4..976989da429 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1102,6 +1102,8 @@ public class AiController { } public CardCollection getCardsToDiscard(int min, final int max, final CardCollection validCards, final SpellAbility sa) { + String logic = sa.getParamOrDefault("AILogic", ""); + if (validCards.size() < min) { return null; } @@ -1111,11 +1113,16 @@ public class AiController { int count = 0; if (sa != null) { sourceCard = sa.getHostCard(); - if ("Always".equals(sa.getParam("AILogic")) && !validCards.isEmpty()) { + if ("Always".equals(logic) && !validCards.isEmpty()) { min = 1; - } else if ("VolrathsShapeshifter".equals(sa.getParam("AILogic"))) { + } else if (logic.startsWith("UnlessAtLife.")) { + int threshold = AbilityUtils.calculateAmount(sourceCard, logic.substring(logic.indexOf(".") + 1), sa); + if (player.getLife() <= threshold) { + min = 1; + } + } else if ("VolrathsShapeshifter".equals(logic)) { return SpecialCardAi.VolrathsShapeshifter.targetBestCreature(player, sa); - } else if ("DiscardCMCX".equals(sa.getParam("AILogic"))) { + } else if ("DiscardCMCX".equals(logic)) { final int cmc = sa.getXManaCostPaid(); CardCollection discards = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(cmc)); if (discards.isEmpty()) { diff --git a/forge-gui/res/cardsfolder/upcoming/professor_onyx.txt b/forge-gui/res/cardsfolder/upcoming/professor_onyx.txt index aaaf99e0b9e..a2d600935b2 100644 --- a/forge-gui/res/cardsfolder/upcoming/professor_onyx.txt +++ b/forge-gui/res/cardsfolder/upcoming/professor_onyx.txt @@ -13,7 +13,7 @@ SVar:DBChooseCard:DB$ ChooseCard | Defined$ Player.IsRemembered | Choices$ Creat SVar:DBSac:DB$ SacrificeAll | ValidCards$ Card.IsRemembered | SubAbility$ DBCleanup | StackDescription$ Each opponent sacrifices a creature with the greatest power among creatures they control. SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearChosen$ True A:AB$ Repeat | Cost$ SubCounter<8/LOYALTY> | Planeswalker$ True | Ultimate$ True | RepeatSubAbility$ TrigDiscard | MaxRepeat$ 7 | StackDescription$ SpellDescription | SpellDescription$ Each opponent may discard a card. If they don't, they lose 3 life. Repeat this process six more times. -SVar:TrigDiscard:DB$ Discard | Defined$ Player.Opponent | Mode$ TgtChoose | Optional$ True | RememberDiscardingPlayers$ True | SubAbility$ DBLoseLife +SVar:TrigDiscard:DB$ Discard | Defined$ Player.Opponent | Mode$ TgtChoose | Optional$ True | RememberDiscardingPlayers$ True | AILogic$ UnlessAtLife.6 | SubAbility$ DBLoseLife SVar:DBLoseLife:DB$ LoseLife | Defined$ Opponent.IsNotRemembered | LifeAmount$ 3 | SubAbility$ DBCleanup DeckHints:Type$Instant|Sorcery DeckHas:Ability$Graveyard & Ability$LifeGain