Sign In Register

How can we help you today?

Start a new topic
Answered

Turn-based challenge turn order

Hi! We are developing a turn-based mechanics in which player can create a challenge, then server code finds him an opponent and add opponent to created challenge.


How GameSparks decides which player make first turn? 


Our game needs this gameflow:


1. First player creates a challenge

  1.1 GS finds him an opponent and joins op to challenge

  1.2 First player makes his first turn - this step is important


2. Second player get a notification about challenge and his turn


etc


Thanks in advance!



Best Answer

Hi Aleksey


When the challenge starts we select a random first player. There is currently no way to override this behaviour I'm afraid.


For turn based challenges, the first player cannot make their turn unless the other player has accepted. To get around this you can store some data against the challenge that you can use for posting the player turn, but it's not very elegant.


Gabriel


Current challenge setup - https://dl.dropboxusercontent.com/spa/8f9wwsl2k101mgg/k9zt8hdq.png


Challenge event settings - https://dl.dropboxusercontent.com/spa/8f9wwsl2k101mgg/5matl2hi.png

Answer

Hi Aleksey


When the challenge starts we select a random first player. There is currently no way to override this behaviour I'm afraid.


For turn based challenges, the first player cannot make their turn unless the other player has accepted. To get around this you can store some data against the challenge that you can use for posting the player turn, but it's not very elegant.


Gabriel

Thanks Gabriel, we just make a "silent" turn if

challenge.nextPlayer

 is not a creator for now.

Is it still the case that when a turn-based challenge is created and accepted, that the player who goes first is randomly selected?  That's what I want, but it looks like it might not be that way anymore.  Please let me know, and I can write my own coin toss if needed.  I would rather use the built-in coin toss if possible, so that I don't have to skip either players' turns (I would like the turn count to be accurate).  Thanks!

+1

How can I prevent a player from requesting "LogChallengeEvent" when it's not his turn.

Normally I'd implement :

if (Spark.getPlayer().getPlayerId() === Spark.getChallenge(Spark.getData().challengeInstanceId).nextPlayer) {
     // do sth...
} else {
     // warn for playing outside of his turn, or just do nothing..
}

but unfortunately the Challenge object does not have a "nextPlayer" field here, how do I access the current player of a challenge in a LogChallengeEventRequest ?

do I even need to do this kind of check?

2 years ago there was this comment, 


"When the challenge starts we select a random first player. There is currently no way to override this behaviour I'm afraid."


Is this still the case after even 2 years? What I am trying to do is have the challenger make a challenge and make the first move, then the chalengee autoaccepts the challenge. If they dont actually want to play in the challenge they cant resign from it or ignore it.


Login to post a comment