ServerHooks beta
Interface of @v12-engine/engine
export interface ServerHooksWhat a game does on a server (Rules.server). Only ever run there: a player's screen has none of it. The lobby's settings come to onGameStart as the lobby left them
Members
onGameEnd
onGameEnd?(world: World, result: GameResult): void;The game ended: who won, as plain data, before it is kept (saveResult)
onGameStart
onGameStart?(world: World, seats: readonly ServerSeat[], settings: Record<string, string>): void;The game starts, with the world made and the lobby's settings
onPlayerJoin
onPlayerJoin?(seat: ServerSeat, world?: World): void;Someone took a seat in the lobby, or came back to theirs in a game (world then)
onPlayerLeave
onPlayerLeave?(seat: ServerSeat, world?: World): void;Someone left their seat: in the lobby, or in a game (world then), where they may come back
saveResult
saveResult?(result: GameResult): void | Promise<void>;Keeps a game's result: in a file, a database, a ranking. A server writes it to a file of its own without
seatSettings
seatSettings?: Record<string, LobbySetting>;Settings of each seat, by name: a race, a difficulty, a colour. Chosen in the lobby by who sits there, and for a seat the computer plays or nobody holds, by any player seated; each seat's (ServerSeat.settings) are handed to its computer player (GameMode.ai) and to the start (onGameStart)
settings
settings?: Record<string, LobbySetting>;Settings of the lobby, by name: what can be chosen, and what is chosen until someone does