How to count game sessions on the server?

0 votes
My game let's users create and share their levels. Each user-created level maintains its own highscore using the Game and Leaderboard service (each user level becomes a separate 'game' in the Game service).

I have several questions:

- is there a limit to the number a separate 'game' objects I can create in the Game service ?

- I would like to maintain on the server the number of time players have played a given level (so, everytime any player plays a level, I would like to increment a counter associated with the game level). What service should I use for that ? I basically need a table with the gamename and a counter. Should I user server side code for that or is there a simpler way? (the Score services let's me do that incrementation, but there is no method for simply querying the score)

Thanks for your help
asked Sep 25, 2015 in App42 Cloud API-BaaS by dujardin (10 points)

1 Answer

0 votes

Hello,

Kinldy find my answer inline for your query and let me know if it helps:

Ques: Is there a limit to the number a separate 'game' objects I can create in the Game service ?

Ans: Yes, there is limit of 200 games under game service in each app and it will increased according to the pricing plan. For more details about pricing, please write us to sales@shephertz.com. 


Ques: I would like to maintain on the server the number of time players have played a given level (so, everytime any player plays a level, I would like to increment a counter associated with the game level). What service should I use for that ?I basically need a table with the gamename and a counter. Should I user server side code for that or is there a simpler way? (the Score services let's me do that incrementation, but there is no method for simply querying the score)

Ans: You can use Storage service for maintaing the level between user to user and user's counter for a game level. Let's say there is 100 users in level one. So for every user you can save meta info along with saveUserScore method which will help you to maintain the players count in Storage service. You can also drill down for fetching the level information information which you save in meta info while calling SaveUserScore method. 

Let me know if above information help you, or you need further help from my side. 

Regards,

Himanshu Sharma

App42 Team

answered Sep 25, 2015 by hs00105 (2,005 points)
Well I'm not sure I totally understand your solution.
I agree with storing the user-created level in StorageService as a document.
I could then create a game linked to this document (provided that I don't hit the game count limit).
I could call saveUserScore everytime a player finishes the level, so the number of records associated with that game would give me my count. But how do I query the number of saved user score for a given game with the Game or Learderboard service? (I just want the number, and not retrieve all the fields).

Suppose I want to let my players go wild with level creation and they end up creating say 10000 levels. 10000 json documents in the StorageDevice doesn't seem problematic, but I would need the ability to create 10000 game objects in the GameService as well. Is this technically viable (regardless of the pricing plan I would need to pay for) ?

Plan B: I only create JSON documents for each level in StorageService and forget about having leaderboards for them. If I wanted to count the played games, I would still need some kind of server side counter, right? (simply querying the JSON level and incrementing a counter directly in the file seems unsafe and kind of overkill)
Ok I think I need to rephrase my question:
- my requirement is that I want to let my players create server side counters and enable any player to increment these counters
- player A creates a counter with a name
- player B retrieves a list of existing counters
- player A and B can both increment this counter as many times as they want
- players can query counters current value

What is the best approach to implement that?
Hello,

Apologies for late reply. Both ways are correct, either you can manage the counter of game level in Storage service or let your user to manage the count for there challenge as they want to increase or decrease.

Let me know if you face any issue while integrating it.

Regards,
Himanshu Sharma
Well if I use the storageservice, and say I have the following JSON doc stored:

{"id":"level1","count":17}


How can I let every user safely increase value of count ?


The only way I can think of is for each player who want's to increase count to make a first API call to retrieve the document, add 1 to 'count' in the document locally and then save the document back to storageService with a second API call.

That's two API calls, and if two users do these calls concurrently, I might end up with a count value of 18 instead of 19.

How can I ensure that all the increase to the counters that are made concurrently are all taken into account?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...