Package wizardquest.settings
Interface SettingsInterface
public interface SettingsInterface
Interface for settings. Provides access to user settings and properties, as
well as the ability to authenticate and create users.
-
Method Summary
Modifier and TypeMethodDescriptionfloatgetEnemyDamageMultiplier(DifficultyEnum difficulty) Gets the value of the enemy damage multiplier design parameter for the specified difficulty.floatgetEnemyMaxHealthMultiplier(DifficultyEnum difficulty) Gets the value of the enemy max health multiplier design parameter for the specified difficulty.intgetMagicRegenRate(DifficultyEnum difficulty) Gets the value of the magic regeneration rate design parameter for the specified difficulty.intgetMaxMagic(DifficultyEnum difficulty) Gets the value of the max magic design parameter for the specified difficulty.intgetMaxStageReached(DifficultyEnum difficulty) Gets the user's personal best for the furthest stage they've reached of the specified difficulty.intgetPlayerMaxHealth(DifficultyEnum difficulty) Gets the value of the player max health design parameter for the specified difficulty.intgetShopItemCount(DifficultyEnum difficulty) Gets the value of the shop item count design parameter for the specified difficulty.intgetStartingLives(DifficultyEnum difficulty) Gets the value of the starting lives design parameter for the specified difficulty.Hashes the username of the currently authenticated user and returns it (as their ID).Returns the role of the currently authenticated user or throws an exception if no user is authenticated.booleanReturns whether the user has telemetry enabled.voidloginWithResult(AuthenticationResult result) Logs in the user using the result from the Authenticator (Python OAuth).voidResets the filepath to the real JSON file, logins_file.json, after running a JUnit test.voidResets the filepath to the real JSON file, settings_file.json, after running a JUnit test.voidsetEnemyDamageMultiplier(DifficultyEnum difficulty, float newEnemyDamageMultiplier) Sets the value of the enemy damage multiplier design parameter for the specified difficulty.voidsetEnemyMaxHealthMultiplier(DifficultyEnum difficulty, float newEnemyMaxHealthMultiplier) Sets the value of the enemy max health multiplier design parameter for the specified difficulty.voidsetLoginsDestinationFile(File file) Allows JUnit tests to write to a temporary JSON file rather than logins_file.json, mitigating any risk of test data corrupting the real JSON file.voidsetMagicRegenRate(DifficultyEnum difficulty, int newMagicRegenRate) Sets the value of the starting lives design parameter for the specified difficulty.voidsetMaxMagic(DifficultyEnum difficulty, int newMaxMagic) Sets the value of the max magic multiplier design parameter for the specified difficulty.voidsetMaxStageReached(DifficultyEnum difficulty, int maxStageReached) Sets the value for the furthest stage the user has gotten to for th specified difficulty.voidsetPlayerMaxHealth(DifficultyEnum difficulty, int newPlayerMaxHealth) Sets the value of the player max health multiplier design parameter for the specified difficulty.voidAllows JUnit tests to write to a temporary JSON file rather than settings_file.json, mitigating any risk of test data corrupting the real JSON file.voidsetShopItemCount(DifficultyEnum difficulty, int newShopItemCount) Sets the value of the shop item count design parameter for the specified difficulty.voidsetStartingLives(DifficultyEnum difficulty, int newStartingLives) Sets the value of the starting lives design parameter for the specified difficulty.voidsetTelemetryEnabled(boolean telemetryEnabled) Attempts to set the user's preference for whether they have telemetry enabled, writing this to their settings in the user database JSON.voidsetUserRole(String userID, RoleEnum role) Sets the role of the specified user or throws an exception if the authenticated user is not a developer.
-
Method Details
-
loginWithResult
Logs in the user using the result from the Authenticator (Python OAuth). Sets the current user's ID, name, and role from the authentication result, and loads their settings from the settings file.- Parameters:
result- the AuthenticationResult returned by Authenticator.login().- Throws:
AuthenticationException- if the result is invalid.
-
getUserRole
Returns the role of the currently authenticated user or throws an exception if no user is authenticated.- Returns:
- the user's role.
- Throws:
AuthenticationException- if no user is authenticated.
-
setUserRole
Sets the role of the specified user or throws an exception if the authenticated user is not a developer.- Parameters:
userID- the user to have their role modified.role- the new role that they will hold.- Throws:
AuthenticationException- if no user is authenticated, or the authenticated user calling the method is not of the Developer role.
-
getUserID
String getUserID()Hashes the username of the currently authenticated user and returns it (as their ID).- Returns:
- the user's ID.
-
isTelemetryEnabled
Returns whether the user has telemetry enabled.- Returns:
- whether the user has telemetry enabled or not.
- Throws:
AuthenticationException- if no user is authenticated.
-
getMaxStageReached
Gets the user's personal best for the furthest stage they've reached of the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the furthest stage the user has got on the specified difficulty.
- Throws:
AuthenticationException- if no user is authenticated.
-
getPlayerMaxHealth
Gets the value of the player max health design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getEnemyDamageMultiplier
Gets the value of the enemy damage multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getEnemyMaxHealthMultiplier
Gets the value of the enemy max health multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getStartingLives
Gets the value of the starting lives design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getMaxMagic
Gets the value of the max magic design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getMagicRegenRate
Gets the value of the magic regeneration rate design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
getShopItemCount
Gets the value of the shop item count design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty being queried.- Returns:
- the value of the design parameter.
-
setTelemetryEnabled
Attempts to set the user's preference for whether they have telemetry enabled, writing this to their settings in the user database JSON. Will throw an exception if no user is authenticated.- Parameters:
telemetryEnabled- whether the user has telemetry enabled or not.- Throws:
AuthenticationException- if the user cannot be authenticated.
-
setMaxStageReached
void setMaxStageReached(DifficultyEnum difficulty, int maxStageReached) throws AuthenticationException Sets the value for the furthest stage the user has gotten to for th specified difficulty.- Parameters:
difficulty- the difficulty the run was on.maxStageReached- the furthest stage the user reached.- Throws:
AuthenticationException- if no user is authenticated.
-
setPlayerMaxHealth
void setPlayerMaxHealth(DifficultyEnum difficulty, int newPlayerMaxHealth) throws AuthenticationException Sets the value of the player max health multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newPlayerMaxHealth- the value it's being set to.- Throws:
AuthenticationException
-
setEnemyDamageMultiplier
void setEnemyDamageMultiplier(DifficultyEnum difficulty, float newEnemyDamageMultiplier) throws AuthenticationException Sets the value of the enemy damage multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newEnemyDamageMultiplier- the value it's being set to.- Throws:
AuthenticationException
-
setEnemyMaxHealthMultiplier
void setEnemyMaxHealthMultiplier(DifficultyEnum difficulty, float newEnemyMaxHealthMultiplier) throws AuthenticationException Sets the value of the enemy max health multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newEnemyMaxHealthMultiplier- the value it's being set to.- Throws:
AuthenticationException
-
setStartingLives
void setStartingLives(DifficultyEnum difficulty, int newStartingLives) throws AuthenticationException Sets the value of the starting lives design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newStartingLives- the value it's being set to.- Throws:
AuthenticationException
-
setMaxMagic
Sets the value of the max magic multiplier design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newMaxMagic- the value it's being set to.- Throws:
AuthenticationException
-
setMagicRegenRate
void setMagicRegenRate(DifficultyEnum difficulty, int newMagicRegenRate) throws AuthenticationException Sets the value of the starting lives design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newMagicRegenRate- the value it's being set to.- Throws:
AuthenticationException
-
setShopItemCount
void setShopItemCount(DifficultyEnum difficulty, int newShopItemCount) throws AuthenticationException Sets the value of the shop item count design parameter for the specified difficulty.- Parameters:
difficulty- the difficulty it's being set for.newShopItemCount- the value it's being set to.- Throws:
AuthenticationException
-
setLoginsDestinationFile
Allows JUnit tests to write to a temporary JSON file rather than logins_file.json, mitigating any risk of test data corrupting the real JSON file.- Parameters:
file- the temporary JSON file to be written to.
-
resetLoginsDestinationFile
void resetLoginsDestinationFile()Resets the filepath to the real JSON file, logins_file.json, after running a JUnit test. -
setSettingsDestinationFile
Allows JUnit tests to write to a temporary JSON file rather than settings_file.json, mitigating any risk of test data corrupting the real JSON file.- Parameters:
file- the temporary JSON file to be written to.
-
resetSettingsDestinationFile
void resetSettingsDestinationFile()Resets the filepath to the real JSON file, settings_file.json, after running a JUnit test.
-