class documentation - a shitload of it
All checks were successful
Linux arm64 / Build (push) Successful in 33s
All checks were successful
Linux arm64 / Build (push) Successful in 33s
This commit is contained in:
@@ -8,7 +8,13 @@ import chess.model.pieces.King;
|
||||
import chess.model.pieces.Pawn;
|
||||
import chess.model.rules.PiecePathChecker;
|
||||
|
||||
/**
|
||||
* Chess board entity, composed of cells.
|
||||
*/
|
||||
public class ChessBoard {
|
||||
/**
|
||||
* Cell of the chess board.
|
||||
*/
|
||||
public static class Cell {
|
||||
private Piece piece;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package chess.model;
|
||||
|
||||
/**
|
||||
* Enumeration of colors for player - either black or white
|
||||
*/
|
||||
public enum Color {
|
||||
White,
|
||||
Black;
|
||||
|
||||
@@ -2,6 +2,9 @@ package chess.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Coordinate of a cell on the chess board.
|
||||
*/
|
||||
public class Coordinate {
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package chess.model;
|
||||
|
||||
/**
|
||||
* Enumation of the different directions from a cell in a chessboard, and how to navigate the cells.
|
||||
*/
|
||||
|
||||
public enum Direction {
|
||||
|
||||
Unset(65),
|
||||
|
||||
@@ -8,6 +8,10 @@ import java.util.Stack;
|
||||
import chess.controller.PlayerCommand;
|
||||
import chess.controller.commands.MoveCommand;
|
||||
|
||||
/**
|
||||
* Game class that represents a chess game.
|
||||
*/
|
||||
|
||||
public class Game {
|
||||
private final ChessBoard board;
|
||||
private Color playerTurn;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package chess.model;
|
||||
|
||||
public class PermissiveGame extends Game {
|
||||
/**
|
||||
* Game where the most ressource-consuming functions are empty.
|
||||
* Mostly used by bots.
|
||||
* @see GameSimulation
|
||||
*/
|
||||
|
||||
public class LightGame extends Game {
|
||||
|
||||
@Override
|
||||
public GameStatus checkGameStatus(Color color) {
|
||||
@@ -1,5 +1,9 @@
|
||||
package chess.model;
|
||||
|
||||
/**
|
||||
* Chess move, composed of a starting position, a finishing position and the eventual enemy pieces taken during the move.
|
||||
*/
|
||||
|
||||
public class Move {
|
||||
private final Coordinate start;
|
||||
private final Coordinate finish;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package chess.model;
|
||||
|
||||
/**
|
||||
* Piece of a game. Posesses a color and the number of time it has been moved.
|
||||
*/
|
||||
|
||||
public abstract class Piece {
|
||||
|
||||
private final Color color;
|
||||
|
||||
@@ -7,6 +7,10 @@ import chess.model.pieces.Pawn;
|
||||
import chess.model.pieces.Queen;
|
||||
import chess.model.pieces.Rook;
|
||||
|
||||
/**
|
||||
* Visitor interface for pieces.
|
||||
*/
|
||||
|
||||
public interface PieceVisitor<T> {
|
||||
|
||||
default T visit(Piece piece) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* Bishop piece.
|
||||
*/
|
||||
public class Bishop extends Piece {
|
||||
|
||||
public Bishop(Color color) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* King piece.
|
||||
*/
|
||||
public class King extends Piece {
|
||||
|
||||
public King(Color color) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* Knight piece.
|
||||
*/
|
||||
public class Knight extends Piece {
|
||||
|
||||
public Knight(Color color) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* Pawn piece.
|
||||
*/
|
||||
public class Pawn extends Piece {
|
||||
|
||||
public Pawn(Color color) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* Queen piece.
|
||||
*/
|
||||
public class Queen extends Piece {
|
||||
|
||||
public Queen(Color color) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import chess.model.Color;
|
||||
import chess.model.Piece;
|
||||
import chess.model.PieceVisitor;
|
||||
|
||||
/**
|
||||
* Rook piece.
|
||||
*/
|
||||
public class Rook extends Piece {
|
||||
|
||||
public Rook(Color color) {
|
||||
|
||||
@@ -12,6 +12,10 @@ import chess.model.pieces.Pawn;
|
||||
import chess.model.pieces.Queen;
|
||||
import chess.model.pieces.Rook;
|
||||
|
||||
/**
|
||||
* Check if a move can be done.
|
||||
*/
|
||||
|
||||
public class PermissiveRuleChecker implements PieceVisitor<Boolean> {
|
||||
|
||||
private final Move move;
|
||||
|
||||
@@ -14,6 +14,9 @@ import chess.model.pieces.Pawn;
|
||||
import chess.model.pieces.Queen;
|
||||
import chess.model.pieces.Rook;
|
||||
|
||||
/**
|
||||
* Check if there are pieces in the path of a move.
|
||||
*/
|
||||
public class PiecePathChecker implements PieceVisitor<Boolean> {
|
||||
|
||||
private final ChessBoard board;
|
||||
|
||||
Reference in New Issue
Block a user