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.
 
 
 
 

51 lines
1.1 KiB

import { Socket } from "socket.io";
export type SocketID = string;
export interface SocketWrapper {
id: SocketID,
socket: Socket
};
export interface Player {
socketData: SocketWrapper;
username: string;
hasTabellone: boolean;
cartelle: number[];
choseAllCartelle: boolean;
ready: boolean;
}
export interface StrippedPlayer {
username: string;
id: SocketID;
ready: boolean;
}
export enum TombolaAction {
NONE,
AMBO = 2,
TERNO,
QUATERNA,
CINQUINA,
TOMBOLA = 15,
DONE
}
export type PracticalTombolaAction = Exclude<Exclude<TombolaAction, TombolaAction.NONE>, TombolaAction.DONE>;
export interface Room {
tabellone: number[];
players: Player[];
gameStarted: boolean;
id: string;
nextProgress: Exclude<TombolaAction, TombolaAction.NONE>;
winners: {
[Prog in PracticalTombolaAction]: StrippedPlayer[] | null;
};
};
export enum RoomJoinError {
NoSuchRoom,
GameHasStarted,
RoomIsFull
};
export const MAX_PLAYERS = 8;
export enum GameStartError {
TooFewPlayers,
TooManyPlayers,
NotReady
}