From e87148ad10b6352c60f5f8b98f8021ec6e73b8e0 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Thu, 5 Nov 2026 20:26:49 -0800 Subject: [PATCH] Pin Math.random in the Activities logic tests so a rare roll cannot fail one at random AI Assisted --- .agents-docs/AGENTS-architecture.md | 1 + scripts/seed-random.mjs | 17 +++++++++++++++++ .../test-web-console-activities-bounce-cars.mjs | 1 + .../test-web-console-activities-bounce-game.mjs | 1 + scripts/test-web-console-activities-bounce.mjs | 1 + scripts/test-web-console-activities-flock.mjs | 1 + .../test-web-console-activities-ghoul-arms.mjs | 1 + ...st-web-console-activities-ghoul-banister.mjs | 1 + .../test-web-console-activities-ghoul-bog.mjs | 1 + .../test-web-console-activities-ghoul-bones.mjs | 1 + ...t-web-console-activities-ghoul-bonestair.mjs | 1 + ...t-web-console-activities-ghoul-bossintro.mjs | 1 + ...st-web-console-activities-ghoul-carnival.mjs | 1 + .../test-web-console-activities-ghoul-cart.mjs | 1 + ...test-web-console-activities-ghoul-chapel.mjs | 1 + .../test-web-console-activities-ghoul-dice.mjs | 1 + ...test-web-console-activities-ghoul-ending.mjs | 1 + .../test-web-console-activities-ghoul-eye.mjs | 1 + ...test-web-console-activities-ghoul-frozen.mjs | 1 + ...st-web-console-activities-ghoul-gameover.mjs | 1 + ...t-web-console-activities-ghoul-graveyard.mjs | 1 + ...est-web-console-activities-ghoul-grounds.mjs | 1 + ...test-web-console-activities-ghoul-gurney.mjs | 1 + ...test-web-console-activities-ghoul-hearse.mjs | 1 + .../test-web-console-activities-ghoul-heart.mjs | 1 + .../test-web-console-activities-ghoul-intro.mjs | 1 + ...est-web-console-activities-ghoul-lantern.mjs | 1 + ...test-web-console-activities-ghoul-marrow.mjs | 1 + .../test-web-console-activities-ghoul-mat.mjs | 1 + .../test-web-console-activities-ghoul-mine.mjs | 1 + .../test-web-console-activities-ghoul-mower.mjs | 1 + .../test-web-console-activities-ghoul-pew.mjs | 1 + .../test-web-console-activities-ghoul-retry.mjs | 1 + .../test-web-console-activities-ghoul-ride.mjs | 1 + ...-web-console-activities-ghoul-sanatorium.mjs | 1 + .../test-web-console-activities-ghoul-sled.mjs | 1 + .../test-web-console-activities-ghoul-story.mjs | 1 + .../test-web-console-activities-ghoul-tray.mjs | 1 + ...est-web-console-activities-ghoul-village.mjs | 1 + .../test-web-console-activities-ghoul-wagon.mjs | 1 + scripts/test-web-console-activities-ghoul.mjs | 1 + scripts/test-web-console-activities-rapids.mjs | 1 + scripts/test-web-console-activities.mjs | 1 + 43 files changed, 59 insertions(+) create mode 100644 scripts/seed-random.mjs diff --git a/.agents-docs/AGENTS-architecture.md b/.agents-docs/AGENTS-architecture.md index 29d1691..f3411f6 100644 --- a/.agents-docs/AGENTS-architecture.md +++ b/.agents-docs/AGENTS-architecture.md @@ -605,6 +605,7 @@ Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --build- - **Banners never get in the way.** A banner over the board (`"Hit!"`, a new level, a power-up) is placed on the frame it first shows, on the part of the board away from the player, and fades to `BANNER_SEE_THROUGH` (0.12) over `BANNER_FADE_MS` while the player, or anything the player must react to (a diving bug, a bomb, a rival, a hazard, the road over a hill), is in its strip; Snake's `bannerRow()` and `underBanner()` are the model. Give the banner object a `see` field, multiply the draw's alpha by it, and export the strip check (`underBanner`) for the unit suite. - **The window owns pausing.** A game never resumes itself; `screens/activities.js` decides when a key or click plays on, including the hold on a question or finish (see the row above), so a game needs nothing of its own for it. Full screen is the window's too (`setFull()`: the button, `F`, and a turn or finish putting it back; `fitFull()` sizes the game to the whole screen (black bars where its shape leaves room) and docks the overlaid panel in a bar that holds it, `data-dock="side"` or `"below"`, or floats it, `"float"`, shrunk to the score while a round plays and the pointer is still; and tells the desktop app `activities-full`); a game only sees a bigger `resize()`, so a new game needs nothing for it, as long as its `resize()` sets the canvas's CSS size. - **Every moment has a sound, and moving things hum.** A game plays a one-shot through the `tone` it is handed for each event worth hearing (a hit, a pickup, a level, a new best, game over) and keeps continuous things (an engine, a motor, wind, water, a fuse, a monster close by) going with `hum(id, name, level, pitch)` from its `tick`, pitch following speed. Never a one-shot every frame: a repeating cue is throttled by a timer in the round. Its own sounds live in `activities/-sfx.js`, named with the game id; the shared kit is in `tones.js`. `create()` defaults `tone` and `hum` to no-ops, since the suites make games with neither, and a sound never changes the game's state. +- **Its logic tests pin the dice.** A game rolls `Math.random` for roads, spawns and layouts, and an unlucky roll once failed a test on CI at random (Ghoul Rush's Eye, Bounce Road twice). Import `./seed-random.mjs` FIRST in every `scripts/test-web-console-activities*.mjs` file: it seeds `Math.random` (set `PLAN2CODE_TEST_SEED` to try another roll), so a test sees the same world on every run. ## Status Line diff --git a/scripts/seed-random.mjs b/scripts/seed-random.mjs new file mode 100644 index 0000000..b7d3ea5 --- /dev/null +++ b/scripts/seed-random.mjs @@ -0,0 +1,17 @@ +// Pins Math.random to a seeded generator for a test file that drives an Activities game, so the +// game's own dice (a road with a crack where a test wanted plain road, a spawn that lands out of +// reach) give the same layout on every run and a rare roll can never fail a test at random. +// Import it FIRST in the file: a game module may roll at load time. +// +// A seed that fails a test is a real finding, not a flake: set PLAN2CODE_TEST_SEED to reproduce +// another roll, for example to hunt a bug the fixed seed hides. + +let state = Number(process.env.PLAN2CODE_TEST_SEED || 20261105) >>> 0; + +// mulberry32: small, fast and good enough for game dice. +Math.random = () => { + state = (state + 0x6d2b79f5) | 0; + let t = Math.imul(state ^ (state >>> 15), 1 | state); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; +}; diff --git a/scripts/test-web-console-activities-bounce-cars.mjs b/scripts/test-web-console-activities-bounce-cars.mjs index 8c5d1ee..eeb58eb 100644 --- a/scripts/test-web-console-activities-bounce-cars.mjs +++ b/scripts/test-web-console-activities-bounce-cars.mjs @@ -5,6 +5,7 @@ // and records every point it draws through, as in // scripts/test-web-console-activities-rapids.mjs. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import { CAR_STYLES, MARGINS, STYLE_NAMES, carLength, carReach, drawCarBody, drawCarShadow, rgbOf, shade, styleOf } from "../src/web-console/public/activities/bounce-cars.js"; diff --git a/scripts/test-web-console-activities-bounce-game.mjs b/scripts/test-web-console-activities-bounce-game.mjs index 43d7298..f53f4ec 100644 --- a/scripts/test-web-console-activities-bounce-game.mjs +++ b/scripts/test-web-console-activities-bounce-game.mjs @@ -6,6 +6,7 @@ // handed, so a stub canvas stands in for the page, as in // scripts/test-web-console-activities.mjs, whose helpers this file copies. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import * as bounce from "../src/web-console/public/activities/bounce.js"; diff --git a/scripts/test-web-console-activities-bounce.mjs b/scripts/test-web-console-activities-bounce.mjs index 436b107..a03dbd1 100644 --- a/scripts/test-web-console-activities-bounce.mjs +++ b/scripts/test-web-console-activities-bounce.mjs @@ -5,6 +5,7 @@ // handed, so a stub canvas stands in for the page, as in // scripts/test-web-console-activities.mjs, whose helpers this file copies. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import * as bounce from "../src/web-console/public/activities/bounce.js"; diff --git a/scripts/test-web-console-activities-flock.mjs b/scripts/test-web-console-activities-flock.mjs index 3b4afe1..792ca66 100644 --- a/scripts/test-web-console-activities-flock.mjs +++ b/scripts/test-web-console-activities-flock.mjs @@ -5,6 +5,7 @@ // handed, so a stub canvas stands in for the page, as in // scripts/test-web-console-activities-rapids.mjs, whose helpers this file copies. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import * as flock from "../src/web-console/public/activities/flock.js"; diff --git a/scripts/test-web-console-activities-ghoul-arms.mjs b/scripts/test-web-console-activities-ghoul-arms.mjs index 208b49f..9cb7702 100644 --- a/scripts/test-web-console-activities-ghoul-arms.mjs +++ b/scripts/test-web-console-activities-ghoul-arms.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's secondary weapons: the double tap that uses one (hammering spends one at most, a hold carries on as bolts), the bag and its HUD pill, what each weapon does, what they may do to a boss, where they are placed and how they drop, and that all of it draws and sounds. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-banister.mjs b/scripts/test-web-console-activities-ghoul-banister.mjs index 1bcd939..b810d45 100644 --- a/scripts/test-web-console-activities-ghoul-banister.mjs +++ b/scripts/test-web-console-activities-ghoul-banister.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Grand Banister (the Manor's bonus round, between the Library and the Ballroom): its shape (every break clears with a jump and swallows a rider that does not jump, the brass under-rails, every low can be ducked, spacing, checkpoints, the clock), the ride's speed on slopes and its lean and brake, its jump, ducking and diving, a vase, a candlestick, a hanging frame, a chandelier on its pendulum, a ghostly butler, the cobwebs, a fall off the rail, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole stair (one that rides well, one that never dodges). // Run with: node --test scripts/test-web-console-activities-ghoul-banister.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-bog.mjs b/scripts/test-web-console-activities-ghoul-bog.mjs index c3aedf6..6b83ea6 100644 --- a/scripts/test-web-console-activities-ghoul-bog.mjs +++ b/scripts/test-web-console-activities-ghoul-bog.mjs @@ -4,6 +4,7 @@ // mud spans that slow and sink you, the Bog Runner's stub and the Drowning // Pool's boss spec. The monsters' rules, the fight and the ride land in // later phases. +import "./seed-random.mjs"; import { test } from "node:test"; import { readFileSync } from "node:fs"; import assert from "node:assert/strict"; diff --git a/scripts/test-web-console-activities-ghoul-bones.mjs b/scripts/test-web-console-activities-ghoul-bones.mjs index b429e94..254f850 100644 --- a/scripts/test-web-console-activities-ghoul-bones.mjs +++ b/scripts/test-web-console-activities-ghoul-bones.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Old Rattlebones: his volley and slam, the skull he throws like a boomerang (and is headless without), the bone rain and the skeletons he raises once his rage begins, the double slam, and what each move looks and sounds like. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-bonestair.mjs b/scripts/test-web-console-activities-ghoul-bonestair.mjs index 3d89688..7d56b1d 100644 --- a/scripts/test-web-console-activities-ghoul-bonestair.mjs +++ b/scripts/test-web-console-activities-ghoul-bonestair.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Bone Stair (the finale's second ride, between Kill II and the Pit): its shape (the spiral's flights and seams, every gap of missing treads clears with a jump and swallows YOU without one, every ribcage can be ducked, spacing, checkpoints, the last step over the Pit's floor), the run's speed (DOWN and LEFT slow YOU), every obstacle's cost and cause (missing treads, treads giving way, ribcages, skeletons, hands, masonry, the rubble), the telegraphs (shadows, creaks and cracks, fingers over the edge, skeletons rising), shooting skeletons down, the pursuit meter (the gap that clean running opens and hits, ducks and holds close), the catch, three hearts of its own, the grade and the dice, endless lives, the finish, no random numbers, its sounds and its drawing on a fake canvas, and bots that play it well and badly. // Run with: node --test scripts/test-web-console-activities-ghoul-bonestair.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-bossintro.mjs b/scripts/test-web-console-activities-ghoul-bossintro.mjs index c9a4686..2d2678c 100644 --- a/scripts/test-web-console-activities-ghoul-bossintro.mjs +++ b/scripts/test-web-console-activities-ghoul-bossintro.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's boss intro cards: every boss room has an entry (the boss's exact name, an epithet, no em dash, never the hero's name), the card shows when a boss room is entered (after the bonus ride too) and in no other room, not again on a retry, any fresh move key, fire or click moves it on after the lockout (repeats and early presses never do), it never moves on by itself, a pause holds it, and it draws for every boss on a fake canvas (through the boss's own art, with a fallback when the art throws or is missing). +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-carnival.mjs b/scripts/test-web-console-activities-ghoul-carnival.mjs index 6f27434..6770e76 100644 --- a/scripts/test-web-console-activities-ghoul-carnival.mjs +++ b/scripts/test-web-console-activities-ghoul-carnival.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Midnight Carnival stage: its four rooms (the Midway, the Hall of Mirrors, the Funhouse with its conveyor floors, the Big Top), grinners that honk out acid balloons, marionettes that drop on their strings, Mirror You that copies your moves and shots half a second late, strongmen that lob barbells, circus hounds that leap through hoops of fire, Cotton Candy and the Custard Pie (found only here), and the Ringmaster, whose puppet hangs on three strings: cut them all and he is open for four seconds. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-cart.mjs b/scripts/test-web-console-activities-ghoul-cart.mjs index bdfca3b..306240c 100644 --- a/scripts/test-web-console-activities-ghoul-cart.mjs +++ b/scripts/test-web-console-activities-ghoul-cart.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Runaway Cart (the Deep Seam Mine's ride room): its shape (between the Collapse and the Seam, every gap clears at the cart's speed with a jump, every beam can be ducked, checkpoints spaced, the clock covers the ride), the cart's speed on slopes, leaning and braking, its jump and its steering in the air, a ramp's launch, landing on the upper or the lower line of a split, a fall into the chasm and the respawn at the last checkpoint, ducking under a beam, rubble, crates (two shots break one), the boulder behind, the buffer stop and the door, the ledge imp, a canary's slide of rubble, endless lives for every new cause, a voice for every event, the drawing, and a bot that rides the whole room. // Run with: node --test scripts/test-web-console-activities-ghoul-cart.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-chapel.mjs b/scripts/test-web-console-activities-ghoul-chapel.mjs index dbbcdf8..b4f0874 100644 --- a/scripts/test-web-console-activities-ghoul-chapel.mjs +++ b/scripts/test-web-console-activities-ghoul-chapel.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Chapel stage: its four rooms, gargoyles that are stone on their perch and dive when you pass under, choir ghosts whose song quickens the monsters near them, censer monks and their smoke, bats in the bells, the bell toll that freezes everything for a second, Holy Water (found only here), and the Choirmaster, whose organ pipes guard him and whose columns of notes have one gap each. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-dice.mjs b/scripts/test-web-console-activities-ghoul-dice.mjs index 8697352..fc06918 100644 --- a/scripts/test-web-console-activities-ghoul-dice.mjs +++ b/scripts/test-web-console-activities-ghoul-dice.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Lucky die: it comes only from a kill, stacks to nine and lasts the run; when a life would be lost one rolls: a 4 to 6 brings Planny back (the monsters in view blown apart in an ordinary room, a boss's room untouched; a 5 adds a heart, a 6 a heart and a Garlic shield), a 3 or 2 costs the life and leaves a gift for the respawn, a 1 only laughs. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-ending.mjs b/scripts/test-web-console-activities-ghoul-ending.mjs index 929786e..eed1d86 100644 --- a/scripts/test-web-console-activities-ghoul-ending.mjs +++ b/scripts/test-web-console-activities-ghoul-ending.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's ending: four pages that obey the story's rules (2 to 4 short lines, no digits, no em dash, YOU on each, the gag's FINAL NOTICE); the House's last room opens it instead of the win; a press turns pages only after the lockout and finishes the typing first; holding fire skips it, a tap never does; the last page wins the run once, with n = round.winN; the window's keys, a click, a pause, its track and its sounds; every scene draws on a fake canvas at many moments; every event it raises has a react; every tone it names exists. // Run with: node --test scripts/test-web-console-activities-ghoul-ending.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-eye.mjs b/scripts/test-web-console-activities-ghoul-eye.mjs index 03eb610..c7a4fde 100644 --- a/scripts/test-web-console-activities-ghoul-eye.mjs +++ b/scripts/test-web-console-activities-ghoul-eye.mjs @@ -8,6 +8,7 @@ // shoot apart), the kill and its retreat in order with the door kept until it has gone, a bot's // fight length, the voices, words and drawing. // Run with: node --test scripts/test-web-console-activities-ghoul-eye.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-frozen.mjs b/scripts/test-web-console-activities-ghoul-frozen.mjs index 730eb83..089fdcb 100644 --- a/scripts/test-web-console-activities-ghoul-frozen.mjs +++ b/scripts/test-web-console-activities-ghoul-frozen.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Frozen Lake stage: its rooms (Ice Fishing Huts, Snowbound Lodge, The Black Ice, the Widow's Web), slippery ice and thin ice that cracks and breaks, under-ice hands, snow shades you only see by their footprints, frozen ghouls that slide and shatter, ice wraiths whose dive leaves you frozen, Hot Cocoa and the Road Flare (found only here), and the Frost Widow, whose veil melts only to a burning barrel or a flare. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-gameover.mjs b/scripts/test-web-console-activities-ghoul-gameover.mjs index 291f9ea..225f4a3 100644 --- a/scripts/test-web-console-activities-ghoul-gameover.mjs +++ b/scripts/test-web-console-activities-ghoul-gameover.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's game over: a lost end plays the mechanical laugh track (and a win does not), and the "G A M E - O V E R" banner drops in letter by letter and draws on a fake canvas. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-graveyard.mjs b/scripts/test-web-console-activities-ghoul-graveyard.mjs index 1026426..b980200 100644 --- a/scripts/test-web-console-activities-ghoul-graveyard.mjs +++ b/scripts/test-web-console-activities-ghoul-graveyard.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Graveyard stage: its four rooms, grasping hands, mourners and their wail, grave robbers, rotters and the legs they leave, carrion crows, the graves rotters climb out of, and Mother Mourning, who can only be hurt while she watches and drops a stone fist on whatever moves. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-grounds.mjs b/scripts/test-web-console-activities-ghoul-grounds.mjs index c9dac2a..146d986 100644 --- a/scripts/test-web-console-activities-ghoul-grounds.mjs +++ b/scripts/test-web-console-activities-ghoul-grounds.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Grounds stage: its four rooms, topiary beasts that creep only when your back is turned, rootlings under the lawn, lantern moths, mulch crawlers, the Hedge shears (found only here), and the Groundskeeper, whose lantern takes triple damage, whose scythe is jumped, whose fire burns the floor and who mounts a mower at half his hp. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-gurney.mjs b/scripts/test-web-console-activities-ghoul-gurney.mjs index 1f9a088..81f9e12 100644 --- a/scripts/test-web-console-activities-ghoul-gurney.mjs +++ b/scripts/test-web-console-activities-ghoul-gurney.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Code Blue (Blackmoor Sanatorium's bonus round, between the Surgical Theater and the Night Ward): its shape (every elevator shaft clears with a jump and swallows a gurney that does not jump, every low can be ducked, spacing, the surge lamps and the blackout waves, checkpoints, the clock), the gurney's speed on slopes, its jump, ducking, a wheelchair that rolls, an IV stand, a lamp or a door overhead, an orderly in a doorway, the surge lamp shot from the air, the lights-out rhythm (the countdown, the dark, the lights back), the heartbeat monitor, a fall down a shaft, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9) and the clean-dark-stretches die, endless lives for every cause, a voice for every event, the drawing, and bots that ride the whole way (one that dodges well, one that never does). // Run with: node --test scripts/test-web-console-activities-ghoul-gurney.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-hearse.mjs b/scripts/test-web-console-activities-ghoul-hearse.mjs index 901c828..a022970 100644 --- a/scripts/test-web-console-activities-ghoul-hearse.mjs +++ b/scripts/test-web-console-activities-ghoul-hearse.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Midnight Hearse (the Graveyard's bonus round, between the Mausoleum Row and Angel's Rest): its shape (two lanes, the gates, every thing spaced for a player, the closed stretches with a gate before each), the hearse's motion (a steady speed, a jump, a duck, a hop between lanes only at a gate), each obstacle and its cost (grave, headstone, cross, branch, hand, crow, wreck), the lamp and its lanterns, the coffins thrown out and the ghouls that sit up in them, the hearts and the grade and the dice, endless lives, the drawing and the sounds, and bots that play it. // Run with: node --test scripts/test-web-console-activities-ghoul-hearse.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-heart.mjs b/scripts/test-web-console-activities-ghoul-heart.mjs index 04418a6..7dd1c20 100644 --- a/scripts/test-web-console-activities-ghoul-heart.mjs +++ b/scripts/test-web-console-activities-ghoul-heart.mjs @@ -6,6 +6,7 @@ // the weak beats that only knock it back, the white, the last thump, the fall, the daylight and its // door), a life lost keeping it all, a bot's fight length at full depth, the voices, words and drawing. // Run with: node --test scripts/test-web-console-activities-ghoul-heart.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-intro.mjs b/scripts/test-web-console-activities-ghoul-intro.mjs index 7380c2e..20ff2a6 100644 --- a/scripts/test-web-console-activities-ghoul-intro.mjs +++ b/scripts/test-web-console-activities-ghoul-intro.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's stage intro cards: every stage has one (3 or 4 lines, short, no em dash, never the hero's name), the card shows when a stage is entered and not before the pick, any move key or fire moves it on after the minimum (repeats and early presses never do) and it never moves on by itself, and it draws on a fake canvas. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-lantern.mjs b/scripts/test-web-console-activities-ghoul-lantern.mjs index c8f95be..f8e0c32 100644 --- a/scripts/test-web-console-activities-ghoul-lantern.mjs +++ b/scripts/test-web-console-activities-ghoul-lantern.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Drowned Lantern (Gallows Bog's bonus round, between the Stilt House and the Drowning Pool, a top-down game on one screen and not a ride): the island, the walk and the slide, the flare and the oil, the shrines and the run to the boat, each hunter's one rule (the Lurker hears steps on wood and dashes down a lane through where it heard you, the wisps guard the shrines and burst in a flare, the leeches never enter the light, the bog bodies take only someone standing still, Old Mother Bog's hand), the hearts and the grade, the clock, determinism, the balance (a bot that ignores the hunters loses, one that plays them wins), the voices, the hums and the drawing. // Run with: node --test scripts/test-web-console-activities-ghoul-lantern.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-marrow.mjs b/scripts/test-web-console-activities-ghoul-marrow.mjs index 836f75a..76d19f4 100644 --- a/scripts/test-web-console-activities-ghoul-marrow.mjs +++ b/scripts/test-web-console-activities-ghoul-marrow.mjs @@ -5,6 +5,7 @@ // weighted pick, the wall in front of the house, the retreat in order and its standing door, a // bot's fight length, the voices, words and drawing. // Run with: node --test scripts/test-web-console-activities-ghoul-marrow.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-mat.mjs b/scripts/test-web-console-activities-ghoul-mat.mjs index be6ec74..1435e0b 100644 --- a/scripts/test-web-console-activities-ghoul-mat.mjs +++ b/scripts/test-web-console-activities-ghoul-mat.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Down the Hatch (the finale's first ride, after the Front Lawn): its shape (eleven swallows, every fork's hole swallows a rider who does not jump and its gristle ledge catches one who does, every uvula can be ducked, spacing, checkpoints every 8 to 10 seconds, the lip), the ride's speed on slopes and bile, its jump and duck, a rib, a uvula-lamp, a squeeze's throb, close and ease (peristalsis), the swallowed furniture, a plunge, the checkpoints, the lip and the door, the bonus round's three hearts and dice (3 to 8), endless lives for every cause, a voice for every event, the drawing, the telegraphs, and bots that ride the whole throat (one that rides well finishes, one that never dodges loses all three hearts without a game over). // Run with: node --test scripts/test-web-console-activities-ghoul-mat.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-mine.mjs b/scripts/test-web-console-activities-ghoul-mine.mjs index 43d5c3e..28bad28 100644 --- a/scripts/test-web-console-activities-ghoul-mine.mjs +++ b/scripts/test-web-console-activities-ghoul-mine.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Deep Seam Mine stage: its four rooms (always dark, the cage lifts, the water, the rockfall), rocks that fall after a dust warning and crush monsters and cost a life, the knocker imp that steals your light but never a life, the canary ghost whose scream brings three rocks down, the dead miner that digs out of the wall, the blind crawler that hunts by sound, the cage you can ride, the Hard Hat and Dynamite (found only here), and the Tommyknocker, who knocks, sweeps his hammer, puts the lights out, sinks into the seam and bursts out dazed, and rages at half his hp. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-mower.mjs b/scripts/test-web-console-activities-ghoul-mower.mjs index c809c8a..37d3b45 100644 --- a/scripts/test-web-console-activities-ghoul-mower.mjs +++ b/scripts/test-web-console-activities-ghoul-mower.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Gardener's Revenge (the Grounds' bonus round, between the Gazebo and the Groundskeeper's Yard): its shape (every pond and ditch clears with a jump and swallows a mower that does not jump, every low can be ducked), the mower's motion, each obstacle's cost and cause, the blades (cutting, the heat, the jam, the lawn cut), the topiary beasts, the hearts, the checkpoints, the finish and the dice, endless lives, the art on a fake canvas, and the two bots (one that plays well finishes in time, one that never dodges loses). // Run with: node --test scripts/test-web-console-activities-ghoul-mower.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-pew.mjs b/scripts/test-web-console-activities-ghoul-pew.mjs index 10c4589..7f4f9fe 100644 --- a/scripts/test-web-console-activities-ghoul-pew.mjs +++ b/scripts/test-web-console-activities-ghoul-pew.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Holy Roller (the Chapel's bonus round, between the Organ Loft and the Choir): an endless-runner seen from behind, in three lanes. Its room and its seeded course (every thing in the way has a safe answer, a safe path exists at every moment), the speed ramp, the lanes and the wall bump, the jump and the slide, each kind of obstacle's cost and cause, the gargoyles and the bell ropes, the wax souls, the combo and the halo's magnet, the grade, the last heart ending the round with the run going on, endless lives, the Garlic shield, the sounds and words, the drawing on a fake canvas, and bots that play it well and badly. // Run with: node --test scripts/test-web-console-activities-ghoul-pew.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-retry.mjs b/scripts/test-web-console-activities-ghoul-retry.mjs index 92a1420..24be587 100644 --- a/scripts/test-web-console-activities-ghoul-retry.mjs +++ b/scripts/test-web-console-activities-ghoul-retry.mjs @@ -1,6 +1,7 @@ // Web console tests, Ghoul Rush's retry mercy: after a loss in a room, each restart of it sets one power-up a few steps ahead of Planny (never the first attempt, never in a ride or bonus room), the kind from its own hash so no shared roll shifts, on a firm surface, replacing the last one uncollected, reset when the room is cleared. // Run with: node --test scripts/test-web-console-activities-ghoul-retry.mjs +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-ride.mjs b/scripts/test-web-console-activities-ghoul-ride.mjs index 56f74a5..3471c6b 100644 --- a/scripts/test-web-console-activities-ghoul-ride.mjs +++ b/scripts/test-web-console-activities-ghoul-ride.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's dark ride (the Midnight Carnival's bonus round): its place (between the funhouse and the Big Top), the bonus round's five hearts and the flow on to the boss, the dice rule, the controls (arrows, Space, the mouse, the duck zone), aim assist, the mini-bosses, the Exit's twist, a bot that rides it all and one that does nothing, the endless-lives code, and every event voiced. // Run with: node --test scripts/test-web-console-activities-ghoul-ride.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-sanatorium.mjs b/scripts/test-web-console-activities-ghoul-sanatorium.mjs index 4c8db5f..4b15c21 100644 --- a/scripts/test-web-console-activities-ghoul-sanatorium.mjs +++ b/scripts/test-web-console-activities-ghoul-sanatorium.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Blackmoor Sanatorium stage: its four rooms, orderlies that grab and throw you (and cost no life), gurneys that park, rattle and roll, flickers you can only hit and be hurt by when the lamps go out, specimen bloaters and their formaldehyde, the lamps' flicker, Smelling Salts and the Bone Saw (found only here), and the Night Matron, whose lantern cone builds heat, is stopped by the medicine cabinets and cannot reach the boards, with her syringes, arms and rage. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-sled.mjs b/scripts/test-web-console-activities-ghoul-sled.mjs index b7af47e..a9c32b0 100644 --- a/scripts/test-web-console-activities-ghoul-sled.mjs +++ b/scripts/test-web-console-activities-ghoul-sled.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Coffin Sled (the Frozen Lake's bonus round, between the Black Ice and the Widow's Web): its shape (every crack clears with a jump and swallows a sled that does not jump, every low can be ducked, spacing, checkpoints, the clock), the sled's speed on slopes, its jump, ducking, a headstone, a drift, a branch, a hand in the snow, the ghoul that pops up and the icicles (bolts that follow the hill), a fall into a crack, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole hill (one that dodges well, one that never does). // Run with: node --test scripts/test-web-console-activities-ghoul-sled.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-story.mjs b/scripts/test-web-console-activities-ghoul-story.mjs index 0b309be..0d80cc6 100644 --- a/scripts/test-web-console-activities-ghoul-story.mjs +++ b/scripts/test-web-console-activities-ghoul-story.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's intro story: 6 to 8 pages that fit the field, never name the hero, stay generic about stages (no names, no counts) and speak to YOU; a run opens on it and ends in The Long Hall; the lockout, the typing that finishes first, every key and a click, the skip by holding fire, a pause that holds it; never in the practice stage select, on a respawn or in a new room; every page draws on a fake canvas at many moments; every sound it asks for exists. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-tray.mjs b/scripts/test-web-console-activities-ghoul-tray.mjs index c800a7f..1ae8739 100644 --- a/scripts/test-web-console-activities-ghoul-tray.mjs +++ b/scripts/test-web-console-activities-ghoul-tray.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Servants' Back Stairs (the East Wing's bonus round, between the Attic and the Crypt): its shape (every gap between flights clears with a jump and swallows a tray that does not jump, every low can be ducked, spacing, checkpoints, greased stretches, the clock), the tray's speed on slopes and grease, its jump and duck, a pot, cutlery, a ham, pans, the cook's dish, the domes and plates (the courses), the cherries, a fall down the stairs, the checkpoint, the jump off the last shelf and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole route (one that dodges well, one that never does). // Run with: node --test scripts/test-web-console-activities-ghoul-tray.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-village.mjs b/scripts/test-web-console-activities-ghoul-village.mjs index c05aab0..0ac9683 100644 --- a/scripts/test-web-console-activities-ghoul-village.mjs +++ b/scripts/test-web-console-activities-ghoul-village.mjs @@ -1,4 +1,5 @@ // Web console tests, Ghoul Rush's Hollow End Village stage: its four rooms, the moonrise (a moon that climbs over each room and, at full, turns the villagers into wolf-men and makes the moonhounds grow), torch mob villagers that lob fire, hanged men that drop on their ropes, shutter ghouls that can be hit only while out, moonhounds, Wolfsbane (found only here), and the Beast of Hollow End, which clings to the wall for double damage, pounces under a shadow, swipes, howls for hounds and rages at half its hp. +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul-wagon.mjs b/scripts/test-web-console-activities-ghoul-wagon.mjs index 1c5301d..a68d56e 100644 --- a/scripts/test-web-console-activities-ghoul-wagon.mjs +++ b/scripts/test-web-console-activities-ghoul-wagon.mjs @@ -1,5 +1,6 @@ // Web console tests, Ghoul Rush's Torch Mob (Hollow End Village's bonus round, between the Square and the Green): its shape (every ditch and the bridge clear with a jump and swallow a wagon that does not jump, every low can be ducked, spacing, checkpoints), the wagon's speed (the brake that is also a duck), every obstacle's cost and cause (barrels, crates, washing lines, inn signs, pitchforks, torches, horses, ditches, the river, the mob), the throwers' wind-up and aim, shooting torches and forks out of the air, the horses, the pursuit meter (the gap that clean riding opens and braking, hits and fire close), the hay fire, the catch, hearts of its own, the grade and the dice, endless lives, the checkpoints, the finish, no random numbers, its sounds and its drawing on a fake canvas, and bots that play it well and badly. // Run with: node --test scripts/test-web-console-activities-ghoul-wagon.mjs +import "./seed-random.mjs"; import { test } from "node:test"; import assert from "node:assert/strict"; import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js"; diff --git a/scripts/test-web-console-activities-ghoul.mjs b/scripts/test-web-console-activities-ghoul.mjs index a082152..65b348b 100644 --- a/scripts/test-web-console-activities-ghoul.mjs +++ b/scripts/test-web-console-activities-ghoul.mjs @@ -5,6 +5,7 @@ // handed, so stub canvases that count or record calls stand in for the page. // The rules are plain functions over a round, driven here slice by slice. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import fs from "node:fs"; diff --git a/scripts/test-web-console-activities-rapids.mjs b/scripts/test-web-console-activities-rapids.mjs index 481a9db..aaf6a49 100644 --- a/scripts/test-web-console-activities-rapids.mjs +++ b/scripts/test-web-console-activities-rapids.mjs @@ -5,6 +5,7 @@ // handed, so a stub canvas stands in for the page, as in // scripts/test-web-console-activities.mjs, whose helpers this file copies. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import * as rapids from "../src/web-console/public/activities/rapids.js"; diff --git a/scripts/test-web-console-activities.mjs b/scripts/test-web-console-activities.mjs index 08ad5d2..5c6a0a0 100644 --- a/scripts/test-web-console-activities.mjs +++ b/scripts/test-web-console-activities.mjs @@ -6,6 +6,7 @@ // walks every entry in ACTIVITIES plus a stub second game defined here, which // is what proves a new game needs no change to the window. +import "./seed-random.mjs"; import test from "node:test"; import assert from "node:assert/strict"; import path from "node:path";