Skip to content

Scoring and Medals

0NATE4 edited this page Oct 15, 2024 · 3 revisions

Scoring

Each game will have it's own scoring system. This could include number of apples eaten, distance or time. To standardise this, we have come up with a medal system. This makes all Mini-Games win condition clear and allows for consistency when giving the player a reward. This system is more beneficial than a standard pass/fail as it motivates the player to do well at the Mini-Games to reach the highest medal and therefore get the best reward.

At this stage, specific rewards from the minigame are yet to be determined but may come in the form of statistics, health boost or items.

Medals

Just like sports, there are 3 medals that can be earned from a Mini-Game; Gold, Silver and Bronze. When you play any Mini-Game, to "win" you should:

  • At least pass each game (get a bronze silver or gold medal)
  • Do as well as possible to get the maximum reward.

If a player gets below a bronze (Fail), they should not recieve any rewards.

Code representation

Each Medal is represented in the enum MiniGameMedals:

image

This is in com/csse3200/game/components/minigame/MiniGameMedals

Medal Thresholds

Each game will have its own scoring system and thresholds for medals. These are stored as constants.

image

This is in source/core/src/main/com/csse3200/game/components/minigame/MiniGameConstants.java Note that the medal thresholds are not final and may change throughout development of the game.

Medal

The class MiniGamesScores has been implemented to keep track of the highest score and medal for each minigame so far. Each minigame have associated methods of getHighScore (to get the highest score so far), getMedal (to get the highest medal so far) and checkAndSetScoreMedal (set the highest medal and score so far, this will be called from within each Mini-Game). Note that this class implements the MiniGameConstants and MiniGameMedals discussed above. An example of these methods for the Snake Mini-Game are provided.

image

source/core/src/main/com/csse3200/game/components/minigame/MiniGamesScores.java

High Score Saving

The high score system ensures that the player’s best performance in each minigame is tracked and saved. The MinigameHighscore class manages these scores.

High Score Logic At the end of each minigame, the current score is compared to the saved high score, and if it's higher, the new score is saved. This process is handled by the addHighScore() method:

public void addHighScore(String minigameName, int score) {
    if (!highscores.containsKey(minigameName) || highscores.get(minigameName) < score) {
        highscores.put(minigameName, score);
    }
}

This method is called when the minigame ends, ensuring the high score is updated and saved. For example, in the snake minigame:

if (snakeGame.getIsGameOver()) {
    GameState.minigame.addHighScore("snake", snakeGame.getScore());
    SaveHandler.save(GameState.class, "saves", FileLoader.Location.LOCAL);
}

High Score Persistence

High scores are stored and saved using the GameState system, which persists them to a JSON file:

{
  "highScores": {
    "snake": 40,
    "maze": 10,
    "bird": 30
  }
}

For further implementation details, you can refer to the save wiki here.

Clone this wiki locally