question

Christian Markowicz avatar image
Christian Markowicz asked

Would the backend data for my game be doable in PlayFab?

Hey! I've started reading some docs, and I'm considering migrating what I've done so far in php and databases to Playfab. I'm wondering if anyone could give me some hints if my setup will be working in playfab. What the DB will contain:

Clients [1..1] --- [0..10] Characters
Characters [1..4] --- [0..10] Crews
Crews [1..1] --- [0..5] Ships
Clients [2..2] --- [0..*] Friendships


(I hope my UML notations are correct ^^)

Excluding Friendships the above can have additional information like name, currency, appearance data etc.

One bonus question would be if the general way of using PlayFab would be to use it directly from client or only from your servers?

Thanks for any answer or suggestion!

10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

Please let me rephrase your case first in case I misunderstood something, please correct me if I were wrong:

  1. The “Clients” you talked about equals to “Player”, and I will use “Player” instead of “Clients” next.
  2. A Player can possess 0-10 Characters
  3. A Character can have 0-10 Crews, however, each Crew only belongs to 1-4 Characters
  4. A Crew can have 0-5 Ships, and each Ship only belongs to One Crew.
  5. A Player can have several Friendships (0-*) with other players, each Friendship contains two players.
  6. A Player can have other information like name, currency, appearance data, etc.

If that’s your case and I didn’t misunderstand anything, I believe that’s possible in PlayFab:

For 2, PlayFab provides the Character feature, which is suitable for your case, please navigate to this blog post to learn about more: Get In Character with PlayFab

For 3, each Character can have their own Player Data, Objects (Entity Objects), etc., you can store the Crew data as Player Data/Objects (It is recommended that all new Titles utilize Entity objects, as that will give the most flexibility and performance for your game). For the case that each Crew only belongs to 1-4 Characters, you may need to add some additional server/client side logic to make that happen.

For 4, let’s suppose you stored the Crew data in Objects in the form of Json object, you can then include the Ship info within each corresponding Crew, for instance, sort of like this:

{  "Crew1":{  "Ships":[  "Ship1",  "Ship2"  ]  },  "Crew2":{  "Ships":[  "Ship3",  "Ship4"  ]  },  "Crew3":{  "Ships":[  "Ship5",  "Ship6"  ]  }}

And, again, for the case that each Ship only belongs to One Crew, you may need to add additional client/server logic to make that happen.

For 5, PlayFab offers the Friends feature for you to utilize, however, friendship on PlayFab is a one-way street, sort of like the following system: Player A adds Player B as a friend, Player B must separately add Player A for the friendship to be mutual. Fortunately, there are already some discussions about workaround solutions for a two-way friend system on the forum, here is one of them you may find helpful:

Two-way friend confirmation with Cloud Script

For 6, PlayFab offers the Currencies feature, so each player’s currency info can fall into that part, for other information, you can save them as Player Data/Objects, and, as I mentioned above, it’s suggested that you utilize Entity Objects.

Above are my own personal solutions, you can come up with your own ones once you are familiar with all the PlayFab features.

For your bonus question:

It depends on your own situation, if your game doesn’t need some server-side logic, it’s ok that you use Client APIs solely in clients, however, if your game needs some server-side logic, you may also want to consider using server APIs in server-side .

1 comment
10 |1200

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

Christian Markowicz avatar image Christian Markowicz commented ·

6th (with the new explenation I provided) is a bit more hassle. I want e.g. currency for the crew and not individual players to buy ships. But I guess I can make some work around by moving currency to the player from crew during a purchase. (note this is not from real money, but gameplay affecting things)

Thanks for the answers so far! =)

0 Likes 0 ·
Christian Markowicz avatar image
Christian Markowicz answered

Thanks for the answer! I spent almost whole day yesterday reading docs, so I'm a bit more up to speed of it now. You got almost everything right of my description, only 6th point should be:
6. Player, Character, Crew and Ship can have additional information such as a currency, apperenceData, name etc

So to continue on:
2nd is ok.

3d I was thinking Entity Group instead? That way I won't have to update multiple players for any data change.

4th, I think I can accept this (one layer down with Entity Groups), but it would be nice if they became their own entities, is this possible? There are a few ambiguities looking at Groups e.g. "The Groups API is designed for any permanent or semi-permanent collections of Entities (players, or non-players)." and "In short, entity groups can be any collection of entities (whether NPC or player-controlled, real or abstract), which need a persistent-state bound to that group." and "Today, entity groups can contain players and/or characters.". This is very confusing if this is a feature uncomplete or if I can make another entity which isn't bound to any player or character?

5th sounds ok either way.

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.

Citrus Yan avatar image Citrus Yan commented ·

For 3, the reasons why I didn't suggest Entity Group is that it only can contain players and/or characters for now. Custom entities are not supported now, let alone having entity group include them.

For 4, based on the current documentation, I don't think the "Creating Custom Entities" feature is available now, please keep an eye on the docs or blog posts for any new updates about this.

For 6, Player and Character having additional information is OK, however, Crew and Ship having them might be a hassle since they cannot become their own entities. Therefore, the way to store additional information in 4th could be a workaround for this current situation.

0 Likes 0 ·
Christian Markowicz avatar image Christian Markowicz Citrus Yan commented ·

I see, from what I can see in docs entity groups has same functions as player and character entities (of saving json).
"Additionally, the same Entity functions that exist for Entities also function for Groups, so you will be able to save json objects, and files directly to the group to save arbitrary game-specific data."

So I think I can have Crews as entity groups of characters, which contain json data of ships.

Thanks for help!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Christian Markowicz commented ·

Yes, group itself is a entity too:)

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.