question

bhester avatar image
bhester asked

Complex Inventory System

Hi,

We are currently looking at moving our game over from Gamesparks to PlayFab and wanted to check on best practices for our players inventory.

In our game, a player unlocks chests which earn players cards. Once a player has enough cards they can Unlock an item by using thier cards and spending coins or gems.

We store the 'meta' data of items in the Title Data. An example of an item:

"Item_3": {
    "DisplayName": "NAME",
    "UnlockLevel": 0,
    "CardsCost": 10,
    "CoinsCost": 500,
    "Rarity": 0,
    "SkillsData": {	
"SomeSkillData":123 }, "Stats": { "SomeStats":123 }, "Levels": [ { "CardsToUnlock": 4, "CoinsToUnlock": 600 }, { "CardsToUnlock": 4, "CoinsToUnlock": 700 }, { "CardsToUnlock": 4, "CoinsToUnlock": 800 } ] }

We can use the above to show our inventory screen, and how many coins/cards players need to unlock items for example.

We are also currently storing the Player inventory in each players Player Data like so:
key = itemInventory

"Item_3": {
    "Level": 0,
    "NumberOfCards": 40,
    "SkillCharge": 3,
    "bUnlocked": false
  },

We can then grab both of those when users attempt to unlock/upgrade in the cloudscript to check they have enough currency and cards for example.

We also update the Player Data if the user unlocks chests and earns cards for specific items in the Cloud scripts.

However, we also want to do a similar process for when a user makes an IAP. Our IAPs could contain some cards for an item, the whole item itself, currency, chests amoung other things. But I can't find the best way to have the IAP award things like cards to the Item_3 in Player Data for example. When the purchase is validated, is there any kind of response that is hit in the API for a player that we can then award them our specific goods for. Or will we need to somehow use the Catalog system in PlayFab?

If we have to use the catalog system, would our use case be viable or will it require a lot of reworking?

Thanks,
Brad

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

In PlayFab, the IAP needs to be implemented with the Catalog items. When the validation API is called and if the purchase is successfully validated, the PlayFab items in that order will be granted to the player, along with relevant events, purchase history and Value-to-Date being recorded for that player. That is by design. So yes, you need to use the Catalog system to implement IAP in PlayFab. Please refer to this document for more detail: Getting started with PlayFab, Unity IAP, and Android. If you don’t want to change your current configuration that stores player inventory in Player Data, you could write a CloudScript function that consumes the item purchased via IAP and update the corresponding Player Data.

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

bhester avatar image bhester commented ·

Thanks for the reply.

So if a player buys my 'AugustPromotionPack_1' for example, I can setup a catalog item for that. Then when the IAP is processed it awards my player that item.
On a successful purchase, we then execute another cloudscript function that checks for any catalog goods that have been awarded and consumes them - awarding the correct content based on the pack type?

Does PlayFab have any 'callback' or 'response' events by default that we can add CloudScript code to? For example, when a player registers for the first time, or makes an IAP, is there something we can add to the CloudScript which is automatically called so we can do specific cloud script actions?
Or will we have to check for the response on the client and call our own cloudscript functions from there instead?

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ bhester commented ·

The IAP purchase could generate some events, for example, player_realmoney_purchase. You can setup a rule on this event such that when this event is fired, the actions you configured in the rule will be executed. Please refer to this document for more detail: Actions and rules quickstart.

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.