From dffdaad6b559c61deef1156541f77d07922d7438 Mon Sep 17 00:00:00 2001 From: Sloth Date: Thu, 24 Apr 2014 16:12:14 +0000 Subject: [PATCH] - Improved and fixed AI using Ashiok, Nightmare Weaver. --- forge-ai/src/main/java/forge/ai/AiCostDecision.java | 5 ++--- .../src/main/java/forge/ai/ability/ChooseCardAi.java | 12 +++++++++--- .../res/cardsfolder/a/ashiok_nightmare_weaver.txt | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiCostDecision.java b/forge-ai/src/main/java/forge/ai/AiCostDecision.java index 13fe48dae96..889958ed421 100644 --- a/forge-ai/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiCostDecision.java @@ -506,9 +506,8 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito if (c == null) { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { - return null; - } - if (amount.equals("All")) { + c = AbilityUtils.calculateAmount(source, "ChosenX", ability); + } else if (amount.equals("All")) { c = source.getCounters(cost.counter); } else { c = AbilityUtils.calculateAmount(source, amount, ability); diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index f0b1f9b4d30..7b9a65837c4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -87,9 +87,15 @@ public class ChooseCardAi extends SpellAbilityAi { } } else if (logic.equals("Ashiok")) { final int loyalty = host.getCounters(CounterType.LOYALTY) - 1; - host.setSVar("ChosenX", "Number$" + loyalty); - choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone")); - choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host); + for (int i = loyalty; i >= 0; i--) { + host.setSVar("ChosenX", "Number$" + i); + choices = ai.getGame().getCardsIn(choiceZone); + choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host); + if (!choices.isEmpty()) { + return true; + } + } + if (choices.isEmpty()) { return false; } diff --git a/forge-gui/res/cardsfolder/a/ashiok_nightmare_weaver.txt b/forge-gui/res/cardsfolder/a/ashiok_nightmare_weaver.txt index e0483b351af..b3890426db9 100644 --- a/forge-gui/res/cardsfolder/a/ashiok_nightmare_weaver.txt +++ b/forge-gui/res/cardsfolder/a/ashiok_nightmare_weaver.txt @@ -3,7 +3,7 @@ ManaCost:1 U B Types:Planeswalker Ashiok Loyalty:3 A:AB$ Mill | Cost$ AddCounter<2/LOYALTY> | ValidTgts$ Opponent | NumCards$ 3 | Destination$ Exile | Planeswalker$ True | RememberMilled$ True | SpellDescription$ Exile the top three cards of target opponent's library. -A:AB$ ChooseCard | Cost$ SubCounter | References$ X | Choices$ Creature.cmcEQChosenX+IsRemembered | ChoiceZone$ Exile | Planeswalker$ True | SubAbility$ DBChangeZone | SpellDescription$ Put a creature card with converted mana cost X exiled with CARDNAME onto the battlefield under your control. That creature is a Nightmare in addition to its other types. +A:AB$ ChooseCard | Cost$ SubCounter | References$ X | Choices$ Creature.cmcEQChosenX+IsRemembered | ChoiceZone$ Exile | Planeswalker$ True | SubAbility$ DBChangeZone | AILogic$ Ashiok | SpellDescription$ Put a creature card with converted mana cost X exiled with CARDNAME onto the battlefield under your control. That creature is a Nightmare in addition to its other types. SVar:DBChangeZone:DB$ ChangeZone | Defined$ ChosenCard | Origin$ Exile | Destination$ Battlefield | ChangeType$ Creature.cmcEQChosenX+IsRemembered | ChangeNum$ 1 | GainControl$ True | Imprint$ True | SubAbility$ DBAnimate SVar:DBAnimate:DB$ Animate | Defined$ Imprinted | Types$ Nightmare | Permanent$ True | SubAbility$ DBCleanImprint SVar:DBCleanImprint:DB$ Cleanup | ClearImprinted$ True