Skip to content

LobbyController beta ​

Interface of @v12-engine/client

ts
export interface LobbyController

A 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 ​

ts
chat(text: string): void;

Says a line to everyone in the lobby, before the game

chatLines ​

ts
readonly chatLines: Accessor<LobbyLine[]>;

The lines said in the lobby, oldest first: the last LOBBY_LINES_KEPT

game ​

ts
readonly game: Accessor<{
        game: string;
        mode: string;
    } | undefined>;

The game and the mode the server runs

join ​

ts
join(options: LobbyJoin): Promise<RemoteSession>;

Connects, joins, and gives the game once it starts. The lobby is seen meanwhile

kick ​

ts
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 ​

ts
leave(): void;

Out of the lobby: the connection closed

name ​

ts
readonly name: Accessor<string>;

The name this player goes by: kept in the settings for the next time

offered ​

ts
readonly offered: Accessor<Record<string, LobbySetting>>;

What the game offers to set for the lobby, by setting id (ServerHooks.settings)

phase ​

ts
readonly phase: Accessor<'lobby' | 'game' | 'ended' | undefined>;

Whether the server is in its lobby, has a game on, or one that ended

ready ​

ts
readonly ready: Accessor<boolean>;

Whether this player said they are ready

reconnect ​

ts
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 ​

ts
rename(name: string): void;

Another name, said to the others and kept

said ​

ts
readonly said: Accessor<string>;

What the lobby says now, in words: connecting, waiting, why it was turned away

seatOffered ​

ts
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 ​

ts
readonly seats: Accessor<ServerSeat[]>;

The seats, as the server last said

set ​

ts
set(setting: string, value: string): void;

A setting of the lobby's, to one of its options

setReady ​

ts
setReady(ready: boolean): void;

Ready, or not: once every player seated is, the game starts

setSeat ​

ts
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 ​

ts
readonly settings: Accessor<Record<string, string>>;

The lobby's settings as chosen, and what the game offers of them

sit ​

ts
sit(player: PlayerId): void;

Another seat, free: what is free is shown by the seats

start ​

ts
start(): void;

Starts now: the computer takes the open seats

state ​

ts
readonly state: Accessor<LobbyState>;

How the lobby is: connecting, waiting in the lobby, watching, playing, refused or failed

url ​

ts
readonly url: Accessor<string>;

The address of the server the lobby is connected to

you ​

ts
readonly you: Accessor<PlayerId | undefined>;

The seat of this player, once seated