question

Benjamin Klingler avatar image
Benjamin Klingler asked

What's the best way to represent stacks of the same item in different inventories?

Howdy!

I am working on a game that requires stacks of items in the inventory. Players of the game can store their items in one of N locations, let's say at the very least in a box and on their person. Furthermore, when a player enters a server, we rely on Playfab to let us know what's in each of these locations.

I see Playfab has a stackable functionality for items, specifically using the "Is stackable" flag which showcases a "Remaining uses" amount; however, I also saw that only one stack is allowed per item. Since our game technically allows you to store some of Item A in a box and some of Item A on the person, what's the recommended way to structure this in Playfab?

We currently have two options that we are considering. Is there a better way than these two, or perhaps something I'm misunderstanding with regards to how Playfab's economy is meant to be structured?

-----

Option 1:

Avoid using "Is stackable" entirely and instead store item amounts inside of the item's custom data. Within the player's title data, we then keep a list of item IDs that are on the person. This way, we can have multiple stacks of items, some of which may be stored on the person. We do not get the benefit that Playfab stackables provide, but we at least get full control over how to stack items and get to keep all item-specific data on the item itself. This also means we have to maintain and merge stacks ourselves, which is less ideal.

Option 2:

Use "Is stackable" and come up with an additional data structure on the title data to show which items, as well as how many of each item, are on the person. We get the benefits that Playfab stackables provide (automatic increment / decrement when granting / revoking items, etc.), but now our additional data structure on the title data has to keep track of an amount that represents a subset of how much of an item we actually have, which may lead to data desynchronization if we're not careful.

-----

While I would love to take advantage of Playfab stackables and go for Option 2, I'm leaning toward Option 1 to keep the data simpler. If stackables allowed for multiple stacks, this would be an easy win for Option 2, but without that, I just can't wrap my head around the feasibility.

Any and all advice would be greatly appreciated. Thank you so much!

In-Game Economy
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

·
Rick Chen avatar image
Rick Chen answered

The Option 1 sounds good for your plan. Here are some other options I can think of:

Option 3:

Create different stackable items for different N locations (with different item id), but you can treat them as the same item on your client-side.

Option 4:

Use the Character feature to represent the different locations. A player can have many characters and each character has its own inventory. You can store the stackable item to different characters.

You can make the choice of these options (including your own options) based on the structure of your game.

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.

Benjamin Klingler avatar image Benjamin Klingler commented ·

Hi Rick, thanks a ton for your response! I hadn't thought of Option 4, that's super interesting. Sadly, a detail I left out was also to have multiple stacks of the same item within the same inventory, so Option 4 just kicks the can a bit. With consideration and much more confidence than before asking the question, I think we're going for Option 1 for simplicity sake.

I really appreciate the help--have a good one! :)

1 Like 1 ·

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.