Sign In Register

How can we help you today?

Start a new topic
Answered

Open Challenge Game Room

Hello. We're building a game with open game rooms that players can freely enter and exit. We are trying to achieve this by searching for an open challenge with FindChallengeRequest, and then if one isn't available, create a public challenge with CreateChallengeRequest and starting the challenge right away with SparkChallenge.startChallenge. 


The problem is that the system wouldn't allow us to start the challenge unless there are at least 2 players. Is there any way to get over this restriction? If not, what is the best approach to achieve these open game rooms on GameSparks?




Best Answer

Hi Hamlet


If you have your rooms set up to trigger a public createChallengeRequest on entry, the first user in will create the challenge. The first user to enter will be regarded as the “challenger” and everyone after that is referred to as “challenged. So when the “challenger” leaves the challenge ends (no one wins), you can use sendRequestAs to issue a WithdrawChallengeRequest from the room creator to close the room, that will end the challenge, then choose one of the remaining users (challengers) to rehost it and create a challenge, accept it for the others, again in cloud code using sendRequestAs to create a new challenge and have all the other users rejoin the new one minus the original creator. 


So basically what's happening here is if one person leaves the room (challenge)it is closed and recreated with the remaining users without them doing a thing.

In the cloud code for JoinChallengeResponse you can customise how many players are required for the SparkChallenge to start with “if accepted.length >=2” or whatever suits your needs best.


Thanks,

Liam


the challenges are designed for when one player challenges another player to a game, so there are all these stuffs about sending and accepting challenges. and then if the initiating player (who created the room) leaves, you need to write a bunch of stuff restarting the challenge (https://support.gamesparks.net/support/discussions/topics/1000062635). and then you need to transfer all that challenge data to the new challenge (it isn’t clear how to do that since the old challenge would have been closed at this point).


"Hello. We're building a game with open game rooms that players can freely enter and exit. We are trying to achieve this by searching for an open challenge with FindChallengeRequest, and then if one isn't available, create a public challenge with CreateChallengeRequest and starting the challenge right away with SparkChallenge.startChallenge. The problem is that the system wouldn't allow us to start the challenge unless there are at least 2 players. Is there any way to get over this restriction? If not, what is the best approach to achieve these open game rooms on GameSparks?"



so in short, the challenge feature provides some features that don’t apply to our use case, and it seems to take less effort to build the room feature that we need than to tweak the challenge feature to work for us.

Answer

Hi Hamlet


If you have your rooms set up to trigger a public createChallengeRequest on entry, the first user in will create the challenge. The first user to enter will be regarded as the “challenger” and everyone after that is referred to as “challenged. So when the “challenger” leaves the challenge ends (no one wins), you can use sendRequestAs to issue a WithdrawChallengeRequest from the room creator to close the room, that will end the challenge, then choose one of the remaining users (challengers) to rehost it and create a challenge, accept it for the others, again in cloud code using sendRequestAs to create a new challenge and have all the other users rejoin the new one minus the original creator. 


So basically what's happening here is if one person leaves the room (challenge)it is closed and recreated with the remaining users without them doing a thing.

In the cloud code for JoinChallengeResponse you can customise how many players are required for the SparkChallenge to start with “if accepted.length >=2” or whatever suits your needs best.


Thanks,

Liam

Login to post a comment