Beispiel #1
0
  /*
   * Sets the white Pieces on the board
   */
  private static void placeWhitePieces(PlayerSet whiteSet, Board board) {
    Space currentSpace = board.getSpace(Rank.One, File.A);
    Iterator<Piece> it = whiteSet.iterator();

    // set the "first" row (Rank 1) of white pieces left to right
    currentSpace.changePiece(it.next());
    for (int i = 0; i < 7; i++) {
      currentSpace = currentSpace.getSpaceRight();
      currentSpace.changePiece(it.next());
    }
    currentSpace = currentSpace.getSpaceForward();

    // set the "second" row ("Rank 2) of white pieces from right to left
    for (int i = 0; i < 8; i++) {
      currentSpace.changePiece(it.next());
      currentSpace = currentSpace.getSpaceLeft();
    }
  }
Beispiel #2
0
  /*
   * Sets the black pieces on the board
   */
  private static void placeBlackPieces(PlayerSet blackSet, Board board) {
    Space currentSpace = board.getSpace(Rank.Eight, File.A);
    Iterator<Piece> it = blackSet.iterator();

    // set the "first" row(Rank 8) of black pieces from left to right
    currentSpace.changePiece(it.next());
    for (int i = 0; i < 7; i++) {
      currentSpace = currentSpace.getSpaceRight();
      currentSpace.changePiece(it.next());
    }
    currentSpace = currentSpace.getSpaceBackward();

    // set the "second" row(Rank 7) of black pieces from right to left
    for (int i = 0; i < 8; i++) {
      currentSpace.changePiece(it.next());
      currentSpace = currentSpace.getSpaceLeft();
    }
  }