Skip to content

Lobby lifecycle: give MatchData a status instead of inferring it from seat occupancy #1328

Open

Description

@devill

Server.MatchData (types.ts:408) has no field for "has this match started", so the
lobby infers it from seat occupancy — a match is running once every seat has a name.

That works while every match has a fixed number of seats. It is never true for a table
you can join, so it blocks #1327.

 interface MatchData {
   gameName: string;
   players: { [id: number]: PlayerMetadata };
+  status: 'open' | 'running';   // the lobby's lifecycle, not the game's
+  creator?: PlayerID;           // who may start it
   gameover?: any;
 }

Plus POST /games/:name/:id/start and LobbyClient.startMatch. Fixed-seat matches still
flip to running on their own when the last seat fills, so nothing changes for them.

Two things read the seat count and shouldn't

plugin-player builds G.players from ctx.numPlayers at setup
(plugin-player.ts:86) and short-circuits opponent on ctx.numPlayers === 2
(plugin-player.ts:70).

- if (ctx.numPlayers === 2)
+ if (game.minPlayers === 2 && game.maxPlayers === 2)

What the game declared is stable for the life of the match; the live count is not. The
plugin also needs a hook, or a newly seated player never gets a G.players entry.

The React lobby counts filled seats to decide whether to show Play. It should read
status, and create matches at minPlayers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions