Skip to content

#78 Player Movement

MarcelEwinger edited this page Jun 7, 2022 · 6 revisions

The server will send an event to the client socket.on('START_ROUND', (data, winner). Data represent the players Object and winner the Winner(socket). The client will update the players object and update the the dice for the players (UI).

Client will read the winner and display the winner (UI).

After that, the Client will check if it's his turn yourTurn= true/false.

  • False
    Client: Display who has the Turn (search in the players object where yourTurn = true).
    The winner will role the dice and the the other clients will listen to UPDATE_DICE
    socket.on(UPDATE_DICE, socket, diceCounts) socket --> The id who has the turn.
    diceCounts --> array with dice_1 and dice_2
    The Client will update the players object with the new dice numbers

  • True
    Client: Display who has the Turn (search in the players object where yourTurn = true).
    The Client will role the dice and after that he will emit an eventto the server. socket.emit('ROLE_THE_DICE', lobby, diceCounts)
    lobby --> room
    diceCounts --> Array with dice_1 and dice_2
    (Optional) --> check if 6er Pasch

After that, the Client will begin to move and after each field, update the player object with the new position. After that send and event to the server. socket.emit(‘UPDATE_PLAYER_POSITION’, lobby, position)
lobby --> room
position --> current field\

If the Cleints lands on the final Field --> coming soon After the final field action finished the client will send an event to server and set the attribute youtTurn false
socket.emit('NEXT_TURN',lobby)
lobby --> room\

The Clients will hearto socket.on('NEXT_TURN', (nextPlayer)).
Client will check if the nextPlayer = his current socket id.\

  • True
    Client will display who has the Turn and begin to role the dice and set the attribute youtTurn to true.\

  • False
    Client will display who has the turn.

For updating the player position for the player who has the turn implement the following event.
socket.on(‘UPDATE_PLAYER_POSITION’, socket, fieldNumber)
socket --> id of the player who has the turn
fieldNumber --> current field of the player
Each time, update the player object and the player position on the map.