question

drew avatar image
drew asked

how to validate playerdata save?

hi,

I am working on a card game and have a screen like a traditional TCG where the player can create a deck based on the cards that they own.

When the user presses "Save Deck" button, I am using UpdateUserData to save a JSON version of the deck.

This seems OK, but how can I validate that when they actually own all the cards in the deck? I can check internally to see if they opened and owned those cards, but where do I do that validation logic prior to allowing the Save? Or is this not something PlayerData is suited for, and if so, what is the best alternative? Do I have to use Azure Function + Cosmos to store the deck info and validate with server side logic?

Thanks

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

·
Gosen Gao avatar image
Gosen Gao answered

Since you mention that you can check if the player owns a specific card, then you can traverse the entire deck and check if each card is owned. Here is the work flow.

  • 1.Press the “Save deck” button.
  • 2.Execute a Cloud Script or Azure Function and pass the deck info as the parameter.
  • 3.In that Cloud Script or Azure Function, you can traverse the entire deck to see if each card is owned.
  • 4.Update User Data if validation passed.

And read only data should be more suit for your scenario, since the deck needs to be validated first while the player data can be updated by the client directly. For more info about player data, please refer to Player Data.

2 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.

drew avatar image drew commented ·

thanks Gosen, so it does sound like I need to use an Azure Function for this.

Do you think PlayerData is the best place to store a card deck?

What about Entity Data? the documents say that entity data is the future, but it also gets confusing since it says you cant save more than "3 objects per entity", but doesnt explain what an "Object" is. Is that an entry into the entity, or a property?

Also, what about Cosmos for this? Do you think it's needed because of any kind of limitations on PlayerData?

thanks again

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao drew commented ·

I won’t say it is the best, both Player Data and Entity Objects are viable places to store decks, and you should decide which is better based on your needs. Please refer to our official documentation to learn more about Entity model and classic model. In addition to the difference in model, you may also need to consider the difference in storage space. A title player account entity can store up to 5 objects, each has a size of 1000 bytes. While each value of Player Data has a size of 300,000 bytes. For more limit info, you can navigate to [Game Manager]->[Title Settings]->[Limits].

0 Likes 0 ·

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.