From 9708019f7e95c22dadb5df6e176faada2c1134fe Mon Sep 17 00:00:00 2001 From: Hanmac Date: Tue, 2 Aug 2016 12:07:29 +0000 Subject: [PATCH] ComputerUtil: updated chooseSomeType to use better check with removing invalid types first. --- .../src/main/java/forge/ai/ComputerUtil.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 4fc3a0bacd0..caf1959165a 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -1745,25 +1745,29 @@ public class ComputerUtil { chosen = "Creature"; } } else if (kindOfType.equals("Creature")) { - Player opp = ai.getOpponent(); if (logic != null) { + List valid = CardType.getAllCreatureTypes(); + valid.removeAll(invalidTypes); + if (logic.equals("MostProminentOnBattlefield")) { - chosen = ComputerUtilCard.getMostProminentCreatureType(game.getCardsIn(ZoneType.Battlefield)); + chosen = ComputerUtilCard.getMostProminentType(game.getCardsIn(ZoneType.Battlefield), valid); } else if (logic.equals("MostProminentComputerControls")) { - chosen = ComputerUtilCard.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Battlefield)); + chosen = ComputerUtilCard.getMostProminentType(ai.getCardsIn(ZoneType.Battlefield), valid); } - else if (logic.equals("MostProminentHumanControls")) { - chosen = ComputerUtilCard.getMostProminentCreatureType(opp.getCardsIn(ZoneType.Battlefield)); + else if (logic.equals("MostProminentOppControls")) { + CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents()); + chosen = ComputerUtilCard.getMostProminentType(list, valid); if (!CardType.isACreatureType(chosen) || invalidTypes.contains(chosen)) { - chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(game.getCardsInGame(), opp)); + list = CardLists.filterControlledBy(game.getCardsInGame(), ai.getOpponents()); + chosen = ComputerUtilCard.getMostProminentType(list, valid); } } else if (logic.equals("MostProminentInComputerDeck")) { - chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(game.getCardsInGame(), ai)); + chosen = ComputerUtilCard.getMostProminentType(ai.getAllCards(), valid); } else if (logic.equals("MostProminentInComputerGraveyard")) { - chosen = ComputerUtilCard.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Graveyard)); + chosen = ComputerUtilCard.getMostProminentType(ai.getCardsIn(ZoneType.Graveyard), valid); } } if (!CardType.isACreatureType(chosen) || invalidTypes.contains(chosen)) { @@ -1772,7 +1776,13 @@ public class ComputerUtil { } else if (kindOfType.equals("Basic Land")) { if (logic != null) { - if (logic.equals("MostNeededType")) { + if (logic.equals("MostProminentOppControls")) { + CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents()); + List valid = CardType.getBasicTypes(); + valid.removeAll(invalidTypes); + + chosen = ComputerUtilCard.getMostProminentType(list, valid); + } else if (logic.equals("MostNeededType")) { // Choose a type that is in the deck, but not in hand or on the battlefield final List basics = new ArrayList(); basics.addAll(CardType.Constant.BASIC_TYPES);