Giving the player a reward from a limited reward pool connected to a backend service

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jebenipapa

I’m not really sure how to better put the question in one sentence.

I’m making a simple test-game for my company that is supposed to give the player a reward if he/she manages to compleate it. Currently I have a primitive random number method that gives the player the reward depending on what number they recieve and send a HTTPRequest to the backend which stores what reward a user got (This is all done with multiple databases thoughout my Webapp).

I was wondering what would be the best way to go about making a function that would not only give a player a reward (as in are there better ways to go about this outside a random number generator), but also once a player gets the reward to signal the either backend or a structure within the game that the reward size gets decreased as less and less of the specific reward become available and ultimatly once the reward is depleted to make the user get another reward which is currenly available.

I was assuming a global variable would be something that I can use however as I’m new to the engine I don’t know is there a way for the variable not to reset between users i.e. if I make a counter-- how can I make this counter be active over all the users that have/are playing instead of it being set a number and setting its self back to that number each time the game is booted up again.

Any ideas even without the solution would be appreciated.
Thank you in advance!

jebenipapa | 2021-07-28 06:55

If the reward pool is shared between all players in a game and it is online multiplayer, I believe that the best approach is to store the variable in the backend and let it select reward and decrease the count.

In local multiplayer you could use a variable (or maybe more than one) in the game scene, but since you are going to use a server anyway I would ge with the logic on backend.

You could use very simple values to represent rewards, just associate an int to type of reward. I would also create an identifier for each game (match, it depends on the nature of the game) to allow multiple matches to run at the same time.

gioele | 2021-07-28 08:47