@hadoku/game-server 0.1.225 → 0.1.226
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/http/room-core.js +18 -36
- package/dist/stats/relay-results.js +7 -12
- package/package.json +5 -5
package/dist/http/room-core.js
CHANGED
|
@@ -69,42 +69,24 @@ function seatOpStatus(res, reason) {
|
|
|
69
69
|
return noMatch(res);
|
|
70
70
|
if (reason === 'not-member' || reason === 'target-not-member')
|
|
71
71
|
return noMatch(res);
|
|
72
|
-
if (reason === 'not-leader')
|
|
73
|
-
res
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (reason === '
|
|
77
|
-
res
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (reason === '
|
|
81
|
-
res
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (reason === '
|
|
85
|
-
res
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (reason === '
|
|
89
|
-
res
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (reason === 'no-bot-seat') {
|
|
93
|
-
res.status(409).json({ error: 'this room has no seat the bot can take' });
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (reason === 'seat-taken') {
|
|
97
|
-
res.status(409).json({ error: 'that seat is already taken' });
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (reason === 'pod-full') {
|
|
101
|
-
res.status(409).json({ error: 'every seat is taken' });
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (reason === 'not-open') {
|
|
105
|
-
res.status(409).json({ error: `seats open ${String(SEATS_OPEN_BEFORE_MS / 60_000)} minutes before the event starts` });
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
72
|
+
if (reason === 'not-leader')
|
|
73
|
+
return refuse(res, 403, 'only the room leader can do that');
|
|
74
|
+
if (reason === 'not-draft' || reason === 'not-lobby')
|
|
75
|
+
return refuse(res, 409, 'this room does not seat through game seats, or its seats are fixed right now');
|
|
76
|
+
if (reason === 'historical')
|
|
77
|
+
return refuse(res, 409, 'a historical room’s field is the event’s, not the leader’s to change');
|
|
78
|
+
if (reason === 'too-few')
|
|
79
|
+
return refuse(res, 400, `a room always keeps at least ${String(MIN_OPEN_SEATS)} seats open`);
|
|
80
|
+
if (reason === 'bad-seat')
|
|
81
|
+
return refuse(res, 400, 'not a seat this room has');
|
|
82
|
+
if (reason === 'no-bot-seat')
|
|
83
|
+
return refuse(res, 409, 'this room has no seat the bot can take');
|
|
84
|
+
if (reason === 'seat-taken')
|
|
85
|
+
return refuse(res, 409, 'that seat is already taken');
|
|
86
|
+
if (reason === 'pod-full')
|
|
87
|
+
return refuse(res, 409, 'every seat is taken');
|
|
88
|
+
if (reason === 'not-open')
|
|
89
|
+
return refuse(res, 409, `seats open ${String(SEATS_OPEN_BEFORE_MS / 60_000)} minutes before the event starts`);
|
|
108
90
|
res.status(400).json({ error: reason });
|
|
109
91
|
}
|
|
110
92
|
/**
|
|
@@ -24,6 +24,7 @@ import { MATCH_ID_PATTERN } from '@wolffm/prefs-client/games';
|
|
|
24
24
|
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
|
+
import { refuse } from '../http/room-core.js';
|
|
27
28
|
/**
|
|
28
29
|
* Who sits in each occupied seat NOW, in seat order, with a dense `playerId` — the match roster's
|
|
29
30
|
* own numbering. A human's `clientId` is their full participant id (the roster's); a bot's is
|
|
@@ -54,21 +55,15 @@ export function attachResultRoute(api, deps) {
|
|
|
54
55
|
api.post('/rooms/:id/result', (req, res) => {
|
|
55
56
|
const roomId = String(req.params.id);
|
|
56
57
|
const room = deps.lobby.get(roomId);
|
|
57
|
-
if (room === undefined)
|
|
58
|
-
res
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
58
|
+
if (room === undefined)
|
|
59
|
+
return refuse(res, 404, 'no such room');
|
|
61
60
|
const caller = callerOf(req);
|
|
62
|
-
if (room.leader !== caller.id && !room.seats.includes(caller.id))
|
|
63
|
-
res
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
61
|
+
if (room.leader !== caller.id && !room.seats.includes(caller.id))
|
|
62
|
+
return refuse(res, 403, 'only a seated player may report a result');
|
|
66
63
|
const body = req.body;
|
|
67
64
|
const matchId = body?.matchId;
|
|
68
|
-
if (typeof matchId !== 'string' || !MATCH_ID_PATTERN.test(matchId))
|
|
69
|
-
res
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
65
|
+
if (typeof matchId !== 'string' || !MATCH_ID_PATTERN.test(matchId))
|
|
66
|
+
return refuse(res, 400, "a result needs its round's own matchId");
|
|
72
67
|
const seats = buildFrozenSeats(room, deps.userKeys, deps.botClientId);
|
|
73
68
|
const built = deps.toReport(body?.result, { matchId, roomId, endedAt: now(), seats });
|
|
74
69
|
if (!built.ok) {
|
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.226",
|
|
4
|
+
"gitHead": "569c405b4e6df7e49cc58f0e83286bb8df530a16",
|
|
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.226",
|
|
20
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.226",
|
|
21
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.259",
|
|
22
22
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
|
|
23
23
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",
|
|
24
24
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.152",
|