Пример #1
0
  private void traverse(GameListener listener, boolean withLines, int plyNumber, int level) {
    while (hasNextMove()) {
      int numOfNextMoves = getNumOfNextMoves();

      Move move = goForwardAndGetMove(true);
      listener.notifyMove(move, getNags(), getComment(), plyNumber, level);

      if (withLines && numOfNextMoves > 1) {
        for (int i = 1; i < numOfNextMoves; i++) {
          goBack(true);
          listener.notifyLineStart(level);

          move = goForwardAndGetMove(i, true);
          listener.notifyMove(move, getNags(), getComment(), plyNumber, level + 1);

          traverse(listener, withLines, plyNumber + 1, level + 1);

          goBackToMainLine(true);
          if (i > 0) listener.notifyLineEnd(level);
        }
      }

      plyNumber++;
    }
  }