@hadoku/game-server 0.1.158 → 0.1.159
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.d.ts +2 -0
- package/dist/http/room-core.js +5 -1
- package/dist/room/lobby.d.ts +8 -0
- package/dist/room/lobby.js +5 -0
- package/package.json +5 -5
package/dist/http/room-core.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface LobbyCore<V extends RoomViewCore, C> {
|
|
|
69
69
|
} | {
|
|
70
70
|
ok: false;
|
|
71
71
|
};
|
|
72
|
+
/** Whether leaving now drops the caller from the room's event, which only an asked-for leave may do. */
|
|
73
|
+
leaveDrops(roomId: string, callerId: string): boolean;
|
|
72
74
|
close(roomId: string, callerId: string): {
|
|
73
75
|
ok: true;
|
|
74
76
|
matches: readonly string[];
|
package/dist/http/room-core.js
CHANGED
|
@@ -291,7 +291,9 @@ export function attachRoomCore(api, deps, opts = {}) {
|
|
|
291
291
|
return noMatch(res);
|
|
292
292
|
res.json(roomBody(room, caller.id));
|
|
293
293
|
});
|
|
294
|
-
// A member steps out of their own room. A tournament entrant mid-
|
|
294
|
+
// A member steps out of their own room. A tournament entrant mid-event is a drop (`forfeited`), and
|
|
295
|
+
// only when they said so (`?drop=1`, the room's own "Leave tournament"): no page closing, Back or
|
|
296
|
+
// "Main menu" ever drops anyone from a tournament (the operator, 2026-11-28).
|
|
295
297
|
rooms.post('/:id/leave', (req, res) => {
|
|
296
298
|
if (parseBody(wire.emptyBody, req, res) === null)
|
|
297
299
|
return;
|
|
@@ -301,6 +303,8 @@ export function attachRoomCore(api, deps, opts = {}) {
|
|
|
301
303
|
const id = String(req.params.id);
|
|
302
304
|
if (!wire.roomIdRe.test(id))
|
|
303
305
|
return noMatch(res);
|
|
306
|
+
if (req.query.drop !== '1' && lobby.leaveDrops(id, caller.id))
|
|
307
|
+
return res.status(409).json({ error: 'leaving now drops you from the tournament', reason: 'drops' });
|
|
304
308
|
const result = lobby.leave(id, caller.id);
|
|
305
309
|
if (!result.ok)
|
|
306
310
|
return noMatch(res);
|
package/dist/room/lobby.d.ts
CHANGED
|
@@ -171,6 +171,12 @@ export interface RoomTypeHooks<G, I extends RoomCreateInput = RoomCreateInput> {
|
|
|
171
171
|
liveMatches(room: LobbyRoom<G>): string[];
|
|
172
172
|
/** A member is leaving and still in the room: what it costs their game (a match it forfeits). */
|
|
173
173
|
leaving?(room: LobbyRoom<G>, memberId: string): Pick<LeaveOk<never>, 'forfeited'> | void;
|
|
174
|
+
/**
|
|
175
|
+
* Whether leaving now would take the member out of an event under way (a tournament's draft or rounds).
|
|
176
|
+
* Such a leave is only ever asked for, never a side effect: `POST /:id/leave` refuses it unless the
|
|
177
|
+
* caller says so (`?drop=1`). Absent: no leave costs anything.
|
|
178
|
+
*/
|
|
179
|
+
leaveDrops?(room: LobbyRoom<G>, memberId: string): boolean;
|
|
174
180
|
/** A Ready: `'keep'` refuses the change quietly (the room's positions are fixed). Called before it is saved. */
|
|
175
181
|
ready?(room: LobbyRoom<G>, memberId: string, ready: boolean): 'keep' | void;
|
|
176
182
|
/** After a saved change to who sits or who is ready (a tournament's field filling, say). */
|
|
@@ -438,6 +444,8 @@ export declare class RoomLobby<V extends PlatformRoomView, I extends RoomCreateI
|
|
|
438
444
|
get(roomId: string): V | undefined;
|
|
439
445
|
/** Whether `memberId` is a member of `roomId`. False when there is no such room. */
|
|
440
446
|
isMember(roomId: string, memberId: string): boolean;
|
|
447
|
+
/** Whether `memberId` leaving `roomId` now would drop them from its event (`RoomTypeHooks.leaveDrops`). */
|
|
448
|
+
leaveDrops(roomId: string, memberId: string): boolean;
|
|
441
449
|
/**
|
|
442
450
|
* Everyone in a room is a player or a spectator, never neither (the operator, 2026-11-02):
|
|
443
451
|
* `'player'` iff `memberId` holds a game seat, `'spectator'` iff they are a member who holds
|
package/dist/room/lobby.js
CHANGED
|
@@ -324,6 +324,11 @@ export class RoomLobby {
|
|
|
324
324
|
const room = this.#rooms.get(roomId);
|
|
325
325
|
return room !== undefined && isRoomMember(room, memberId);
|
|
326
326
|
}
|
|
327
|
+
/** Whether `memberId` leaving `roomId` now would drop them from its event (`RoomTypeHooks.leaveDrops`). */
|
|
328
|
+
leaveDrops(roomId, memberId) {
|
|
329
|
+
const room = this.#rooms.get(roomId);
|
|
330
|
+
return room !== undefined && isRoomMember(room, memberId) && this.hooksOf(room).leaveDrops?.(room, memberId) === true;
|
|
331
|
+
}
|
|
327
332
|
/**
|
|
328
333
|
* Everyone in a room is a player or a spectator, never neither (the operator, 2026-11-02):
|
|
329
334
|
* `'player'` iff `memberId` holds a game seat, `'spectator'` iff they are a member who holds
|
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.159",
|
|
4
|
+
"gitHead": "57586f6329004b90a6811e9fbea44892db00bc76",
|
|
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.
|
|
21
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
22
|
-
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.
|
|
20
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.159",
|
|
21
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.159",
|
|
22
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.192",
|
|
23
23
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
|
|
24
24
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.143",
|
|
25
25
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.143",
|