Class MinigameHighscore

java.lang.Object
com.csse3200.game.gamestate.data.MinigameHighscore
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class MinigameHighscore extends Object implements com.badlogic.gdx.utils.Json.Serializable
  • Constructor Details

    • MinigameHighscore

      public MinigameHighscore()
  • Method Details

    • addHighScore

      public void addHighScore(String minigameName, int score)
      Add or update the high score for a specific minigame.
      Parameters:
      minigameName - The name of the minigame.
      score - The score to be saved.
    • getHighScore

      public int getHighScore(MiniGameNames minigameName)
      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 interface com.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 interface com.badlogic.gdx.utils.Json.Serializable
      Parameters:
      json - the file to read from
      jsonData - the data in the file
    • getAllHighScores

      public Map<String,Integer> getAllHighScores()
      Get all the high scores.
      Returns:
      A map containing all the high scores.