plourdegui avatar image
plourdegui asked

Continuous resource incrementation over time

We are building an idle game in which resources increase over time, based on the various "upgrades" that the player possesses.

At the moment, resources are defined as attributes of the "Player Data".

We increment the resources on the client side, over time, in an update loop.

Once in a while, we save the data against the server, in the player data, via a CloudScript.

I understand that this approach exposes the risk of cheating the data on the client side.

A possible solution we thought about is to make a validation whenever we save the data from a CloudScript. Yet, we would also like to benefit from the other aspects of having resources defined as VC.

Is there a way to rather define a Virtual Currency which recharges over time, having an infinite "recharge maximum" ?

Can the "recharge rate" value be updated via the API at runtime?

Our idea would be to update the recharge rate every time the player purchases an "upgrade".

If this is not the recommended approach, could you kindly share your thoughts as to how developers usually implement this kind of "Idle Game" mechanic?

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

Well first, VCs are signed int32 values, so no, you cannot have an "infinite" recharge amount. In general, idle games use large number libraries, and store their values as simple data, since otherwise they would require number values that no language or processor supports. Also, you would not want to use a VC for the balance of the player's currency in an idle game, since that value is updated (and spent) at an extremely high rate - for most idle games, if they tried to do this, they would run into the rate limits on calls quickly.

For security, you'll want to do one of two things:

1. Use Cloud Script, as you first thought. In the script, you'll be taking some input from the player on changes over time (you would not call a Cloud Script every time they purchased a resource, as again, that would be far too high of a rate), so that you can walk through all the changes to check if they're legitimate (check the time since the last transaction, what the player balance should be based upon that, and whether the purchases are reasonable).

2. If you want higher security, you'll want to use a custom game server, so that the server can host the interactions with the player. In that model, when the player signs in, you'll use matchmake to get them to a sever (even though it's a single player game, this would still be the model - they're not playing with others, but they need the server info to connect to it). The server would get the info on the state of the player from PlayFab, calculate the current state based upon the elapsed time since it was updated, and then host the session for the player. In that model, you could hit the server as often as you want, since it would only periodically be updating the PlayFab data for that player (every couple of minutes or so would be all you'd need).

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.