question

tomasz avatar image
tomasz asked

Player personal minigame leaderboard,How to display personal leaderboard of minigames played

Hello I have following problem

Lets say I have a game that have 3 minigames in it.
Each minigame has easy/medium/hard difficulty level with different scoring system per each level.

Formula for calculating score per level is stored in playfab catalogues custom data - each minigame has corresponding catalogue item.

Question is - how can I properly save user scores for each minigame and then show user his own personal leaderboard from best score to lowest one ?

Example flow looks like that:

  1. User selects difficuflty level in app
  2. finishes the game in some amount of seconds
  3. we execute custom cloudscript function to calculate mini game score
  4. function arguments are gameId, difficulty level and time in seconds on which we base our score.
  5. Function gets corresponding game data from 'minigames' catalogue items - gets formula from custom data by difficulty level and calculates the score.


Now I need now to save it somewhere.

What part of playfab should I use to save player minigames score so after he plays the game I can present him his own like leaderboard per difficulty so all of his attempts are displayed ?

Leaderboards are generated per statistic per player but I need to combine data for one player.

Should I use some 3rd party database for it or is it possible to do only by playfab tools?

Workaround for that - to save only best score would be to create statistic called GameId_DifficultyLevel and update it in cloudscript only when user beat his previous saved score - but that wont save all his other scores - just the best one.

I hope the description is somewhat clear :)

,

Hello I have following problem

Lets say I have a game that have 3 minigames in it.
Each minigame has easy/medium/hard difficulty level with different scoring system per each level.

Formula for calculating score per level is stored in playfab catalogues custom data - each minigame has corresponding catalogue item.

Question is - how can I properly save user scores for each minigame and then show user his own personal leaderboard from best score to lowest one ?

Example flow looks like that:

  1. User selects difficuflty level in app
  2. finishes the game in some amount of seconds
  3. we execute custom cloudscript function to calculate mini game score
  4. function arguments are gameId, difficulty level and time in seconds on which we base our score.
  5. Function gets corresponding game data from 'minigames' catalogue items - gets formula from custom data by difficulty level and calculates the score.


Now I need now to save it somewhere.

What part of playfab should I use to save player minigames score so after he plays the game I can present him his own like leaderboard per difficulty so all of his attempts are displayed ?

Leaderboards are generated per statistic per player but I need to combine data for one player.

Should I use some 3rd party database for it or is it possible to do only by playfab tools?

Workaround for that - to save only best score would be to create statistic called GameId_DifficultyLevel and update it in cloudscript only when user beat his previous score - but that wont save all his other scores - just the best one.

I hope the description is somewhat clear :)

Player DataLeaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Do you mean you want to store the personal history score leaderboard for every player? If so, you can store the history score record as a JSON to Player Read-Only Data directly. PlayFab supports to store the escaped JSON string as the value of Play Read-Only Data’s K/V pairs. So you can store the player’s history score as the Player Read-Only Data according to the date. We suggest you call Server API UpdateUserReadOnlyData on CloudScript to update the data. Then you need to use a sorting algorithm on the client to sort it to get the personal leaderboard. The request body of UpdateUserReadOnlyData would be something like this.

{
    "PlayFabId": "{
                {PlayFabId}}",
    "Data": {
        "Easy": "{\"0501\":12,\"0502\":23,\"0503\":24,\"0504\":34,\"0505\":45}"
    }
}
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.