@Test public void testTroopParser() throws IOException, BotBadBaseException { int fail = 0; for (int i = 0; i < troopImageNames.length; i++) { String s = troopImageNames[i]; BufferedImage image = ImageIO.read(TestImageParser.class.getResourceAsStream(imageLocation + s)); int[] troops = ImageParser.parseTroopCount(image); try { Assert.assertArrayEquals(expectedTroops[i], troops); } catch (AssertionError e) { fail++; System.err.println(e.getMessage() + " " + Arrays.toString(expectedTroops[i]) + " vs " + Arrays.toString(troops)); } } System.out.println("Troop Success Rate: " + (1 - (float)fail / troopImageNames.length)); }
public static int[] parseTroopCount() throws BotException { BufferedImage image = RobotUtils.screenShot(Area.ATTACK_GROUP); int[] troopCount = parseTroopCount(image); logger.info("[Troop count: " + Arrays.toString(troopCount) + "]"); return troopCount; }
ImageParser { public static int[] parseTroopCount() throws BotException { BufferedImage image = RobotUtils.screenShot(Area.ATTACK_GROUP); int[] troopCount = parseTroopCount(image); logger.info("[Troop count: " + Arrays.toString(troopCount) + "]"); return troopCount; } }
ImageParser { public static int[] parseTroopCount() throws BotException { BufferedImage image = RobotUtils.screenShot(Area.ATTACK_GROUP); int[] troopCount = parseTroopCount(image); logger.info("[Troop count: " + Arrays.toString(troopCount) + "]"); return troopCount; }  }
ImageParser { public static int[] parseTroopCount() throws BotException { BufferedImage image = RobotUtils.screenShot(Area.ATTACK_GROUP); int[] troopCount = parseTroopCount(image); logger.info("[Troop count: " + Arrays.toString(troopCount) + "]"); return troopCount; }  static int parseGold(BufferedImage image); static int parseElixir(BufferedImage image); static int parseDarkElixir(BufferedImage image); static int[] parseTroopCount(); static int[] parseLoot(); static boolean isCollectorFullBase(); }
ImageParser { public static int[] parseTroopCount() throws BotException { BufferedImage image = RobotUtils.screenShot(Area.ATTACK_GROUP); int[] troopCount = parseTroopCount(image); logger.info("[Troop count: " + Arrays.toString(troopCount) + "]"); return troopCount; }  static int parseGold(BufferedImage image); static int parseElixir(BufferedImage image); static int parseDarkElixir(BufferedImage image); static int[] parseTroopCount(); static int[] parseLoot(); static boolean isCollectorFullBase();  }