question

dev avatar image
dev asked

Logic flow for character selection

Hi, we are new to playfab and we are exploring how we could use playfab for our upcoming game. It will be a character card game and we would like to get a better sense of how to use playfab.

So... If we have pack of cards for players to purchase and the character cards will be drawn randomly, can you please clarify if the following flow is what we should be doing?

1. Setup a catalog named "Characters"
2. Setup each character as a seperate item in the catalog
3. Setup containers for each character group (rare, super rare etc)
4. Setup bundles/stores for different container combinations
5. Client API (PurchaseItem) for purchasing a pack
6. Client API (UnlockContainerItem) to reveal characters in the pack
7. Server API (GrantCharacterToUser) when player selects one of the characters from the pack
8. Client API (UpdateCharacterData) to set power, mana etc of the character

Thank so much!

Characters
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 answered

Given all the factors - the need for a large number of characters, the fact that each character has only a small amount of unique data associated with it, as well as how the way characters are to be managed, your best bet is going to be to manage them as inventory items. Ideally, you would make all cards stackables, so that each different card only takes up one inventory item space, but it sounds like you want players to be able to have multiple cards of a single character, each with its own properties. If so, your data needs could grow quite dramatically, since you'll need to store unique data for each individual character card that the player has, so you'll need to decide in that case what your upper limit will be on how many total cards the player can have. You'll want to check the Limits tab for your title in the Add-ons Marketplace, for price options on upgrading the total number of inventory items a player has, so that you have all the info you need.

The random packs of cards are easy to create in our system - simply create them as Containers, with a number of "draws" from random result tables (drop tables). You can set up those tables to be different rarity levels, so that you could have a container which gives 5 common cards, 2 uncommon, and 1 rare, for instance. And since drop tables can reference drop tables, you can organize your groupings of cards however you need for your own management.

Since your upgrade system is complex (items plus currency), you'll need to use Cloud Script to make sure you have a server-authoritative way to manage those exchanges. We will be adding a "crafting" system later on which would replace the need for this, but for now, Cloud Script is your best bet. When making that exchange, it's best to do it in this order: check that the user has the necessary items/VC, then add the new item, then remove the items/VC that are being used to "pay" for the item you just added. As long as your Cloud Script runs in the CPU limit time (which, unless you're making calls to external web services which are slow to respond, shouldn't be an issue), failures during that process should be exceedingly rare, but it's always better to have the player get something for free rather than lose something in those rare instances.

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

dev avatar image dev commented ·

Hi Brendan, I have setup some items for testing and put them into drop tables and containers, all is working well. Thanks for your help.

My question now is, when the user chooses a character, should I convert that in PlayFab? Or should I just remove the character in the inventory and make custom data for the player? Still haven't exactly figured out how the character system works as the player is only allowed to use 1 character at a time for my game.

Greatly appreciate you advise. Thanks!

0 Likes 0 ·
brendan avatar image brendan dev commented ·

So the two ways to create a Character in a Player account are:

1. (which sounds like what you want to do) sell or grant to the player an item which is tagged as a "token for character". The client can then exchange that item for a Character by calling https://api.playfab.com/Documentation/Client/method/GrantCharacterToUser. That is the secure process which checks that the player has the item in question, removes it, and creates the Character.

2. Just grant the player a Character directly via https://api.playfab.com/Documentation/Server/method/GrantCharacterToUser.

0 Likes 0 ·
dev avatar image dev brendan commented ·

Ok, that I understand. But what if the player has decided to switch to another character? Should I be doing this if that happens?

1) Grant a character card to player that is identical to the current selected character

2) Remove current character that the player has

3) Exchange the new character card selected for the new Character by calling GrantCharacterTo User

0 Likes 0 ·
Show more comments
brendan avatar image
brendan answered

I think I need to understand exactly what you mean when you say "character", first. In our service, we have a character system. In it, a character is an entity which resides in the player account, and which has its own statistics, inventory, and virtual currency balances. Is that what you have in mind?

You should put all items that can be added to player inventory in any way into a single catalog. While you can use multiple catalogs for different purposes, the original intent of the system was that everything goes in one catalog, which you change over time based on the needs of your game releases - that's why it's a Catalog Version.

We do have the concept of character tokens in our catalog system, but those are inventory items that can be exchanged to create a character in the player account, as a way to control how players create characters. Again, this comes down to your design goals and requirements.

Bundles are inventory items that come with other items "for free", as it were.

Containers are closed boxes that hold other (potentially indeterminate until the box is opened) items. If you set a usage count, one will be consumed when the container is opened, and if you set a key item, the player must have that item to open the container (the key's usage count is also decremented).

PurchaseItem is used for purchases of things from your catalog which are paid for with virtual currency. It sounds like you're targeting mobile (iOS/Android), in which case you would use receipt validation for real money purchases via the receipt validation API calls.

If you can provide more details on how your character system is intended to work, I'm sure we can help to design the best solution for you.

10 |1200

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

dev avatar image
dev answered

Hi Brendan,

Thanks for your detailed explanation, we are still trying to get the hang onto how everything links together on the client side on the app and server side on PlayFab.

This is our intended character system. It will be something very similar to "Magical Dice" where players can buy different character packs with virtual currency. Each pack consists of say 5 character cards and they will be drawn randomly based on the weights set in the containers. The drawn character cards will be saved into their inventory and they can select a character card and use such character during their gameplay. Each character will have different skills, attack strength, defence strength, exp, mana etc. Players are allowed to swap to other characters available in their inventory between games.

Characters can be graded with consumption of other character cards + an amount of virtual currency. Levelling up a character will increase difference attributes based on the designed characters. Characters have different grades (ie S, A, B, C etc) and of course a higher grade means a stronger version of the same character. There is a max value for the levels which the characters can upgrade to for each grade (ie C is 5, B is 10, A is 20, A+ is 40 etc). Players can also fuse 2 identical character card that have the same grade and max levels into a higher grade level one card (ie 2x B grade character A with level 10 can fuse into a level 1 grade B character A). The fusing process will also consume an amount of virtual currency.

On top of the characters, there are also item packs (swords, shields etc) that players can purchase with virtual currency. The item packs work similar to characters in terms of randomness, grades, levelling and fusing of items. The items will increase/decrease certain attributes of the selected character such as attack, defence, special powers etc. The equipped items are NOT character specific, meaning that if the player changes characters, the already equipped items will be equipped onto the newly selected character.

This is basically the planned system that we are working on. Pretty much just some standard basic structure for character card related games. Would be great if you could give us some directions in how to setup PlayFab. Thanks so much!

4 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 ·

Sure thing. My initial take on it, based on what I've seen with other character card games is that you'll likely want to manage all these characters as inventory items. But let me as a few questions, so that I can best advise:

  • How many different characters can a player have?
  • How many properties (skills, etc.) can a character have?
  • How many of those properties (if any) will be statistics that you want to track with a leaderboard?
0 Likes 0 ·
dev avatar image dev brendan commented ·

Hi Brendan,

Each player can only choose 1 character at a time, say if the player chose Character A and decided to change to Character B, the original Character A will remain in the player's inventory.

There will likely be around 8 properties for each character.

None of the properties will be used for statistics for the leaderboard.

Thanks!

0 Likes 0 ·
brendan avatar image brendan dev commented ·

Understood on character selection - but the question is, how many characters can a user have in total? Is there a limited number of "slots"? Or could they have 100 different characters to choose from, potentially?

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.