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

Hello,

I have 4+ players and I would like to list information about them in turn order in the UI along with an indicator of whose turn it is.  I see the next player field but how do I get a list of players in turn order?


Thanks,

Chris


2 people like this

Hey,


Is there any way to get an order of turns for any challenge in the case of 5 players?

Login to post a comment