Class PlayFab
java.lang.Object
com.csse3200.game.components.login.PlayFab
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A class used to return the result of a user action (registration/login). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the list of high scores on the leaderboard.static String
Retrieves the name of the currently logged-in player.Retrieves the list of usernames on the leaderboard.static PlayFab.Response
Logs in a user via PlayFab with the provided username and password.static void
static PlayFab.Response
registerUser
(String username, String password) Registers a new user in PlayFab with the provided credentials.static void
submitScore
(String gameName, int score) Submits the player's score for the specified game to the leaderboard.static void
updateLeaderboard
(String gameName) Updates the leaderboard for the specified game by retrieving the top scores.
-
Field Details
-
isLogin
public static boolean isLogin
-
-
Constructor Details
-
PlayFab
Constructor to initialize PlayFab with the given Title ID.- Parameters:
titleId
- The PlayFab Title ID to be used for authentication.
-
-
Method Details
-
main
-
registerUser
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
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
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
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
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
Retrieves the list of usernames on the leaderboard.- Returns:
- An
ArrayList
of usernames.
-
getHighscores
Retrieves the list of high scores on the leaderboard.- Returns:
- An
ArrayList
of high scores.
-