question

eliassanto avatar image
eliassanto asked

How can i create a database of default characters.

I want to create a set of default character that belong to the game and have its atributes loaded from playfab, like i would have Warrior, Mage, Archer, and each one of this will have different default atributes values.

The player will then be able to purchase one of this default characters, when he does that, a copy of that default character now belong to him and he can edit its atributes whiout affecting the default, that belongs to the game.

My question is: how do i do that?, i saw a lot of tutorial vídeos on youtube that says: you can do this, you can do this, but none of how to do this.

Character DataCharacters
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

We show a lot of basic feature usage in our videos, but you're correct that you do need to extrapolate a bit for many game-specific features. The simplest way to accomplish this would be by setting up the definitions of each of your character types in Title Data, so that you can have all the info you need in a single Key (if it's not a lot of data, you could just put all the info for all the characters in one Key) as stringified JSON. That way, you could just parse that into an object when you get it from the service and use it directly. It also means that if you need to adjust anything about the values later on, you could just change it in Title Data, and all characters created past that point would use the new values. And speaking of that, any values that are meant to always remain the same for all characters should definitely just be in Title Data and not stored on the individual character, so that you apply those values globally to everyone (that way, even characters created earlier would use the updated values).

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

eliassanto avatar image eliassanto commented ·

First, thanks for the reply.

I'm doing as you suggested, but everytime i try to upload my json file, i recieve "There was a error parsing your file, Please check your JSON syntax".

I've manage to create the Title data by copy pasting the content of my json into the value field, playfab recognized it as a json, and it Works, but for some reason i can't upload the file, i always have to copy paste the content.

0 Likes 0 ·
eliassanto avatar image eliassanto commented ·

I've downloaded the json file back through the button in the playfab title data, it's a totally different format, it has a lot of \ separating the values.

@Brendan

0 Likes 0 ·
brendan avatar image brendan eliassanto commented ·

Can you let us know the Title ID, so that we can have a look. The only escape sequencing that should exist in the downloaded catalog JSON is in the CustomData, which does require that sub-elements be escaped, since it's a single string.

0 Likes 0 ·
eliassanto avatar image eliassanto brendan commented ·
0 Likes 0 ·
Show more comments
Show more comments
emaalouly1 avatar image
emaalouly1 answered

I don't know if it's descent to do this, but here's what I have done:

- Create an Item Catalog called "Characters" (this catalog's items will be considered as character)

- When a player purchases one of the default characters just create a new character to this player using GrantCharacterToUser function (cloud script), and assign the "Name" with the same ID as the one in the "Characters" catalog

Now all you have to do is when you start the game on a client, you get all the player's characters using GetAllUsersCharacters, now you can get each character's details from the "Characters" catalog using GetCatalogItems.

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 ·

What specifically are you storing in the Catalog entry for the Character?

0 Likes 0 ·
emaalouly1 avatar image emaalouly1 brendan commented ·

I am storing the character's class, description and display name, along with its price. Tags can also be used for small descriptions like "Two swords, One sword" or they can even be used to set some values for the attack damage of skills maybe? Because storing them on the client side might give the users the ability to tweak with them. Title Data just gives you the ability to store key and its value so it's not much of data.

Am I right or am I wrong?

0 Likes 0 ·
brendan avatar image brendan emaalouly1 commented ·

You can store up to 20,000 bytes worth of data in a single Title Data value, so you can actually store quite a lot of data there. Personally, if it were my game, that would be my preference, as I like using JSON data to store complex objects - it's easy to just serialize and deserialize it, then. In JavaScript (if you're doing the setup of the characters in Cloud Script to prevent cheating), it's a one-line call - JSON.parse(). That would also then not take up one slot in your catalog. But if you prefer using the catalog, that's not an issue.

1 Like 1 ·
Jeff Gennusa avatar image
Jeff Gennusa answered

I wish someone, anyone, would just post some cloud script code to give me an idea of how to do this. searching pages and pages and zero code to show how to do anything.

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.