Hello!
We have an inventory in our game that needs to store store frequently changing data for each item instance. Items can also be containers with other items inside.
So we store this per item instance.
Inventory Item Instance:
- Count
- x,y Position in a container
- Durability
- List of contained items
The player can modify the inventory basically at any time. This is a session based game with a dedicated server so bulk updates to the inventory will happen at the end of a match. When not being in a match the player can also modify the inventory. It will also be possible to add items in some way as items have a certain stack size and can be split and combined by the user.
Currently we are storing all of this as Character/Player Data which has the advantage that the whole inventory can be updated with a single cloud script call. We didn't implement validation yet in cloud script but in theory it should be doable. (Just check if the call didn't change the overall number of a certain item type)
I see issues though later when going life because this lacks features like transaction history and is harder to connect to some kind of shop. We would have to rely on very carefully crafted cloud script to make it work safely.
Looking at the inventory system PlayFab provides it seems like we could use it in theory as it provides metadata of item instances for storing our custom item data (position, durability,contained items).
But practically this would require a quite high amount of API calls. What is now a single call to to write the new inventory would then later be:
- revoke items not present anymore
https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/revokeinventoryitems - grant new items
https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/grantitemstouser - for every item that has it's count changed call:
https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/modifyitemuses - for every items that was moved or has changed durability call:
https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/updateuserinventoryitemcustomdata
Our inventory has a lot of items in it. Every character can have 30 items and the shared storage (like the big chest in diablo) can have more than 100.
I have a hard time imagining how to implement this. The dedicated server is most probably not the biggest problem since it is a trusted source and can do all the updates required to the inventory in several steps even though this would not be ideal.
But when the client want's to do inventory management when not playing a game it would mean every change has to happen with PlayFab. That could be a lot of calls to:
- grant item
- revoke item
- modify item uses
- update custom data
Is there a rate limit on on any of those calls I just found a limit on how many custom data key/value pairs can be modified at once.
In general, would you recommend using the PlayFab inventory system for something like that?
Best Regards
Markus