From a11906c21b0940b25a325b6ab35c2033fbae27cc Mon Sep 17 00:00:00 2001 From: Hanmac Date: Tue, 2 Aug 2016 11:59:34 +0000 Subject: [PATCH] ComputerUtilCard: add getMostProminentBasicLandType and a more generic getMostProminentType change getMostProminentCreatureType to use the generic form too --- .../src/main/java/forge/ai/ComputerUtilCard.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 6313a40dfe6..61d8f8e5f27 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -570,6 +570,10 @@ public class ComputerUtilCard { return maxName; } + public static String getMostProminentBasicLandType(final CardCollectionView list) { + return getMostProminentType(list, CardType.getBasicTypes()); + } + /** *

* getMostProminentCreatureType. @@ -579,6 +583,10 @@ public class ComputerUtilCard { * @return a {@link java.lang.String} object. */ public static String getMostProminentCreatureType(final CardCollectionView list) { + return getMostProminentType(list, CardType.getAllCreatureTypes()); + } + + public static String getMostProminentType(final CardCollectionView list, final List valid) { if (list.size() == 0) { return ""; } @@ -587,7 +595,7 @@ public class ComputerUtilCard { for (final Card c : list) { for (final String var : c.getType()) { - if (CardType.isACreatureType(var)) { + if (valid.contains(var)) { if (!map.containsKey(var)) { map.put(var, 1); } else { @@ -596,14 +604,14 @@ public class ComputerUtilCard { } } } // for - + int max = 0; String maxType = ""; for (final Entry entry : map.entrySet()) { final String type = entry.getKey(); // Log.debug(type + " - " + entry.getValue()); - + if (max < entry.getValue()) { max = entry.getValue(); maxType = type;