Package com.csse3200.game.gamestate.data
Class MinigameHighscore
java.lang.Object
com.csse3200.game.gamestate.data.MinigameHighscore
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHighScore
(String minigameName, int score) Add or update the high score for a specific minigame.Get all the high scores.int
getHighScore
(MiniGameNames minigameName) Get the high score for a specific minigame.void
read
(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonData) Read from the JSON file to get the high scorevoid
write
(com.badlogic.gdx.utils.Json json) Write to the JSON file with the new high score
-
Constructor Details
-
MinigameHighscore
public MinigameHighscore()
-
-
Method Details
-
addHighScore
Add or update the high score for a specific minigame.- Parameters:
minigameName
- The name of the minigame.score
- The score to be saved.
-
getHighScore
Get the high score for a specific minigame.- Parameters:
minigameName
- The name of the minigame.- Returns:
- The high score for the minigame, or 0 if no score is available.
-
write
public void write(com.badlogic.gdx.utils.Json json) Write to the JSON file with the new high score- Specified by:
write
in interfacecom.badlogic.gdx.utils.Json.Serializable
- Parameters:
json
- the file to write to
-
read
public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonData) Read from the JSON file to get the high score- Specified by:
read
in interfacecom.badlogic.gdx.utils.Json.Serializable
- Parameters:
json
- the file to read fromjsonData
- the data in the file
-
getAllHighScores
Get all the high scores.- Returns:
- A map containing all the high scores.
-