Sign In Register

How can we help you today?

Start a new topic
Answered

Find Challenge By Number Of Players

Hello. We have a number of challenges each with a max number of player limited to 4. We would like to find one random challenge that has no more than 2 existing players (so as to leave one spot open after joining). What is the best way to do that? 


Best Answer

Hi Hamlet,


As the first user issuing a CreateChallengeRequest to create the challenge itself, the second player to join will be using a JoinChallengeRequest. When the challenge receives its first join request, you could check in cloud code for JoinChallengeRequest to see if its the first one, if it is it the challenge will now have have two users, at this point you could move this challenge into a randomPublicChallenge collection which you could use pick from randomly in your game.


Thanks,

Liam

1 Comment

Answer

Hi Hamlet,


As the first user issuing a CreateChallengeRequest to create the challenge itself, the second player to join will be using a JoinChallengeRequest. When the challenge receives its first join request, you could check in cloud code for JoinChallengeRequest to see if its the first one, if it is it the challenge will now have have two users, at this point you could move this challenge into a randomPublicChallenge collection which you could use pick from randomly in your game.


Thanks,

Liam

Login to post a comment