Class SaveManager

java.lang.Object
de.tum.cit.fop.maze.game_saves.SaveManager

public class SaveManager extends Object
Manages saving and loading game state to/from JSON files. Handles separate save files for story mode and endless mode.
  • Constructor Details

    • SaveManager

      public SaveManager()
  • Method Details

    • saveGame

      public static void saveGame(GameScreenMemento memento, boolean isStoryMode)
      Saves the current game state to a JSON file.
      Parameters:
      memento - The game state to save
      isStoryMode - True for story mode, false for endless mode
    • loadGame

      public static GameScreenMemento loadGame(boolean isStoryMode)
      Loads a saved game state from a JSON file.
      Parameters:
      isStoryMode - True for story mode, false for endless mode
      Returns:
      The loaded game state, or null if no save file exists
    • hasSave

      public static boolean hasSave(boolean isStoryMode)
      Checks if a save file exists for the specified game mode.
      Parameters:
      isStoryMode - True for story mode, false for endless mode
      Returns:
      True if a save file exists
    • createGameFieldMemento

      public static GameFieldMemento createGameFieldMemento(GameField gameField)
      Converts a GameField to a GameFieldMemento for serialization.
      Parameters:
      gameField - The game field to convert
      Returns:
      A memento containing the game field state
    • restoreGameField

      public static GameField restoreGameField(GameFieldMemento memento)
      Restores a GameField from a GameFieldMemento.
      Parameters:
      memento - The memento containing the game field state
      Returns:
      The restored game field