A React/Express online multiplayer Tombola client/server combo.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

  1. import { Socket } from "socket.io";
  2. export type SocketID = string;
  3. export interface SocketWrapper {
  4. id: SocketID,
  5. socket: Socket
  6. };
  7. export interface Player {
  8. socketData: SocketWrapper;
  9. username: string;
  10. hasTabellone: boolean;
  11. cartelle: number[];
  12. choseAllCartelle: boolean;
  13. ready: boolean;
  14. }
  15. export interface StrippedPlayer {
  16. username: string;
  17. id: SocketID;
  18. ready: boolean;
  19. }
  20. export enum TombolaAction {
  21. NONE,
  22. AMBO = 2,
  23. TERNO,
  24. QUATERNA,
  25. CINQUINA,
  26. TOMBOLA = 15,
  27. DONE
  28. }
  29. export type PracticalTombolaAction = Exclude<Exclude<TombolaAction, TombolaAction.NONE>, TombolaAction.DONE>;
  30. export interface Room {
  31. tabellone: number[];
  32. players: Player[];
  33. gameStarted: boolean;
  34. id: string;
  35. nextProgress: Exclude<TombolaAction, TombolaAction.NONE>;
  36. winners: {
  37. [Prog in PracticalTombolaAction]: StrippedPlayer[] | null;
  38. };
  39. };
  40. export enum RoomJoinError {
  41. NoSuchRoom,
  42. GameHasStarted,
  43. RoomIsFull
  44. };
  45. export const MAX_PLAYERS = 8;
  46. export enum GameStartError {
  47. TooFewPlayers,
  48. TooManyPlayers,
  49. NotReady
  50. }