Package javachess.model
Class Game
java.lang.Object
java.util.Observable
javachess.model.Game
Class that represents a chess game.
It contains the players, the board, and the game logic.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSet the FEN string of the current board state.getBoard()Get the current player.getFEN()Get the FEN string of the current board state.getMove()Get the next player without changing the actual player.Get the previous player without changing the actual player.voidstatic voidvoidplayGame()Main method to play the game.booleanSet the move for the game.Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Field Details
-
move
-
actualPlayer
protected int actualPlayer -
promoteTo
-
configParser
-
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
Constructor for the Game class. Initializes the board, players, and language service.- Parameters:
board- The board to be used in the game.
-
Game
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
-
getMove
-
getBoard
-
getNextPlayer
Get the next player without changing the actual player.- Returns:
- The next 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
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
Get the current player.- Returns:
- The current player.
-
getFEN
Get the FEN string of the current board state. -
fromFEN
Set the FEN string of the current board state.- Parameters:
fen- The FEN string to be set.
-