@hadoku/game-server 0.1.255 → 0.1.256
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.
- package/dist/stats/rated.d.ts +13 -0
- package/dist/stats/rated.js +12 -0
- package/dist/stats/relay-results.d.ts +2 -2
- package/dist/stats/relay-results.js +11 -14
- package/package.json +5 -5
|
@@ -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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.256",
|
|
4
|
+
"gitHead": "99dd1c144e4d4a67ae56a1d82a2e59559ce6d79c",
|
|
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.
|
|
20
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
21
|
-
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.
|
|
19
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.256",
|
|
20
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.256",
|
|
21
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.289",
|
|
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",
|