Class GameStateManager

java.lang.Object
dev.laszlomocsy.tzaar.utils.GameStateManager

public class GameStateManager extends Object
This class is responsible for saving and loading the game state.
  • Method Details

    • saveGame

      public static void saveGame(GameState gameState, Component dialogParent)
      Saves the given game state to a file.
      Parameters:
      gameState - The game state to save.
      dialogParent - The parent component of the dialog.
    • loadGame

      public static Optional<GameState> loadGame(Component dialogParent)
      Loads a game state from a file.
      Parameters:
      dialogParent - The parent component of the dialog.
      Returns:
      The loaded game state.
    • saveToFile

      public static boolean saveToFile(GameState gameState, File file)
      Saves the given game state to a file.
      Parameters:
      gameState - The game state to save.
      file - The file to save the game state to.
      Returns:
      True if the game state was saved successfully, false otherwise.
    • loadFromFile

      public static Optional<GameState> loadFromFile(File file)
      Loads a game state from a file.
      Parameters:
      file - The file to load the game state from.
      Returns:
      The loaded game state.
    • generateGameState

      public static GameState generateGameState(Board board, String player1Name, String player2Name)
      Converts a board to a game state.
      Parameters:
      board - The board to convert.
      player1Name - The name of player 1.
      player2Name - The name of player 2.
      Returns:
      The game state generated from the board.
    • generateBoard

      public static Board generateBoard(GameState gameState)
      Converts a game state to a board.
      Parameters:
      gameState - The game state to convert.
      Returns:
      The board generated from the game state.