Skip to content

1681-engine / index / Matchmaker

Class: Matchmaker ​

Defined in: src/net/lobby/Matchmaker.ts:37

The matchmaking queue, pure: tickets in, matches out, no clock of its own and no sockets. Each find(now) takes the oldest ticket of a mode as the anchor, gathers the groups within its rating window (and each within theirs, so a newcomer is not thrown in with veterans because a veteran waited), and fills the teams from the closest ratings first, never splitting a party; the teams are then balanced by rating. A window grows with the wait, so anyone is matched in the end; a ticket nothing fits waits for the next call.

Constructors ​

Constructor ​

ts
new Matchmaker(modes): Matchmaker;

Defined in: src/net/lobby/Matchmaker.ts:41

Parameters ​

ParameterType
modesreadonly MatchMode[]

Returns ​

Matchmaker

Accessors ​

size ​

Get Signature ​

ts
get size(): number;

Defined in: src/net/lobby/Matchmaker.ts:48

Returns ​

number

Methods ​

add() ​

ts
add(ticket): void;

Defined in: src/net/lobby/Matchmaker.ts:57

Adds a ticket (replacing one of the same id); throws on an unknown mode or a group too big for a team.

Parameters ​

ParameterType
ticketTicket

Returns ​

void


find() ​

ts
find(now): FoundMatch[];

Defined in: src/net/lobby/Matchmaker.ts:87

Every match that can be made now; their tickets leave the queue.

Parameters ​

ParameterType
nownumber

Returns ​

FoundMatch[]


get() ​

ts
get(id): Ticket | undefined;

Defined in: src/net/lobby/Matchmaker.ts:70

Parameters ​

ParameterType
idstring

Returns ​

Ticket | undefined


mode() ​

ts
mode(id): MatchMode | undefined;

Defined in: src/net/lobby/Matchmaker.ts:52

Parameters ​

ParameterType
idstring

Returns ​

MatchMode | undefined


remove() ​

ts
remove(id): Ticket | undefined;

Defined in: src/net/lobby/Matchmaker.ts:64

Parameters ​

ParameterType
idstring

Returns ​

Ticket | undefined


waiting() ​

ts
waiting(mode): Ticket[];

Defined in: src/net/lobby/Matchmaker.ts:75

The tickets waiting for a mode, oldest first.

Parameters ​

ParameterType
modestring

Returns ​

Ticket[]


windowOf() ​

ts
windowOf(t, now): number;

Defined in: src/net/lobby/Matchmaker.ts:80

How far a ticket's rating window reaches now.

Parameters ​

ParameterType
tTicket
nownumber

Returns ​

number

Released under the MIT License.