@hadoku/game-server 0.1.82 → 0.1.84

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.
@@ -29,8 +29,18 @@
29
29
  * count down from nothing, hide Start, and — on the host's page — begin the
30
30
  * same match a second time. Only `hostOf` outlives zero, for the relay.
31
31
  *
32
+ * ## A room's starts are numbered
33
+ *
34
+ * Every start carries `round`, its place in the room's run of starts (0, 1, 2, …), and `series`,
35
+ * a number drawn at the room's first start that stays the same for all of them. A seed alone has
36
+ * no memory, so a game that picks from a small pool by seed repeats itself by chance; with these
37
+ * two a game deals in an order instead — a map rotation that plays every map before any comes
38
+ * round again, a first turn that moves round the table. Every page reads the same pair from the
39
+ * room body, so every page deals alike without having seen the rounds before.
40
+ *
32
41
  * In memory only: a countdown lasts seconds, and a restart mid-countdown
33
- * costs one press of Start.
42
+ * costs one press of Start. The numbering goes with it: after a restart a room's
43
+ * next start is round 0 of a new series.
34
44
  */
35
45
  /** The 3-2-1. */
36
46
  export declare const COUNTDOWN_MS = 3000;
@@ -38,6 +48,10 @@ export declare const COUNTDOWN_MS = 3000;
38
48
  export interface StartView {
39
49
  matchId: string;
40
50
  seed: number;
51
+ /** This start's place in the room's run of starts, from 0. */
52
+ round: number;
53
+ /** Drawn at the room's first start; the same for every start of the room after it. */
54
+ series: number;
41
55
  hostId: string;
42
56
  startsInMs: number;
43
57
  }
@@ -29,8 +29,18 @@
29
29
  * count down from nothing, hide Start, and — on the host's page — begin the
30
30
  * same match a second time. Only `hostOf` outlives zero, for the relay.
31
31
  *
32
+ * ## A room's starts are numbered
33
+ *
34
+ * Every start carries `round`, its place in the room's run of starts (0, 1, 2, …), and `series`,
35
+ * a number drawn at the room's first start that stays the same for all of them. A seed alone has
36
+ * no memory, so a game that picks from a small pool by seed repeats itself by chance; with these
37
+ * two a game deals in an order instead — a map rotation that plays every map before any comes
38
+ * round again, a first turn that moves round the table. Every page reads the same pair from the
39
+ * room body, so every page deals alike without having seen the rounds before.
40
+ *
32
41
  * In memory only: a countdown lasts seconds, and a restart mid-countdown
33
- * costs one press of Start.
42
+ * costs one press of Start. The numbering goes with it: after a restart a room's
43
+ * next start is round 0 of a new series.
34
44
  */
35
45
  /** The 3-2-1. */
36
46
  export const COUNTDOWN_MS = 3_000;
@@ -40,6 +50,8 @@ export function createStarts(opts = {}) {
40
50
  const random = opts.random ?? Math.random;
41
51
  const pending = new Map();
42
52
  const hosts = new Map();
53
+ /** Each room's run of starts: its series number, and how many starts it has had. */
54
+ const runs = new Map();
43
55
  const live = (roomId) => {
44
56
  const p = pending.get(roomId);
45
57
  if (p === undefined)
@@ -53,6 +65,8 @@ export function createStarts(opts = {}) {
53
65
  const toView = (p) => ({
54
66
  matchId: p.matchId,
55
67
  seed: p.seed,
68
+ round: p.round,
69
+ series: p.series,
56
70
  hostId: p.hostId,
57
71
  startsInMs: Math.max(0, p.startsAt - now()),
58
72
  });
@@ -69,13 +83,18 @@ export function createStarts(opts = {}) {
69
83
  if (hostId === undefined)
70
84
  return { ok: false, reason: 'no-player' };
71
85
  const t = now();
86
+ const run = runs.get(room.id) ?? { series: Math.floor(random() * 0x7fffffff), started: 0 };
87
+ runs.set(room.id, run);
72
88
  const start = {
73
89
  // The stats store's MATCH_ID_PATTERN holds: [A-Za-z0-9_-]{8,64}.
74
90
  matchId: `m-${t.toString(36)}-${Math.floor(random() * 1e9).toString(36)}`,
75
91
  seed: Math.floor(random() * 0x7fffffff),
92
+ round: run.started,
93
+ series: run.series,
76
94
  hostId,
77
95
  startsAt: t + countdownMs,
78
96
  };
97
+ run.started += 1;
79
98
  pending.set(room.id, start);
80
99
  hosts.set(room.id, hostId);
81
100
  return { ok: true, start: toView(start) };
@@ -90,6 +109,7 @@ export function createStarts(opts = {}) {
90
109
  forget(roomId) {
91
110
  pending.delete(roomId);
92
111
  hosts.delete(roomId);
112
+ runs.delete(roomId);
93
113
  },
94
114
  };
95
115
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.82",
4
- "gitHead": "371fca27b0544afcd0e5080ee47a5ce9ad0459dc",
3
+ "version": "0.1.84",
4
+ "gitHead": "5d7f66a24489cea213bc35dadbe2cc76fee5edcf",
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.82",
20
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.82",
21
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.115",
19
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.84",
20
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.84",
21
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.117",
22
22
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.1.31",
23
23
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.125",
24
24
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.125",