question

John Peterson avatar image
John Peterson asked

Question about Player Inventory wth Durable/Stackable items.

Dear PlayFab Community,

I am using The Unity SDK with C#.

I have created some Catalog items that I've marked as Durable and Stackable:

(Note: I'm not wholly sure I understand these concepts, as the documentation for these aspects is a little thin, particularly with the interplay between the various options.)

In any event, I have granted my user a Tile_A, Tile_B, Tile_A, and Tile_A (in that order) from the Dashboard:

In my Unity app, I'm making a call to GetUserInventory to retrieve the inventory. Here are the results:

{
   "Items":[
      {
         "ItemId":"Tile_B",
         "ItemInstanceId":"EEB8B4E36771F0A4",
         "ItemClass":"Tile",
         "Annotation":"Granted via Game Manager",
         "CatalogVersion":"0.1",
         "BundleParent":"",
         "DisplayName":"Tile B",
         "UnitCurrency":"",
         "UnitPrice":0,
         "BundleContents":[
         ]
      },
      {
         "ItemId":"Tile_A",
         "ItemInstanceId":"61AA4CEF9992BD7A",
         "ItemClass":"Tile",
         "Annotation":"Granted via Game Manager",
         "CatalogVersion":"0.1",
         "BundleParent":"",
         "DisplayName":"Tile A",
         "UnitCurrency":"",
         "UnitPrice":0,
         "BundleContents":[
         ]
      }
   ]
}

I would have expected Tile_A to have some "counter" or "amount" that showed 3 (kind of like we see on the Dashboard for the player's inventory). Maybe in the RemainingUses field of the ItemInstance object. However, that field appears to be null.

How do I get the number of items in the stack with the Unity SDK and C#?

Also, I am intending to increment and decrement the amount of this item. This item represents a collectible element that will generally increase over time. However, it can be gifted to alliance members, which would decrement the player's amount. Is the use of Durable in this context appropriate? Or would this be considered a Consumable?

Thanks in advance for any help that anyone can provide!

In-Game EconomyPlayer Inventory
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

·
John Peterson avatar image
John Peterson answered

Ah, I think I found my issue. Looks like Unity's JsonUtility doesn't support nullable primitives (of which RemainingUses is):

http://answers.unity3d.com/questions/1332811/will-jsonutility-support-nullable-primitive-types.html

Sorry for the inconvenience! However, the latter part of my question remains: how should I define my Catalog item for the way I intend to use it?

Thanks again!

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

brendan avatar image brendan commented ·

That's correct - the number in the stack will be in the RemainingUses. For your use case, it depends: How are you planning to gift the item to alliance members? If you're simply modifying the use count in Cloud Script for each player, that should work fine.

0 Likes 0 ·
John Peterson avatar image John Peterson brendan commented ·

Hi @Brendan! Thanks for the confirmation about the RemainingUses and it's function.

I wasn't really sure *how* I'd go about managing the counts. For increasing inventory, I was planning on using the Gift-based interfaces. Maybe the server's GrantItemsToUser. For decreasing (as in the example that we'd "trade" with other alliance members), I was planning on the server's ModifyItemUses. But, I'm not wholly certain if those are appropriate, and whether I should explore other API. If you have any recommendations, or links to other Forum posts that might deal with this, I'd be very much obliged.

0 Likes 0 ·
brendan avatar image brendan John Peterson commented ·

No, those are the API calls I'd recommend using, in fact. I'd say you're no the right track. :)

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.