Skip to content

Nouvelle architecture de l’API

Jérémie edited this page Nov 22, 2022 · 1 revision

Ce document contient les spécifications de l’API du Jeu du 10.

STATUS: Draft

Game Phases

In lobby:
  1. lobby
At table:
  1. waiting (players can move seats freely during this phase)
  2. bidding
  3. playing
  4. paused (state is saved, players cannot move seats, rejoining players will reclaim their seat and hand, new players can take the place and hand of any empty seat.)
  5. done

Types

These are type specs for network transmission only. Internal types on either ends are not defined by this document.

  • Name
    • String of length 1-64, maybe exclude ‘\’ and other risky chars? Can’t be only whitespace.
  • Seat
    • Integer 0-3. Player in seat 0 is always with player in seat 2; 1 with 3.
  • Team
    • Integer 0-1. Team 0 is always players in seats 0 and 2. Team 1 is players in seats 1 and 3.
  • BidAction
    • Integer 50-100, any number in that range that is also a multiple a 5 means the player is bidding that amount. Any other number means they are passing.
  • CardIndex
    • String of length 2-3, consisting of the concatenation of a CardColour and CardRank.
  • CardColour
    • String of length 1 consisting of one of {♠, ♡, ♢, ♣}, representing the colour of the card.
  • CardRank
    • String of length 1-2 consisting of one of {5, 6, 7, 8, 9, 10, J, Q, K, A}

Events (server → client)

Cette section liste les types d’événements envoyés par le serveur aux clients et leur contenu. Un WebSocket packet peut contenir plus d’un événement.

  • lobbychange when a table is opened, closed or when the players change. Only when phase: lobby.
    • tables: array of tables, each consisting of
      • name (Name)
      • id (UUID)
      • players: array of player Names
  • playerjoin when a player joins the table. Only when at a table.
    • id (UUID)
    • name (Name)
  • playersit when a player chooses a seat. Only when at a table.
    • seat (Seat)
    • hand (array of CardIndexes, only joining when game has already started)
  • playerstand when a player stands up. Only when at a table. Changes phase to paused.
    • seat (Seat)
  • playerleave when a player leaves the table.
  • playerbid when a player bids. Only when phase: bidding.
    • seat (Seat)
    • bid (BidAction)
  • playerplay when a player plays a card. Only when phase: playing.
    • seat (Seat)
    • card (CardIndex)
    • next (Seat)
  • score
    • 0: (Integer 0-100)
    • 1: (Integer 0-100)
  • gamestart when the bid is settled and the regular play begins.
    • next (Seat)
    • bid (Integer)
  • trumpselect when the trump is decided on the first round.
    • colour (CardColour)
  • roundstart when the
    • next (Seat)
  • roundend when 4 cards have been played and the round ends.
    • winner (Seat)
    • play (array of CardIndexes in order of player seat)
  • gameend after the winning move is played. Only when phase: done.
  • error to deny a client request.
    • error (string)

Requests (client → server)

Cette section liste les types de requêtes envoyées par le client au serveur et leur contenu. Le serveur répond toujours avec un ou plusieurs des événements de la section précédente.

  • namechange pour changer le nom du joueur.
    • name (Name)
  • newtable pour créer une nouvelle table
    • name (Name)
  • jointable
    • id (UUID)
  • sit
    • seat (Seat)
  • leavetable
  • bid
    • bid (BidAction)
  • playcard
    • card (CardIndex)

Random Implementation Notes

Spectators are just players without a seat. There is no hard limit to the number of players per table, just to the number of seated players.

Ideas

Maybe "table is for the max 4 seated players and "room" is for everyone around the table including spectating players?