How to handle next turn when someone left room?

0 votes
Hello, Suppose one room has max 5 player of capacity and 5 active players are playing. now 3rd player left room, and someone else join that room, Now i want to put that player on 3rd position, hows that possible? If its not clear what i want then let me know, will tell you in details. Thanks.
asked Feb 16, 2016 in Cocos2D-X by smitpatel88 (33 points)

1 Answer

+1 vote
 
Best answer

Hello Smit,

The server considers the turn based on the sequence user enters in the room. In your case, if the 3rd player leaves the room and a new user joins then the new user will be on the 5th spot i.e. last in the sequence.

You can define your own custom turn mechanism. We have already provided the custom turn management APIs in the cocos2dx SDK to override the default server logic.

You can go through this blog to understand more about the same.

Let me know if you have any further queries.

Thanks.

answered Feb 17, 2016 by rajeev.etc (1,660 points)
selected Feb 17, 2016 by smitpatel88
Thanks for reply, i got the idea how i have to handle it.
Also can you tell me when new user joins room, how to detect whether game is running or not?
Whenever game starts, you can set a property say "isGameStarted" to true and the same can be set to false when you stop the game. The users can check for this property to know game is running or not.
so you mean in room's properties, right?
but it has 2kb size limitation.
Yes, you can set this as a room property.
As of now, this can be done using properties but if this is road blocker for you then we can add one api to know the game state. But this will be available in our next release.
Thank you so much.
I think api should be there for game state.
May i know when is your next release date?
The next release is scheduled for 29th Feb. I will update this thread once it is live.
Hi rajeev,
Any update on this?
thanks.
Hi Smit,
Apologies for replying late on this.
We have updated our cocos2dx SDK with new API to check the game status in a turn-based room.
Please download the latest version of the SDK from our GitHubRepo(https://github.com/shephertz/AppWarpCocos2DX/tree/master/V_1.10.3), use the following API to get the game status:
                void getGameStatus();
Result of the request is provided in the onGetGameStatusDone callback of the TurnBasedRoomListener.
Let me know if you face any problem.
Thanks.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...