Class Storage

java.lang.Object
javatro.storage.Storage

public class Storage extends Object
The Storage class serves as a facade to interact with the underlying storage mechanism managed by StorageManager. It provides methods for saving, loading, and updating game data runs. This class uses the Singleton pattern.
  • Field Details

    • isNewDeck

      public static Boolean isNewDeck
      Indicates if a new deck is being used.
    • saveActive

      public static boolean saveActive
      Stores whether storage is active for the game or not
  • Method Details

    • getStorageInstance

      public static Storage getStorageInstance()
      Retrieves the singleton instance of Storage.
      Returns:
      The singleton instance of Storage.
    • updateSaveFile

      public void updateSaveFile() throws JavatroException
      Updates the save file by delegating to the StorageManager.
      Throws:
      JavatroException - If an error occurs during saving.
    • getSerializedRunData

      public TreeMap<Integer,List<String>> getSerializedRunData()
      Retrieves a deep copy of the serialized run data.
      Returns:
      A TreeMap containing all serialized run data.
    • setSerializedRunData

      public void setSerializedRunData(TreeMap<Integer,ArrayList<String>> serializedRunData)
      Sets the serialized run data by delegating to the StorageManager.
      Parameters:
      serializedRunData - The run data to be set.
    • addNewRun

      public void addNewRun()
      Adds a new run to the storage with default values.
    • getNumberOfRuns

      public int getNumberOfRuns()
      Retrieves the total number of runs stored.
      Returns:
      The total number of runs.
    • getValue

      public String getValue(int runNumber, int idx)
      Retrieves a specific value from a run.
      Parameters:
      runNumber - The run number.
      idx - The index of the value to retrieve.
      Returns:
      The value as a String.
    • setValue

      public void setValue(int runNumber, int idx, String value)
      Sets a specific value for a given run and saves it.
      Parameters:
      runNumber - The run number.
      idx - The index of the value to set.
      value - The value to be set.
    • getRunChosen

      public int getRunChosen()
      Retrieves the currently selected run index.
      Returns:
      The index of the current run.
    • setRunChosen

      public void setRunChosen(int runChosen)
      Sets the currently selected run index.
      Parameters:
      runChosen - The run index to set.