LobbyController beta
Interface of @v12-engine/client
export interface LobbyControllerA game's lobby on a server (createLobby): who sits where (seats, you), the game and its settings, what the server says (said), and what a player does there: another seat (sit), a name (rename), ready (setReady), a setting (set), start now (start), out (leave). join connects and gives the game once it starts; reconnect takes a dropped game back to its seat (what GameClient's reconnect is given)
Members
chat
chat(text: string): void;Says a line to everyone in the lobby, before the game
chatLines
readonly chatLines: Accessor<LobbyLine[]>;The lines said in the lobby, oldest first: the last LOBBY_LINES_KEPT
game
readonly game: Accessor<{
game: string;
mode: string;
} | undefined>;The game and the mode the server runs
join
join(options: LobbyJoin): Promise<RemoteSession>;Connects, joins, and gives the game once it starts. The lobby is seen meanwhile
kick
kick(player: PlayerId): void;Votes to let another seated player go: once most of the others vote so, they are let go (ServerSeat.kick says how it stands)
leave
leave(): void;Out of the lobby: the connection closed
name
readonly name: Accessor<string>;The name this player goes by: kept in the settings for the next time
offered
readonly offered: Accessor<Record<string, LobbySetting>>;What the game offers to set for the lobby, by setting id (ServerHooks.settings)
phase
readonly phase: Accessor<'lobby' | 'game' | 'ended' | undefined>;Whether the server is in its lobby, has a game on, or one that ended
ready
readonly ready: Accessor<boolean>;Whether this player said they are ready
reconnect
reconnect(session: RemoteSession): Promise<void>;Back in a game whose connection dropped: a new connection, the seat asked for again by its token, the session resumed
rename
rename(name: string): void;Another name, said to the others and kept
said
readonly said: Accessor<string>;What the lobby says now, in words: connecting, waiting, why it was turned away
seatOffered
readonly seatOffered: Accessor<Record<string, LobbySetting>>;What the game offers to set for each seat (ServerHooks.seatSettings): each seat's are on it (ServerSeat.settings)
seats
readonly seats: Accessor<ServerSeat[]>;The seats, as the server last said
set
set(setting: string, value: string): void;A setting of the lobby's, to one of its options
setReady
setReady(ready: boolean): void;Ready, or not: once every player seated is, the game starts
setSeat
setSeat(player: PlayerId, setting: string, value: string): void;A setting of a seat (a race, a difficulty), to one of its options: one's own, or one no other player holds
settings
readonly settings: Accessor<Record<string, string>>;The lobby's settings as chosen, and what the game offers of them
sit
sit(player: PlayerId): void;Another seat, free: what is free is shown by the seats
start
start(): void;Starts now: the computer takes the open seats
state
readonly state: Accessor<LobbyState>;How the lobby is: connecting, waiting in the lobby, watching, playing, refused or failed
url
readonly url: Accessor<string>;The address of the server the lobby is connected to
you
readonly you: Accessor<PlayerId | undefined>;The seat of this player, once seated