From 44aed6b85d3434cb77868246232aefe24d3ee35d Mon Sep 17 00:00:00 2001 From: Sloth Date: Mon, 22 Sep 2014 07:25:46 +0000 Subject: [PATCH] - Added AI support for Duneblast. --- .../java/forge/ai/ability/ChooseCardAi.java | 29 +++++++++++++++++++ forge-gui/res/cardsfolder/d/duneblast.txt | 3 +- 2 files changed, 30 insertions(+), 2 deletions(-) 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 6e4ef77dc89..9deb79b7e8e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -105,6 +105,25 @@ public class ChooseCardAi extends SpellAbilityAi { if (CardLists.getValidCards(choices, "Card.nonLand", host.getController(), host).isEmpty()) { return false; } + } else if (logic.equals("Duneblast")) { + List aiCreatures = ai.getCreaturesInPlay(); + List oppCreatures = ai.getOpponent().getCreaturesInPlay(); + aiCreatures = CardLists.getNotKeyword(aiCreatures, "Indestructible"); + oppCreatures = CardLists.getNotKeyword(oppCreatures, "Indestructible"); + + // Use it as a wrath, when the human creatures threat the ai's life + if (aiCreatures.isEmpty() && ComputerUtilCombat.sumDamageIfUnblocked(oppCreatures, ai) >= ai.getLife()) { + return true; + } + + Card chosen = ComputerUtilCard.getBestCreatureAI(aiCreatures); + aiCreatures.remove(chosen); + int minGain = 200; + + if ((ComputerUtilCard.evaluateCreatureList(aiCreatures) + minGain) >= ComputerUtilCard + .evaluateCreatureList(oppCreatures)) { + return false; + } } } @@ -204,6 +223,16 @@ public class ChooseCardAi extends SpellAbilityAi { } else { choice = ComputerUtilCard.getWorstPermanentAI(options, false, false, false, false); } + } else if (logic.equals("Duneblast")) { + List aiCreatures = ai.getCreaturesInPlay(); + aiCreatures = CardLists.getNotKeyword(aiCreatures, "Indestructible"); + + if (aiCreatures.isEmpty()) { + return null; + } + + Card chosen = ComputerUtilCard.getBestCreatureAI(aiCreatures); + return chosen; } else { choice = ComputerUtilCard.getBestAI(options); } diff --git a/forge-gui/res/cardsfolder/d/duneblast.txt b/forge-gui/res/cardsfolder/d/duneblast.txt index 46f0df551ea..81f460cccf5 100644 --- a/forge-gui/res/cardsfolder/d/duneblast.txt +++ b/forge-gui/res/cardsfolder/d/duneblast.txt @@ -1,9 +1,8 @@ Name:Duneblast ManaCost:4 W B G Types:Sorcery -A:SP$ ChooseCard | Cost$ 4 W G B | Defined$ You | Amount$ 1 | Choices$ Creature | ChoiceTitle$ Choose a creature | SubAbility$ DBDestroyAll | RememberChosen$ True | SpellDescription$ Choose up to one creature. Destroy the rest. +A:SP$ ChooseCard | Cost$ 4 W G B | Defined$ You | Amount$ 1 | Choices$ Creature | ChoiceTitle$ Choose a creature | AILogic$ Duneblast | SubAbility$ DBDestroyAll | RememberChosen$ True | SpellDescription$ Choose up to one creature. Destroy the rest. SVar:DBDestroyAll:DB$ DestroyAll | ValidCards$ Creature.IsNotRemembered | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True -SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/duneblast.jpg Oracle:Choose up to one creature. Destroy the rest. \ No newline at end of file