We are building an turn based card game application in which
1. Users are selected randomly which are present in room.
2. Selected user have to choose one card fro 52 cards.
3. If the selected card is Ace of Spade , winner is declared.
4. If the wrong card is selected, game continues with next turn for other users in same room.
Above steps in Detail:
1. Users are selected randomly which are present in room.
i. Getting All rooms by warpClient.getAllRooms()
iii. In Success response of onGetAllRoomsDone -> All rooms are returned. Then room is created or not is achieved by looping through all rooms with getLiveRoomInfo(roomId)
iv. In Success response of onGetLiveRoomInfoDone -> If room dose not exist we are creating it by createTurnRoomWithRoomName()
else f room exists then joining and subscribing the room by joinAndSubscribeRoom(roomId)
vi. In Success response of onJoinAndSubscribeRoomDone() -> we are calling startGame(false)
v. In Success response of onGameStarted() -> we are selecting the user and starting the game based on the nextTurn in the response.
Above flow will be same for all joined users in room. First joined users can start the game successfully. The issue is For next turn user is if next turn user tries to run startGame(false) its failing with error as BAD_REQUEST = 4 in method onStartGameDone().
I have also tried above steps with Dev Console, but no two users can startGame() at the same time.
https://apphq.shephertz.com/appWarp#/testManager
So our query is:
1. When to call the startGame? On joining the room or On next turn completed