private int countFlags(boolean minesOnly) {
        int flaggedCount = 0;
        for (int x = 0; x < xCells; x++)
            for (int y = 0; y < yCells; y++) {
                final Cell.Type type = cells[x][y].getType();
                if (!minesOnly && type == Cell.Type.FLAGGED)
                    flaggedCount++;
                if (type == Cell.Type.FLAGGED_MINE)
                    flaggedCount++;
            }
        return flaggedCount;
    }