Package de.tum.cit.fop.maze.game_saves
Class SaveManager
java.lang.Object
de.tum.cit.fop.maze.game_saves.SaveManager
Manages saving and loading game state to/from JSON files.
Handles separate save files for story mode and endless mode.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GameFieldMementocreateGameFieldMemento(GameField gameField) Converts a GameField to a GameFieldMemento for serialization.static booleanhasSave(boolean isStoryMode) Checks if a save file exists for the specified game mode.static GameScreenMementoloadGame(boolean isStoryMode) Loads a saved game state from a JSON file.static GameFieldrestoreGameField(GameFieldMemento memento) Restores a GameField from a GameFieldMemento.static voidsaveGame(GameScreenMemento memento, boolean isStoryMode) Saves the current game state to a JSON file.
-
Constructor Details
-
SaveManager
public SaveManager()
-
-
Method Details
-
saveGame
Saves the current game state to a JSON file.- Parameters:
memento- The game state to saveisStoryMode- True for story mode, false for endless mode
-
loadGame
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
Converts a GameField to a GameFieldMemento for serialization.- Parameters:
gameField- The game field to convert- Returns:
- A memento containing the game field state
-
restoreGameField
Restores a GameField from a GameFieldMemento.- Parameters:
memento- The memento containing the game field state- Returns:
- The restored game field
-