public static boolean findTowers(int x, int y, Player activePlayer) { // The input variables is the position of the new mark. // Find towers by iterating from that square on the board // Returning a bool; true if one or more towers has been found boolean[][] field = new boolean[Gameboard.COLUMNS_AND_ROWS][Gameboard.COLUMNS_AND_ROWS]; for (int i = 0; i < Gameboard.COLUMNS_AND_ROWS; i++) { // initializing the array... for (int j = 0; j < Gameboard.COLUMNS_AND_ROWS; j++) { field[i][j] = false; } } // 1. find cluster around x,y field = FindClusterRecurse(new FieldIndex(x, y), field, activePlayer.getActiveMark()); // printing the cluster for debug: // Gdx.app.log("Tower", "Found cluster:"); // for(int i=0; i<Gameboard.NUMBER_OF_ROWS; i++){ // String s = ""; // for(int j=0; j<Gameboard.NUMBER_OF_COLUMNS; j++){ // if(field[j][Gameboard.NUMBER_OF_ROWS-i-1]) // s += "*"; // else // s += " "; // } // Gdx.app.log("", s); // } // 2. find towers in this cluster ArrayList<SkillType> skillList = FindTowersInCluster(field, activePlayer); // 3. adding skills to the player String debugString = ""; if (!activePlayer.isSilenced()) { for (SkillType s : skillList) { if (s == SkillType.SHOOT) { activePlayer.addShootCount(); debugString += "shoot, "; } else if (s == SkillType.BUILD) { activePlayer.addBuildCount(); debugString += "build, "; } else if (s == SkillType.SILENCE) { activePlayer.addSilenceCount(); debugString += "silence, "; } else if (s == SkillType.SKILLCAP) { activePlayer.addSkillCap(); debugString += "skillCap, "; } } } Gdx.app.log("Tower", "Found skills: " + debugString); return !skillList.isEmpty(); }