Improved documentation in Board

This commit is contained in:
Kai S. K. Engelbart 2019-08-13 06:16:10 +02:00
parent dcef49c4eb
commit b682485e40

View File

@ -460,12 +460,10 @@ public class Board implements Cloneable {
// Fullmove counter // Fullmove counter
log.setFullmoveCounter(Integer.parseInt(parts[5])); log.setFullmoveCounter(Integer.parseInt(parts[5]));
// TODO: Synchronize with game
} }
/** /**
* @return A FEN-encoded string representing the board * @return a FEN-encoded string representing the board
*/ */
public String toFEN() { public String toFEN() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -564,26 +562,56 @@ public class Board implements Cloneable {
return board; return board;
} }
/**
* @param pos The position from which to return a piece
* @return The piece at the position
*/
public Piece get(Position pos) { public Piece get(Position pos) {
return boardArr[pos.x][pos.y]; return boardArr[pos.x][pos.y];
} }
/**
* Places a piece at a position.
*
* @param pos The position to place the piece at
* @param piece The piece to place
*/
public void set(Position pos, Piece piece) { public void set(Position pos, Piece piece) {
boardArr[pos.x][pos.y] = piece; boardArr[pos.x][pos.y] = piece;
} }
/**
* @param move The move from which position to return a piece
* @return The piece at the position of the move
*/
public Piece getPos(Move move) { public Piece getPos(Move move) {
return get(move.pos); return get(move.pos);
} }
/**
* @param move The move from which destination to return a piece
* @return The piece at the destination of the move
*/
public Piece getDest(Move move) { public Piece getDest(Move move) {
return get(move.dest); return get(move.dest);
} }
/**
* Places a piece at the position of a move.
*
* @param move The move at which position to place the piece
* @param piece The piece to place
*/
public void setPos(Move move, Piece piece) { public void setPos(Move move, Piece piece) {
set(move.pos, piece); set(move.pos, piece);
} }
/**
* Places a piece at the destination of a move.
*
* @param move The move at which destination to place the piece
* @param piece The piece to place
*/
public void setDest(Move move, Piece piece) { public void setDest(Move move, Piece piece) {
set(move.dest, piece); set(move.dest, piece);
} }