question

Dustin Auxier avatar image
Dustin Auxier asked

Best method to calculate a total value from all player datas?,

I plan to include a poll in my game where players can apply a number of votes to different items in the poll. The poll would be made of many entries, several hundred most likely. Players can adjust or change which entries their votes are applied to at any time.

Currently I have players submitting their votes via cloudscript / azure function which validates them and stores them in the player's readonly PlayerData.

My problem I've encountered is how to total the number votes in real time (or close to it) for display in the client so that players can see how popular different items in the poll currently are. The simple solution sounds like it would be to write a server-side function that iterates through every player data and does the calculations and publishes the up-to-date data but I've found out that this is unacceptably slow, requiring an individual api call for every individual player.

There are entity objects and GetProfiles but even that seems to be limited to 25 profiles at a time?

An alternative may be to keep a total record that is adjusted accordingly by a delta every time a player submits their individual votes based on what their previous votes were, but this introduces multiple versions of truth and I'm concerned about this method becoming out of sync and inaccurate.

Is there anything on the playfab side that can handle this or do I need to look into some azure capabilities for data storage and retrieval instead?

,

Player DataCloudScript
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

·
Xiao Zha avatar image
Xiao Zha answered

From your description, it seems like you need some global variables to achieve real time update of the vote count for all players. Although PlayFab has the feature to store global data which is called Title Data. But it’s not suitable for your situation, as it’s not designed for frequent changes. For you case, you may need to use an external database to achieve this function.

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.