question

Kelly Brett avatar image
Kelly Brett asked

Consuming skill from inventory item.

Use case:

Redeem a token that gives a player enhanced ability for 20 shots.

The token itself has a single use, redemption which grants the user a skill that has 20 uses.

A task might not consume all uses, thus the need to separate token from skill.

I currently have defined the skill in my catalog, the token is a bundle that contains 20 of the skill.

Is there a cleaner way to access the instanceid on the skill that is contained within the token?

Currently, I feel as though I need to grab the player inventory and create a list of "Skills" that are a property of the "Token" based upon the tokens bundleid in order to have access to the "Skills" instanceid so that I can consume the uses.

Is there a concise way to get the instanceids of the items in a bundle when you buy an item or do you have to just query the user inventory subsequent to purchasing the bundle?

Player 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

·
Sarah Zhang avatar image
Sarah Zhang answered

Yes, there is such a way to get the instanceIds of the items that come with a bundle when you buy the bundle. When purchasing a bundle, the response of PurchaseItem API will also provide the instance ID of each item in the bundle. You can check the API reference and use the REST API testing tool -- Postman to test the API method and check the response. So, you don't have to query the user inventory to access the “skill” instances.

Besides, according to your description, it seems the Container is more suitable to implement the “token”. Bundles are items that come with other items included. Containers are items that have other items "inside" that are not added to the player inventory until the Container is unlocked. In other words, you needn't unlock a Bundle instance to get the items that come with it.

In your case, once the player purchases a Bundle, the Bundle instance and the “skill” instances would be granted to the user together. But if the player purchases a Container, only the Container instance would be granted to the user. Then the player needs to use to API UnlockContainerInstance to consume the Container instance and get the inside-content.

The response of PurchaseItem contains the Container’s instanceId. The player can call UnlockContainerInstance to “redeem” it. Then the player can get content items’ instance Ids from the response of UnlockContainerInstance. If so, you needn’t query the user inventory to access the “skill” instances too.

10 |1200

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

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.