question

andrearossini avatar image
andrearossini asked

"Premium" Tournament

Hi,

we would like to create a premium tournament system in our game. Basically it's a leaderboard, where player gain points winning game only if he has payed a buy-in price.

Let's assume that a tournament has a fixed duration: 1 day. During a day, a player can do 2 thing:

- Play for the current, running, tournament (if he has payed the buy-in the day before)

- Pay the buy-in for the next tournament and register himself for tomorrow.

We use a cycling statistic system (resetting stat every X time) in order to re-use same statistic for different tournament.

We thought about setup a PlayFab Scheduled Task that call a Cloud Script function every X time to switch tournament (archive the running one and start the next one). What about if this call fail for any reason? Has scheduled task a feature to detect that and re-run the task?

Also, every tournament switch we would like to automatically reset a statistic from an external service (like cron-job.org) calling this: https://api.playfab.com/documentation/admin/method/IncrementPlayerStatisticVersion

Here we have the same problem descrived above: what about if that call fail?

Last point: is there any kind of limit for the number of IncrementPlayerStatisticVersion that we can do?

What do you think is the best way to achieve this tournament system using PlayFab?

Thank you very much.

Best regards,

Andrea

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

·
brendan avatar image
brendan answered

By default, the Client API call to update statistics is disabled. That's because if you let the client be authoritative about stats, you'll get rampant cheating. What you should do is have the report of statistics be from a dedicated server or Cloud Script, so that you can have server-authoritative checks of the data before the statistics are written. As part of that, if you want to require that the user has to have purchased something (possibly an item that has a Usage Period of 1 day), you can check that there.

But no, while you can increment a statistic every day through the Admin API (with your own tool server) or by setting the leaderboard to reset daily (which would be at 00:00 UTC, though it can be up to a couple of minutes after exactly 00:00, based on the current load) you cannot increment a statistic from Cloud Script currently.

I would recommend using your own server with the Admin API if you want an exact 00:00:00 time for the statistic update, or a different time of day - otherwise, just use the daily reset.

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

andrearossini avatar image andrearossini commented ·

"you cannot increment a statistic from Cloud Script currently.": I know that.

My idea was to run on cloud script (with a scheduled task) the part that switch active tournament data (it makes some changes in TitleData). My question was about Scheduled Task... Can I detect an error and re-run the task in order to be sure that the call has completed normally?

Then, the IncrementStatistic will be done by an external service.

Thank you.

0 Likes 0 ·
brendan avatar image brendan andrearossini commented ·

If you're using an external server to make the call to increment the statistic version, why not use it to make the change to Title Data for the tournament? That would ensure that the changes are aligned, time-wise.

With a Scheduled Task, no, you can't detect an error and automatically re-run the script. We are planning on adding retry to tasks in the future (though it won't be unlimited - after repeated failures trying to do the same thing, we'll have to assume that there's an essential bug in the logic).

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.