Package de.tum.cit.fop.maze
Class AchievementController
java.lang.Object
de.tum.cit.fop.maze.AchievementController
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
ConstructorsConstructorDescriptionDefault constructor initializing all achievements to false and counts to zero. -
Method Summary
Modifier and TypeMethodDescriptionstatic AchievementControllerCreates a new AchievementController with default values and saves it to the JSON file.intGets the total number of kills.intGets the total number of points.booleanChecks if the console achievement is unlocked.booleanisEnd()Checks if the end achievement is unlocked.booleanChecks if the first blood achievement is unlocked.booleanisInvis()Checks if the invisibility achievement is unlocked.booleanisKills()Checks if the kills achievement is unlocked.booleanisPoints()Checks if the points achievement is unlocked.booleanisStart()Checks if the start achievement is unlocked.booleanChecks if the upgrades achievement is unlocked.static AchievementControllerLoads achievements from the local JSON file.voidsetConsole(boolean console) Sets the console achievement status and saves to JSON.voidsetEnd(boolean end) Sets the end achievement status and saves to JSON.voidsetFirstBlood(boolean firstBlood) Sets the first blood achievement status and saves to JSON.voidsetInvis(boolean invis) Sets the invisibility achievement status and saves to JSON.voidsetKills(boolean kills) Sets the kills achievement status and saves to JSON.voidsetKillsAmount(int killsAmount) Sets the total number of kills and saves to JSON.voidsetPoints(boolean points) Sets the points achievement status and saves to JSON.voidsetPointsNumber(int pointsNumber) Sets the total number of points and saves to JSON.voidsetStart(boolean start) Sets the start achievement status and saves to JSON.voidsetUpgrades(boolean upgrades) Sets the upgrades achievement status and saves to JSON.
-
Constructor Details
-
AchievementController
public AchievementController()Default constructor initializing all achievements to false and counts to zero.
-
-
Method Details
-
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
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.
-