Sign In Register

How can we help you today?

Start a new topic
Answered

Who's turn is it?

https://docs.gamesparks.net/documentation/cloud-code-api/spark-cloud-code-api/sparkchallenge


How do I know on the cloud who's turn it is?  The client API has a nextPlayer field.  What should I be using on the cloud?


Best Answer

Hi Vince,


You can't get the nextPlayer in SparkChallenge I'm afraid. You can use Spark.getData().nextPlayer in ChallengeTurnTakenMessage or in the ChallengeStartedMessage. What exactly are you trying to achieve here ? Let me know and we'll help you find a solution.


Thanks,

Liam


Answer

Hi Vince,


You can't get the nextPlayer in SparkChallenge I'm afraid. You can use Spark.getData().nextPlayer in ChallengeTurnTakenMessage or in the ChallengeStartedMessage. What exactly are you trying to achieve here ? Let me know and we'll help you find a solution.


Thanks,

Liam

I'm trying to setup the initial game state.  When the challenge starts, I'd like the cloud to know the order of the players and who is to act first.  Is the global ChallengeStartedMessage the right place to do this?  Spark.getData().nextPlayer returns null/undefined.

Hi Vince, 


The following will get the nextPlayer in the ChallengeStartedMessage.

  

var nextPlayer = Spark.getData().challenge.nextPlayer

  

Thanks,

Liam

Login to post a comment