question

MoonHeonYoung avatar image
MoonHeonYoung asked

Can i implement the following functions?

I am developing a mobile rpg game.

i want to implement global-boss features like many other RPG games

i.e.

One boss is created per week, and the boss's health is shared by all players.

Whenever a player challenges a boss, he will face a monster with updated health.

so When the boss monster's health becomes 0 (by challenge of all players)

The rewards are given in the order of the user who did the most damage.

How do I implement the above function?

First of all, the boss monster's HP must be shared.

Photons that need realtime matching don't seem to be a suitable alternative.

Can PlayFab's shared group data be an alternative?

And when implementing the above process, for example when the boss monster's hp is 1

If two players challenge at the same time, duplicate results will occur.

(Two players who killed the monster)

How do I solve the this case?

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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> One boss is created per week, and the boss's health is shared by all players. Whenever a player challenges a boss, he will face a monster with updated health. so When the boss monster's health becomes 0 (by challenge of all players)

It sounds like the health point of this boss is a global variable that can be read and written by all players, is it right? If so, PlayFab doesn’t provide the feature to handle such global variables. We would suggest you use the external cache such as Azure Redis.

For other monster information such as the description and configuration (global constant), you can store them in the Title Data. Since Title Data values are copied and distributed to potentially hundreds of machines in the PlayFab server cluster. As part of this process, Title Data is cached, and changes may take up to fifteen minutes to refresh in those caches. Title Data is best suited for Global Constant/Static Data and is not suitable or reliable as Global Variables.

>> The rewards are given in the order of the user who did the most damage.

To implement the rewarding feature, you can consider using PlayFab Leaderboard. You can store the players’ damage points as the statistics, so PlayFab can rank them based on the amount of damage and reward players according to their rankings.

>> Can PlayFab's shared group data be an alternative?

PlayFab Shared Group Data also doesn’t support storing such global variables. As our document, especially the warning message said, Shared Group Data should not be used by groups larger than a dozen or so players, at most. One issue is that too many players attempting to read the same data at the same time will result in delays reading the data. And you need to special care should be taken to prevent players from over-writing each other’s data. In the instance that multiple players try to write to the same Key at the same time, only one of those writes will "win", resulting in the loss of the other user's data.

>> If two players challenge at the same time, duplicate results will occur. (Two players who killed the monster) How do I solve this case?

The method of preventing the shared resource contention is the distributed lock. As the above answer said, PlayFab doesn’t provide the feature to handle the global variable, except for using Redis, you also need to implement the distributed lock on your own. You can refer to the corresponding documents such as Distributed locks with Redis – Redis to implement it.

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.