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 Type
    Method
    Description
    float
    Gets the value of the enemy damage multiplier design parameter for the specified difficulty.
    float
    Gets the value of the enemy max health multiplier design parameter for the specified difficulty.
    int
    Gets the value of the magic regeneration rate design parameter for the specified difficulty.
    int
    Gets the value of the max magic design parameter for the specified difficulty.
    int
    Gets the user's personal best for the furthest stage they've reached of the specified difficulty.
    int
    Gets the value of the player max health design parameter for the specified difficulty.
    int
    Gets the value of the shop item count design parameter for the specified difficulty.
    int
    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.
    boolean
    Returns whether the user has telemetry enabled.
    void
    Logs in the user using the result from the Authenticator (Python OAuth).
    void
    Resets the filepath to the real JSON file, logins_file.json, after running a JUnit test.
    void
    Resets the filepath to the real JSON file, settings_file.json, after running a JUnit test.
    void
    setEnemyDamageMultiplier(DifficultyEnum difficulty, float newEnemyDamageMultiplier)
    Sets the value of the enemy damage multiplier design parameter for the specified difficulty.
    void
    setEnemyMaxHealthMultiplier(DifficultyEnum difficulty, float newEnemyMaxHealthMultiplier)
    Sets the value of the enemy max health multiplier design parameter for the specified difficulty.
    void
    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.
    void
    setMagicRegenRate(DifficultyEnum difficulty, int newMagicRegenRate)
    Sets the value of the starting lives design parameter for the specified difficulty.
    void
    setMaxMagic(DifficultyEnum difficulty, int newMaxMagic)
    Sets the value of the max magic multiplier design parameter for the specified difficulty.
    void
    setMaxStageReached(DifficultyEnum difficulty, int maxStageReached)
    Sets the value for the furthest stage the user has gotten to for th specified difficulty.
    void
    setPlayerMaxHealth(DifficultyEnum difficulty, int newPlayerMaxHealth)
    Sets the value of the player max health multiplier design parameter for the specified difficulty.
    void
    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.
    void
    setShopItemCount(DifficultyEnum difficulty, int newShopItemCount)
    Sets the value of the shop item count design parameter for the specified difficulty.
    void
    setStartingLives(DifficultyEnum difficulty, int newStartingLives)
    Sets the value of the starting lives design parameter for the specified difficulty.
    void
    setTelemetryEnabled(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.
    void
    setUserRole(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

      void loginWithResult(AuthenticationResult result) throws AuthenticationException
      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

      RoleEnum getUserRole() throws AuthenticationException
      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

      void setUserRole(String userID, RoleEnum role) throws AuthenticationException
      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

      boolean isTelemetryEnabled() throws AuthenticationException
      Returns whether the user has telemetry enabled.
      Returns:
      whether the user has telemetry enabled or not.
      Throws:
      AuthenticationException - if no user is authenticated.
    • getMaxStageReached

      int getMaxStageReached(DifficultyEnum difficulty) throws AuthenticationException
      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

      int getPlayerMaxHealth(DifficultyEnum difficulty)
      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

      float getEnemyDamageMultiplier(DifficultyEnum difficulty)
      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

      float getEnemyMaxHealthMultiplier(DifficultyEnum difficulty)
      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

      int getStartingLives(DifficultyEnum difficulty)
      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

      int getMaxMagic(DifficultyEnum difficulty)
      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

      int getMagicRegenRate(DifficultyEnum difficulty)
      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

      int getShopItemCount(DifficultyEnum difficulty)
      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

      void setTelemetryEnabled(boolean telemetryEnabled) throws AuthenticationException
      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

      void setMaxMagic(DifficultyEnum difficulty, int newMaxMagic) throws AuthenticationException
      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

      void setLoginsDestinationFile(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.
      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

      void setSettingsDestinationFile(File file)
      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.