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 dc23c4cdb7c..db861634ebe 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.List; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -274,6 +275,22 @@ public class ChooseCardAi extends SpellAbilityAi { if (ai.equals(sa.getActivatingPlayer())) { choice = ComputerUtilCard.getBestAI(options); } // TODO: improve ai + } else if (logic.equals("Phylactery")) { + CardCollection aiArtifacts = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.ARTIFACTS); + CardCollection indestructibles = CardLists.filter(aiArtifacts, CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE)); + CardCollection nonCreatures = CardLists.filter(aiArtifacts, Predicates.not(Presets.CREATURES)); + CardCollection creatures = CardLists.filter(aiArtifacts, Presets.CREATURES); + if (!indestructibles.isEmpty()) { + // Choose the worst (smallest) indestructible artifact so that the opponent would have to waste + // removal on something unpreferred + choice = ComputerUtilCard.getWorstAI(indestructibles); + } else if (!nonCreatures.isEmpty()) { + // The same as above, but for non-indestructible non-creature artifacts (they can't die in combat) + choice = ComputerUtilCard.getWorstAI(nonCreatures); + } else if (!creatures.isEmpty()) { + // Choose the best (hopefully the fattest, whatever) creature so that hopefully it won't die too easily + choice = ComputerUtilCard.getBestAI(creatures); + } } else { choice = ComputerUtilCard.getBestAI(options); } diff --git a/forge-gui/res/cardsfolder/p/phylactery_lich.txt b/forge-gui/res/cardsfolder/p/phylactery_lich.txt index 58f0915bf74..704f26ae557 100644 --- a/forge-gui/res/cardsfolder/p/phylactery_lich.txt +++ b/forge-gui/res/cardsfolder/p/phylactery_lich.txt @@ -4,7 +4,7 @@ Types:Creature Zombie PT:5/5 K:Indestructible K:ETBReplacement:Other:TrigChooseArtifact -SVar:TrigChooseArtifact:DB$ ChooseCard | Choices$ Artifact.YouCtrl | RememberChosen$ True | SubAbility$ DBPutCounter | SpellDescription$ As CARDNAME enters the battlefield, put a phylactery counter on an artifact you control. +SVar:TrigChooseArtifact:DB$ ChooseCard | Choices$ Artifact.YouCtrl | RememberChosen$ True | SubAbility$ DBPutCounter | AILogic$ Phylactery | SpellDescription$ As CARDNAME enters the battlefield, put a phylactery counter on an artifact you control. SVar:DBPutCounter:DB$ PutCounter | CounterType$ PHYLACTERY | CounterNum$ 1 | Defined$ Remembered | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True T:Mode$ Always | TriggerZones$ Battlefield | IsPresent$ Permanent.counters_GE1_PHYLACTERY+YouCtrl | PresentCompare$ EQ0 | Execute$ TrigSac | TriggerDescription$ When you control no permanents with phylactery counters on them, sacrifice CARDNAME.