question

johndose avatar image
johndose asked

Beginner Question: game item data

I have tons of question with backend service, but this is main one. What should I do to start building player inventory and shop?I need to build up card display system like clash royale

Image result for clash royale card

Image result for clash royale card

or heartstone like

Image result for hearthstone card

I want to make player understand which item they choose, what information they need of this item, and price of this item. Last but not least, after player selected item into their deck(deck creation like heartstone or clash royale), player can use them in play scene(data transfer between scene). How can I build up this system?Thank you all!

etc2j.jpeg (10.9 KiB)
10 |1200

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

JayZuo avatar image
JayZuo answered

Based on the amount of your card characters, there will be multiple solutions for your game. If your card collection is small, you can use a character system like the UnicornBattle demo.

But according to your description, it seems you will have a large number of card characters like this topic: https://community.playfab.com/questions/3830/logic-flow-for-character-selection.html. In this scenario, your best bet is going to be to manage them as inventory items. You can set up a catalog and in the catalog, set each card character as a item (For different level, you might also set different item for upgrade system). For character's attributes, you can store them in item's custom data. Then players can purchase and view cards they have like in Player Inventory

For more info, you can check @Brendan's answer . And if you still have any problem, please feel free to ask here. ;)

10 |1200

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

johndose avatar image
johndose answered

@JayZuo Thank you for answering. Yes, I understand the direction and work flow for building my system now, thank you for your suggestion. However, the main problem I have still exist, which is how to code it.

I have watched all video in PlayFab offical youtube channel for function introduction, but except angrybot(which still not have show core code to build in-game UI and exact json or c# data), there have no any other video to teach beginner how to deal with inventory system which normally is heart of the game.

Also, I have looked though the Player Inventory page, which mainly describe how to call a method, but still not easy to understand how to call it, how to elaborate it etc.

just like this example code

void MakePurchase() {
    PlayFabClientAPI.PurchaseItem(new PurchaseItemRequest {
        // In your game, this should just be a constant matching your primary catalog
        CatalogVersion = "CharacterClasses",
        ItemId = "MediumHealthPotion",
        Price = 5,
        VirtualCurrency = "AU"
    }, LogSuccess, LogFailure);
}

void GetInventory() {
    PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), LogSuccess, LogFailure);
}

void ConsumePotion() {
    PlayFabClientAPI.ConsumeItem(new ConsumeItemRequest {
        ConsumeCount = 1,
        // This is a hex-string value from the GetUserInventory result
        ItemInstanceId = "potionInstanceId"
    }, LogSuccess, LogFailure);
}

If I want store my item(card), is that need to make anything within void MakePurchase?Or I need to start code in json file, which I need which type of format(sorry that I am really new to these kind of things)to code?If so, how can I transfer those item list data, transfer the item player want to purchase to MakePurchase method?And how to link with PlayFab GameManager(how gamemanager understand which item it actually is)? These question I am still really concern.

Furthermore, how can I deal with data and UI present at the same time(maybe out of topic)

Image result for clash royale card

just like this picture, which can show all the information of this card and also base in one outlook(icon sprite,panel, other state sprite, data etc), is that need to separate to different thing, just need to store in the game file itself or need to upload to playfab either?If it does not need to, how can it define this card purchasable or unpurchasable?


Moreover, if those card are not stackable, but still can be get by player with some gacha system, if I want that exceed card transfer to other currency or material, how can I do that?

Thank you for answering and sorry for noob question, I really want to work with this amazing backend service, hope you can understand.

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.

brendan avatar image brendan commented ·

It's actually much simpler than it sounds like you're thinking.

1. Create a catalog. In it, define at least VC prices (and RM - Real Money - prices, if you're not using a receipt validation system), and use Custom Data to define the "schema" of the item. Have a look at this tutorial for in-depth info on catalogs: https://api.playfab.com/docs/tutorials/landing-commerce/catalogs

2. Sell or grant items to players using our secure API calls. For grants, use a custom game server or Cloud Script, so that you can code in cheat protection. If you're targeting mobile, we'd recommend only selling VC for real-world money, and use VC for all other in-game purchases/upgrades. https://api.playfab.com/docs/tutorials/landing-players/inventory

For the unique data per item, store that in the item instance Custom Data. Limit that to only the specific data you need, as it's quite limited in total space.

And that's really it. Selling/granting the items puts them in the player inventory, which makes it visible on the player account in the Game Manager.

0 Likes 0 ·
johndose avatar image johndose commented ·

@Brendan Thank you, now I have little bit clear what I need to do.

But, there still have something missed.

1. After I create a catalog and item in PlayFab, how can that specific item link to specific card

how to specific identify the one card which player want to use, want to purchase?

Image result for clash royale

like this diagram, how to make client know which card player selected, whether link with the correct itemID(how to code)?

2.Is that card UI(like the diagram) can be place inside Unity, I can just put it in Unity scene, and just need to connect the level, cost , price , state of the card with PlayFab?If so, how can I connect with those attribute, without any error(mean that get the correct data the card have)?


3.if those card are not stackable, but still can be get by player with some gacha system, if I want that exceed card transfer to other currency or material, how can I do that?

Thank you

0 Likes 0 ·
brendan avatar image brendan johndose commented ·

The ItemId of the item in the catalog is how you would reference it, for a purchase (usually using a Store). The item in the catalog is the definition of the card. The item instance that's generated from that, and places in the player inventory, is the item that the player has. I would strongly advise reading all the tutorials in our Commerce section: https://api.playfab.com/docs/tutorials#landing-commerce

So for 1 and 2, you would read the Catalog when you start the game, so that you have the base info about all the items. If you're showing a sale page, you'd read the Store that you want to show the player. Either of those could have prices, but I'd put them in the Store. If you're showing the player their own inventory, you'd read the player inventory.

But I'm not clear on what you mean by how you can connect them "without any error". You would use the properties in the response JSON to populate your interface. If you're running into errors, what are they, specifically?

For 3, can you clarify the question? From your design intent, I would say you always want the cards to be stackable. But I don't know what you mean by "exceed card transfer"?

0 Likes 0 ·
johndose avatar image johndose brendan commented ·

@Brendan I have read a lot of tutorial already, I am still not understand clearly, how to implement itemID into itemScript inside Unity.

So, you mean that once I set itemID into itemScript, that item will get all the attribute I set in PlayFab, right?Did not need to have special API to call?


the "without any error" is that I wonder is that will be happen like item data swipe with another item data, I think that only happen if I implement wrong itemID right?

For 3, just like heartstone, if I want player cannot stack over 1 card, if they get another one which will automatically transfer become other thing like VC or material. How to deal with this special case?

Thank

0 Likes 0 ·
Show more comments

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.