question

Dylan Hunt avatar image
Dylan Hunt asked

Global stats - where to put it?

So I have local stats, such as personal win rate, total gold collected, stuff like that.

But what about global stats? Where is the best way to put this? Title data?

Stuff like total # of games anyone has ever played. Stuff you wouldn't normally put in leaderboard or since it's not per-person, but the game as a whole.

I'd call it at the end of each match just from the master client. The master client would have a special cloud script that does the normal personal stats that go on the leaderboard, but then also the global match stats.

We want to have it per-version, so maybe like....

"stats-v0.8.25":
{
    "someStat": 2,
    "someBulkStat":
    {
        "someNestedStat": 5"
    {
}
Title 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

·
Joshua Strunk avatar image
Joshua Strunk answered

There is no system in PlayFab designed to handle global statistics, certainly not TitleData.

I would handle this by having a custom tool which calculates the desired stats by processing saved PlayStream logs. If I had a really good reason to have it updated in real-time would write a server application to process the PlayStream events as they come in.

4 comments
10 |1200

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

Dylan Hunt avatar image Dylan Hunt commented ·

Hmm, would title data be suitable if it's not updated that often? It essentially is title stats. It wouldn't be updated in realtime -- once every 20 minutes or so per "master" of the match. It would update global stats that are not dynamic and would never change.

For example, specifically:

"stats-v0.8.25":
{
                   
"globalClass1Wins": 0,
"globalClass2Wins": 0, "totalKills": 0, "totalDeaths": 0
}

Pretty much like this. It seems quite suitable for titleData if we delete old versions (we want to use it to check class balance - and also for the sake of "interesting stats").

However, I see what you're saying about the PlayStream events: I thought you can only access LIVE playstream events. How can I get a playstream log?

I'm still new to playstream, so I've only really been using a custom playstream event at the END of a match, and batch them all at once with ExecuteCloudScript().

SHOULD I (standard-wise), instead of batching all at once at the end, be generating custom playstream events every time someone dies or gets a kill? Then use the existing server playstream logs to do my game over events?

0 Likes 0 ·
brendan avatar image brendan Dylan Hunt commented ·

The way this would work is by using the Event Archive. You would process the logs periodically (every 20 minutes would be fine, yes), as Joshua described, and update the Title Data for the new values. Do bear in mind that Title Data is sharded and cached (the only way it can be served to all users at once), so when it is updated, there will be a short delay (up to a few seconds) before all caches are updated with the new value.

1 Like 1 ·
Dylan Hunt avatar image Dylan Hunt brendan commented ·

Ah, I see -- that would be horrible for common events, gotcha (really good info to know). Hmm, event archive seems to be the way. I was trying to find a post or doc about it, but it seems a bit tough to find. Some posts hint I need to setup an Amazon S3. Do you have an official doc, by chance?

0 Likes 0 ·
Show more comments

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.