Table of Contents

Class LeaderboardModule

Namespace
Titipi.MocaLib

Firebase Firestore-backed leaderboard with per-player score submission, top-N queries, and rank calculation via server-side aggregate counts. Firestore path: leaderboards/{leaderboardName}/scores/{userId}. Requires FirebaseModule to be initialized first.

public static class LeaderboardModule
Inheritance
LeaderboardModule
Inherited Members

Properties

IsInitialized

Whether the module has been successfully initialized.

Initialization

Initialize()

Initializes the module. Requires IsInitialized to be true.

Methods

GetPlayerRank(string, string, Action<int, int>, Action<Exception>)

Returns the current player's 1-based rank and score via onSuccess. Rank is computed using two server-side aggregate counts: players with a strictly higher score, and players with the same score but an earlier submission timestamp (tie-breaking).

GetRankAtScore(string, string, int, Action<int>, Action<Exception>)

Returns the 1-based rank that a hypothetical score would achieve, computed by counting all players with a strictly higher score.

GetTopScores(string, string, int, Action<List<LeaderboardEntry>>, Action<Exception>)

Fetches the top topCount entries ordered by score descending, then by UpdatedAt ascending to break ties (earlier submissions rank higher).

SubmitScore(string, string, int, Action, Action<Exception>)

Submits newScore to Firestore. Only writes if newScore is higher than the player's current stored score. Reads the display name and avatar from PlayerProfileModule if it is initialized. Firestore path: leaderboards/{leaderboardName}/scores/{userId}.

UpdatePlayerProfile(string, string, string, string, Dictionary<string, object>, Action, Action<Exception>)

Updates the current player's display name, avatar, and metadata in their leaderboard document without modifying their score.