Class Game


public class Game extends Observable
Class that represents a chess game. It contains the players, the board, and the game logic.
  • Field Details

    • move

      public Move move
    • actualPlayer

      protected int actualPlayer
    • promoteTo

      public Piece promoteTo
    • configParser

      public final ConfigParser configParser
    • languageService

      public final LanguageService languageService
  • Constructor Details

    • Game

      public Game()
      Constructor for the Game class. Initializes the board, players, and language service.
    • Game

      public Game(boolean withBot, int depth)
      Constructor for the Game class. Initializes the board, players, and language service.
      Parameters:
      withBot - True if the game should be played against a bot, false otherwise.
    • Game

      public Game(Board board)
      Constructor for the Game class. Initializes the board, players, and language service.
      Parameters:
      board - The board to be used in the game.
    • Game

      public Game(Board board, boolean withBot, int depth)
      Constructor for the Game class.
      Parameters:
      board - The board to be used in the game.
      withBot - True if the game should be played against a bot, false otherwise.
  • Method Details

    • main

      public static void main(String[] args)
    • getMove

      public Move getMove()
    • getBoard

      public Board getBoard()
    • getNextPlayer

      public Player getNextPlayer()
      Get the next player without changing the actual player.
      Returns:
      The next player.
    • getPreviousPlayer

      public Player getPreviousPlayer()
      Get the previous player without changing the actual player.
      Returns:
      The previous player.
    • incrementPlayer

      public void incrementPlayer()
    • playGame

      public void playGame()
      Main method to play the game.
    • setMove

      public boolean setMove(Move move, boolean castling)
      Set the move for the game.
      Parameters:
      move - The move to be made.
      castling - True if the move is a castling move, false otherwise. It is false by default.
      Returns:
      True if the move is valid, false otherwise.
    • getCurrentPlayer

      public Player getCurrentPlayer()
      Get the current player.
      Returns:
      The current player.
    • getFEN

      public String getFEN()
      Get the FEN string of the current board state.
    • fromFEN

      public void fromFEN(String fen)
      Set the FEN string of the current board state.
      Parameters:
      fen - The FEN string to be set.