Skip to main content

Class: Game

Get events from the game and put everything on the screen. Provide an interface for the players: play area, settings and others

Constructors

constructor

new Game(options?)

Parameters

NameType
optionsIGameOptions

Properties

client

client: Client


lobby

lobby: LobbyRoom


room

room: Room<Record<string, any>, Record<string, unknown>>


ws

ws: WSOptions

Accessors

sessionID

get sessionID(): string

If connected to game room, will return its session ID

Returns

string

Methods

create

create(roomName, options?): Promise<Room<Record<string, any>, Record<string, unknown>>>

Parameters

NameType
roomNamestring
options?RoomCreateOptions

Returns

Promise<Room<Record<string, any>, Record<string, unknown>>>


destroy

destroy(): void

Returns

void


getAvailableRooms

getAvailableRooms(gameName?): Promise<colRoomAvailable<any>[]>

Parameters

NameType
gameName?string

Returns

Promise<colRoomAvailable<any>[]>


join

join(roomName, options?): Promise<Room<Record<string, any>, Record<string, unknown>>>

This one is probably useless for game rooms. Use joinOrCreate instead.

Parameters

NameType
roomNamestring
options?RoomCreateOptions

Returns

Promise<Room<Record<string, any>, Record<string, unknown>>>


joinById

joinById(roomId, options?): Promise<Room<Record<string, any>, Record<string, unknown>>>

Parameters

NameType
roomIdstring
options?RoomCreateOptions

Returns

Promise<Room<Record<string, any>, Record<string, unknown>>>


joinLobby

joinLobby(): Promise<LobbyRoom>

Returns

Promise<LobbyRoom>


joinOrCreate

joinOrCreate(roomName, options?): Promise<Room<Record<string, any>, Record<string, unknown>>>

Parameters

NameType
roomNamestring
options?RoomCreateOptions

Returns

Promise<Room<Record<string, any>, Record<string, unknown>>>