question

ikivilyov avatar image
ikivilyov asked

Best way to build data storage for Sims-like game with PlayFab

I am building a game ver much similar to Sims. The Player in this game can choose from multiple game items, e.g. furniture, and place in anywhere in his room. After saving furniture placement in the room, the Player can return back to edit mode and change items' positions or remove it.

My initial approach was to put all the items to a Catalog so Player can select an item from this list. And I thought to add the items Player choose to place in the room as Inventory items with Custom Data containing their specific position in the room. That way Inventory becomes Player's Room.

After I researched the API I thought that it's probably not the best possible solution for some reasons:

1. Cannot save Custom Data at the same moment when adding an item to the inventory

2. Cannot remove multiple items within one request. Actually there's no API call to "remove" the item from the inventory, rather "consume" it.

I am thinking to use Player Data (Title Data) as a storage of items' position in the room. I could make a one key named "room" and store a JSON with all the items and their positions like this (considering there's no strict limits for the value length):

{"Item": {"ItemId": "ITEM_1", "Position": ["0,0"]}, "Item": {"ItemId": "ITEM_2", "Position": ["1,1"] }}

Is this a good fit for PlayFab or maybe there's a better way for data storage of game like this?

10 |1200

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

Hernando avatar image
Hernando answered

Actually, there is limit about size of a player data value in PlayFab, for free tier, the maximum of that is 10000 bytes. So it might be not a recommend workaround for your scenario.

However, the first approach you post I guess it can be a pretty solution. For the two reasons that make it difficult for you to implement can be solved very well.

>> 1. Cannot save Custom Data at the same moment when adding an item to the inventory

The CustomData can be add to inventory item instances as part of a grant operation. A Sample Request there is in API DOCGrantItemsToUsercan be referred.

>> 2. Cannot remove multiple items within one request. Actually there's no API call to "remove" the item from the inventory, rather "consume" it.

The API RevokeInventoryItemscan remove the item from the player's inventory.


1 comment
10 |1200

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

ikivilyov avatar image ikivilyov commented ·

Thanks mate! Didn't notice that calls in API docs at the first glance!

0 Likes 0 ·
Flarvain avatar image
Flarvain answered

Hey guys,

Sorry to necro an older article but this is almost exactly what i'm looking to do. Is there a github with a basic example, or a quickstart/ tutorial on how to do this?

I'm using this for a 'buildings' Catalog which stores itemID, instanceID, level, xPos, yPos for each building and i currently have this all working fine using a json database locally for saving and loading.

I think the first method of creating a catalog of 'buildings' then instancing them by adding them to my inventory is the right way to go but im just failing with the syntax of it all. Very new to playfab.

Trying to, at the same time do all my logic server side so that i can do verification of actions and stop client hacks.

Thanks,

1 comment
10 |1200

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

Flarvain avatar image Flarvain commented ·

@Hernando, @ikivilyov - Just saw the hint people don't get notified unless i add an @ for them.

Thanks,

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.