Class Persistence

java.lang.Object
com.csse3200.game.persistence.Persistence

public class Persistence extends Object
Class for loading and saving the user profile / savefile.

Save files should be in the format <profilename>$<unixtime>$<slot>.json.

  • Method Details

    • load

      public static net.dermetfan.utils.Pair<Profile,Integer> load(Savefile save)
      Load a user profile from a savefile.
      Parameters:
      save - the savefile object
      Returns:
      the profile and the slot
    • create

      public static net.dermetfan.utils.Pair<Profile,Integer> create(String profileName, int slot)
      Create a new user profile.
      Parameters:
      profileName - the name of the profile, or null to use the default name
      slot - the slot to save the profile to
      Returns:
      the profile and the slot
    • fetch

      public static List<Savefile> fetch()
      Fetch saves organized by slot.
      Returns:
      the list of savefiles
    • save

      public static void save(int slot, Profile profile)
      Save the current user profile to a specific slot.
      Parameters:
      slot - the slot to save the profile to
      profile - the profile to save