question

Sergey Yakovlev avatar image
Sergey Yakovlev asked

How to implement Character-specific inventory?

Hi,

I have a fixed amount of unique characters for users to play. Let's say Paladin, Mage, Thief.

Those characters may purchase items unique to the class (dagger for the thief, staff for the mage) or basically the same items across all classes (boots).

How to better make them have separate stores and inventories? For example, all of them have to purchase their boots instance separately. Only a thief can see and buy a dagger in the store.

I can see a couple of options but do not like them, hoping there's a better way.

1. Create duplicates of basic items so that they look the same but are unique: boots_thief, boots_mage. The downside is obviously an explosion of items in the backend with a high probability of mistakes.

2. Have Tags for classes on backend items. Have a large JSON or something in Player Data mapping characters and item instances, then use this to do filtering on a client. The downside is that purchasing an item for a character is no longer a transaction because adding data to JSON is a separate operation that can fail after money is charged.

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

PlayFab has a feature to create Characters for players and the Character has its own Inventory. You can check Character related API here: Characters - REST API (PlayFab Client) | Microsoft Learn. As for the specific stores, you can create 3 stores for each Character. In this way, it will be easy to customize the Store content for each Character.

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

Sergey Yakovlev avatar image Sergey Yakovlev commented ·

Hi and thanks for looking at it! The link you provided says nothing about the Inventory for characters. But I found it here.

As for the store, you propose to go with my option 1 and just be careful with the items that are the same for each character when duplicating or editing them manually?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao Sergey Yakovlev commented ·

Sorry for the confusion. If the boots item are different, you need to create them like your option 1. If they are basic the same, you can just create one, and add custom data to the item instance granted based on the character.

0 Likes 0 ·
Sergey Yakovlev avatar image Sergey Yakovlev Gosen Gao commented ·

Boots are the same, just need to be purchased separately for each character.

But isn't there a problem with adding any custom data that it breaks transactional nature of the purchase?

0 Likes 0 ·
Show more comments
Sergey Yakovlev avatar image Sergey Yakovlev commented ·

Accepting your answer as I do not hear better alternatives but I still see that your last approach is vulnerable due to the loss of the transaction capabilities:

User purchase item - > disconnect happens -> User update item instance data is not invoked (but can be stashed on the client till connection restores as a backup)

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.