Class AchievementController

java.lang.Object
de.tum.cit.fop.maze.AchievementController

public class AchievementController extends Object
Manages the achievements in the game, including loading, saving, and updating their status. It handles the persistence of achievement data to a JSON file.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor initializing all achievements to false and counts to zero.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new AchievementController with default values and saves it to the JSON file.
    int
    Gets the total number of kills.
    int
    Gets the total number of points.
    boolean
    Checks if the console achievement is unlocked.
    boolean
    Checks if the end achievement is unlocked.
    boolean
    Checks if the first blood achievement is unlocked.
    boolean
    Checks if the invisibility achievement is unlocked.
    boolean
    Checks if the kills achievement is unlocked.
    boolean
    Checks if the points achievement is unlocked.
    boolean
    Checks if the start achievement is unlocked.
    boolean
    Checks if the upgrades achievement is unlocked.
    Loads achievements from the local JSON file.
    void
    setConsole(boolean console)
    Sets the console achievement status and saves to JSON.
    void
    setEnd(boolean end)
    Sets the end achievement status and saves to JSON.
    void
    setFirstBlood(boolean firstBlood)
    Sets the first blood achievement status and saves to JSON.
    void
    setInvis(boolean invis)
    Sets the invisibility achievement status and saves to JSON.
    void
    setKills(boolean kills)
    Sets the kills achievement status and saves to JSON.
    void
    setKillsAmount(int killsAmount)
    Sets the total number of kills and saves to JSON.
    void
    setPoints(boolean points)
    Sets the points achievement status and saves to JSON.
    void
    setPointsNumber(int pointsNumber)
    Sets the total number of points and saves to JSON.
    void
    setStart(boolean start)
    Sets the start achievement status and saves to JSON.
    void
    setUpgrades(boolean upgrades)
    Sets the upgrades achievement status and saves to JSON.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AchievementController

      public AchievementController()
      Default constructor initializing all achievements to false and counts to zero.
  • Method Details

    • loadAchievements

      public static AchievementController loadAchievements()
      Loads achievements from the local JSON file. If the file does not exist, it creates default achievements.
      Returns:
      The loaded or newly created AchievementController instance.
    • createDefaultAchievements

      public static AchievementController createDefaultAchievements()
      Creates a new AchievementController with default values and saves it to the JSON file.
      Returns:
      The newly created AchievementController instance.
    • isStart

      public boolean isStart()
      Checks if the start achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setStart

      public void setStart(boolean start)
      Sets the start achievement status and saves to JSON.
      Parameters:
      start - The new status of the start achievement.
    • isEnd

      public boolean isEnd()
      Checks if the end achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setEnd

      public void setEnd(boolean end)
      Sets the end achievement status and saves to JSON.
      Parameters:
      end - The new status of the end achievement.
    • isFirstBlood

      public boolean isFirstBlood()
      Checks if the first blood achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setFirstBlood

      public void setFirstBlood(boolean firstBlood)
      Sets the first blood achievement status and saves to JSON.
      Parameters:
      firstBlood - The new status of the first blood achievement.
    • isUpgrades

      public boolean isUpgrades()
      Checks if the upgrades achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setUpgrades

      public void setUpgrades(boolean upgrades)
      Sets the upgrades achievement status and saves to JSON.
      Parameters:
      upgrades - The new status of the upgrades achievement.
    • isKills

      public boolean isKills()
      Checks if the kills achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setKills

      public void setKills(boolean kills)
      Sets the kills achievement status and saves to JSON.
      Parameters:
      kills - The new status of the kills achievement.
    • isInvis

      public boolean isInvis()
      Checks if the invisibility achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setInvis

      public void setInvis(boolean invis)
      Sets the invisibility achievement status and saves to JSON.
      Parameters:
      invis - The new status of the invisibility achievement.
    • isConsole

      public boolean isConsole()
      Checks if the console achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setConsole

      public void setConsole(boolean console)
      Sets the console achievement status and saves to JSON.
      Parameters:
      console - The new status of the console achievement.
    • isPoints

      public boolean isPoints()
      Checks if the points achievement is unlocked.
      Returns:
      True if unlocked, false otherwise.
    • setPoints

      public void setPoints(boolean points)
      Sets the points achievement status and saves to JSON.
      Parameters:
      points - The new status of the points achievement.
    • getKillsAmount

      public int getKillsAmount()
      Gets the total number of kills.
      Returns:
      The number of kills.
    • setKillsAmount

      public void setKillsAmount(int killsAmount)
      Sets the total number of kills and saves to JSON.
      Parameters:
      killsAmount - The new kill count.
    • getPointsNumber

      public int getPointsNumber()
      Gets the total number of points.
      Returns:
      The number of points.
    • setPointsNumber

      public void setPointsNumber(int pointsNumber)
      Sets the total number of points and saves to JSON.
      Parameters:
      pointsNumber - The new point count.