Sign In Register

How can we help you today?

Start a new topic
Answered

How to implement a very basic challenge

I need to implement a very basic challenge that runs as follows:


1. Player A issues a challenge to Player B

2. If Player B responds to the challenge within 30 seconds he immediately wins the challenge.

3. If Player B fails to respond within 30 seconds Player A wins the challenge.


Step 1 is obviously straight forward. My idea for step 2 is to bind cloud code to the AcceptChallengeRequest and immediately call winChallenge with Player B.


I'm unsure what the best way to go about implementing step 3 is.  I am aware that I can set an expiry time when logging a CreateChallengeRequest, but I can't see a way of running cloud code when the challenge expires in order to call winChallenge with Player A. I could probably use the scheduler to log an event after 30 seconds but would rather use a built in challenge mechanic if there is one that fits my needs.


Any suggestions?


Thanks in advance!


Best Answer

Hi Rob,


The Scheduler is probably the best way to do this alright. You could use the ChallengestartedMessage and ChallengeTurnTakenMessages to create the schedulers and then use the LogChallengeEventRequest for the challenge to cancel it before the timer runs out. If it runs out on a certain players turn you can set the other player as the winner. Does that sound like it would work for you ?


Regards,

Liam

1 Comment

Answer

Hi Rob,


The Scheduler is probably the best way to do this alright. You could use the ChallengestartedMessage and ChallengeTurnTakenMessages to create the schedulers and then use the LogChallengeEventRequest for the challenge to cancel it before the timer runs out. If it runs out on a certain players turn you can set the other player as the winner. Does that sound like it would work for you ?


Regards,

Liam

Login to post a comment