@hadoku/game-server 0.1.255 → 0.1.257

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.
@@ -217,8 +217,10 @@ export interface HostedRoomSpec {
217
217
  minTier?: RoomFloorTier;
218
218
  }
219
219
  /**
220
- * The room type of a registered game the host does not play itself: `plainRoomType`, opened at eight
221
- * seats (or the game's `max`, if smaller) and growing to `max`. A relay game's room is its match, of
222
- * `table.seats` (every seat, when the game names no table). The game's tier floor is every room's.
220
+ * The room type of a registered game the host does not play itself. A relay game's room is its match:
221
+ * `plainRoomType`, opened at eight seats (or the game's `max`, if smaller), growing to `max`, its match
222
+ * of `table.seats` (every seat, when the game names no table). A game with no runtime here seats its
223
+ * players on its own server, so its room has no seats: nobody sits, and a stored room's are dropped.
224
+ * The game's tier floor is every room's.
223
225
  */
224
226
  export declare function hostedRoomType<I extends RoomCreateInput>(spec: HostedRoomSpec): RoomTypeHooks<PlainGame, I>;
@@ -79,15 +79,17 @@ export function plainRoomType(size) {
79
79
  /** The most seats a hosted room opens with; one whose game seats fewer opens at its game's `max`. */
80
80
  const HOSTED_OPENING_SEATS = 8;
81
81
  /**
82
- * The room type of a registered game the host does not play itself: `plainRoomType`, opened at eight
83
- * seats (or the game's `max`, if smaller) and growing to `max`. A relay game's room is its match, of
84
- * `table.seats` (every seat, when the game names no table). The game's tier floor is every room's.
82
+ * The room type of a registered game the host does not play itself. A relay game's room is its match:
83
+ * `plainRoomType`, opened at eight seats (or the game's `max`, if smaller), growing to `max`, its match
84
+ * of `table.seats` (every seat, when the game names no table). A game with no runtime here seats its
85
+ * players on its own server, so its room has no seats: nobody sits, and a stored room's are dropped.
86
+ * The game's tier floor is every room's.
85
87
  */
86
88
  export function hostedRoomType(spec) {
87
- const plain = plainRoomType({
88
- seats: Math.min(HOSTED_OPENING_SEATS, spec.seats.max),
89
- max: spec.seats.max,
90
- ...(spec.runtime === 'relay' ? { relaySeats: spec.table?.seats ?? spec.seats.max } : {}),
91
- });
92
- return spec.minTier === undefined ? plain : { ...plain, minTier: spec.minTier };
89
+ const relay = spec.runtime === 'relay';
90
+ const plain = plainRoomType(relay ? { seats: Math.min(HOSTED_OPENING_SEATS, spec.seats.max), max: spec.seats.max, relaySeats: spec.table?.seats ?? spec.seats.max } : { seats: 0, max: 0 });
91
+ const hosted = relay
92
+ ? plain
93
+ : { ...plain, usesSeats: () => false, decode: (app, version, ctx) => ({ ...plain.decode(app, version, ctx), seats: [] }) };
94
+ return spec.minTier === undefined ? hosted : { ...hosted, minTier: spec.minTier };
93
95
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Whether a finished match moves anyone's rating: the platform's rule, which a game that says
3
+ * nothing gets. The operator, 2026-12-04: *"if bomberman plays 6 player game with 3 real people and
4
+ * 3 bots, that should still get counted"*, and *"the game was allowed to decide"*.
5
+ */
6
+ import type { MatchSeatReport } from '@wolffm/prefs-client/games';
7
+ /** The accounts the fleet's own automation plays under: never a player. */
8
+ export declare const TEST_IDENTITY: RegExp;
9
+ /**
10
+ * Rated when at least two seats are signed-in people (`kind: 'user'`) who are not test identities,
11
+ * and no seat is one. A bot or a guest neither counts toward the two nor unrates the match.
12
+ */
13
+ export declare function ratedSeats(seats: readonly Pick<MatchSeatReport, 'kind' | 'displayName'>[], isTest?: (name: string) => boolean): boolean;
@@ -0,0 +1,12 @@
1
+ /** The accounts the fleet's own automation plays under: never a player. */
2
+ export const TEST_IDENTITY = /^wp-/;
3
+ /**
4
+ * Rated when at least two seats are signed-in people (`kind: 'user'`) who are not test identities,
5
+ * and no seat is one. A bot or a guest neither counts toward the two nor unrates the match.
6
+ */
7
+ export function ratedSeats(seats, isTest = (name) => TEST_IDENTITY.test(name)) {
8
+ const users = seats.filter((s) => s.kind === 'user');
9
+ if (users.some((s) => isTest(s.displayName ?? '')))
10
+ return false;
11
+ return users.length >= 2;
12
+ }
@@ -76,7 +76,7 @@ export interface ResultRouteDeps {
76
76
  /** Each `/room` connection's friend key, by participant id. */
77
77
  userKeys: ReadonlyMap<string, string>;
78
78
  stats: StatsReporter;
79
- /** The game's own: its bundle's payload, as the store's report, or why not. */
79
+ /** The game's own: its bundle's payload, as the store's report, or why not. A report that leaves `rated` out is rated by `ratedSeats`. */
80
80
  toReport(raw: unknown, ctx: RoundContext): ReportOutcome;
81
81
  botClientId?: (seat: number) => string;
82
82
  log: (line: Record<string, unknown>) => void;
@@ -92,7 +92,7 @@ export declare function attachResultRoute(api: Router, deps: ResultRouteDeps): v
92
92
  *
93
93
  * Identity is the server's own, as on the result route: who holds each seat now, by key or as a
94
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.
95
+ * players — a leader alone in the lobby "winning" is not a match. Rated by the platform's rule (`ratedSeats`).
96
96
  */
97
97
  export declare function relayOutcomeReport(input: {
98
98
  room: Pick<ResultRoom, 'seats' | 'members' | 'aiSeats'>;
@@ -25,6 +25,7 @@ import { AI_SEAT, CLOSED_SEAT } from '@wolffm/platform-wire/seats';
25
25
  import { participantHandle } from '@wolffm/rooms-protocol';
26
26
  import { callerOf } from '../http/request.js';
27
27
  import { refuse } from '../http/room-core.js';
28
+ import { ratedSeats } from './rated.js';
28
29
  /**
29
30
  * Who sits in each occupied seat NOW, in seat order, with a dense `playerId` — the match roster's
30
31
  * own numbering. A human's `clientId` is their full participant id (the roster's); a bot's is
@@ -71,7 +72,7 @@ export function attachResultRoute(api, deps) {
71
72
  res.status(built.reason === 'bad-result' ? 400 : 422).json({ ok: false, error: built.reason });
72
73
  return;
73
74
  }
74
- deps.stats.report(built.report);
75
+ deps.stats.report({ ...built.report, rated: built.report.rated ?? ratedSeats(built.report.seats) });
75
76
  res.json({ ok: true });
76
77
  });
77
78
  }
@@ -83,7 +84,7 @@ export function attachResultRoute(api, deps) {
83
84
  *
84
85
  * Identity is the server's own, as on the result route: who holds each seat now, by key or as a
85
86
  * guest (`buildFrozenSeats`), never anything the bundle sent. Null for fewer than two seated
86
- * players — a leader alone in the lobby "winning" is not a match.
87
+ * players — a leader alone in the lobby "winning" is not a match. Rated by the platform's rule (`ratedSeats`).
87
88
  */
88
89
  export function relayOutcomeReport(input) {
89
90
  const frozen = buildFrozenSeats(input.room, input.userKeys);
@@ -92,16 +93,12 @@ export function relayOutcomeReport(input) {
92
93
  // The room seats buildFrozenSeats kept, in its order: frozen[i] sits at occupied[i].
93
94
  const occupied = input.room.seats.flatMap((holder, seat) => (holder === null || holder === CLOSED_SEAT ? [] : [seat]));
94
95
  const won = new Set(input.winners.filter((w) => occupied.includes(w)));
95
- return {
96
- matchId: input.matchId,
97
- roomId: input.roomId,
98
- endedAt: input.endedAt,
99
- seats: frozen.map((f, i) => {
100
- const seat = occupied[i];
101
- const placement = won.size === 0 || won.has(seat) ? 1 : 2;
102
- return f.kind === 'user'
103
- ? { seat, kind: 'user', userKey: f.userKey, displayName: f.name, placement }
104
- : { seat, kind: f.kind, displayName: f.name, placement };
105
- }),
106
- };
96
+ const seats = frozen.map((f, i) => {
97
+ const seat = occupied[i];
98
+ const placement = won.size === 0 || won.has(seat) ? 1 : 2;
99
+ return f.kind === 'user'
100
+ ? { seat, kind: 'user', userKey: f.userKey, displayName: f.name, placement }
101
+ : { seat, kind: f.kind, displayName: f.name, placement };
102
+ });
103
+ return { matchId: input.matchId, roomId: input.roomId, endedAt: input.endedAt, rated: ratedSeats(seats), seats };
107
104
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.255",
4
- "gitHead": "bd56441796a344d86f4ec3864896652db6ef01b5",
3
+ "version": "0.1.257",
4
+ "gitHead": "200c3dd1e6887b83b9d7572babb84ffbd8f38ec9",
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.",
@@ -16,9 +16,9 @@
16
16
  "play/remote/"
17
17
  ],
18
18
  "dependencies": {
19
- "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.255",
20
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.255",
21
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.288",
19
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.257",
20
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.257",
21
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.290",
22
22
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
23
23
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.158",
24
24
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.158",