@hadoku/game-server 0.1.120 → 0.1.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ export interface ResultRoom {
68
68
  * `botClientId(seat)`, by SEAT number, never by how many bots came before it, so it agrees with
69
69
  * the roster whichever seats the bots took. A bot is named as the room names it (`aiSeats`).
70
70
  */
71
- export declare function buildFrozenSeats(room: Pick<ResultRoom, 'seats' | 'members' | 'aiSeats'>, userKeys: ReadonlyMap<string, string>, botClientId?: (seat: number) => string): FrozenSeat[];
71
+ export declare function buildFrozenSeats(room: Pick<ResultRoom, 'seats' | 'members' | 'aiSeats'>, userKeys: Pick<ReadonlyMap<string, string>, 'get'>, botClientId?: (seat: number) => string): FrozenSeat[];
72
72
  export interface ResultRouteDeps {
73
73
  lobby: {
74
74
  get(roomId: string): ResultRoom | undefined;
@@ -84,3 +84,21 @@ export interface ResultRouteDeps {
84
84
  }
85
85
  /** Mount `POST /rooms/:id/result` on `api` (mounted at `/api`, below the tier floor). */
86
86
  export declare function attachResultRoute(api: Router, deps: ResultRouteDeps): void;
87
+ /**
88
+ * A room match the relay itself saw end, as the store's report — no host POST involved. A cardtable
89
+ * room's relay seats each player at their ROOM seat (`gameSeatOf`), so the leader's
90
+ * `{ t: 'over', winners }` names room seats, and the report keeps those numbers: placement 1 for a
91
+ * winner, 2 for every other seat, and 1 for everyone when `winners` names nobody seated (a draw).
92
+ *
93
+ * Identity is the server's own, as on the result route: who holds each seat now, by key or as a
94
+ * guest (`buildFrozenSeats`), never anything the bundle sent. Null for fewer than two seated
95
+ * players — a leader alone in the lobby "winning" is not a match.
96
+ */
97
+ export declare function relayOutcomeReport(input: {
98
+ room: Pick<ResultRoom, 'seats' | 'members' | 'aiSeats'>;
99
+ userKeys: Pick<ReadonlyMap<string, string>, 'get'>;
100
+ winners: readonly number[];
101
+ matchId: string;
102
+ roomId: string;
103
+ endedAt: number;
104
+ }): MatchReport | null;
@@ -80,3 +80,33 @@ export function attachResultRoute(api, deps) {
80
80
  res.json({ ok: true });
81
81
  });
82
82
  }
83
+ /**
84
+ * A room match the relay itself saw end, as the store's report — no host POST involved. A cardtable
85
+ * room's relay seats each player at their ROOM seat (`gameSeatOf`), so the leader's
86
+ * `{ t: 'over', winners }` names room seats, and the report keeps those numbers: placement 1 for a
87
+ * winner, 2 for every other seat, and 1 for everyone when `winners` names nobody seated (a draw).
88
+ *
89
+ * Identity is the server's own, as on the result route: who holds each seat now, by key or as a
90
+ * guest (`buildFrozenSeats`), never anything the bundle sent. Null for fewer than two seated
91
+ * players — a leader alone in the lobby "winning" is not a match.
92
+ */
93
+ export function relayOutcomeReport(input) {
94
+ const frozen = buildFrozenSeats(input.room, input.userKeys);
95
+ if (frozen.length < 2)
96
+ return null;
97
+ // The room seats buildFrozenSeats kept, in its order: frozen[i] sits at occupied[i].
98
+ const occupied = input.room.seats.flatMap((holder, seat) => (holder === null || holder === CLOSED_SEAT ? [] : [seat]));
99
+ const won = new Set(input.winners.filter((w) => occupied.includes(w)));
100
+ return {
101
+ matchId: input.matchId,
102
+ roomId: input.roomId,
103
+ endedAt: input.endedAt,
104
+ seats: frozen.map((f, i) => {
105
+ const seat = occupied[i];
106
+ const placement = won.size === 0 || won.has(seat) ? 1 : 2;
107
+ return f.kind === 'user'
108
+ ? { seat, kind: 'user', userKey: f.userKey, displayName: f.name, placement }
109
+ : { seat, kind: f.kind, displayName: f.name, placement };
110
+ }),
111
+ };
112
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.120",
4
- "gitHead": "d082664a2ae59161386bf8b543e536c941f13d1b",
3
+ "version": "0.1.122",
4
+ "gitHead": "ec2c8f9df0be37e946bc115de1815a9eee439487",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The server parts any hosted game shares, above the kernel: the app config and edge auth, the room core (identity, seats, sessions, membership, the room list, the generic room routes), match hosting (the host contract, local and remote JVMs, placement, the start queue, recordings, the in-process and relay runtimes), streams, erase, telemetry and usage. Knows no game; Magic plugs in from apps/server. MIT; imports only node built-ins, express, socket.io, @wolffm/* and the platform packages.",
@@ -17,9 +17,9 @@
17
17
  "play/remote/"
18
18
  ],
19
19
  "dependencies": {
20
- "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.120",
21
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.120",
22
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.153",
20
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.122",
21
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.122",
22
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.155",
23
23
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.0",
24
24
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.134",
25
25
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.134",