Class PlayFab

java.lang.Object
com.csse3200.game.components.login.PlayFab

public class PlayFab extends Object
The PlayFab class handles user registration, login, and leaderboard management via PlayFab's client API. It allows for initializing the PlayFab client with a Title ID, and provides methods for user registration, login, updating leaderboards, and submitting scores.
  • Field Details

    • isLogin

      public static boolean isLogin
  • Constructor Details

    • PlayFab

      public PlayFab(String titleId)
      Constructor to initialize PlayFab with the given Title ID.
      Parameters:
      titleId - The PlayFab Title ID to be used for authentication.
  • Method Details

    • main

      public static void main(String[] args)
    • registerUser

      public static PlayFab.Response registerUser(String username, String password)
      Registers a new user in PlayFab with the provided credentials.
      Parameters:
      username - The desired username for the user.
      password - The desired password for the user.
      Returns:
      A PlayFab.Response object containing a success or failure message.
    • loginUser

      public static PlayFab.Response loginUser(String username, String password)
      Logs in a user via PlayFab with the provided username and password.
      Parameters:
      username - The username of the registered account.
      password - The password of the registered account.
      Returns:
      A PlayFab.Response object containing a success or failure message.
    • getPlayerName

      public static String getPlayerName()
      Retrieves the name of the currently logged-in player.
      Returns:
      The name of the logged-in player, or "Guest" if no user is logged in.
    • updateLeaderboard

      public static void updateLeaderboard(String gameName)
      Updates the leaderboard for the specified game by retrieving the top scores.
      Parameters:
      gameName - The name of the game for which the leaderboard is being updated.
    • submitScore

      public static void submitScore(String gameName, int score)
      Submits the player's score for the specified game to the leaderboard.
      Parameters:
      gameName - The name of the game.
      score - The score to be submitted.
    • getUsernames

      public ArrayList<String> getUsernames()
      Retrieves the list of usernames on the leaderboard.
      Returns:
      An ArrayList of usernames.
    • getHighscores

      public ArrayList<String> getHighscores()
      Retrieves the list of high scores on the leaderboard.
      Returns:
      An ArrayList of high scores.