mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Move Ghoul Rush into activities/ghoul-rush/ and split ghoul.js
Every Ghoul Rush file moves under activities/ghoul-rush/, sorted into core, arms, draw, story, sfx, stages/<stage> and rides/<ride>, with names unchanged. ghoul.js is now a facade over seven parts in core/, taking it from over the 3,000 line cap to 50 lines. Also in this tree: the Drowned Lantern replaces the Bog Runner, the "Use a Lucky Die?" question, the Old Mother Bog rework, Rapid fire at 60 ms, the rules for the finale's first kill (not plugged in yet), and small fixes the suites asked for (the Stilt House's and Drowning Pool's weapons). AI Assisted
This commit is contained in:
1 parent
0454bdd19a
commit
903fbf5680
160 files changed
+11022
-7061
No files matched your search
+130
-115
@@ -5,7 +5,7 @@
|
||||
|
||||
```
|
||||
plan2code/
|
||||
├── src/ # Source workflow prompts (14 markdown files)
|
||||
├── src/ # Source workflow prompts (17 markdown files)
|
||||
│ ├── plan2code-0-pathfinder-references/ # Reference files for pathfinder skill
|
||||
│ │ ├── brief.md # Dated plain-English decision briefs
|
||||
│ │ ├── chart.md # MODE A: destination + frontier grills, templates
|
||||
@@ -27,13 +27,16 @@ plan2code/
|
||||
│ │ └── session-end.md # Next-step routing at review session end
|
||||
│ ├── plan2code-init-update-references/ # Reference files for init-update skill
|
||||
│ │ └── ai-agent-file-sync.md # Step 7: replace AI configs with AGENTS.md refs
|
||||
│ └── plan2code-4-finalize-references/ # Reference files for finalize skill
|
||||
│ └── community-feedback-submission.md # STEP 6.5 payload schema + submission tiers
|
||||
│ ├── plan2code-4-finalize-references/ # Reference files for finalize skill
|
||||
│ │ └── community-feedback-submission.md # STEP 6.5 payload schema + submission tiers
|
||||
│ ├── skill-scripts/ # Scripts shared across skills: install.js copies the ones a skill lists into skills/<skill>/scripts/ (specs, commit-msg, review-scope, agents-md, agent-files, common)
|
||||
│ └── plan2code-<skill>-scripts/ # A skill's own scripts, same copy rule (pathfinder, finalize, changelog, git and xray each have one)
|
||||
├── plan2code-bot/ # Autonomous end-to-end workflow test runner (TypeScript, tsup, Claude Agent SDK, vitest); user docs in .readme/test-bot.md
|
||||
├── plan2code-metrics/ # Recursive self-improvement toolchain
|
||||
│ ├── src/ # TypeScript source
|
||||
│ │ └── prompts/ # Internal AI prompt templates (no char limit)
|
||||
│ └── dist/ # Built output (tsup)
|
||||
├── plan2code-app/ # Desktop app (Rust + Tauri): wraps the console in a window, agent-less setup screen; cargo fmt/clippy/test, see its README
|
||||
├── src/statusline-claude/ # Claude CLI status line (Node.js, zero deps, single file)
|
||||
│ ├── statusline.js # Self-contained: config, git, formatters, render
|
||||
│ └── statusline-config.json # Default config template
|
||||
@@ -44,7 +47,7 @@ plan2code/
|
||||
│ └── plan2code.ico # Desktop shortcut icon (Windows)
|
||||
├── src/web-console/ # Local browser UI bundled into every skill (Node.js, zero deps, no build)
|
||||
│ ├── console.mjs # CLI the agent drives: open, post, wait, chat, keep, status, stop, help
|
||||
│ ├── server.mjs, routes.mjs, static.mjs, cmd-*.mjs, picker.mjs, and the by-job files (files, sessions, patches, scan, inbox, workspace, settings)
|
||||
│ ├── server.mjs, routes.mjs, static.mjs, cmd-*.mjs, picker.mjs, and the by-job files (files, sessions, patches, scan, inbox, workspace, settings, agents, agent-lookup, git-repo, handoffs, in-app, loop-setup, notepads, open-link, pointers, spec-files, update-check)
|
||||
│ ├── console.md, console-*.md, notes/, building*.md # Agent-facing contract (console.md read once, the rest on demand)
|
||||
│ └── public/ # Page assets served to the browser
|
||||
├── scripts/ # Development scripts
|
||||
@@ -60,12 +63,15 @@ plan2code/
|
||||
│ ├── node-test.mjs, page-test-helpers.mjs # `npm test`'s `node --test`, files at once capped at one per spare core; the page tests' browser sessions and their redraw-safe `styleOf()`, `stylesOf()`, `scrollCard()`
|
||||
│ ├── test-launcher.mjs, test-getting-started.mjs # Launcher suite; newcomer docs kept in step
|
||||
│ ├── test-skill-scripts.mjs, test-script-<skill>.mjs, test-git-repo.mjs, skill-script-helpers.mjs, fixture-helpers.mjs # Skill script suites and fixtures
|
||||
│ ├── check-versions.mjs, fix-line-endings.mjs, play.mjs # Six-file version sync; restores LF everywhere (also pretest + pre-commit); tries the games from src/
|
||||
│ ├── measure-console-wire.mjs, css-helpers.mjs, ghoul-test-helpers.mjs, fixtures/, console-wire-runs/ # Wire-size probe and its captured runs; shared CSS and Ghoul Rush test helpers; skill-script fixtures
|
||||
│ └── validate-char-count.js # Pre-commit character count validator
|
||||
├── skills/ # Generated, gitignored build output — one Agent Skill per src/ prompt
|
||||
│ └── plan2code-<name>/ # SKILL.md plus references/ and scripts/ where present
|
||||
│ # Generated by npm run build:skills; consumed by skills add
|
||||
├── .husky/ # Git hooks (husky)
|
||||
│ └── pre-commit # Runs character count validation
|
||||
│ └── pre-commit # Runs fix-line-endings, then character count validation
|
||||
├── .agents-docs/ # The detail files AGENTS.md links to (this file and its siblings)
|
||||
├── .claude/ # Repo-local Claude Code config (NOT installed by install.js)
|
||||
│ └── skills/ # Maintainer-only dev skills, e.g. plan2code-publish/, plan2code-launcher-update/
|
||||
├── .github/ISSUE_TEMPLATE/ # bug.yml, idea.yml, config.yml (target of the console's feedback button)
|
||||
@@ -174,9 +180,9 @@ Anything a workflow step decides with one correct answer (parsing a spec's check
|
||||
|
||||
| Script | Skills | Does |
|
||||
|---|---|---|
|
||||
| `specs.mjs` | plan, revise-plan, document, implement, implement-review, review, quick-task, finalize, handoff | `list` / `status` (Phase Checklist, groups, task markers, numbering, the implement selection verdict, consistency checks) / `metrics` / `mark` / `archive`. Imports `scanProject()` from the bundled `web-console/scan.mjs`, so the dashboard and the skills share one spec classifier |
|
||||
| `specs.mjs` | plan, revise-plan, document, implement, implement-review, review, quick-task, finalize, handoff, diagnose | `list` / `status` (Phase Checklist, groups, task markers, numbering, the implement selection verdict, consistency checks) / `metrics` / `mark` / `archive`. Imports `scanProject()` from the bundled `web-console/scan.mjs`, so the dashboard and the skills share one spec classifier |
|
||||
| `commit-msg.mjs` | implement(-review), review, quick-task, finalize, init-update, git | The `<subject>` / `AI Assisted` commit command (two `-m` flags), with optional `git add` |
|
||||
| `review-scope.mjs` | review, implement(-review), quick-task | Review Mode's git fallback: files, lines, doc share, base branch |
|
||||
| `review-scope.mjs` | review, implement(-review), quick-task, finalize | Review Mode's git fallback: files, lines, doc share, base branch |
|
||||
| `agents-md.mjs` | init, init-update | AGENTS.md structure, budget, orphans, broken links, always-inline sections |
|
||||
| `agent-files.mjs` | init, init-update | Detect and replace other agents' config files with AGENTS.md pointers |
|
||||
| `pathfinder.mjs` (own) | 0-pathfinder | `reconcile`, `frontier`, `claim`, `resolve`, `rule-out`, `trail`, `gate`, `lint`, `brief-data` |
|
||||
@@ -252,117 +258,126 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `public/activities/bounce-road.js` | Bounce Road's road, rules only: the jump math every hole is sized by (`airMs(v)`, `reach(v)`, `LONGEST_JUMP`, `JUMP_FAIR`, `TOP_SPEED`, `MAX_SPEED`), `stageFor(n)` (built once a stage: the ten of `bounce-roads.js`, then laps from `LAP_FROM`, quicker, keener, busier, the Monster at every Monster Mash) and `stageName`, `newRoad(seed)` and `buildStage(road, n, random)` (a stage's rows from its own seed, by the stage's piece weights: straights, cracks, rivers on bridges with one or two broken spans or a drawbridge, splits round flowerbeds, ramps before a crack with stars beyond, cone or block chicanes, crumbling road, train crossings, swaying bridges, boost strips, slicks, balls, sprinklers, drops and gusts; every hole after a `RUNUP` with a sign and no longer than `MAX_HOLE`, the bridge between two breaks long enough to land `LONGEST_JUMP` on), `ensureRoad`, `groundAt(road, x, d, t)` (a row's edges eased from the row before's; a drawbridge water while lifted, a swaying bridge shifted, crumbled road a hole), `rowGone`, `spanAt`, `holesIn`, `firstAt`, `plainRow`, `safeSpot` (no hole, water, timed part or rails for `RESPAWN_RUN` ahead), and where each timed thing is at a moment: `swayOff`, `drawLift`, `crumbleAt` (falling away `CRUMBLE_DELAY` after you reach it, at `CRUMBLE_SPEED`, under a fair speed), `trainAt` (on, and lit `TRAIN_WARN_MS` before), `ballX`, `sprayAt`, `gustAt`; plus `seeded`, `GROUND`, `MARK`, `SPAN` |
|
||||
| `public/activities/bounce-rivals.js` | Bounce Road's rivals, rules only: `RIVALS` (the Zigzag, Brick, Frog, Nudge, Hauler, Sneak, Bruiser, Racer, Cop and Monster: box, mass, speed, points, how readily each dodges, how often each comes, its car style and whether it comes from behind), `makeCar`, `think(round, car, ms, random)` (each kind's choice of speed and line: the Zigzag's weave, into your path when you follow; the Brick holding your lane and brake-checking from in front, then resting `BRAKE_REST_MS` or more; the Frog's hops toward you; the Nudge's chase and up to 1 + 2 times the stage's `sharp` swipes; the Hauler drifting to block; the Sneak dropping up to `SNEAK_DROPS` cones while you follow; the Bruiser slamming you within `BRUISER_RANGE`; the Racer passing then fleeing; the Cop sitting on your roomier side and leaning in to push you to the near edge for `COP_MS`, never on a bridge or by the water (`nearWater`), nor the Bruiser; the Monster keeping `BOSS_AHEAD` in front, hopping every `BOSS_HOP_MS` to come down where you will be and dropping tires; every rival rubber-banded to stay near you, swerving from under your landing as sharply as its stage allows, keeping to the narrowest road just ahead and the band a swaying bridge always covers, holding a slower car's speed, and hopping any hole, drawbridge, barrier or coming train, or flying off a ramp), `spawnRival`, `pickKind` (one of each special kind at a time), `HEAVY`, `RIVAL_MIN_SPEED` |
|
||||
| `public/activities/bounce-roads.js` | Bounce Road's ten stages as data (no imports): `FIELD_W`, `FIELD_H`, `ROW`, `MAX_HOLE`, `LAP_FROM`, and per stage its length, par time, road widths, piece weights (straights, holes, rivers, splits, ramps, chicanes, crumbling road, trains, swaying bridges, boost strips, slicks, balls, sprinklers, drops, gusts), crack and broken span lengths, bridge widths and shares of broken, double and drawbridge spans, flowerbed sizes, barrier and drop kinds, the rivals' count, kinds, pace and sharpness, power-ups, stars, and whether the Monster comes |
|
||||
| `public/activities/ghoul.js` | Ghoul Rush: its rules as plain exported functions over a round in one room of a haunted house seen side on, the view `FIELD_W` (96) by `FIELD_H` (54) units with y counted up, scrolled along a room hundreds of units long by `round.camX` (`newRound(seed)`, the stage packs (`PACKS`, see `ghoul-graveyard.js`) merged into its tables and run where its own rules run, through a `KIT` of helpers; `roomFor(id, depth)` (built once per room and depth, the stages already cleared that run: the monsters quicker (`pace`, `DEPTH_PACE` a stage), let out sooner (`every`, `DEPTH_EVERY`), a bolt tougher (`tough`) and more of them out of wall doors (`extra`), each capped, the boss with `BOSS_DEPTH_HP` more hp a stage up to `BOSS_DEPTH_MAX` and more points (`bossPoints`)), `roomName(spec, n)`, the run of stages (it starts in the hall, `ROOMS[0]`; out of the hall and out of each boss room the phase is `pick` with `round.offer`, `OFFER_N` stages from `stagesLeft(round)` shuffled by the `random` handed to `advance`; `steerPick(round, dir)` moves `round.pick`, `pickStage(round, i)` takes one once `PICK_HOLD_MS` has passed and enters its first room, `round.stage`/`stageAt` track the way through its rooms, `round.cleared` the stages done in order, and with none left the run is won: `round.won`, `round.over`, a `won` event), `groundAt` (ground pieces are solid blocks; a gap is a pit), `shelfThere`, `footing` (the highest surface within `STEP_UP` of a walker), `jumpHeightAt(dx)` (the suite's measure of what a jump clears), `jump`, `moveYou` (running at `RUN_SPEED` on the ground and in the air alike, a step of `STEP_UP` walked, a taller one a wall, shelves one way: jumped up through, landed on from above by crossing their line so no fall goes through one, dropped through with down; `COYOTE_MS` to still jump off an edge, a press `JUMP_BUFFER_MS` before landing jumps on it, up let go while rising cuts the jump to `CUT_V`), `spawnMonster`, `solid` (a crawler or a door's zombie still coming up, a gourdling still in the air or finding its feet, and a faded ghost can neither hurt nor be hit; a faded ghost within `GHOST_CLEAR` of you never turns solid), `ghostSight`, `throwBone` (timed to come down at your chest), `aimAt` (a bolt tilts toward the nearest monster or bone ahead within `AIM_DY` of your chest, by up to `AIM_MAX`), `hurt`, `kill` (points times `chainMult(chain)`, the chain stepping for each kill within `CHAIN_MS` up to `MAX_MULT`, doubled for a headshot (the top `HEAD_SHARE`), a stomp or a chandelier; `DROP_CANDY` and `DROP_POWER` drops), `lose`, `applyPower`, `advance` in 4 ms slices over `round.input`, which `key()` and `release()` set: the timers, a jump press, the jump cut, your move, the door, the arena lock, the blaster (a bolt every `FIRE_MS`, `RAPID_MS` with Rapid fire, three with Spread shot, each flying `SHOT_SPEED` until a monster, a bone, the boss, a wall or `SHOT_RANGE`), the spawners (wall doors that hold while you are within `DOOR_CLEAR`, loose boards within `CRAWL_NEAR`, roosting bats within `BAT_NEAR`, the rest as the camera reaches them), the hurry zombies every `HURRY_MS` once the bonus is gone, the monsters (zombies lurch within `LURCH_RANGE` and never walk off an edge or onto a shelf, bats swoop in level passes at your chest turning `BAT_TURN` past you and never drop onto your head, ghosts drift through walls, skeletons wind up `SKEL_WINDUP_MS` and throw every `SKEL_MS` within `SKEL_RANGE` but not closer than `SKEL_NEAR`), the bosses (the Great Gourd waits `GOURD_WAIT_MS`, hops to where you stood (its shadow shows where) and slams down letting up to `MAX_SEEDS` gourdlings loose; Old Rattlebones' fight lives in `ghoul-bones.js`; shockwaves run `WAVE_H` high both ways at `WAVE_SPEED`; a stomp does `STOMP_DAMAGE`), the bones and shockwaves, the bolts, stomps (which bounce you at `STOMP_V`), the chandeliers (`CHANDELIER_SHAKE_MS` once you run under, then down on whatever is below), the hits (a Garlic shield takes one and sees off what touched you), the pickups, the crumbling boards (`CRUMBLE_MS`, back after `CRUMBLE_BACK_MS`) and a fall down a pit), `underBanner(round, y)` and `bannerY`, `chainMult`, `seeded`), the `MONSTERS` and `BOSSES` (with `POWERS`, `TIMED`, `powerHere` and the pickup points re-exported from `ghoul-powers.js`), `NEW_TONES` (the blips it asks `tones.js` for), and the game contract with `release()` (`key(name, repeat)`: held arrows run, up jumps once a press, never on a repeat, never again until let go and never with the press that plays on, down drops through a shelf, held space fires and its release stops; a pause lets go of every key and drops a press); a hit or a fall costs one of `START_LIVES`, holds `CRASH_MS` and puts you back at the room's start (in a locked boss fight, the arena's, the boss's hp kept) for `READY_MS`, safe for `SAFE_MS`, the room's monsters and spawners back where they began; through the door `ROOM_POINTS` times the room, the bonus left (Line truncated
|
||||
| `public/activities/ghoul-draw.js` | Ghoul Rush's drawing: `drawScene(ctx, view)` from one view object `ghoul.js` refills each frame, in room units turned the right way up and scrolled by the camera: the strip above the field in the page's colors with the pills (laid out by `hudLayout`: the room, lives, the bonus, the chain with its window emptying, the key once held, the power-ups; a second row rather than run off the board, the rows centered in the strip), still layers `CHUNK` units of a room wide drawn off screen once per room and scale and copied each frame (a few kept; each room's look in fixed colors, `LOOKS`: wallpaper, moonlit windows, decor by room (portraits, bookcases, curtains, pots, ferns, rafters with cobwebs, headstones), wainscot, floorboards, pits, shelves, wall doors and loose boards), the crumbling boards, a wall door standing open, the chandeliers, the exit door (padlocked, then open and glowing), candy, power-ups and the key, the monsters (a zombie in a ragged shirt with mismatched eyes, lurching; a crawler's hand through the boards, then crawling; a bat with flapping wings; a sheet ghost fading in and out; a skeleton raising a bone; gourdlings), bones and shockwaves, the bosses (the Great Gourd with a carved glowing face and a red shadow where it will land; Old Rattlebones, drawn by `ghoul-bones-draw.js`) and the boss bar, Planny (his star eye in your highlight in every state, stick arms, one holding the flashlight blaster that flares as it fires, stepping, arms up in the air or cheering, spinning with an "o" when hit, slumped at the end, garlic circling him while he has some; arms and feet in `limbInk(look)`), the bolts, sparks, rings, floating words kept on the field by `labelSpot`, the chain's big number, banners (`BANNER_SHADE`) the stage pick (`drawPicker`: a card per stage offered with its picture, `drawStagePicture`, its first room's wall and moonlit window over its boss room's floor with its boss standing there drawn by the same `BOSS_ART` as in play, name, line and boss, the one picked out raised and edged in gold, `stageColor` its boss room's), and the start and end strip with the big final score and a dot per stage, lit in each cleared stage's color (gold for the record before a run); `react(e, kit)` turns each event into those effects and its blips, a monster's own sound through `VOICES` (each kind's tone in `ghoul-sfx.js` by act: `appear` (a runner's `warn`, a bat's `wake`, a wraith's `notice`), `climb`, `hop`, `growl`, `lunge`, `shriek`, `dive`, `spit`, `throw`, `hurt` (one every 140 ms), `die`, and a boss's `wake`, `hop`, `slam`, `windup`; a "throw" event names its thrower in `by` and a "spit" its spitter in `kind`); the stage packs' drawing (`ART`: an `outdoor` look draws its pack's backdrop instead of walls, graves for doors, and each pack's monsters, bosses, missiles, hazards and lights by kind; a pack may also draw `sky` (every frame, under the still layers, so its backdrop leaves the sky clear) and `moving` (what moves in its scenery, over the still layers)); `readColors(canvas)`, `contrast`, `lookOf`; decides nothing |
|
||||
| `public/activities/ghoul-rooms.js` | Ghoul Rush's rooms and stages as data (no imports): the long hall every run starts in (`ROOMS[0]`), then `STAGES` (each an id, title, line and four room ids, the last a boss's, checked at load; `stageById`, `roomById`), `FIELD_W`, `FIELD_H`, `FLOOR_Y`, `CEILING_Y`, `CHANDELIER_Y`, and per room its look, name and line, length, ground pieces (pits between, steps and walls), shelves (`crumble` kind), start, key, door, candy rows, power-ups, spawns (zombies, wall doors, crawlers' boards, bats, ghosts, skeletons), chandeliers and boss (`gourd`, `bones` or a pack's, the last room of its stage); a door's fifth entry names what comes out of it (rotters out of the Graveyard's graves) |
|
||||
| `public/activities/ghoul-bones.js` | Old Rattlebones' fight, the East Wing's boss, as a boss pack in the shape of the stage packs (no imports; `ghoul.js` hands each rule its kit `k`; it plugs in through `PACKS` with `bosses`, `boss` and `hazards`, and `ghoul.js` re-exports `BONES_KEEP`, `BONES_MS`, `BONES_RAGE_MS`, `BONES_WINDUP_MS` and `VOLLEY`): 90 hp; every `BONES_MS` he winds up for a volley, a slam or the skull, picked at random by `pickAct` (never one three times running, the first a volley); the skull is a `skull` hazard that flies level at your chest `SKULL_REACH` past you and curves back to his neck while `b.headless` (no weak spot; a bolt to the skull does `SKULL_HIT`, eaten, with `SKULL_STAGGER_MS` between hits); at half his hp (`BONES_RAGE`) he shakes (`BONES_SHAKE_MS`), attacks every `BONES_RAGE_MS`, slams in a double (`DOUBLE_GAP_MS`), hurls bone rain (`rain` hazards: a shadow for `RAIN_WARN_MS`, then a bone) and raises skeletons (`raise` hazards, at most `MAX_BONY` alive or cracking). |
|
||||
| `public/activities/ghoul-bones-draw.js` | Old Rattlebones' drawing, `boneArt(d)` plugged into `ghoul-draw.js`'s `PACK_ART`: the boss (headless while the skull is out, arms to the skull or up for rain, shaking with flaring eyes in his rage), the skull in flight, the bone rain's shadows and falling bones, the cracking floor, `lights`, `react` cases for his new events (`skullWind`, `skullThrow`, `skullTurn`, `skullBack`, `rainWind`, `rainThrow`, `rainLand`, `bonesRage`, `raiseWind`, `raised`), and `LOSE_WORDS` / `LOSE_SOUNDS` for `skull` and `rain`. |
|
||||
| `public/md-field.js` | A Markdown answer field on CodeMirror 6: every multiline box the person types into renders its Markdown live. |
|
||||
| `public/md-field.css` | The frame a Markdown field wears inside its shadow root, linked beside `notepad-editor.css`. |
|
||||
| `public/activities/ghoul-rush/ghoul.js` | Ghoul Rush's public face and nothing else: it re-exports the parts below, so the page and the tests import from one place. Everything lives under `ghoul-rush/`: `core/` (the rules, rooms, run flow, power-ups, dice, bonus rounds), `arms/` (secondary weapons), `draw/` (shared drawing), `story/` (the intro story, stage and boss cards, game over), `sfx/` (shared sounds), `stages/<stage>/` and `rides/<ride>/` (each with its rules, art and sounds). |
|
||||
| `public/activities/ghoul-rush/core/ghoul-tables.js` | Ghoul Rush's numbers and tables: the shared timings and sizes, `PACKS` with every pack's monsters, bosses and hooks joined in, the seeded dice, and `roomFor`. Loads first and imports none of the other parts. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-kit.js` | `KIT`, the helpers handed to the stage packs: one object `ghoul-play.js` fills as it loads, so a part that only passes it on has no load-order tie to the play loop. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-planny.js` | The ground and Planny: surfaces, shelves, landing, and how he runs, jumps and falls. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-monsters.js` | The monsters: spawning, how each kind moves, and what they throw. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-fight.js` | Bosses and damage: a boss's fight and fall, hurting and killing a monster, losing a life. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-play.js` | The play loop: `KIT` and `RUN_KIT`, the blaster and bolts, hits, stomps, timers, one slice of play, and `advance()`. |
|
||||
| `public/activities/ghoul-rush/core/ghoul-window.js` | The game's contract with the Activities page: `create`, keys and pointer, what events set off, `ROOM_MUSIC`, the view handed to the drawing. |
|
||||
| `public/activities/ghoul-rush/stages/marrow/ghoul-marrow.js` | The finale's rules: Marrow, the house itself. Kill I, The Lawn: its windows, moves and retreat. Not plugged in yet. |
|
||||
| `public/activities/ghoul-rush/draw/ghoul-draw.js` | Ghoul Rush's drawing: `drawScene(ctx, view)` from one view object `ghoul.js` refills each frame, in room units turned the right way up and scrolled by the camera: the strip above the field in the page's colors with the pills (laid out by `hudLayout`: the room, lives, the bonus, the chain with its window emptying, the key once held, the power-ups; a second row rather than run off the board, the rows centered in the strip), still layers `CHUNK` units of a room wide drawn off screen once per room and scale and copied each frame (a few kept; each room's look in fixed colors, `LOOKS`: wallpaper, moonlit windows, decor by room (portraits, bookcases, curtains, pots, ferns, rafters with cobwebs, headstones), wainscot, floorboards, pits, shelves, wall doors and loose boards), the crumbling boards, a wall door standing open, the chandeliers, the exit door (padlocked, then open and glowing), candy, power-ups and the key, the monsters (a zombie in a ragged shirt with mismatched eyes, lurching; a crawler's hand through the boards, then crawling; a bat with flapping wings; a sheet ghost fading in and out; a skeleton raising a bone; gourdlings), bones and shockwaves, the bosses (the Great Gourd with a carved glowing face and a red shadow where it will land; Old Rattlebones, drawn by `ghoul-bones-draw.js`) and the boss bar, Planny (his star eye in your highlight in every state, stick arms, one holding the flashlight blaster that flares as it fires, stepping, arms up in the air or cheering, spinning with an "o" when hit, slumped at the end, garlic circling him while he has some; arms and feet in `limbInk(look)`), the bolts, sparks, rings, floating words kept on the field by `labelSpot`, the chain's big number, banners (`BANNER_SHADE`) the stage pick (`drawPicker`: a card per stage offered with its picture, `drawStagePicture`, its first room's wall and moonlit window over its boss room's floor with its boss standing there drawn by the same `BOSS_ART` as in play, name, line and boss, the one picked out raised and edged in gold, `stageColor` its boss room's), and the start and end strip with the big final score and a dot per stage, lit in each cleared stage's color (gold for the record before a run); `react(e, kit)` turns each event into those effects and its blips, a monster's own sound through `VOICES` (each kind's tone in `ghoul-sfx.js` by act: `appear` (a runner's `warn`, a bat's `wake`, a wraith's `notice`), `climb`, `hop`, `growl`, `lunge`, `shriek`, `dive`, `spit`, `throw`, `hurt` (one every 140 ms), `die`, and a boss's `wake`, `hop`, `slam`, `windup`; a "throw" event names its thrower in `by` and a "spit" its spitter in `kind`); the stage packs' drawing (`ART`: an `outdoor` look draws its pack's backdrop instead of walls, graves for doors, and each pack's monsters, bosses, missiles, hazards and lights by kind; a pack may also draw `sky` (every frame, under the still layers, so its backdrop leaves the sky clear) and `moving` (what moves in its scenery, over the still layers)); `readColors(canvas)`, `contrast`, `lookOf`; decides nothing |
|
||||
| `public/activities/ghoul-rush/core/ghoul-rooms.js` | Ghoul Rush's rooms and stages as data (no imports): the long hall every run starts in (`ROOMS[0]`), then `STAGES` (each an id, title, line and four room ids, the last a boss's, checked at load; `stageById`, `roomById`), `FIELD_W`, `FIELD_H`, `FLOOR_Y`, `CEILING_Y`, `CHANDELIER_Y`, and per room its look, name and line, length, ground pieces (pits between, steps and walls), shelves (`crumble` kind), start, key, door, candy rows, power-ups, spawns (zombies, wall doors, crawlers' boards, bats, ghosts, skeletons), chandeliers and boss (`gourd`, `bones` or a pack's, the last room of its stage); a door's fifth entry names what comes out of it (rotters out of the Graveyard's graves) |
|
||||
| `public/activities/ghoul-rush/stages/wing/ghoul-bones.js` | Old Rattlebones' fight, the East Wing's boss, as a boss pack in the shape of the stage packs (no imports; `ghoul.js` hands each rule its kit `k`; it plugs in through `PACKS` with `bosses`, `boss` and `hazards`, and `ghoul.js` re-exports `BONES_KEEP`, `BONES_MS`, `BONES_RAGE_MS`, `BONES_WINDUP_MS` and `VOLLEY`): 90 hp; every `BONES_MS` he winds up for a volley, a slam or the skull, picked at random by `pickAct` (never one three times running, the first a volley); the skull is a `skull` hazard that flies level at your chest `SKULL_REACH` past you and curves back to his neck while `b.headless` (no weak spot; a bolt to the skull does `SKULL_HIT`, eaten, with `SKULL_STAGGER_MS` between hits); at half his hp (`BONES_RAGE`) he shakes (`BONES_SHAKE_MS`), attacks every `BONES_RAGE_MS`, slams in a double (`DOUBLE_GAP_MS`), hurls bone rain (`rain` hazards: a shadow for `RAIN_WARN_MS`, then a bone) and raises skeletons (`raise` hazards, at most `MAX_BONY` alive or cracking). |
|
||||
| `public/activities/ghoul-rush/stages/wing/ghoul-bones-draw.js` | Old Rattlebones' drawing, `boneArt(d)` plugged into `ghoul-draw.js`'s `PACK_ART`: the boss (headless while the skull is out, arms to the skull or up for rain, shaking with flaring eyes in his rage), the skull in flight, the bone rain's shadows and falling bones, the cracking floor, `lights`, `react` cases for his new events (`skullWind`, `skullThrow`, `skullTurn`, `skullBack`, `rainWind`, `rainThrow`, `rainLand`, `bonesRage`, `raiseWind`, `raised`), and `LOSE_WORDS` / `LOSE_SOUNDS` for `skull` and `rain`. |
|
||||
| `scripts/test-web-console-activities-ghoul-bones.mjs` | Old Rattlebones' suite: the random attack order, the volley and slam, the skull's flight and the headless window, the skull shot, the rage, the double slam, bone rain, the skeleton cap and the reactions. |
|
||||
| `public/activities/ghoul-graveyard.js` | Ghoul Rush's Graveyard stage pack, its rules (no imports: `ghoul.js` hands each rule a kit `k` of its own helpers). A stage pack is plain data and functions that `ghoul.js` merges into its own tables (`PACKS`): `monsters` (with `perch`: its spawn names its height, `flies`: a horde one comes in high), `walkers`/`zombies`/`stackers`/`climbers` (joining the sets of those names), `act` (start), `solid`, `move`, `kill`, `horde` (fields a horde one comes with), `bosses`, `boss` (one slice of its fight), `guard` (true while shots and stomps glance off, a `bossBlock` event) and `hazards` (by kind, one slice of a box on the floor that hurts while `live`; kept in `round.hazards`). Three more fields a stage may add (the Grounds does): `cut` (kinds the Hedge shears kill outright), `weak` (by boss kind, `(boss, shot) => damage multiplier` for a weak spot; `bossHit` then carries `how: "weak"` and `weak: true`) and `cause` (what a boss's touch is called when it costs a life). The Chapel adds more: `tick(round, ms, k)` (a stage-wide twist run first in every slice; it may set `round.stunMs`, which freezes you and every monster, boss, hazard and missile while bolts in flight still fly, and keeps its state in `round.twist`), `stone` (by kind, true while shots glance off and a stomp does nothing; `glance` event), `shot(round, m, s, k, random)` (the damage multiplier of a bolt that hit `m`, free to splash), `target(round, s, k)` (true when a bolt struck something of the pack's that is no monster, such as an organ pipe) and, on a monster, `hasteMs` and `haste` (its time runs faster while `hasteMs` is over 0). On the drawing side a look may be `custom: true` with a `pack` id (the pack's art then draws the whole wall, floor and shelves) and the art may return `decor` (by the look's `decor` name). On the drawing side a stage's art may also return `react(e, k)` (its own events; `ghoul-draw.js`'s `react` falls through to `ART.react`, which returns true when it handled `e`), `ground` and `shelf` (the floor pieces and shelves of an outdoor look), `waves` and `powers`; a boss event must carry `kind` or its voice never plays. The Graveyard's: grasping hands (`HANDS_*`: lurk unseen, rise, grab, sink, creep under level ground after you), the mourner (wails every `WAIL_MS`, slowing you to `SLOW_SHARE` speed for `SLOW_MS` within `WAIL_REACH`; `round.you.slowMs`), the grave robber (digs in within `ROBBER_DIG`, comes up `ROBBER_BEHIND` behind you), the rotter (a zombie whose body-shot death leaves its `legs` walking), the carrion crow (perches, dives at your chest, climbs, dives again), and Mother Mourning (`angel`: weeps `ANGEL_WEEP_MS` as stone flinging headstones, turns `ANGEL_TURN_MS`, watches `ANGEL_WATCH_MS` when only she can be hurt and any move drops a `fist` hazard after `FIST_WARN_MS`; at `ANGEL_RAGE` her wings spread, the weep shorter, the watch longer, a shockwave each way as each weep begins) |
|
||||
| `public/activities/ghoul-graveyard-draw.js` | The Graveyard's drawing: `LOOKS` for its four rooms (`outdoor: true`, so `ghoul-draw.js` draws `backdrop` instead of walls: the night sky, stars, the moon, hills with dead trees, iron fences, mausoleums, fog and headstones) and `graveyardArt(d)`, handed `ghoul-draw.js`'s helpers, returning the open `grave` and `openGrave` a rotter climbs out of, `monsters`, `bosses` (Mother Mourning: hands over her face while she weeps, lowered with burning eyes while she watches, wings spread in a rage, cracks as she is worn down), `missiles` (a flung headstone), `hazards` (a stone fist: its shadow, then the fist) and `lights` |
|
||||
| `public/activities/ghoul-grounds.js` | Ghoul Rush's Grounds stage pack, its rules (no imports; same shape as the Graveyard's, plus the pack fields `cut`, `weak` and `cause`): the topiary beast (`still` while you face it, `creep` when your back is turned; events `rustle` and `freeze`), the rootling (`trail`, `warn`, `up`, `sink`; events `rootWarn` and `rootUp`), the lantern moth (flocks of three, quicker in the dark), the mulch crawler (`pile`, `burst`, `crawl`; event `leaves`), the Hedge shears' `snip` event, and the Groundskeeper (`keeper`: a scythe sweep along the floor (or, now and then, a high `sweep` hazard you stay on the ground under), a lobbed lantern fire hazard, his lantern a `weak` spot only while open (`b.lit`), and at half hp a mower with `rev`, `charge` and `stall`) |
|
||||
| `public/activities/ghoul-grounds-draw.js` | The Grounds' drawing: `LOOKS` for its four rooms (`outdoor: true`), `groundsArt(d)` returning `monsters`, `bosses`, `hazards` (the fire), `waves` (the scythe), `powers` (the shears), `lights`, `backdrop`, `ground`, `shelf` and `react(e, k)` for the Grounds' own events; its `VOICES` (each kind's tone per act, `keeper.weak` for a weak-spot hit instead of `keeper.hurt`, `shears.snip` for a cut instead of the dying cry), `LOSE_WORDS` and `LOSE_SOUNDS`, which `ghoul-draw.js` spreads into its own tables |
|
||||
| `public/activities/ghoul-chapel.js` | Ghoul Rush's Chapel stage pack, its rules (no imports; same shape as the Grounds', plus the pack hooks `tick`, `stone`, `shot` and `target`, and a room field `toll`): the gargoyle (`perch` as stone, `wake`, `dive`, `return`; events `glance`, `gargoyleWake`, `gargoyleDive`, `gargoylePerch`), the choir ghost (sings, giving nearby monsters `hasteMs`), the censer monk (`smoke` hazard), the bell bat (`roost` until the toll), the bell toll (`tick`: `bellSwing`, `toll`, `tollEnd`, `round.stunMs`), Holy Water's splash (`shot`, event `holySplash`) and the Choirmaster (`choirmaster`: four pipes in `b.pipes` that bolts hit through `target`, a `guard` while any sounds, columns of `note` hazards with one gap, a rage that brings pipes back one by one) |
|
||||
| `public/activities/ghoul-chapel-draw.js` | The Chapel's drawing: `LOOKS` for its four rooms (indoor but `custom: true` with `pack: "chapel"`, so `ghoul-draw.js` hands the walls, floor and shelves to `chapelArt(d)`'s `backdrop`, `ground` and `shelf`), `chapelArt(d)` returning those plus `decor` (the room's pews, belfry, organ or stalls), `monsters`, `bosses`, `hazards` (smoke, the bell, notes), `powers`, `lights` and `react(e, k)`; its `VOICES` (the bell has only `swing` and `toll`: the thaw after a toll is quiet on purpose), `LOSE_WORDS` and `LOSE_SOUNDS` |
|
||||
| `public/activities/ghoul-sanatorium.js` | Ghoul Rush's Blackmoor Sanatorium stage pack, its rules (no imports; same shape as the Chapel's, plus the pack fields `unseen`, `harmless`, `platform` and `land`, a room field `flicker`, `round.blackout`/`round.twist` for the lamps and the kit's `fling`): the orderly (`reach`, `hold`, a throw that costs no life, `you.heldMs`; events `orderlyReach`, `orderlyGrab`, `orderlyThrow`, `saltsBreak`), the gurney (`parked` as a floor you can stand on, `rattle`, `roll`, `rest`; `gurneyRattle`, `gurneyRoll`, `gurneyRest`), the flicker (`m.unseen`: bolts and touch go through it until a blackout, the Lantern's light or the Salts' glow; `flickerShow`), the specimen bloater (a `jar` missile with its own `cause` that `land`s as a `formaldehyde` hazard; `jarWind`, `jarBreak`), the lamps (`tick`: `flickerWarn`, `lightsOut`, `lightsOn`), the Salts and the Saw (`shot`) and the Night Matron (`matron`: `b.beam` cone, `b.heat`, `b.cabinets`, syringes, arms, rage; `syringeWind`, `syringes`, `armWarn`, `armReach`, `matronRage`) |
|
||||
| `public/activities/ghoul-sanatorium-draw.js` | The Sanatorium's art: `LOOKS` (indoor but `custom: true` with `pack: "sanatorium"` and `noMoon`, so `sanatoriumArt(d)`'s `backdrop`, `ground` and `shelf` draw the tiled walls, windows, decor, floors, the ward's cabinets, the baths' tubs and each room's boards), `monsters` (orderly with its grab pose, gurney, flicker with its fade and afterimage, specimen bloater), the `matron` with her cone cut by the floor and the cabinets, `missiles` (jar, syringe), `hazards` (formaldehyde, arm with its crack of light), `powers` (Salts, Saw), `lights`, `react(e, k)` and two generic hooks `ghoul-draw.js` calls: `front(ctx, v)` (over Planny and before the dark: the ceiling lamps, the tubs' water, the orderly's fingers, the Matron's heat on him) and `dim(v)` (the dark layer's alpha, raised in a blackout and in a stutter); its `VOICES` (borrowed tones; `lights`, `salts` and `saw` are no monsters), `LOSE_WORDS` and `LOSE_SOUNDS` |
|
||||
| `public/activities/ghoul-village.js` | Ghoul Rush's Hollow End Village stage pack, its rules (no imports; no new pack field: it uses `tick`, `shot`, `land`, `weak` (now handed `(boss, shot, round, k)`) and `solid`, and draws no random number): the moonrise (`tick`; `round.twist` = `{ moon, full, ms }`, events `fullMoon`, `villagerTurn`, `villagerWolf`, `houndGrow`), the torch mob villager (a group of three, `torchWind`, the `torch` missile that `land`s as a `torchfire` hazard, `torchLand`; turned into a leaping wolf-man at full moon), the hanged man (`hangedWarn`, `hangedDrop`, `hangedSnap`, `hangedHaul`), the shutter ghoul (`solid` only while out; `shutterRattle`, `shutterLunge`, `shutterPull`), the moonhound (the hellhound's leap, grown at full moon), Wolfsbane's double damage and shying (`baneShy`) and the Beast of Hollow End (`beastLeap`, `beastCling`, `beastPounce` with a `shadow` hazard, `beastLand`, `swipeWind`, `beastSwipe` with a `claw` hazard, `beastHowl`, `houndCall`, `beastMoon`) |
|
||||
| `public/activities/ghoul-village-draw.js` | The Village's art: `LOOKS` (street, square and green outdoors, the inn a `custom` indoor look, all `pack: "village"`), `villageArt(d)` returning the world's hooks plus the monsters (the torch mob villager and the wolf-man it turns into over 800 ms, the hanged man on his rope, the shutter ghoul reaching out of a window, the moonhound with a glowing mane when grown), the `beast` (a werewolf in every move: cling with a glowing weak spot, bound, pounce, land, swipe, howl at the moon, rage), `missiles` (torch), `hazards` (torchfire, the landing shadow, the claw swipe), `powers` (Wolfsbane's badge), `lights` and `react(e, k)`; its `VOICES` (borrowed tones, plus `moon.full` and `bane.active`), `EVENT_VOICE` (event to `[kind, act]`, each played once; the hounds' call is quiet), `LOSE_WORDS` and `LOSE_SOUNDS`. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-village-world.js` | The Village's world: the night sky and the moon that climbs and reddens with `round.twist.moon` (`sky`, drawn every frame under the still layers), the crooked timber-framed houses with a window for every shutter ghoul, the church and spire, the gallows, the green's far cottages, well and arena walls, the Crooked Inn (hearths, barrels, bar, lanterns, the moon in its windows), cobbles, planks and turf (`ground`), awnings, rooftops, balconies, tables, carts and thatch (`shelf`), and `moving` (curtains that twitch as you pass, fire, moonlight falling in), `front` (the full-moon wash, Wolfsbane's petals, the Beast's rage) and `lights` |
|
||||
| `public/activities/ghoul-mine-world.js` | The Deep Seam Mine's world (no imports; `mineWorld(d)` takes ghoul-draw.js's helpers): the rock wall with its strata and facets, the timber that holds it up (props and cap beams, scaffolds and galleries as `shelf`), rails and sleepers on the floor (`ground`), oil lamps on hooks with their flames and warm halos (`moving`) and their holes in the dark (`lights`, none in a blackout), the shaft's lining, walers, guide rails and headframe with the cage lift drawn on its cable over a winch wheel with a counterweight (`cage`, and its front bars in `front`), the tunnels' low roof, pipes, stalled pump, drips and knee-deep water with a lit surface and Planny's wake (`front`), the collapse's broken props, cracks, rubble heaps and buried cart, the seam's glittering ore vein, stalactites and galleries, and the `rock` hazard in its three states; layouts are worked out once per room from the room alone and kept. Scene tool: `prototypes/ghoul-rush-tools/scene-mine-world.mjs` |
|
||||
| `public/activities/ghoul-village-wolf.js` | The Village's werewolf, one skeleton for the Beast and a turned villager: poses (`POSES`: stand, rear, swipe, howl, crouch, leap, land, rest, cling, shy, down, sleep), `mixPose` to blend them, and `wolfKit(d).figure` to draw one |
|
||||
| `public/activities/ghoul-mine.js` | Ghoul Rush's Deep Seam Mine stage pack, its rules (no imports; draws no random number): uses `tick`, `harmless`, `platform`, `solid`, `kill`, `weak` and a boss's blackout (`round.blackout`). The rockfall (`tick`; a room field `rocks` in ms; the `rock` hazard in states `warn`, `fall`, `rubble`, events `rockWarn`, `rockFall`, `rockLand`; the Hard Hat's `rockBounce`), the noise you make (`round.twist` = `{ next, quiet, noise, reach, wade }`, `wade` splashes), the knocker imp (touch steals light, not a life: `you.dimMs` and `you.dimBy`, `impSteal`, `impDrop`; the Hard Hat stops it), the canary ghost (`canaryScream`: three rocks), the dead miner (buried in the wall, `minerDig`, `pickWind`, `pickSwing` with a `pick` hazard, cause `pickaxe`), the blind crawler (`blindLost`, `blindHear`), the cage lift (a spawn row `["cage", x, lowest y, highest y]`, a `platform` kind that is not solid and never hurts), Dynamite placed in each room (its rules, the `stick` and `blast` hazards, `dynThrow` and `dynBlast`, moved to `ghoul-arms.js`) and the Tommyknocker (`tommyKnock`, `sweepWind`, `tommySweep` with a `hammer` hazard, `tommyDark`, `tommySink`, `tommyKnockDark`, `tommyBurst`, `tommyRage`; dazed double damage through `weak`) |
|
||||
| `public/activities/ghoul-mine-draw.js` | The Mine's art (the rooms in `ghoul-mine-world.js`, the Tommyknocker in `ghoul-mine-tommy.js`): `LOOKS` (`custom: true`, `pack: "mine"`, always dark), `mineArt(d)` returning `backdrop` (rock, strata, timber props, oil lamps), `ground` (rails), `shelf` (timber landings), `front` (the water along the floor), `dim` (the blackout), `monsters` (imp, canary, miner, blind crawler, cage), the `tommy` boss, `hazards` (rock, stick, blast, pick, hammer), `powers` (Hard Hat, Dynamite), `lights` and `react`; its `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS` and `LOSE_SOUNDS`. Its header lists every field the art reads off the rules; `ghoul-draw.js` shrinks Planny's glow and drops his cone while `you.dimMs` is over 0 |
|
||||
| `public/activities/ghoul-mine-tommy.js` | The Tommyknocker's figure for `ghoul-mine-draw.js`: `tommyKit(d)` (no imports, `ghoul-draw.js`'s helpers handed in) returns `figure(ctx, v, b)`, a miner-giant half grown into the seam (stone shoulder with crystals, lantern on his helmet, a door-sized hammer) drawn by act: leaning on the hammer, the overhead knocks, the drawn-back sweep, rest, sinking, bursting out dazed with stars, raged cracks, hurt flash. |
|
||||
| `public/activities/ghoul-cart.js` | Ghoul Rush's Runaway Cart, the Mine's ride room, its rules (no imports; draws no random number): the first room where a pack takes Planny's movement over. It adds the pack fields `ride` (a list of `(round, ms, k) => true` hooks run each slice before the walking rules; one that returns true has moved him) and `place` (a list of `(round, k)` hooks run whenever he is put down in a room: a room set up, a respawn), uses `target` (the crates), and `round.camLead` (units the camera leads further). The cart (`round.cart`, null elsewhere) rides the room's `ride.track` polylines (slope speed, lean and brake, jump, air steering, ramp launch, landing on the line under it, derail into the chasm), ducks under `ride.beams`, wrecks on `rubble` and unbroken `crates` (two bolts break one), is chased by the boulder, passes `checks` (a life lost puts it back at the last) and halts at `stop` where the door opens; a ledge imp (`ledgeimp`) leaps into it and steals light, a canary's scream drops a slide of rubble on the track ahead. Exports `flight`, `trackY`, `linesAt` and `linesOf` for the unit suite. Events `cartJump`, `cartLand`, `cartLaunch`, `cartBrake`, `cartDuck`, `crateHit`, `crateBreak`, `cartCrash`, `boulderNear`, `checkpoint`, `cartStop`, `ledgeLeap`, `slideWarn`, `slideFall`; causes `derail`, `beam`, `crash`, `boulder` |
|
||||
| `public/activities/ghoul-cart-draw.js` | The Runaway Cart's art: `LOOKS` (`custom: true`, `pack: "cart"`, always dark), `cartArt(d)` returning `backdrop`, `ground`, `moving` (every frame: the cave in cached parallax tiles over a chasm, the trestled track, ledge pillars, signal posts, rubble and the buffer stop in cached chunks, hanging lamps, signal lamps, crates, a slide's dust and pour; the cart too once it has stopped, so Planny walks out past it), `front` (the cart over Planny, the beams, the boulder, flying splinters, speed streaks, the foreground rock), `lights` (headlamp, hanging and far lamps, signals, beams), `monsters` (the ledge imp) and `react`; its `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS` and `LOSE_SOUNDS`. It keeps its own offscreen layer cache (keyed by scale), draws no random numbers (a hash) and leaves short-lived bits in the view's `fx` (`cartBits`, `cartPours`, `cartLand`, `cartStop`). Its header lists every field the art reads off the rules |
|
||||
| `public/activities/ghoul-sfx-mine.js` | The Mine's own sounds as data (no imports): `MINE_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-bog.js` | Ghoul Rush's Gallows Bog stage pack, its rules (no imports; a pack `ghoul.js` plugs in through `PACKS`, handed the kit `k`): the lurker, leech swarm, will-o'-wisp and bog body (`MONSTERS`, with `walkers`/`zombies` sets), `act`, `solid`, `swoops`, `unseen`, `move`, `kill`, `horde`, `tick` (the wisp's lure), `bosses`/`boss`, `weak`, `cause` and `hazards`, and Old Mother Bog (`BOSSES`). Its header notes the movers, the lure and the boss fight land in a later phase: this file stands the pack up so the stage's rooms can be walked. The stage's second twist lives in the engine, not here: a room field `mud` (frozen `[x0, x1]` spans), `mudAt` in `ghoul.js`, `you.mud` and `you.mudMs` (the run sags from `WATER_SPEED` toward `MUD_SPEED_MIN` and a jump toward `MUD_JUMP_MIN` over `MUD_MS`; a shelf, the air and Stilt Boots (`round.effects.boots`) let go of it) |
|
||||
| `public/activities/ghoul-bog-draw.js` | The Gallows Bog's drawing: `LOOKS` for its rooms (`outdoor: true`, `pack: "bog"`) and `bogArt(d)`, handed `ghoul-draw.js`'s helpers, returning the night swamp rooms (boardwalk planks over black water, moss veils, fireflies, the hag's lit stilt house and her open-water arena), `monsters` (a lurker's eyes, a leech swarm, a will-o'-wisp, a bog body), `bosses` (Old Mother Bog and her cauldron), `hazards` (the mud wave, the muck patches), the Stilt Boots' and Harpoon's badges and the events' looks and sounds; its `VOICES` are borrowed house tones until the sound page's vote, `LOSE_WORDS` and `LOSE_SOUNDS` already named |
|
||||
| `public/activities/ghoul-bogboat.js` | The Bog Runner (Gallows Bog's bonus round) as a pack (`BOGBOAT`), modeled on the Midnight Hearse for its lanes and the Torch Mob for its pursuit meter: pack fields `ride`, `place` and `target`; state in `round.runner` (`id: "bogboat"`); a flat channel of two lanes (open water and the mud flats) switched at banks, with sunken snags and cypress knees to jump, moss veils and low limbs to duck, the hag's charms and gas pockets to shoot, and the wake (a leech swarm `gap` units behind that closes on slow or stalled riding and catches you at `WAKE_CATCH`). Its checkpoints and grade (3 to 9 dice) run through the Cart's bonus machinery. Adds no monster, boss or hazard kind and draws no random number; every event starts with `bogboat` and every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-bogboat-draw.js` | The Bog Runner's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK, SHOOT and SWITCH glyphs for the ride's lanes) and `bogboatArt(d)` (pale moon, drowned cypresses, mist, black channel and mud flats by `moving`, the bow, the signs and the wake meter by `front`); no random numbers, everything from a hash |
|
||||
| `public/activities/ghoul-sfx-bog.js` | Gallows Bog's own sounds as data (no imports): `BOG_SFX` with `tones` (a `ghoul<Kind><Act>` tone for each act of the lurker, leech, wisp, bog body and Old Mother Bog) and an empty `music` until the music vote is wired in (the rooms play borrowed tracks through `ROOM_MUSIC`); the tones are first drafts (option 1 of each act) until the sound vote; merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-sfx-bogboat.js` | The Bog Runner's own sounds as data (no imports): `BOGBOAT_SFX` with `tones` (`ghoulBogboat<Act>`) and the ride's `music` track; first drafts until the vote; merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-carnival.js` | Ghoul Rush's Midnight Carnival stage pack, its rules (no imports; draws no random number): uses `tick` (the ring of samples Mirror You reads and its bolts in `round.twist`), `shot` (Cotton Candy's slow, a marionette's string at the top of its body), `target` (a bolt crossing a marionette's string or one of the puppet's three), `guard` (the Ringmaster is open only with the puppet down), `swoops` (a balloon, a circus hound's leap), `solid`, `kill` and `fourLegged`. Grinner and its acid balloons, marionette (drops when you pass under), Mirror You (copies you 500 ms late, mirrored, its bolts cancel yours), strongman (barbells), circus hound, and the Ringmaster (a gantry over the ring that follows its puppet at a lag, the puppet stalking you and working to a fixed script of leap, stomp, whip and charge, three strings from the gantry to its head and hands that move with it, open 4 s when they are cut, rage with hounds from the cages); `CARNIVAL_ROOMS` lists the stage's rooms, with a place before the Big Top for the dark ride. The room field `belts` and Planny's `you.belt` (the funhouse's conveyor floors) are run by `ghoul.js`. |
|
||||
| `public/activities/ghoul-carnival-draw.js` | The Carnival's art: `LOOKS` (`custom: true`, `pack: "carnival"`), `carnivalArt(d)` returning the world's hooks (from `ghoul-carnival-world.js`) plus `monsters`, the `ringmaster` boss (gantry, puppet in each pose, strings, whip), `missiles` (barbell), `hazards` (foot, whip, charge), `waves` (the puppet's), `powers` (Cotton Candy), `front` (Mirror You's bolts, Cotton Candy's glow), `lights` and `react`, and `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`. Its header lists what the art reads off the rules. |
|
||||
| `public/activities/ghoul-carnival-world.js` | The Carnival's world (no imports; `carnivalWorld(d)` takes ghoul-draw.js's helpers): the night sky with a Ferris wheel (`sky`), tents, booths and swagged bulbs on the Midway, the Hall of Mirrors' gilded panels and glints, the Funhouse's crooked walls, spiral discs and clown-mouth door, the Big Top's striped canvas, ring curb, crowd, trapeze boards, gantry rail and cages (open once the Ringmaster rages), and the belts' chevrons (`moving`). |
|
||||
| `public/activities/ghoul-sfx-carnival.js` | The Carnival's own sounds as data (no imports): `CARNIVAL_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-ride.js` | The Carnival's dark ride (a bonus round) as a pack (`RIDE`), the rules ported from `prototypes/ghoul-rush-ride/gallery.html`. Pack fields `ride` (returns true, so Planny never walks; steps the ride in 16 ms steps), `place` (makes `round.gallery`, the ride's state) and a new `pointer` (the mouse, handed on by `ghoul.js`'s `pointer(type, x, y)`); the entities (`K`: pop, lant, axe, chand, door, hand, head, eyes, boss, inno, mir, web, mini), hit tests with aim assist, the duck zone, hearts through `kit.lose`, the grade (5 to 9 dice, `perf.dice`). Events `ride<Name>` (`SOUNDS`), causes `CAUSES`. Its own seeded random stream; draws no `Math.random` |
|
||||
| `public/activities/ghoul-ride-scenes.js` | The dark ride's scene table as data (12 rooms, lengths, speeds, spawn rows in author coordinates), no imports |
|
||||
| `public/activities/ghoul-ride-core.js` | The ride's shared basics: the 96 by 54 field's constants, math helpers, the bound state `G` (a live import), `rnd`/`rand` (seeded) and `vrand` (visual) |
|
||||
| `public/activities/ghoul-ride-draw.js` | The ride's art entry (`rideArt(d, die)`: `field(ctx, v)` draws the whole field by phase, `tick` the cascade's sounds); `ghoul-draw.js` hands over to it when `round.gallery` is set. Parts: `ghoul-ride-gfx.js` (canvas helpers), `ghoul-ride-draw-kinds.js` (animatronics, mini-bosses, the Barker), `ghoul-ride-draw-sets.js` (the 12 sets, far walls, aisle, near layer), `ghoul-ride-draw-hud.js` (car and Planny, HUD, duck strip, reticle, title, end cascade) |
|
||||
| `public/activities/ghoul-ride-gfx.js` | The ride's drawing helpers: the bound 2D context and the short fill, stroke and shape calls the ride's art is written in |
|
||||
| `public/activities/ghoul-ride-draw-kinds.js` | The ride's drawn things: every figure, beast, lantern, blade, door, hand, head, mirror, web and boss, a port of the prototype's draw code (`prototypes/ghoul-rush-ride/gallery.html`) |
|
||||
| `public/activities/ghoul-ride-draw-sets.js` | The ride's rooms drawn: each room's far wall, set pieces front and back, aisle and the near pillars, a port of the prototype's world draw |
|
||||
| `public/activities/ghoul-ride-draw-hud.js` | The ride's car and the screen around it: Planny in his car, blood and sparks, the lens, the hearts, the progress bar, the room plaque, the aim, the title and the cleared card |
|
||||
| `public/activities/ghoul-ride-voices.js` | The ride's `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `react` (every `ride<Name>` event plays tone `ghoulRide<Name>`) |
|
||||
| `public/activities/ghoul-sfx-ride.js` | The ride's synthesized sounds as `tones` (`ghoulRide<Kind>`) and its music `ghoulRideDrone` (`RIDE_SFX`, merged by `ghoul-sfx.js`) |
|
||||
| `public/activities/ghoul-frozen.js` | Ghoul Rush's Frozen Lake stage pack, its rules (imports only `burrow` from the Graveyard; draws no random number): uses `tick` (thin ice, the blizzard, the Widow's spikes, web and barrels), `place`, `unseen`, `solid`, `kill`, `target`, `land`, `weak`, `cause`, `guard`, `swoops` and `slides`. The generic slippery-ice rule (`iceRun`, room field `ice`) and thin-ice rule (`stepThin`, room field `thin`, `round.thin`), the under-ice hand, snow shade (unseen, footprints), Frozen Ghoul (slides, shatters into shards), Ice Wraith (its dive freezes), Hot Cocoa, the Frost Widow (veil, barrels, weak spot, blizzard, spikes, web, rage) and `FROZEN_ROOMS`. Every constant is exported and documented in its header |
|
||||
| `public/activities/ghoul-frozen-draw.js` | The Frozen Lake's art: `LOOKS` (`custom: true`), `frozenArt(d)` returning the world's hooks (from `ghoul-frozen-world.js`) plus `monsters`, the Frost Widow boss, `hazards` (shards, spikes, webs, barrels, the flare and its fire), `powers` (Hot Cocoa), `front`, `lights` and `react`, and `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-frozen-world.js` | The Frozen Lake's world (no imports; `frozenWorld(d)` takes ghoul-draw.js's helpers): the night sky with moon, aurora and far mountains (`sky`), the huts, the Lodge's fallen roof, the Black Ice and the Widow's web (`backdrop`, `ground` with the ice's gloss, `shelf`), and `moving` (open water in the holes, thin ice drawn from `round.thin`, never from `spec.ground`, the faces under the Black Ice, falling snow) and `lights`. Draws no random number |
|
||||
| `public/activities/ghoul-flare.js` | The Road Flare's rules (`useFlare`, `stepFlareFly`, `stepRoadFire`; no imports, handed the helpers by `ghoul-arms.js`): a lob that lands as a patch of fire, burns monsters on a tick, melts a Frozen Ghoul at once, shows a shade and melts the Widow's veil; never hurts Planny |
|
||||
| `public/activities/ghoul-sled.js` | The Coffin Sled (the Frozen Lake's bonus round) as a pack (`SLED`), modeled on the Runaway Cart (`ghoul-cart.js`): pack fields `ride`, `place` and `target`; the track of ice lines with cracks, headstones, drifts, low branches, hands, icicles and popping ghouls, checkpoints, hearts through the Cart's bonus machinery and the grade (3 to 9 dice). Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-hearse.js` | The Midnight Hearse (the Graveyard's bonus round) as a pack (`HEARSE`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in `round.runner` (`id: "hearse"`); a flat road of two lanes (road and verge) switched with LEFT/RIGHT inside the lane gates, open graves, headstones and crosses to jump, low branches and the lychgate arch to duck, hands and crows to shoot, closed stretches to go round, lanterns that keep the lamp lit (an unbroken lamp is the grade's `steady` die), and coffins thrown out by each hit with a ghoul to shoot in each. Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-hearse-draw.js` | The Midnight Hearse's art: `LOOKS` (`pack: "hearse"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK, SHOOT and SWITCH glyphs for the hearse's lane) and `hearseArt(d)` (sky, hills, cemetery, road, verge, things and the hearse by `moving`; the cab door, lows, fog, glyphs and lamp gauge by `front`; `dim` when the lamp is out); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-sled-draw.js` | The Coffin Sled's art: `LOOKS`, `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `sledArt(d)` (the sky, hills, ice and things by `moving`, the lid, the lows and foreground flakes by `front`); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-gurney.js` | Code Blue (Blackmoor Sanatorium's bonus round) as a pack (`GURNEY`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; the gurney along `ride.track` (shafts are the gaps), wheelchairs that roll, IV stands, lamps and doors overhead, orderlies in doorways, the lights-out waves (`lightsAt`), the surge lamps and the heartbeat monitor's beat; its state is `round.runner` (`pack: "codeblue"`, put back if another pack's `place` clears the shared slot); draws no random number; imports the cart's track helpers |
|
||||
| `public/activities/ghoul-gurney-draw.js` | Code Blue's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` and `gurneyArt(d)` (the corridors, shafts and floors by `moving`; the gurney, lows, glyphs, countdown and monitor by `front`; `dim` and `lights` for the blackouts); no imports but the Sled's glyph colors |
|
||||
| `public/activities/ghoul-mower.js` | The Gardener's Revenge (the Grounds' bonus round) as a pack (`MOWER`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `mower`); a flat lawn run on a ride-on mower with gaps (ponds, ha-ha ditches), junk, hedge arches, clothes lines of gloves and snapping topiary beasts, and the twist: holding fire lowers the blades, which cut tall grass, weeds and thorn hedges in the zone ahead (the blades heat and jam, so they are pulsed); the lawn-cut share is the grade's steady die; hearts through the Cart's bonus machinery; no random numbers |
|
||||
| `public/activities/ghoul-mower-draw.js` | The Gardener's Revenge's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK and CUT glyphs) and `mowerArt(d)` (sky, manor, topiary and railings by `moving`, the lawn with its ponds and ditches, the mower with its blades and heat gauge, the lows and the lawn gauge by `front`); no random numbers |
|
||||
| `public/activities/ghoul-sfx-frozen.js` | The Frozen Lake's own sounds as data (no imports): `FROZEN_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-sfx-mower.js` | The Gardener's Revenge's own sounds as data (no imports): `MOWER_SFX` with first-draft `tones` (`ghoulMower<Act>`, each under 1.2 s) and the `ghoulMowerRide` track (sound and music picks still pending); merged by `ghoul-sfx.js` via `STAGE_SFX`, the track set in `ROOM_MUSIC` |
|
||||
| `public/activities/ghoul-pew.js` | Holy Roller (the Chapel's bonus round) as a pack (`PEW`): a Subway-Surfers style endless-runner seen from behind, pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `pew`). `you.x` is only the distance run; the pew's own `lane` (a float to `laneTo`), `h`, `slide`, `combo` and `magnet` live in `round.runner`. Left/right presses change lane (a wall bump at the edge), up jumps, down slides (fast-fall in the air), fire shoots down the lane; a speed ramp by distance (`speedAt`); `KINDS` (switch: pillar, confessional, pewx; jump: kneeler, stand, cracks, hatch; slide: censer, banner, beam; shoot: garg with 2 hp, bell rope), wax souls and halos, the combo and the steady die (souls share); a hit shoves the pew to a calm lane. Pure rules, no random numbers |
|
||||
| `public/activities/ghoul-pew-course.js` | Holy Roller's seeded course (no imports): written in seconds and laid by the speed ramp (`xAt`, `speedAt`, `V0`, `ACC`), `COURSE` { items [x, lane, kind, len], souls, checks, finish } |
|
||||
| `public/activities/ghoul-pew-draw.js` | Holy Roller's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `pewArt(d)`, whose `field(ctx, view)` draws the WHOLE field (ghoul-draw.js has a `round.runner.id === "pew"` branch like the dark ride's `round.gallery` one, then adds the hearts, flash, banner, cards and HUD pills) plus the progress track, souls and combo strip, and the events' effects |
|
||||
| `public/activities/ghoul-pew-world.js` | Holy Roller's pseudo-3D nave: `worldArt(d)` with `paint(ctx, view)`; the projection `(lane, depth, height)` to the screen with scale = near / (near + depth) toward a vanishing point, far-to-near cells with fog as alpha, stained glass, pillars and ribs, pews, candlelight and god rays pulsing on the organ's beat (`pulse`, `BPM`), every thing's art and telegraph glyph, the souls, bolts, the pew and hero from behind, speed streaks and vignette. A reusable pattern for "run into the screen" rides. No random numbers (hashes) |
|
||||
| `public/activities/ghoul-sfx-pew.js` | Holy Roller's own sounds as data (no imports): `PEW_SFX` with 17 tones (lane, bump, jump, land, slide, dive, soul, halo, crash, check, finish, speed swell, gargoyle and bell) and the driving `ghoulPewDirge` track at 132 BPM (first drafts, merged by `ghoul-sfx.js`) |
|
||||
| `public/activities/ghoul-sfx-hearse.js` | The Midnight Hearse's own sounds as data (no imports): `HEARSE_SFX` with 19 first-draft `ghoulHearse<Act>` tones (none over 1.2 s) and the `ghoulHearseRide` track (a funeral march at a gallop, built from three four-bar parts); merged by `ghoul-sfx.js`, named in `ROOM_MUSIC`. Sounds and music still to be picked by ear |
|
||||
| `public/activities/ghoul-sfx-sled.js` | The Coffin Sled's own sounds as data (no imports): `SLED_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` (the room plays the Graveyard's `ghoulGraves`) |
|
||||
| `public/activities/ghoul-banister.js` | The Grand Banister (the Manor's bonus round) as a pack (`BANISTER`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `banister`); YOU slide down a grand staircase's banister along `ride.track` (the first `rails` lines are the handrail, the breaks between them gaps to jump; the rest are brass under-rails beside it, the split track: a jump with DOWN held dives onto one, a jump off its end lands back on the handrail), vases and candlesticks to jump, hanging portrait frames to duck, chandeliers on a pendulum (`swingAt`: a wall from the bob to the roof, lethal to a ducking rider while the bob is mid-swing, so you brake or lean (LEFT/RIGHT) to time them or take the under-rail), ghostly butlers that lunge (jump or two bolts) and cobwebs to shoot. Adds no monster, boss or hazard kind; no random numbers. Its header documents the room fields |
|
||||
| `public/activities/ghoul-banister-draw.js` | The Grand Banister's art: `LOOKS` (`pack: "banister"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK and DIVE glyphs) and `banisterArt(d)` (damask wall, moonlit windows, a zig-zag of staircase flights, portraits whose eyes follow YOU, the rails, props, butlers and webs by `moving`; the hanging frames, the chandeliers with the arc they swing through, sparks and glyphs by `front`); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-sfx-banister.js` | The Grand Banister's own sounds as data (no imports): `BANISTER_SFX` with 14 first-draft `ghoulBan<Act>` tones (each under 1.2 s) and the `ghoulBanister` track (a harpsichord waltz at a gallop, built from three four-bar parts); merged by `ghoul-sfx.js` via `STAGE_SFX`, named in `ROOM_MUSIC` (sound and music picks still pending) |
|
||||
| `public/activities/ghoul-wagon.js` | The Torch Mob (Hollow End Village's bonus round) as a pack (`WAGON`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; a hay wagon along `ride.track` (ditches and the collapsed bridge are the gaps, a rising line end a ramp), barrels and crates, washing lines and inn signs, villagers who hurl pitchforks (duck) and torches (jump), spooked horses, and the pursuit meter (`gap`: the mob runs at `MOB_V`, DOWN is a duck and the brake, a hit, a burning hay load and the surge close it, a shot torch or fork opens it, inside `PANIC_ON` the horses bolt, at `CATCH_GAP` it is a heart); its state is `round.runner` (`id: "wagon"`); draws no random number; imports the cart's track helpers |
|
||||
| `public/activities/ghoul-wagon-draw.js` | The Torch Mob's art: `LOOKS` (`pack: "wagon"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` and `wagonArt(d)` (the sky, rooftops, street, cobbled road, ditches, the bridge and river, the things, the mob and the wagon by `moving`; the lows, throws in the air, the hay fire, glyphs and the mob's meter by `front`); no random numbers; imports the Sled's glyph colors and the rules' constants |
|
||||
| `public/activities/ghoul-sfx-wagon.js` | The Torch Mob's own sounds as data (no imports): `WAGON_SFX` with 18 first-sketch `ghoulWagon<Act>` tones and the `ghoulWagonRide` track (a D minor gallop built from three 4-bar patterns); merged by `ghoul-sfx.js`, the room's track named in `ROOM_MUSIC` (`wagon`) |
|
||||
| `public/activities/ghoul-story.js` | Ghoul Rush's intro story: the pages' text as data and the rules (lockout, reveal, skip) as plain functions over a round; drawn by `ghoul-story-draw.js`, sounded by `ghoul-sfx-story.js`, the lore bible in `prototypes/Ghoul-Rush-TODO.md` |
|
||||
| `public/activities/ghoul-story-draw.js` | The intro story's drawing (`storyArt(d)`): eight animated scenes in canvas shapes (the road, the house on the hill, the hunger, the long arms, the farthest rooms, why YOU, no way back, the door to The Long Hall) with the heading, the lines typing out, the page dots, the always-visible skip hint with its hold bar and the pulsing continue hint; drawn over the field while `round.phase === "story"`; reuses the intro card's helpers (`poly`, `dot`, `stroke`, `faint`, `flame`, `titleLayout`, `dropAt`); no gradients |
|
||||
| `public/activities/ghoul-story-draw.js` | The intro story's drawing: `ghoulStoryDraw(d)` scenes for the pages in `ghoul-story.js` |
|
||||
| `public/activities/ghoul-sfx-story.js` | The intro story's own sounds as data (no imports): `STORY_SFX` tones for the pages' `cues` (wind, a bell, a heartbeat, a door creak, knocks, a whisper, the flashlight click, the page turn) and the `hums` drone under the whole story; merged by `ghoul-sfx.js` |
|
||||
| `public/activities/ghoul-sfx-gurney.js` | Code Blue's own sounds as data (no imports): `GURNEY_SFX`, 18 first-pick `ghoulBlue<Act>` tones and the track `ghoulBlueRide`; merged by `ghoul-sfx.js` (the room plays it via `ROOM_MUSIC.codeblue`) |
|
||||
| `public/activities/ghoul-tray.js` | The Servants' Back Stairs (the East Wing's bonus round) as a pack (`TRAY`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; the track of shelves and stair flights with gaps, rolling pots and cutlery, hams and pans, cooks who fling dishes, the courses (silver domes and flying plates, seven is the grade's acts die), the cherries, grease stretches, checkpoints and the grade (3 to 9 dice). State is `round.runner` (id `tray`), the shared slot for a rolling bonus ride. Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-tray-draw.js` | The Servants' Back Stairs' art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, the telegraph glyphs (`telegraphMarks`, `telegraphs`: JUMP, DUCK, SHOOT) and `trayArt(d)` (the kitchen, shelves and stairs, things and cooks by `moving`; the tray, hams and pans, flour and glyphs by `front`); no random numbers |
|
||||
| `public/activities/ghoul-sfx-tray.js` | The Servants' Back Stairs' sounds and music as data (no imports): `TRAY_SFX` with 13 first-draft tones and the `ghoulTrayRide` track; merged by `ghoul-sfx.js` |
|
||||
| `public/activities/ghoul-sfx-chapel.js` | The Chapel's own sounds as data (no imports): `CHAPEL_SFX`, its `tones` (the 35 picked `ghoul<Kind><Act>` sounds of the gargoyles, choir ghosts, monks, bell bats, the Choirmaster, the bell and Holy Water's splash) and `music` (`ghoulNave`, `ghoulTower`, `ghoulLoft`, `ghoulChoir`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-sfx-sanatorium.js` | Blackmoor Sanatorium's own sounds as data (no imports): `SANATORIUM_SFX`, its `tones` (the 38 picked `ghoul<Kind><Act>` sounds of the orderlies, gurneys, flickers, specimen bloaters, the Night Matron, the lamps, Smelling Salts and the Bone Saw) and `music` (`ghoulAdmissions`, `ghoulBaths`, `ghoulTheater`, `ghoulWard`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-sfx-village.js` | Hollow End Village's own sounds as data (no imports): `VILLAGE_SFX`, its `tones` (the 42 picked `ghoul<Kind><Act>` sounds of the torch mob, hanged men, shutter ghouls, moonhounds, the Beast, the full moon and Wolfsbane) and `music` (`ghoulStreet`, `ghoulInn`, `ghoulSquare`, `ghoulGreen`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js` | Ghoul Rush's Graveyard stage pack, its rules (no imports: `ghoul.js` hands each rule a kit `k` of its own helpers). A stage pack is plain data and functions that `ghoul.js` merges into its own tables (`PACKS`): `monsters` (with `perch`: its spawn names its height, `flies`: a horde one comes in high), `walkers`/`zombies`/`stackers`/`climbers` (joining the sets of those names), `act` (start), `solid`, `move`, `kill`, `horde` (fields a horde one comes with), `bosses`, `boss` (one slice of its fight), `guard` (true while shots and stomps glance off, a `bossBlock` event) and `hazards` (by kind, one slice of a box on the floor that hurts while `live`; kept in `round.hazards`). Three more fields a stage may add (the Grounds does): `cut` (kinds the Hedge shears kill outright), `weak` (by boss kind, `(boss, shot) => damage multiplier` for a weak spot; `bossHit` then carries `how: "weak"` and `weak: true`) and `cause` (what a boss's touch is called when it costs a life). The Chapel adds more: `tick(round, ms, k)` (a stage-wide twist run first in every slice; it may set `round.stunMs`, which freezes you and every monster, boss, hazard and missile while bolts in flight still fly, and keeps its state in `round.twist`), `stone` (by kind, true while shots glance off and a stomp does nothing; `glance` event), `shot(round, m, s, k, random)` (the damage multiplier of a bolt that hit `m`, free to splash), `target(round, s, k)` (true when a bolt struck something of the pack's that is no monster, such as an organ pipe) and, on a monster, `hasteMs` and `haste` (its time runs faster while `hasteMs` is over 0). On the drawing side a look may be `custom: true` with a `pack` id (the pack's art then draws the whole wall, floor and shelves) and the art may return `decor` (by the look's `decor` name). On the drawing side a stage's art may also return `react(e, k)` (its own events; `ghoul-draw.js`'s `react` falls through to `ART.react`, which returns true when it handled `e`), `ground` and `shelf` (the floor pieces and shelves of an outdoor look), `waves` and `powers`; a boss event must carry `kind` or its voice never plays. The Graveyard's: grasping hands (`HANDS_*`: lurk unseen, rise, grab, sink, creep under level ground after you), the mourner (wails every `WAIL_MS`, slowing you to `SLOW_SHARE` speed for `SLOW_MS` within `WAIL_REACH`; `round.you.slowMs`), the grave robber (digs in within `ROBBER_DIG`, comes up `ROBBER_BEHIND` behind you), the rotter (a zombie whose body-shot death leaves its `legs` walking), the carrion crow (perches, dives at your chest, climbs, dives again), and Mother Mourning (`angel`: weeps `ANGEL_WEEP_MS` as stone flinging headstones, turns `ANGEL_TURN_MS`, watches `ANGEL_WATCH_MS` when only she can be hurt and any move drops a `fist` hazard after `FIST_WARN_MS`; at `ANGEL_RAGE` her wings spread, the weep shorter, the watch longer, a shockwave each way as each weep begins) |
|
||||
| `public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js` | The Graveyard's drawing: `LOOKS` for its four rooms (`outdoor: true`, so `ghoul-draw.js` draws `backdrop` instead of walls: the night sky, stars, the moon, hills with dead trees, iron fences, mausoleums, fog and headstones) and `graveyardArt(d)`, handed `ghoul-draw.js`'s helpers, returning the open `grave` and `openGrave` a rotter climbs out of, `monsters`, `bosses` (Mother Mourning: hands over her face while she weeps, lowered with burning eyes while she watches, wings spread in a rage, cracks as she is worn down), `missiles` (a flung headstone), `hazards` (a stone fist: its shadow, then the fist) and `lights` |
|
||||
| `public/activities/ghoul-rush/stages/grounds/ghoul-grounds.js` | Ghoul Rush's Grounds stage pack, its rules (no imports; same shape as the Graveyard's, plus the pack fields `cut`, `weak` and `cause`): the topiary beast (`still` while you face it, `creep` when your back is turned; events `rustle` and `freeze`), the rootling (`trail`, `warn`, `up`, `sink`; events `rootWarn` and `rootUp`), the lantern moth (flocks of three, quicker in the dark), the mulch crawler (`pile`, `burst`, `crawl`; event `leaves`), the Hedge shears' `snip` event, and the Groundskeeper (`keeper`: a scythe sweep along the floor (or, now and then, a high `sweep` hazard you stay on the ground under), a lobbed lantern fire hazard, his lantern a `weak` spot only while open (`b.lit`), and at half hp a mower with `rev`, `charge` and `stall`) |
|
||||
| `public/activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js` | The Grounds' drawing: `LOOKS` for its four rooms (`outdoor: true`), `groundsArt(d)` returning `monsters`, `bosses`, `hazards` (the fire), `waves` (the scythe), `powers` (the shears), `lights`, `backdrop`, `ground`, `shelf` and `react(e, k)` for the Grounds' own events; its `VOICES` (each kind's tone per act, `keeper.weak` for a weak-spot hit instead of `keeper.hurt`, `shears.snip` for a cut instead of the dying cry), `LOSE_WORDS` and `LOSE_SOUNDS`, which `ghoul-draw.js` spreads into its own tables |
|
||||
| `public/activities/ghoul-rush/stages/chapel/ghoul-chapel.js` | Ghoul Rush's Chapel stage pack, its rules (no imports; same shape as the Grounds', plus the pack hooks `tick`, `stone`, `shot` and `target`, and a room field `toll`): the gargoyle (`perch` as stone, `wake`, `dive`, `return`; events `glance`, `gargoyleWake`, `gargoyleDive`, `gargoylePerch`), the choir ghost (sings, giving nearby monsters `hasteMs`), the censer monk (`smoke` hazard), the bell bat (`roost` until the toll), the bell toll (`tick`: `bellSwing`, `toll`, `tollEnd`, `round.stunMs`), Holy Water's splash (`shot`, event `holySplash`) and the Choirmaster (`choirmaster`: four pipes in `b.pipes` that bolts hit through `target`, a `guard` while any sounds, columns of `note` hazards with one gap, a rage that brings pipes back one by one) |
|
||||
| `public/activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js` | The Chapel's drawing: `LOOKS` for its four rooms (indoor but `custom: true` with `pack: "chapel"`, so `ghoul-draw.js` hands the walls, floor and shelves to `chapelArt(d)`'s `backdrop`, `ground` and `shelf`), `chapelArt(d)` returning those plus `decor` (the room's pews, belfry, organ or stalls), `monsters`, `bosses`, `hazards` (smoke, the bell, notes), `powers`, `lights` and `react(e, k)`; its `VOICES` (the bell has only `swing` and `toll`: the thaw after a toll is quiet on purpose), `LOSE_WORDS` and `LOSE_SOUNDS` |
|
||||
| `public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js` | Ghoul Rush's Blackmoor Sanatorium stage pack, its rules (no imports; same shape as the Chapel's, plus the pack fields `unseen`, `harmless`, `platform` and `land`, a room field `flicker`, `round.blackout`/`round.twist` for the lamps and the kit's `fling`): the orderly (`reach`, `hold`, a throw that costs no life, `you.heldMs`; events `orderlyReach`, `orderlyGrab`, `orderlyThrow`, `saltsBreak`), the gurney (`parked` as a floor you can stand on, `rattle`, `roll`, `rest`; `gurneyRattle`, `gurneyRoll`, `gurneyRest`), the flicker (`m.unseen`: bolts and touch go through it until a blackout, the Lantern's light or the Salts' glow; `flickerShow`), the specimen bloater (a `jar` missile with its own `cause` that `land`s as a `formaldehyde` hazard; `jarWind`, `jarBreak`), the lamps (`tick`: `flickerWarn`, `lightsOut`, `lightsOn`), the Salts and the Saw (`shot`) and the Night Matron (`matron`: `b.beam` cone, `b.heat`, `b.cabinets`, syringes, arms, rage; `syringeWind`, `syringes`, `armWarn`, `armReach`, `matronRage`) |
|
||||
| `public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js` | The Sanatorium's art: `LOOKS` (indoor but `custom: true` with `pack: "sanatorium"` and `noMoon`, so `sanatoriumArt(d)`'s `backdrop`, `ground` and `shelf` draw the tiled walls, windows, decor, floors, the ward's cabinets, the baths' tubs and each room's boards), `monsters` (orderly with its grab pose, gurney, flicker with its fade and afterimage, specimen bloater), the `matron` with her cone cut by the floor and the cabinets, `missiles` (jar, syringe), `hazards` (formaldehyde, arm with its crack of light), `powers` (Salts, Saw), `lights`, `react(e, k)` and two generic hooks `ghoul-draw.js` calls: `front(ctx, v)` (over Planny and before the dark: the ceiling lamps, the tubs' water, the orderly's fingers, the Matron's heat on him) and `dim(v)` (the dark layer's alpha, raised in a blackout and in a stutter); its `VOICES` (borrowed tones; `lights`, `salts` and `saw` are no monsters), `LOSE_WORDS` and `LOSE_SOUNDS` |
|
||||
| `public/activities/ghoul-rush/stages/village/ghoul-village.js` | Ghoul Rush's Hollow End Village stage pack, its rules (no imports; no new pack field: it uses `tick`, `shot`, `land`, `weak` (now handed `(boss, shot, round, k)`) and `solid`, and draws no random number): the moonrise (`tick`; `round.twist` = `{ moon, full, ms }`, events `fullMoon`, `villagerTurn`, `villagerWolf`, `houndGrow`), the torch mob villager (a group of three, `torchWind`, the `torch` missile that `land`s as a `torchfire` hazard, `torchLand`; turned into a leaping wolf-man at full moon), the hanged man (`hangedWarn`, `hangedDrop`, `hangedSnap`, `hangedHaul`), the shutter ghoul (`solid` only while out; `shutterRattle`, `shutterLunge`, `shutterPull`), the moonhound (the hellhound's leap, grown at full moon), Wolfsbane's double damage and shying (`baneShy`) and the Beast of Hollow End (`beastLeap`, `beastCling`, `beastPounce` with a `shadow` hazard, `beastLand`, `swipeWind`, `beastSwipe` with a `claw` hazard, `beastHowl`, `houndCall`, `beastMoon`) |
|
||||
| `public/activities/ghoul-rush/stages/village/ghoul-village-draw.js` | The Village's art: `LOOKS` (street, square and green outdoors, the inn a `custom` indoor look, all `pack: "village"`), `villageArt(d)` returning the world's hooks plus the monsters (the torch mob villager and the wolf-man it turns into over 800 ms, the hanged man on his rope, the shutter ghoul reaching out of a window, the moonhound with a glowing mane when grown), the `beast` (a werewolf in every move: cling with a glowing weak spot, bound, pounce, land, swipe, howl at the moon, rage), `missiles` (torch), `hazards` (torchfire, the landing shadow, the claw swipe), `powers` (Wolfsbane's badge), `lights` and `react(e, k)`; its `VOICES` (borrowed tones, plus `moon.full` and `bane.active`), `EVENT_VOICE` (event to `[kind, act]`, each played once; the hounds' call is quiet), `LOSE_WORDS` and `LOSE_SOUNDS`. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/stages/village/ghoul-village-world.js` | The Village's world: the night sky and the moon that climbs and reddens with `round.twist.moon` (`sky`, drawn every frame under the still layers), the crooked timber-framed houses with a window for every shutter ghoul, the church and spire, the gallows, the green's far cottages, well and arena walls, the Crooked Inn (hearths, barrels, bar, lanterns, the moon in its windows), cobbles, planks and turf (`ground`), awnings, rooftops, balconies, tables, carts and thatch (`shelf`), and `moving` (curtains that twitch as you pass, fire, moonlight falling in), `front` (the full-moon wash, Wolfsbane's petals, the Beast's rage) and `lights` |
|
||||
| `public/activities/ghoul-rush/stages/mine/ghoul-mine-world.js` | The Deep Seam Mine's world (no imports; `mineWorld(d)` takes ghoul-draw.js's helpers): the rock wall with its strata and facets, the timber that holds it up (props and cap beams, scaffolds and galleries as `shelf`), rails and sleepers on the floor (`ground`), oil lamps on hooks with their flames and warm halos (`moving`) and their holes in the dark (`lights`, none in a blackout), the shaft's lining, walers, guide rails and headframe with the cage lift drawn on its cable over a winch wheel with a counterweight (`cage`, and its front bars in `front`), the tunnels' low roof, pipes, stalled pump, drips and knee-deep water with a lit surface and Planny's wake (`front`), the collapse's broken props, cracks, rubble heaps and buried cart, the seam's glittering ore vein, stalactites and galleries, and the `rock` hazard in its three states; layouts are worked out once per room from the room alone and kept. Scene tool: `prototypes/ghoul-rush-tools/scene-mine-world.mjs` |
|
||||
| `public/activities/ghoul-rush/stages/village/ghoul-village-wolf.js` | The Village's werewolf, one skeleton for the Beast and a turned villager: poses (`POSES`: stand, rear, swipe, howl, crouch, leap, land, rest, cling, shy, down, sleep), `mixPose` to blend them, and `wolfKit(d).figure` to draw one |
|
||||
| `public/activities/ghoul-rush/stages/mine/ghoul-mine.js` | Ghoul Rush's Deep Seam Mine stage pack, its rules (no imports; draws no random number): uses `tick`, `harmless`, `platform`, `solid`, `kill`, `weak` and a boss's blackout (`round.blackout`). The rockfall (`tick`; a room field `rocks` in ms; the `rock` hazard in states `warn`, `fall`, `rubble`, events `rockWarn`, `rockFall`, `rockLand`; the Hard Hat's `rockBounce`), the noise you make (`round.twist` = `{ next, quiet, noise, reach, wade }`, `wade` splashes), the knocker imp (touch steals light, not a life: `you.dimMs` and `you.dimBy`, `impSteal`, `impDrop`; the Hard Hat stops it), the canary ghost (`canaryScream`: three rocks), the dead miner (buried in the wall, `minerDig`, `pickWind`, `pickSwing` with a `pick` hazard, cause `pickaxe`), the blind crawler (`blindLost`, `blindHear`), the cage lift (a spawn row `["cage", x, lowest y, highest y]`, a `platform` kind that is not solid and never hurts), Dynamite placed in each room (its rules, the `stick` and `blast` hazards, `dynThrow` and `dynBlast`, moved to `ghoul-arms.js`) and the Tommyknocker (`tommyKnock`, `sweepWind`, `tommySweep` with a `hammer` hazard, `tommyDark`, `tommySink`, `tommyKnockDark`, `tommyBurst`, `tommyRage`; dazed double damage through `weak`) |
|
||||
| `public/activities/ghoul-rush/stages/mine/ghoul-mine-draw.js` | The Mine's art (the rooms in `ghoul-mine-world.js`, the Tommyknocker in `ghoul-mine-tommy.js`): `LOOKS` (`custom: true`, `pack: "mine"`, always dark), `mineArt(d)` returning `backdrop` (rock, strata, timber props, oil lamps), `ground` (rails), `shelf` (timber landings), `front` (the water along the floor), `dim` (the blackout), `monsters` (imp, canary, miner, blind crawler, cage), the `tommy` boss, `hazards` (rock, stick, blast, pick, hammer), `powers` (Hard Hat, Dynamite), `lights` and `react`; its `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS` and `LOSE_SOUNDS`. Its header lists every field the art reads off the rules; `ghoul-draw.js` shrinks Planny's glow and drops his cone while `you.dimMs` is over 0 |
|
||||
| `public/activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js` | The Tommyknocker's figure for `ghoul-mine-draw.js`: `tommyKit(d)` (no imports, `ghoul-draw.js`'s helpers handed in) returns `figure(ctx, v, b)`, a miner-giant half grown into the seam (stone shoulder with crystals, lantern on his helmet, a door-sized hammer) drawn by act: leaning on the hammer, the overhead knocks, the drawn-back sweep, rest, sinking, bursting out dazed with stars, raged cracks, hurt flash. |
|
||||
| `public/activities/ghoul-rush/rides/cart/ghoul-cart.js` | Ghoul Rush's Runaway Cart, the Mine's ride room, its rules (no imports; draws no random number): the first room where a pack takes Planny's movement over. It adds the pack fields `ride` (a list of `(round, ms, k) => true` hooks run each slice before the walking rules; one that returns true has moved him) and `place` (a list of `(round, k)` hooks run whenever he is put down in a room: a room set up, a respawn), uses `target` (the crates), and `round.camLead` (units the camera leads further). The cart (`round.cart`, null elsewhere) rides the room's `ride.track` polylines (slope speed, lean and brake, jump, air steering, ramp launch, landing on the line under it, derail into the chasm), ducks under `ride.beams`, wrecks on `rubble` and unbroken `crates` (two bolts break one), is chased by the boulder, passes `checks` (a life lost puts it back at the last) and halts at `stop` where the door opens; a ledge imp (`ledgeimp`) leaps into it and steals light, a canary's scream drops a slide of rubble on the track ahead. Exports `flight`, `trackY`, `linesAt` and `linesOf` for the unit suite. Events `cartJump`, `cartLand`, `cartLaunch`, `cartBrake`, `cartDuck`, `crateHit`, `crateBreak`, `cartCrash`, `boulderNear`, `checkpoint`, `cartStop`, `ledgeLeap`, `slideWarn`, `slideFall`; causes `derail`, `beam`, `crash`, `boulder` |
|
||||
| `public/activities/ghoul-rush/rides/cart/ghoul-cart-draw.js` | The Runaway Cart's art: `LOOKS` (`custom: true`, `pack: "cart"`, always dark), `cartArt(d)` returning `backdrop`, `ground`, `moving` (every frame: the cave in cached parallax tiles over a chasm, the trestled track, ledge pillars, signal posts, rubble and the buffer stop in cached chunks, hanging lamps, signal lamps, crates, a slide's dust and pour; the cart too once it has stopped, so Planny walks out past it), `front` (the cart over Planny, the beams, the boulder, flying splinters, speed streaks, the foreground rock), `lights` (headlamp, hanging and far lamps, signals, beams), `monsters` (the ledge imp) and `react`; its `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS` and `LOSE_SOUNDS`. It keeps its own offscreen layer cache (keyed by scale), draws no random numbers (a hash) and leaves short-lived bits in the view's `fx` (`cartBits`, `cartPours`, `cartLand`, `cartStop`). Its header lists every field the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/stages/mine/ghoul-sfx-mine.js` | The Mine's own sounds as data (no imports): `MINE_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-rush/stages/bog/ghoul-bog.js` | Ghoul Rush's Gallows Bog stage pack, its rules (no imports; a pack `ghoul.js` plugs in through `PACKS`, handed the kit `k`): the lurker, leech swarm, will-o'-wisp and bog body (`MONSTERS`, with `walkers`/`zombies` sets), `act`, `solid`, `swoops`, `unseen`, `move`, `kill`, `horde`, `tick` (the wisp's lure), `bosses`/`boss`, `weak`, `cause` and `hazards`, and Old Mother Bog (`BOSSES`, hp 360, her fight in `moveMother` with `startMove` setting each move's wind-up act, wait and telegraph event: the wave opens, then a weighted `pickAttack` by phase (`phaseOf`, `WEIGHTS`; never one move three times running, `COOLDOWN` picks for the slow moves, a summon only under its cap, counted by `hagAdds` on adds marked `m.hag`). Full health: wave, spit, bog hands (`boghand` hazards: a ripple, then a hand), surge (a waist-deep charge past you), mud shell (`shellShot` in `target` chips it; broken she reels in `stagger` with the cauldron open, ignored she heals `SHELL_HEAL`) and dive (relocate); under three quarters the double wave, volley and leech brood join. Under half (after her first dive): stomp (a shadow, a leap, a slam and a wave each way), tide (a `tide` hazard over every plank after `TIDE_WARN_MS`; shelves are dry), drowning pull (drags `you.x` toward her on the planks, never off a plank's end) and call the drowned (bog bodies). Under a quarter: the wisp lantern (her wisps, gone for good once shot out) and combos (`toIdle`, `motherCombo`). `guard` is under water or shelled; `weak` is the open cauldron (late in a rest, or reeling). `planked` keeps her whole body on one plank height except in `UNSTOOD` acts; `b.floor` is the plank height; `b.plan` forces a move for tests). The stage's second twist lives in the engine, not here: a room field `mud` (frozen `[x0, x1]` spans), `mudAt` in `ghoul.js`, `you.mud` and `you.mudMs` (the run sags from `WATER_SPEED` toward `MUD_SPEED_MIN` and a jump toward `MUD_JUMP_MIN` over `MUD_MS`; a shelf, the air and Stilt Boots (`round.effects.boots`) let go of it) |
|
||||
| `public/activities/ghoul-rush/stages/bog/ghoul-bog-draw.js` | The Gallows Bog's drawing: `LOOKS` for its rooms (`outdoor: true`, `pack: "bog"`) and `bogArt(d)`, handed `ghoul-draw.js`'s helpers, returning the night swamp rooms (boardwalk planks over black water, moss veils, fireflies, the hag's lit stilt house and her open-water arena), `monsters` (a lurker's eyes, a leech swarm, a will-o'-wisp, a bog body), `bosses` (Old Mother Bog and her cauldron, a pose for every move, plus `motherMarks`: the boiling mud of a call, the stomp's shadow, the undertow's streaks), `hazards` (the mud wave, the muck patches, the bog hands' ripples and arms, the tide's warning and its water over the planks), the Stilt Boots' and Harpoon's badges and the events' looks and sounds; its `VOICES` are borrowed house tones until the sound page's vote, `LOSE_WORDS` and `LOSE_SOUNDS` already named |
|
||||
| `public/activities/ghoul-rush/rides/lantern/ghoul-lantern.js` | The Drowned Lantern (Gallows Bog's bonus round, not a ride) as a pack (`LANTERN`): a top-down game on one fixed screen where YOU carry a lantern over an island of mossy hummocks and plank walks round Old Mother Bog's pool, light five wisp shrines (stand on a stone `SHRINE_MS`, the time kept if you step off), then run back to the boat at the landing. Pack fields `ride` (moves Planny) and `place`; state in `round.runner` (`id` "lantern"), positions in field units with y counted down; the room's `ride` holds the island (`hummocks`, `planks` as hummock pairs, `shrines`, `start`, `boat`, `pool`, `bodies`) and the hunters' tables (`lurker` route, `leeches` routes, `wisps`: a guardian per shrine with its `phase`, roamers with `wake`). Keys: arrows walk (a walk into the water slides along the shore or plank, `slide`), SPACE flares (a ring `FLARE_R` that bursts wisps and scatters leeches, costing `FLARE_OIL`; a sputter without the oil); `fire()` and the arm double-tap are off for this room. The oil burns down over `OIL_MS` and the light (`lightR`) with it; a lit shrine fills it. One rule per hunter: the Lurker hears steps on wood, flares and shrines, swims to the spot, lines up a lane through it (`AIM_MS`) and dashes (it strikes where it heard you), rests deaf, and cowers once Mother rises; guardian wisps circle their shrine and rush a lantern within `GUARD_SENSE` on a `LEASH`, roamers leave the pool at the third to fifth shrine; leeches stay at the light's edge and bite only once the flame gutters; bog bodies rise only for someone standing still beside them; Mother's hand (from the third shrine or `MOTHER_LATE_S`) tracks, locks and slams, one after another once the fifth raises her. Catches cost the bonus round's hearts and never move Planny; `lanternMeet` names each hunter's rule once; `runner.marks` lists what a banner must keep clear of (read by ghoul.js's `underBanner`); `lanternHums` gives ghoul.js the held sounds; the grade is `total` 5, `hits` (kinds that caught you), `acts` (flare pops and close calls), `steady` (the flame never guttered). No random numbers; a Planny put at the door finishes too, as a ride's finish line does |
|
||||
| `public/activities/ghoul-rush/rides/lantern/ghoul-lantern-draw.js` | The Drowned Lantern's art, the whole field drawn by `lanternArt(d).field` (like Holy Roller's): `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `TAGS` (each hunter's rule, shown once over it, one at a time); the water and Mother's pool, the island and the boat, then one dark layer with a hole per light (`paintDark` from ghoul-draw.js), and over it what the dark must never hide: the island's moonlit edges, the shrines' beacons and progress, the bodies' bubbles and red reach, the leeches' eyes, Mother's eyes, head and hand shadow, the Lurker's eyes, its lane and dash, the wisps, Planny with the ring of his light (the leeches' line, red when the oil is low) and the boat's beacon; the HUD band (shrine flames, the hint line, the oil bar with its flare ticks); no random numbers, everything from a hash and the clock |
|
||||
| `public/activities/ghoul-rush/stages/bog/ghoul-sfx-bog.js` | Gallows Bog's own sounds as data (no imports): `BOG_SFX` with `tones` (a `ghoul<Kind><Act>` tone for each act of the lurker, leech, wisp, bog body and Old Mother Bog, her 22 newer acts first drafts too: a telegraph tone per move and one for each effect) and an empty `music` until the music vote is wired in (the rooms play borrowed tracks through `ROOM_MUSIC`); the tones are first drafts (option 1 of each act) until the sound vote; merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-rush/rides/lantern/ghoul-sfx-lantern.js` | The Drowned Lantern's own sounds as data (no imports): `LANTERN_SFX` with `tones` (`ghoulLantern<Act>`: a creak per step on wood, the flare, the shrine, a cue per hunter heard before it reaches you, Mother's wake, rise, hand and slam), `hums` (`ghoulLanternLurk`, `ghoulLanternMother`, asked for through `lanternHums`) and `music` (`ghoulLanternTheme`, the picked Tiptoe plucks track, named in `ROOM_MUSIC`); first drafts until the vote; merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-rush/stages/carnival/ghoul-carnival.js` | Ghoul Rush's Midnight Carnival stage pack, its rules (no imports; draws no random number): uses `tick` (the ring of samples Mirror You reads and its bolts in `round.twist`), `shot` (Cotton Candy's slow, a marionette's string at the top of its body), `target` (a bolt crossing a marionette's string or one of the puppet's three), `guard` (the Ringmaster is open only with the puppet down), `swoops` (a balloon, a circus hound's leap), `solid`, `kill` and `fourLegged`. Grinner and its acid balloons, marionette (drops when you pass under), Mirror You (copies you 500 ms late, mirrored, its bolts cancel yours), strongman (barbells), circus hound, and the Ringmaster (a gantry over the ring that follows its puppet at a lag, the puppet stalking you and working to a fixed script of leap, stomp, whip and charge, three strings from the gantry to its head and hands that move with it, open 4 s when they are cut, rage with hounds from the cages); `CARNIVAL_ROOMS` lists the stage's rooms, with a place before the Big Top for the dark ride. The room field `belts` and Planny's `you.belt` (the funhouse's conveyor floors) are run by `ghoul.js`. |
|
||||
| `public/activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js` | The Carnival's art: `LOOKS` (`custom: true`, `pack: "carnival"`), `carnivalArt(d)` returning the world's hooks (from `ghoul-carnival-world.js`) plus `monsters`, the `ringmaster` boss (gantry, puppet in each pose, strings, whip), `missiles` (barbell), `hazards` (foot, whip, charge), `waves` (the puppet's), `powers` (Cotton Candy), `front` (Mirror You's bolts, Cotton Candy's glow), `lights` and `react`, and `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`. Its header lists what the art reads off the rules. |
|
||||
| `public/activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js` | The Carnival's world (no imports; `carnivalWorld(d)` takes ghoul-draw.js's helpers): the night sky with a Ferris wheel (`sky`), tents, booths and swagged bulbs on the Midway, the Hall of Mirrors' gilded panels and glints, the Funhouse's crooked walls, spiral discs and clown-mouth door, the Big Top's striped canvas, ring curb, crowd, trapeze boards, gantry rail and cages (open once the Ringmaster rages), and the belts' chevrons (`moving`). |
|
||||
| `public/activities/ghoul-rush/stages/carnival/ghoul-sfx-carnival.js` | The Carnival's own sounds as data (no imports): `CARNIVAL_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride.js` | The Carnival's dark ride (a bonus round) as a pack (`RIDE`), the rules ported from `prototypes/ghoul-rush-ride/gallery.html`. Pack fields `ride` (returns true, so Planny never walks; steps the ride in 16 ms steps), `place` (makes `round.gallery`, the ride's state) and a new `pointer` (the mouse, handed on by `ghoul.js`'s `pointer(type, x, y)`); the entities (`K`: pop, lant, axe, chand, door, hand, head, eyes, boss, inno, mir, web, mini), hit tests with aim assist, the duck zone, hearts through `kit.lose`, the grade (5 to 9 dice, `perf.dice`). Events `ride<Name>` (`SOUNDS`), causes `CAUSES`. Its own seeded random stream; draws no `Math.random` |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-scenes.js` | The dark ride's scene table as data (12 rooms, lengths, speeds, spawn rows in author coordinates), no imports |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-core.js` | The ride's shared basics: the 96 by 54 field's constants, math helpers, the bound state `G` (a live import), `rnd`/`rand` (seeded) and `vrand` (visual) |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-draw.js` | The ride's art entry (`rideArt(d, die)`: `field(ctx, v)` draws the whole field by phase, `tick` the cascade's sounds); `ghoul-draw.js` hands over to it when `round.gallery` is set. Parts: `ghoul-ride-gfx.js` (canvas helpers), `ghoul-ride-draw-kinds.js` (animatronics, mini-bosses, the Barker), `ghoul-ride-draw-sets.js` (the 12 sets, far walls, aisle, near layer), `ghoul-ride-draw-hud.js` (car and Planny, HUD, duck strip, reticle, title, end cascade) |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-gfx.js` | The ride's drawing helpers: the bound 2D context and the short fill, stroke and shape calls the ride's art is written in |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-draw-kinds.js` | The ride's drawn things: every figure, beast, lantern, blade, door, hand, head, mirror, web and boss, a port of the prototype's draw code (`prototypes/ghoul-rush-ride/gallery.html`) |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-draw-sets.js` | The ride's rooms drawn: each room's far wall, set pieces front and back, aisle and the near pillars, a port of the prototype's world draw |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-draw-hud.js` | The ride's car and the screen around it: Planny in his car, blood and sparks, the lens, the hearts, the progress bar, the room plaque, the aim, the title and the cleared card |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-voices.js` | The ride's `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `react` (every `ride<Name>` event plays tone `ghoulRide<Name>`) |
|
||||
| `public/activities/ghoul-rush/rides/dark-ride/ghoul-sfx-ride.js` | The ride's synthesized sounds as `tones` (`ghoulRide<Kind>`) and its music `ghoulRideDrone` (`RIDE_SFX`, merged by `ghoul-sfx.js`) |
|
||||
| `public/activities/ghoul-rush/stages/frozen/ghoul-frozen.js` | Ghoul Rush's Frozen Lake stage pack, its rules (imports only `burrow` from the Graveyard; draws no random number): uses `tick` (thin ice, the blizzard, the Widow's spikes, web and barrels), `place`, `unseen`, `solid`, `kill`, `target`, `land`, `weak`, `cause`, `guard`, `swoops` and `slides`. The generic slippery-ice rule (`iceRun`, room field `ice`) and thin-ice rule (`stepThin`, room field `thin`, `round.thin`), the under-ice hand, snow shade (unseen, footprints), Frozen Ghoul (slides, shatters into shards), Ice Wraith (its dive freezes), Hot Cocoa, the Frost Widow (veil, barrels, weak spot, blizzard, spikes, web, rage) and `FROZEN_ROOMS`. Every constant is exported and documented in its header |
|
||||
| `public/activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js` | The Frozen Lake's art: `LOOKS` (`custom: true`), `frozenArt(d)` returning the world's hooks (from `ghoul-frozen-world.js`) plus `monsters`, the Frost Widow boss, `hazards` (shards, spikes, webs, barrels, the flare and its fire), `powers` (Hot Cocoa), `front`, `lights` and `react`, and `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js` | The Frozen Lake's world (no imports; `frozenWorld(d)` takes ghoul-draw.js's helpers): the night sky with moon, aurora and far mountains (`sky`), the huts, the Lodge's fallen roof, the Black Ice and the Widow's web (`backdrop`, `ground` with the ice's gloss, `shelf`), and `moving` (open water in the holes, thin ice drawn from `round.thin`, never from `spec.ground`, the faces under the Black Ice, falling snow) and `lights`. Draws no random number |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-flare.js` | The Road Flare's rules (`useFlare`, `stepFlareFly`, `stepRoadFire`; no imports, handed the helpers by `ghoul-arms.js`): a lob that lands as a patch of fire, burns monsters on a tick, melts a Frozen Ghoul at once, shows a shade and melts the Widow's veil; never hurts Planny |
|
||||
| `public/activities/ghoul-rush/rides/sled/ghoul-sled.js` | The Coffin Sled (the Frozen Lake's bonus round) as a pack (`SLED`), modeled on the Runaway Cart (`ghoul-cart.js`): pack fields `ride`, `place` and `target`; the track of ice lines with cracks, headstones, drifts, low branches, hands, icicles and popping ghouls, checkpoints, hearts through the Cart's bonus machinery and the grade (3 to 9 dice). Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-rush/rides/hearse/ghoul-hearse.js` | The Midnight Hearse (the Graveyard's bonus round) as a pack (`HEARSE`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in `round.runner` (`id: "hearse"`); a flat road of two lanes (road and verge) switched with LEFT/RIGHT inside the lane gates, open graves, headstones and crosses to jump, low branches and the lychgate arch to duck, hands and crows to shoot, closed stretches to go round, lanterns that keep the lamp lit (an unbroken lamp is the grade's `steady` die), and coffins thrown out by each hit with a ghoul to shoot in each. Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js` | The Midnight Hearse's art: `LOOKS` (`pack: "hearse"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK, SHOOT and SWITCH glyphs for the hearse's lane) and `hearseArt(d)` (sky, hills, cemetery, road, verge, things and the hearse by `moving`; the cab door, lows, fog, glyphs and lamp gauge by `front`; `dim` when the lamp is out); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/rides/sled/ghoul-sled-draw.js` | The Coffin Sled's art: `LOOKS`, `VOICES` (borrowed tones), `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `sledArt(d)` (the sky, hills, ice and things by `moving`, the lid, the lows and foreground flakes by `front`); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/rides/gurney/ghoul-gurney.js` | Code Blue (Blackmoor Sanatorium's bonus round) as a pack (`GURNEY`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; the gurney along `ride.track` (shafts are the gaps), wheelchairs that roll, IV stands, lamps and doors overhead, orderlies in doorways, the lights-out waves (`lightsAt`), the surge lamps and the heartbeat monitor's beat; its state is `round.runner` (`pack: "codeblue"`, put back if another pack's `place` clears the shared slot); draws no random number; imports the cart's track helpers |
|
||||
| `public/activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js` | Code Blue's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` and `gurneyArt(d)` (the corridors, shafts and floors by `moving`; the gurney, lows, glyphs, countdown and monitor by `front`; `dim` and `lights` for the blackouts); no imports but the Sled's glyph colors |
|
||||
| `public/activities/ghoul-rush/rides/mower/ghoul-mower.js` | The Gardener's Revenge (the Grounds' bonus round) as a pack (`MOWER`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `mower`); a flat lawn run on a ride-on mower with gaps (ponds, ha-ha ditches), junk, hedge arches, clothes lines of gloves and snapping topiary beasts, and the twist: holding fire lowers the blades, which cut tall grass, weeds and thorn hedges in the zone ahead (the blades heat and jam, so they are pulsed); the lawn-cut share is the grade's steady die; hearts through the Cart's bonus machinery; no random numbers |
|
||||
| `public/activities/ghoul-rush/rides/mower/ghoul-mower-draw.js` | The Gardener's Revenge's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK and CUT glyphs) and `mowerArt(d)` (sky, manor, topiary and railings by `moving`, the lawn with its ponds and ditches, the mower with its blades and heat gauge, the lows and the lawn gauge by `front`); no random numbers |
|
||||
| `public/activities/ghoul-rush/stages/frozen/ghoul-sfx-frozen.js` | The Frozen Lake's own sounds as data (no imports): `FROZEN_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` via `STAGE_SFX` (its rooms play existing tracks, set in `ROOM_MUSIC`) |
|
||||
| `public/activities/ghoul-rush/rides/mower/ghoul-sfx-mower.js` | The Gardener's Revenge's own sounds as data (no imports): `MOWER_SFX` with first-draft `tones` (`ghoulMower<Act>`, each under 1.2 s) and the `ghoulMowerRide` track (sound and music picks still pending); merged by `ghoul-sfx.js` via `STAGE_SFX`, the track set in `ROOM_MUSIC` |
|
||||
| `public/activities/ghoul-rush/rides/pew/ghoul-pew.js` | Holy Roller (the Chapel's bonus round) as a pack (`PEW`): a Subway-Surfers style endless-runner seen from behind, pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `pew`). `you.x` is only the distance run; the pew's own `lane` (a float to `laneTo`), `h`, `slide`, `combo` and `magnet` live in `round.runner`. Left/right presses change lane (a wall bump at the edge), up jumps, down slides (fast-fall in the air), fire shoots down the lane; a speed ramp by distance (`speedAt`); `KINDS` (switch: pillar, confessional, pewx; jump: kneeler, stand, cracks, hatch; slide: censer, banner, beam; shoot: garg with 2 hp, bell rope), wax souls and halos, the combo and the steady die (souls share); a hit shoves the pew to a calm lane. Pure rules, no random numbers |
|
||||
| `public/activities/ghoul-rush/rides/pew/ghoul-pew-course.js` | Holy Roller's seeded course (no imports): written in seconds and laid by the speed ramp (`xAt`, `speedAt`, `V0`, `ACC`), `COURSE` { items [x, lane, kind, len], souls, checks, finish } |
|
||||
| `public/activities/ghoul-rush/rides/pew/ghoul-pew-draw.js` | Holy Roller's art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS` and `pewArt(d)`, whose `field(ctx, view)` draws the WHOLE field (ghoul-draw.js has a `round.runner.id === "pew"` branch like the dark ride's `round.gallery` one, then adds the hearts, flash, banner, cards and HUD pills) plus the progress track, souls and combo strip, and the events' effects |
|
||||
| `public/activities/ghoul-rush/rides/pew/ghoul-pew-world.js` | Holy Roller's pseudo-3D nave: `worldArt(d)` with `paint(ctx, view)`; the projection `(lane, depth, height)` to the screen with scale = near / (near + depth) toward a vanishing point, far-to-near cells with fog as alpha, stained glass, pillars and ribs, pews, candlelight and god rays pulsing on the organ's beat (`pulse`, `BPM`), every thing's art and telegraph glyph, the souls, bolts, the pew and hero from behind, speed streaks and vignette. A reusable pattern for "run into the screen" rides. No random numbers (hashes) |
|
||||
| `public/activities/ghoul-rush/rides/pew/ghoul-sfx-pew.js` | Holy Roller's own sounds as data (no imports): `PEW_SFX` with 17 tones (lane, bump, jump, land, slide, dive, soul, halo, crash, check, finish, speed swell, gargoyle and bell) and the driving `ghoulPewDirge` track at 132 BPM (first drafts, merged by `ghoul-sfx.js`) |
|
||||
| `public/activities/ghoul-rush/rides/hearse/ghoul-sfx-hearse.js` | The Midnight Hearse's own sounds as data (no imports): `HEARSE_SFX` with 19 first-draft `ghoulHearse<Act>` tones (none over 1.2 s) and the `ghoulHearseRide` track (a funeral march at a gallop, built from three four-bar parts); merged by `ghoul-sfx.js`, named in `ROOM_MUSIC`. Sounds and music still to be picked by ear |
|
||||
| `public/activities/ghoul-rush/rides/sled/ghoul-sfx-sled.js` | The Coffin Sled's own sounds as data (no imports): `SLED_SFX` with an empty `tones` and `music` until the user picks them; merged by `ghoul-sfx.js` (the room plays the Graveyard's `ghoulGraves`) |
|
||||
| `public/activities/ghoul-rush/rides/banister/ghoul-banister.js` | The Grand Banister (the Manor's bonus round) as a pack (`BANISTER`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; state in the shared `round.runner` slot (id `banister`); YOU slide down a grand staircase's banister along `ride.track` (the first `rails` lines are the handrail, the breaks between them gaps to jump; the rest are brass under-rails beside it, the split track: a jump with DOWN held dives onto one, a jump off its end lands back on the handrail), vases and candlesticks to jump, hanging portrait frames to duck, chandeliers on a pendulum (`swingAt`: a wall from the bob to the roof, lethal to a ducking rider while the bob is mid-swing, so you brake or lean (LEFT/RIGHT) to time them or take the under-rail), ghostly butlers that lunge (jump or two bolts) and cobwebs to shoot. Adds no monster, boss or hazard kind; no random numbers. Its header documents the room fields |
|
||||
| `public/activities/ghoul-rush/rides/banister/ghoul-banister-draw.js` | The Grand Banister's art: `LOOKS` (`pack: "banister"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` (JUMP, DUCK and DIVE glyphs) and `banisterArt(d)` (damask wall, moonlit windows, a zig-zag of staircase flights, portraits whose eyes follow YOU, the rails, props, butlers and webs by `moving`; the hanging frames, the chandeliers with the arc they swing through, sparks and glyphs by `front`); no random numbers. Its header lists what the art reads off the rules |
|
||||
| `public/activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js` | The Grand Banister's own sounds as data (no imports): `BANISTER_SFX` with 14 first-draft `ghoulBan<Act>` tones (each under 1.2 s) and the `ghoulBanister` track (a harpsichord waltz at a gallop, built from three four-bar parts); merged by `ghoul-sfx.js` via `STAGE_SFX`, named in `ROOM_MUSIC` (sound and music picks still pending) |
|
||||
| `public/activities/ghoul-rush/rides/wagon/ghoul-wagon.js` | The Torch Mob (Hollow End Village's bonus round) as a pack (`WAGON`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; a hay wagon along `ride.track` (ditches and the collapsed bridge are the gaps, a rising line end a ramp), barrels and crates, washing lines and inn signs, villagers who hurl pitchforks (duck) and torches (jump), spooked horses, and the pursuit meter (`gap`: the mob runs at `MOB_V`, DOWN is a duck and the brake, a hit, a burning hay load and the surge close it, a shot torch or fork opens it, inside `PANIC_ON` the horses bolt, at `CATCH_GAP` it is a heart); its state is `round.runner` (`id: "wagon"`); draws no random number; imports the cart's track helpers |
|
||||
| `public/activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js` | The Torch Mob's art: `LOOKS` (`pack: "wagon"`), `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, `telegraphMarks`/`telegraphs` and `wagonArt(d)` (the sky, rooftops, street, cobbled road, ditches, the bridge and river, the things, the mob and the wagon by `moving`; the lows, throws in the air, the hay fire, glyphs and the mob's meter by `front`); no random numbers; imports the Sled's glyph colors and the rules' constants |
|
||||
| `public/activities/ghoul-rush/rides/wagon/ghoul-sfx-wagon.js` | The Torch Mob's own sounds as data (no imports): `WAGON_SFX` with 18 first-sketch `ghoulWagon<Act>` tones and the `ghoulWagonRide` track (a D minor gallop built from three 4-bar patterns); merged by `ghoul-sfx.js`, the room's track named in `ROOM_MUSIC` (`wagon`) |
|
||||
| `public/activities/ghoul-rush/story/ghoul-story.js` | Ghoul Rush's intro story: the pages' text as data and the rules (lockout, reveal, skip) as plain functions over a round; drawn by `ghoul-story-draw.js`, sounded by `ghoul-sfx-story.js`, the lore bible in `prototypes/Ghoul-Rush-TODO.md` |
|
||||
| `public/activities/ghoul-rush/story/ghoul-story-draw.js` | The intro story's drawing (`storyArt(d)`): eight animated scenes in canvas shapes (the road, the house on the hill, the hunger, the long arms, the farthest rooms, why YOU, no way back, the door to The Long Hall) with the heading, the lines typing out, the page dots, the always-visible skip hint with its hold bar and the pulsing continue hint; drawn over the field while `round.phase === "story"`; reuses the intro card's helpers (`poly`, `dot`, `stroke`, `faint`, `flame`, `titleLayout`, `dropAt`); no gradients |
|
||||
| `public/activities/ghoul-rush/story/ghoul-sfx-story.js` | The intro story's own sounds as data (no imports): `STORY_SFX` tones for the pages' `cues` (wind, a bell, a heartbeat, a door creak, knocks, a whisper, the flashlight click, the page turn) and the `hums` drone under the whole story; merged by `ghoul-sfx.js` |
|
||||
| `public/activities/ghoul-rush/rides/gurney/ghoul-sfx-gurney.js` | Code Blue's own sounds as data (no imports): `GURNEY_SFX`, 18 first-pick `ghoulBlue<Act>` tones and the track `ghoulBlueRide`; merged by `ghoul-sfx.js` (the room plays it via `ROOM_MUSIC.codeblue`) |
|
||||
| `public/activities/ghoul-rush/rides/tray/ghoul-tray.js` | The Servants' Back Stairs (the East Wing's bonus round) as a pack (`TRAY`), modeled on the Coffin Sled: pack fields `ride`, `place` and `target`; the track of shelves and stair flights with gaps, rolling pots and cutlery, hams and pans, cooks who fling dishes, the courses (silver domes and flying plates, seven is the grade's acts die), the cherries, grease stretches, checkpoints and the grade (3 to 9 dice). State is `round.runner` (id `tray`), the shared slot for a rolling bonus ride. Adds no monster, boss or hazard kind and draws no random number; every number is an exported constant documented in its header |
|
||||
| `public/activities/ghoul-rush/rides/tray/ghoul-tray-draw.js` | The Servants' Back Stairs' art: `LOOKS`, `VOICES`, `EVENT_VOICE`, `LOSE_WORDS`, `LOSE_SOUNDS`, the telegraph glyphs (`telegraphMarks`, `telegraphs`: JUMP, DUCK, SHOOT) and `trayArt(d)` (the kitchen, shelves and stairs, things and cooks by `moving`; the tray, hams and pans, flour and glyphs by `front`); no random numbers |
|
||||
| `public/activities/ghoul-rush/rides/tray/ghoul-sfx-tray.js` | The Servants' Back Stairs' sounds and music as data (no imports): `TRAY_SFX` with 13 first-draft tones and the `ghoulTrayRide` track; merged by `ghoul-sfx.js` |
|
||||
| `public/activities/ghoul-rush/stages/chapel/ghoul-sfx-chapel.js` | The Chapel's own sounds as data (no imports): `CHAPEL_SFX`, its `tones` (the 35 picked `ghoul<Kind><Act>` sounds of the gargoyles, choir ghosts, monks, bell bats, the Choirmaster, the bell and Holy Water's splash) and `music` (`ghoulNave`, `ghoulTower`, `ghoulLoft`, `ghoulChoir`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-rush/stages/sanatorium/ghoul-sfx-sanatorium.js` | Blackmoor Sanatorium's own sounds as data (no imports): `SANATORIUM_SFX`, its `tones` (the 38 picked `ghoul<Kind><Act>` sounds of the orderlies, gurneys, flickers, specimen bloaters, the Night Matron, the lamps, Smelling Salts and the Bone Saw) and `music` (`ghoulAdmissions`, `ghoulBaths`, `ghoulTheater`, `ghoulWard`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `public/activities/ghoul-rush/stages/village/ghoul-sfx-village.js` | Hollow End Village's own sounds as data (no imports): `VILLAGE_SFX`, its `tones` (the 42 picked `ghoul<Kind><Act>` sounds of the torch mob, hanged men, shutter ghouls, moonhounds, the Beast, the full moon and Wolfsbane) and `music` (`ghoulStreet`, `ghoulInn`, `ghoulSquare`, `ghoulGreen`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` via `STAGE_SFX` |
|
||||
| `scripts/test-web-console-activities-ghoul-chapel.mjs` | The Chapel's suite: each monster, the bell toll and its freeze, Holy Water's splash, the Choirmaster's pipes, notes and rage, a voice for every act, each event playing exactly one picked sound, and every picked tone present in the merged tones and in `ghoul-sfx-chapel.js` |
|
||||
| `scripts/test-web-console-activities-ghoul-sanatorium.mjs` | The Sanatorium's suite: the orderly's reach, hold and throw (and the Salts), the gurney's park, rattle, roll and rest and its floor, the flicker's unseen state, the lamps' timing, the specimen's jar and puddle, both power-ups (stage-only), the Matron's cone, heat, cabinets, syringes, arms and rage, endless lives for every new cause, and a voice for every act |
|
||||
| `scripts/test-web-console-activities-ghoul-village.mjs` | The Village's suite: the rooms, the moonrise timing, the turn and the grow at full moon (and the per-room reset), the villager's group, torch and fire, the hanged man's drop, the shutter ghoul hit only while out, the moonhound, Wolfsbane (stage-only, double damage, shying), the Beast's wall leap, cling weak spot, pounce shadow, swipe, howl and its cap, the rage, endless lives for every new cause, no random draws, and a voice for every act and event |
|
||||
| `scripts/test-web-console-activities-ghoul-mine.mjs` | The Mine's suite: the rooms and the cage rows, rockfall timing, aim and crush, the Hard Hat (stage-only, bounce), the imp's light steal (no life, ended by a shot or a stomp, blocked by the hat), the canary's scream and its three rocks, the miner's dig and swing, the blind crawler losing and hearing you (and the water's louder steps), water slowing you, the cage carrying Planny, Dynamite (a double tap, the bag, the blast), every Tommyknocker move including the dark, the decoy, the burst, the dazed double damage and the rage cap on imps, no random draws, endless lives for every new cause, and a voice for every act and event |
|
||||
| `scripts/test-web-console-activities-ghoul-carnival.mjs` | The Carnival's suite: the rooms and the belts, grinners and their balloon cap, balloons and their acid, the marionette's drop and its string, Mirror You (the delay, the mirrored moves, jumps, its bolts and their canceling, stunned by a pie), the strongman, the circus hound (a swoop, duckable), Cotton Candy, the Custard Pie, every Ringmaster move (stalk, leap, charge, stomp, whip, the strings following, open, rage, hounds, the script), no random draws, endless lives for every new cause, and a voice for every act |
|
||||
| `scripts/test-web-console-activities-ghoul-grounds.mjs` | The Grounds' suite: each monster's behavior, the shears, the Groundskeeper's moves and phases, a voice for every act, each event playing exactly one picked sound, and every picked tone present in the merged tones |
|
||||
| `scripts/test-web-console-activities-ghoul-bog.mjs` | Gallows Bog's suite: the stage row and its rooms, the mud (slow, sink, jump, shelf, boots), each monster's behavior (the lurker's eyes and snap, the leech's latch, the wisp's light, the bog body's rise), the wisp lure and its fairness cap, the harpoon under the water, Old Mother Bog's wave, weak cauldron, muck, sink and resurface, a voice for every act with exactly one picked sound per event, words and a sound for every cause, both cards, the round flow, drawing dark and lit, and a seeded bot on a draw that throws if the pack asks for a random number |
|
||||
| `scripts/test-web-console-activities-ghoul-bogboat.mjs` | The Bog Runner's suite: the ride's course, the lanes and banks, jumping, ducking and shooting, the wake and its panic, checkpoints, the grade, endless lives, the telegraphs, drawing, and bots that dodge and do not |
|
||||
| `public/activities/ghoul-picker-draw.js` | The choice of stage, its drawing: `pickerArt(d)`, handed `ghoul-draw.js`'s helpers (`lookOf`, `label`, `roundRect`, `circle`, `BOSS_ART`, `drawGourdFire`, `GOLD`), returning `drawPicker` (a card per stage offered: its picture of its rooms with its boss standing there, its name, line and boss, the pick raised and edged in gold, and how to choose), `drawSelect` (the stage select for testing: every stage in a list, two columns past 8, the one picked out with its picture and a chip per room) and `stageColor` (a stage's boss room's color, also the tally dots'). Split from `ghoul-draw.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/ghoul-powers.js` | Ghoul Rush's power-ups and pickups (no imports: `ghoul.js` hands its rules a kit, `POWER_KIT`, of `landing`, `MAX_LIVES` and the numbers they need): `POWERS` (each power-up's name, line, color, `ms` if timed, drop `weight`, and its rule, the Lantern's `dark`), `TIMED`, `PILL_WORDS`, `FLAP_CLEAR`, `HOURGLASS_MS`, `CANDY_POINTS`, `POWER_POINTS`, `CRYSTAL_POINTS`, `powerHere(round, kind)` (whether a power-up can turn up in the room as it is now; a new rule, such as a stage-only power-up, goes in `POWERS` and is checked here), `pickPower`, `applyPower(round, kind, kit)` (`ghoul.js` exports it bound to its kit as `applyPower(round, kind)`) and `pickups` (candy, placed and dropped power-ups, crystals up high and the key, taken by touch; drops fall and fade). Split from `ghoul.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/ghoul-arms.js` | Ghoul Rush's secondary weapons (imports only `ghoul-powers.js`; a pack in `PACKS`, `ARMS`): the double tap (`pressFire`, `releaseFire`, called from the game's `key()` and `release()`, never from `round.input.fire`, so bots never throw), the bag `round.arms` (`useArm`, `armOnTop`: a ride room skips what needs a floor), each weapon's rule (a shot with `arm` through `moveShots`, or a hazard), and `armBossDamage` (scaled to depth, capped at `ARM_BOSS_SHARE` of a boss's hp a fight). Weapons' names, bundles and caps are in `POWERS` (`arm: true`, weight 0), the stage's own in `STAGE_ARMS`, the kill drop band in `armDrop`, all in `ghoul-powers.js`. |
|
||||
| `public/activities/ghoul-arms-draw.js` | The weapons' art (`armsArt(d)`): their badges (`powers`), `hazards`, `shot` for one in flight, `pill` for the HUD's icon and count, `front` (stars over the dazed), `lights` and `react`. Dynamite's stick, blast and badge stay in `ghoul-mine-draw.js`. |
|
||||
| `public/activities/ghoul-rockets.js` | The Bottle Rocket's rules, the common weapon every stage sells: one use lights three rockets, one ahead, one up and one behind |
|
||||
| `public/activities/ghoul-rockets-draw.js` | The Bottle Rocket's drawing (`rocketArt(d)`): the muzzle's flash and smoke, the flared rocket on a stick with a glowing head, the fountain of sparks it sheds and the burst when it goes off |
|
||||
| `public/activities/ghoul-pans.js` | The Cast-Iron Skillet's rules, the East Wing's weapon: three pans that circle Planny, then spiral outward until they are off screen |
|
||||
| `public/activities/ghoul-sfx-arms.js` | The weapons' `tones` (`ARMS_SFX`), merged by `ghoul-sfx.js` like a stage's. A first pass, not yet picked by ear. |
|
||||
| `scripts/test-web-console-activities-ghoul-bog.mjs` | Gallows Bog's suite: the stage row and its rooms, the mud (slow, sink, jump, shelf, boots), each monster's behavior (the lurker's eyes and snap, the leech's latch, the wisp's light, the bog body's rise), the wisp lure and its fairness cap, the harpoon under the water, Old Mother Bog's wave, weak cauldron, muck, sink and resurface, every move (wind-up, telegraph event, effect, a clean dodge costs nothing, a hit a heart), the phase unlocks, cooldowns and caps, planks while standing, her fall clearing every hazard and add, a skilled bot that must kill her in 60 to 120 s on four seeds and an idle bot she kills, a voice for every act with exactly one picked sound per event, words and a sound for every cause, both cards, the round flow, drawing dark and lit, and a seeded bot on a draw that throws if the pack asks for a random number |
|
||||
| `scripts/test-web-console-activities-ghoul-lantern.mjs` | The Drowned Lantern's suite: the room and its tables, the walk and the slide, steps on wood, the flare and the oil, the shrines, Mother's wake and rise and the boat, each hunter's rule (the Lurker's hearing, lane and dash, the guardian and roaming wisps, the leeches at the light's edge and their bite, the bodies that take only the still, Mother's hand and its gaps), hearts, endless lives and the grade, the clock, determinism (no random drawn), the balance (a bot that ignores the hunters loses every shrine order, one that plays them wins each with hearts left), the rule tags and banner marks, the hums, voices and drawing |
|
||||
| `public/activities/ghoul-rush/draw/ghoul-picker-draw.js` | The choice of stage, its drawing: `pickerArt(d)`, handed `ghoul-draw.js`'s helpers (`lookOf`, `label`, `roundRect`, `circle`, `BOSS_ART`, `drawGourdFire`, `GOLD`), returning `drawPicker` (a card per stage offered: its picture of its rooms with its boss standing there, its name, line and boss, the pick raised and edged in gold, and how to choose), `drawSelect` (the stage select for testing: every stage in a list, two columns past 8, the one picked out with its picture and a chip per room) and `stageColor` (a stage's boss room's color, also the tally dots'). Split from `ghoul-draw.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/ghoul-rush/core/ghoul-powers.js` | Ghoul Rush's power-ups and pickups (no imports: `ghoul.js` hands its rules a kit, `POWER_KIT`, of `landing` and the numbers they need): `POWERS` (each power-up's name, line, color, `ms` if timed, drop `weight`, and its rule, the Lantern's `dark`), `TIMED`, `PILL_WORDS`, `FLAP_CLEAR`, `HOURGLASS_MS`, `CANDY_POINTS`, `POWER_POINTS`, `CRYSTAL_POINTS`, `powerHere(round, kind)` (whether a power-up can turn up in the room as it is now; a new rule, such as a stage-only power-up, goes in `POWERS` and is checked here), `pickPower`, `applyPower(round, kind, kit)` (`ghoul.js` exports it bound to its kit as `applyPower(round, kind)`) and `pickups` (candy, placed and dropped power-ups, crystals up high and the key, taken by touch; drops fall and fade). Split from `ghoul.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-arms.js` | Ghoul Rush's secondary weapons (imports only `ghoul-powers.js`; a pack in `PACKS`, `ARMS`): the double tap (`pressFire`, `releaseFire`, called from the game's `key()` and `release()`, never from `round.input.fire`, so bots never throw), the bag `round.arms` (`useArm`, `armOnTop`: a ride room skips what needs a floor), each weapon's rule (a shot with `arm` through `moveShots`, or a hazard), and `armBossDamage` (scaled to depth, capped at `ARM_BOSS_SHARE` of a boss's hp a fight). Weapons' names, bundles and caps are in `POWERS` (`arm: true`, weight 0), the stage's own in `STAGE_ARMS`, the kill drop band in `armDrop`, all in `ghoul-powers.js`. |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-arms-draw.js` | The weapons' art (`armsArt(d)`): their badges (`powers`), `hazards`, `shot` for one in flight, `pill` for the HUD's icon and count, `front` (stars over the dazed), `lights` and `react`. Dynamite's stick, blast and badge stay in `ghoul-mine-draw.js`. |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-rockets.js` | The Bottle Rocket's rules, the common weapon every stage sells: one use lights three rockets, one ahead, one up and one behind |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-rockets-draw.js` | The Bottle Rocket's drawing (`rocketArt(d)`): the muzzle's flash and smoke, the flared rocket on a stick with a glowing head, the fountain of sparks it sheds and the burst when it goes off |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-pans.js` | The Cast-Iron Skillet's rules, the East Wing's weapon: three pans that circle Planny, then spiral outward until they are off screen |
|
||||
| `public/activities/ghoul-rush/arms/ghoul-sfx-arms.js` | The weapons' `tones` (`ARMS_SFX`), merged by `ghoul-sfx.js` like a stage's. A first pass, not yet picked by ear. |
|
||||
| `scripts/test-web-console-activities-ghoul-arms.mjs` | The weapons' suite: the double tap through the keys (repeats, feathering, hammering), the bag and its pill, each weapon, bosses (scale, cap, guards, the half-hp drop), placement in every room, the drop band's single draw, ride rooms, drawing and sounds. |
|
||||
| `public/activities/ghoul-run.js` | Ghoul Rush's run flow (no imports: `ghoul.js` hands its rules `RUN_KIT`, the room and stage tables, the timings and the helpers that set a room up, and binds them): `newRound`, `setupRoom`/`resetRoom`, the stage pick (`stagesLeft`, `nextRoom`, `steerPick`, `pickStage`), the stage select for testing (`openSelect`, `steerSelect`, `takeSelect`: a practice round, `round.practice`, that keeps no best score or record), `camera`, `respawn`, `lockArena`, `clearRoom`, and a room's monster supply (`spawners`, `horde`, `hurry`). `ghoul.js` re-exports `newRound`, `stagesLeft`, `steerPick`, `pickStage`, `steerSelect` and `takeSelect`, and its game answers `stageSelect()`. Split from `ghoul.js` to keep it under the 3,000-line cap, with the same random draws in the same order |
|
||||
| `public/activities/ghoul-dice.js` | Ghoul Rush's Lucky die rules (no imports: `ghoul.js` hands them `DICE_KIT`): `MAX_DICE` (9), `ROLL_MS`, `TUMBLE_MS`, `SAVED_TIME_MS`, `markRest` (the last solid ground Planny stood on), `reviveSpot`, `beginRoll` (called by `lose` when `round.dice > 0` and not `round.infinite`: the round holds in the phase `roll`), `rollDice` (one die at a time from advance's `random`, events `diceStart`, `diceRoll`, `diceFace`, `diceSaved`, `diceFail`; a six revives with the Garlic shield and `SAFE_MS`, and blows apart every monster in view in a room without a boss (`diceBlast`, kills with `how: "luck"`, points but no drops); no six hands the loss back to `takeLife`) |
|
||||
| `public/activities/ghoul-bonus.js` | Ghoul Rush's bonus rounds, the rules (imports only `MAX_DICE`; no random numbers): a room with `bonus: true` (the Runaway Cart; the Carnival's dark ride is meant to follow) gets `round.bonusRound = { hearts, max, dice, over, won, perf }` on entering it (null elsewhere; `round.bonus` is already the time bonus score). A life lost in it is a heart lost through the same `lose`/`takeLife` (so Garlic, the safe moment and `round.infinite` work as ever; no Lucky die is rolled for a heart); the last heart gone calls `endBonus(round, false)` from `respawn` (no dice, no game over, the run's lives untouched), and a finish alive calls `endBonus(round, true)` from `clearRoom` (`diceFor`: `BONUS_FLOOR` 3 plus up to 6 by hearts, clean obstacles, acts and a steady hand, added to `round.dice` up to `MAX_DICE`). A room's pack notes its performance in `bonusRound.perf` (`total`, `hits`, `acts`, `goal`, `steady`); both ends hold the phase "clear" for the card (`CARD_MS`, `CARD_LOST_MS`) and set `bonusRound.result`. Events `bonusStart`, `bonusEnd`; `heartsText(b)` is the HUD pill |
|
||||
| `public/activities/ghoul-bonus-draw.js` | The bonus rounds' art (`bonusArt(d, die)`): `card` ("BONUS CLEARED! +N LUCKY DICE" with the dice tumbling in, or the short "BONUS LOST"), `react` (the intro banner, the end, the hearts-left float) and `tick` (a click for each die landed) |
|
||||
| `public/activities/ghoul-dice-draw.js` | The Lucky die's art (`diceArt(d)`: the small drop, the rolling die on a panel placed away from Planny, the sweeping "LUCKY-SAVE" word, and `react` for the dice events, which plays `ghoulLuckySave` once on the revive) |
|
||||
| `public/activities/ghoul-gameover-draw.js` | The lost end screen's "G A M E - O V E R" (`gameOverBanner(d)`, `dropAt`): nine letters dropping in with a stagger and one bounce, then bobbing on a sine wave under a slow pulse, red and bone with a dark shadow, drawn above the score panel and never on a win. `ghoul.js` keeps ticking the clock on the lost end screen (`view.overMs`) and plays the mechanical laugh track there: `ghoulLaughTrack`, `ghoulLaughTrack2` and `ghoulLaughTrack3` in `ghoul-sfx.js`, one second apiece (a tone may not pass 1.2 s). |
|
||||
| `public/activities/ghoul-intros.js` | The stage intro cards' words and colors: `INTROS` per stage id (`title`, `palette` {a, b, glow}, `kicker`, 3 or 4 `lines` of flavor text at most `MAX_LINE` characters, `boss`), `introFor(id)`. Always addressed to YOU. A test fails for a stage in `STAGES` with no card. |
|
||||
| `public/activities/ghoul-intro-draw.js` | The intro card's drawing (`introArt(d)`, `titleLayout`, `dropAt`): the title's letters dropping in and glowing, one themed flourish per stage (frost crystals, bunting, pickaxe sparks, leaves, candle flames, ...), the lines fading in, the boss and the pulsing "Press any move key or fire to enter". Drawn over the field while `round.phase === "intro"`. The phase itself lives in `ghoul-run.js` (`startIntro`, `stepIntro`, `takeIntro`, `INTRO_MIN_MS` 1.2 s: any fresh move key, fire or a click moves on after it, repeats never, and the card never moves on by itself); the tone is `ghoulStageIntro`. |
|
||||
| `public/activities/ghoul-boss-intros.js` | The boss intro cards' words: `BOSS_INTROS` per boss id (`name`, which must equal the boss's `name` in its pack's `bosses` table, an `epithet` of at most `MAX_EPITHET` characters and an optional `accent` color), `bossIntroFor(id)`. A test fails for a boss room whose boss has no entry. |
|
||||
| `public/activities/ghoul-bossintro-draw.js` | The boss intro card's drawing (`bossIntroArt(d)`): a "BOSS FIGHT" title whose letters slam in with a screen shake and a heartbeat pulse, the boss drawn from its own art (`BOSS_ART`, the way the stage pick does) at a big scale in a spotlight on the stage's palette, its name, the epithet and the pulsing "Press any move key or fire to start the fight"; a boss whose art throws falls back to a silhouette. Drawn over the field while `round.phase === "bossintro"`. The phase lives in `ghoul-run.js` (`startBossIntro`, run by `enter` on every boss room, and `onCard`; it shares `introMs`, `stepIntro`, `takeIntro` and `INTRO_MIN_MS` with the stage card, and a respawn never shows it); the tone is `ghoulBossIntro`. |
|
||||
| `public/activities/ghoul-monsters-draw.js` | The generic monsters' art (`monsterArt(d)`, no imports; `ghoul-draw.js` hands it its helpers `ellipse`, `circle`, `line`, `rotate`, `turned`, `eye` and the colors): `drawZombie`, `drawZombieKin`, `drawHuntsman`, `drawCrawler`, `drawBat`, `drawGhost`, `drawSkeleton`, `drawGourdling`, `drawHound`, `drawSpider`, `drawWraith`, `drawSpitter` and the missiles `drawBoneShape` and `drawGlob`. Split from `ghoul-draw.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/ghoul-rush/core/ghoul-run.js` | Ghoul Rush's run flow (no imports: `ghoul.js` hands its rules `RUN_KIT`, the room and stage tables, the timings and the helpers that set a room up, and binds them): `newRound`, `setupRoom`/`resetRoom`, the stage pick (`stagesLeft`, `nextRoom`, `steerPick`, `pickStage`), the stage select for testing (`openSelect`, `steerSelect`, `takeSelect`: a practice round, `round.practice`, that keeps no best score or record), `camera`, `respawn`, `lockArena`, `clearRoom`, and a room's monster supply (`spawners`, `horde`, `hurry`). `ghoul.js` re-exports `newRound`, `stagesLeft`, `steerPick`, `pickStage`, `steerSelect` and `takeSelect`, and its game answers `stageSelect()`. Split from `ghoul.js` to keep it under the 3,000-line cap, with the same random draws in the same order |
|
||||
| `public/activities/ghoul-rush/core/ghoul-dice.js` | Ghoul Rush's Lucky die rules (no imports: `ghoul.js` hands them `DICE_KIT`): `MAX_DICE` (9, the most one bonus or ride pays; dice in hand have no limit), `ROLL_MS`, `TUMBLE_MS`, `SAVED_TIME_MS`, `markRest` (the last solid ground Planny stood on), `reviveSpot`, `beginRoll` (called by `lose` when `round.dice > 0` and not `round.infinite`: the round holds in the phase `ask` and asks "Use a Lucky Die?", the event `diceAsk`), `askStep`, `steerAsk`, `answerAsk` (Yes spends one die and holds in the phase `roll`; No keeps every die, the event `diceKeep`, and lets the loss go ahead; a press inside `ASK_GUARD_MS` is ignored so the key held at the death cannot answer), , `rollDice` (one die at a time from advance's `random`, events `diceStart`, `diceRoll`, `diceFace`, `diceSaved`, `diceFail`; a six revives with the Garlic shield and `SAFE_MS`, and blows apart every monster in view in a room without a boss (`diceBlast`, kills with `how: "luck"`, points but no drops); no six hands the loss back to `takeLife`) |
|
||||
| `public/activities/ghoul-rush/core/ghoul-bonus.js` | Ghoul Rush's bonus rounds, the rules (imports only `MAX_DICE`; no random numbers): a room with `bonus: true` (the Runaway Cart; the Carnival's dark ride is meant to follow) gets `round.bonusRound = { hearts, max, dice, over, won, perf }` on entering it (null elsewhere; `round.bonus` is already the time bonus score). A life lost in it is a heart lost through the same `lose`/`takeLife` (so Garlic, the safe moment and `round.infinite` work as ever; no Lucky die is rolled for a heart); the last heart gone calls `endBonus(round, false)` from `respawn` (no dice, no game over, the run's lives untouched), and a finish alive calls `endBonus(round, true)` from `clearRoom` (`diceFor`: `BONUS_FLOOR` 3 plus up to 6 by hearts, clean obstacles, acts and a steady hand, added to `round.dice`, which has no limit). A room's pack notes its performance in `bonusRound.perf` (`total`, `hits`, `acts`, `goal`, `steady`); both ends hold the phase "clear" for the card (`CARD_MS`, `CARD_LOST_MS`) and set `bonusRound.result`. Events `bonusStart`, `bonusEnd`; `heartsText(b)` is the HUD pill |
|
||||
| `public/activities/ghoul-rush/core/ghoul-bonus-draw.js` | The bonus rounds' art (`bonusArt(d, die)`): `card` ("BONUS CLEARED! +N LUCKY DICE" with the dice tumbling in, or the short "BONUS LOST"), `react` (the intro banner, the end, the hearts-left float) and `tick` (a click for each die landed) |
|
||||
| `public/activities/ghoul-rush/core/ghoul-dice-draw.js` | The Lucky die's art (`diceArt(d)`: the small drop, the rolling die on a panel placed away from Planny, the `ask` panel ("Use a Lucky Die?" with YES and NO, the lit one gold), the sweeping "LUCKY-SAVE" word, and `react` for the dice events, which plays `ghoulLuckySave` once on the revive) |
|
||||
| `public/activities/ghoul-rush/story/ghoul-gameover-draw.js` | The lost end screen's "G A M E - O V E R" (`gameOverBanner(d)`, `dropAt`): nine letters dropping in with a stagger and one bounce, then bobbing on a sine wave under a slow pulse, red and bone with a dark shadow, drawn above the score panel and never on a win. `ghoul.js` keeps ticking the clock on the lost end screen (`view.overMs`) and plays the mechanical laugh track there: `ghoulLaughTrack`, `ghoulLaughTrack2` and `ghoulLaughTrack3` in `ghoul-sfx.js`, one second apiece (a tone may not pass 1.2 s). |
|
||||
| `public/activities/ghoul-rush/story/ghoul-intros.js` | The stage intro cards' words and colors: `INTROS` per stage id (`title`, `palette` {a, b, glow}, `kicker`, 3 or 4 `lines` of flavor text at most `MAX_LINE` characters, `boss`), `introFor(id)`. Always addressed to YOU. A test fails for a stage in `STAGES` with no card. |
|
||||
| `public/activities/ghoul-rush/story/ghoul-intro-draw.js` | The intro card's drawing (`introArt(d)`, `titleLayout`, `dropAt`): the title's letters dropping in and glowing, one themed flourish per stage (frost crystals, bunting, pickaxe sparks, leaves, candle flames, ...), the lines fading in, the boss and the pulsing "Press any move key or fire to enter". Drawn over the field while `round.phase === "intro"`. The phase itself lives in `ghoul-run.js` (`startIntro`, `stepIntro`, `takeIntro`, `INTRO_MIN_MS` 1.2 s: any fresh move key, fire or a click moves on after it, repeats never, and the card never moves on by itself); the tone is `ghoulStageIntro`. |
|
||||
| `public/activities/ghoul-rush/story/ghoul-boss-intros.js` | The boss intro cards' words: `BOSS_INTROS` per boss id (`name`, which must equal the boss's `name` in its pack's `bosses` table, an `epithet` of at most `MAX_EPITHET` characters and an optional `accent` color), `bossIntroFor(id)`. A test fails for a boss room whose boss has no entry. |
|
||||
| `public/activities/ghoul-rush/story/ghoul-bossintro-draw.js` | The boss intro card's drawing (`bossIntroArt(d)`): a "BOSS FIGHT" title whose letters slam in with a screen shake and a heartbeat pulse, the boss drawn from its own art (`BOSS_ART`, the way the stage pick does) at a big scale in a spotlight on the stage's palette, its name, the epithet and the pulsing "Press any move key or fire to start the fight"; a boss whose art throws falls back to a silhouette. Drawn over the field while `round.phase === "bossintro"`. The phase lives in `ghoul-run.js` (`startBossIntro`, run by `enter` on every boss room, and `onCard`; it shares `introMs`, `stepIntro`, `takeIntro` and `INTRO_MIN_MS` with the stage card, and a respawn never shows it); the tone is `ghoulBossIntro`. |
|
||||
| `public/activities/ghoul-rush/draw/ghoul-monsters-draw.js` | The generic monsters' art (`monsterArt(d)`, no imports; `ghoul-draw.js` hands it its helpers `ellipse`, `circle`, `line`, `rotate`, `turned`, `eye` and the colors): `drawZombie`, `drawZombieKin`, `drawHuntsman`, `drawCrawler`, `drawBat`, `drawGhost`, `drawSkeleton`, `drawGourdling`, `drawHound`, `drawSpider`, `drawWraith`, `drawSpitter` and the missiles `drawBoneShape` and `drawGlob`. Split from `ghoul-draw.js` to keep it under the 3,000-line cap |
|
||||
| `public/activities/pills.js` | The pills every game but Mini golf draws along its top (no imports): `drawPill(ctx, x, y, w, h, text, color, fill, textY)` on one opaque dark backing, `PILL`, the same in light and dark and over any scene, a timer's share still left tinted at `PILL_TINT`, and the text in `pillInk(color, tinted)`: the pill's own color when it reads at `PILL_CONTRAST` (4.5:1) on the backing (and on the tint while a timer runs), else the least step toward white that does, so warnings stay red; lives are the one solid pill: a pill in the `LIVES` color is drawn on `LIVES_BACK` in white (`LIVES_INK`), its text from `livesText(n)` (a heart per life up to five, `♥ xN` past that, `♡` at none); `pillTint` and `pillContrast` for the unit suite |
|
||||
| `public/activities/golf.js` | Mini golf: six eighteen-hole courses, one round at a time; its rules and physics as plain exported functions (`newRound(courseId)`, `holesOf`, `coursePar`, `strike`, `advance` on a fixed 4 ms sub-step, `nextHole`, `total`, `toPar`, `predictPath` for the spyglass, `moverAt`, `gateShut`, plus ice that barely slows the ball and wells that pull it in or push it away), the `POWERUPS` held for the next putt (`round.held`, then `round.active` for that putt), the arcade swing (`startSwing`, `setPower`, `meterAt`, `meterZone`, `swingShot`: a ping-pong power meter, slow at the bottom and fast at the top, with a MAX band that boosts and an overswing band that shanks; a shot clock in `advance()` that starts the meter after `SHOT_CLOCK_MS` and dribbles the ball after `METER_TRIPS` trips; all on the round's own clock), the pop-up gags, and the game contract with `pointer()` (the aim follows the pointer, a press swings, a press held on a roll fast-forwards), `release()` (held arrows turn the aim, held space fast-forwards) and `lowerIsBetter`, `courses` (the dashboard's cards), `preview(canvas, id, w, h)` (a course's card art) and `setCourse(id)`; deterministic (no `Math.random()`), a read-only `round` getter for the unit suite only |
|
||||
| `public/activities/golf-draw.js` | Mini golf's drawing: `drawCourse(ctx, view)` from a plain view `golf.js` builds, each hole in its theme's fixed palette (`pirate`, `cave` with its darkness and glows, or a newer course's look from `golf-looks.js`, asked first for its grounds, water, tunnels, gates and wells), ice, the scorecard and banners in the course's voice, a bare view for the dashboard's card art, `knownGround`/`knownLiquid` for the unit suite, and `readColors(canvas)`, which reads the `--golf-*` properties `styles/activities.css` mixes from the tokens for the ball, pills and scorecard; decides nothing |
|
||||
@@ -397,9 +412,9 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `public/state.js` | the page's shared state (`page.S` the server's truth, `page.local` what is staged) and the `redraw()` / save hooks every screen calls; defines only |
|
||||
| `public/tones.js` | the activities' sound engine, all synthesized in the browser. Three parts: a shared kit of rich one-shot sounds (`RICH`: `layers` of parts played together, each a wave or a noise (`noise`, `pink`, `brown`) with its own `delay`, `gain`, `attack`, a sweeping `filter` and `vibrato`: `explode`, `smash`, `skid`, `whoosh`, `splashBig`, `fanfare`, `gameOver` and some fifty more, up to 1.2 s, at most `MAX_VOICES` parts sounding at once), held **hums** (`hum(id, name, level, pitch)`, called every frame a game wants it: oscillators and noise through one filter that follows the pitch, pulsed for an engine's strokes; a hum not asked for within `HUM_HOLD_MS` fades by itself, so a paused or closed game goes quiet without saying so, `hushTones()` quiets every one and the Activities window calls it whenever it stops ticking; at most `MAX_HUMS`; shared ones `car`, `toycar`, `electric`, `outboard`, `river`, `wind`, `cycle`, `fuse`, `haunt`, `squeal`, `meter`, `swarm`, `train`, `crowd`), and each game's own extras in `public/activities/<id>-sfx.js` (`{ tones, hums }`, plain objects, names prefixed with the game id, merged and frozen here; a name may be defined once across all of them, which `scripts/test-web-console-tones.mjs` checks along with every spec's shape and every name a game's source asks for). Everything plays through one compressor. The older single blips (`BLIPS`): `tone(name, level, pitch)` with an optional loudness from 0 to 1 and an optional pitch that scales every frequency, kept between 0.25 and 4, `unlockTones()`; Snake's blips plus golf's `putt`, `wall`, `bump`, `cup`, `ace` (a three-note rise), `splash`, `power` (a power-up, three notes), `tunnel`, `boom` (a cannon putt), `sizzle` (lava) and `fall` (the pit), the countdown's `count` and `go`, Stack Deploy's `thunk`, `slice` and `perfect`, which it pitches up a scale step for each perfect in a row, and Bumper Ring's `ram`, pitched and leveled by how hard the hit, and `rev`, a rival winding up a dash, and Hot Potato's `tick`, the fuse, which it ticks quicker and pitches higher as the fuse burns down, and `pop`, a pass, and Crossing Rush's `hop`, which it pitches up a step for each quick hop forward in a row, `boing`, a send-back, `bell`, a train coming, and `horn`, and Bounce Road's `engine`, a soft low triangle hum it plays every few frames while you pick up speed (quiet once you cruise or coast), pitched up with your speed, `spring`, a jump, pitched with your speed, and `squash`, a rival flattened, pitched up a step for each in a chain, and `beat`, a low thump while your wheels run on the verge (it borrows the other games' blips for its hazards and rivals), and Rapids Run's `pew` (a shot, a short soft triangle played quietly about seven times a second while fire is held), `charge` (a buoy taken), `lowcell` (the low battery's two-note beep, quicker the lower it runs), `dambreak` (a dam bursting) and `skim` (a bank skimmed at speed, pitched up the more you have skimmed), and Ghoul Rush's `ghoulBlast` (the blaster's bolt, a short soft triangle repeated while fire is held), `zombiePop` (a kill, pitched up a step for each in the chain), `ghoulStomp`, `ghoulBoo`, `ghoulRoar` and `zombieGroan` (now kept for the other games and the tests: Ghoul Rush's monsters speak with their own voices from `ghoul-sfx.js`), `ghoulCandy` (pitched up for candy in quick succession), `batSwoop` (a bat's kill), `doorUnlock` (the key), `doorThrough` (the door to the next room) and `creakBoard` (a crawler coming up, a chandelier or a crumbling board about to go), all soft triangles and sines), silent while Play sounds is off; separate from `sound.js`'s cue queue |
|
||||
| `public/music.js` | the games' chiptune music: a small sequencer over `tones.js`'s context and compressor (`audioOut()`). A game calls `music(name, intensity)` from its `tick`; the track fades out within `MUSIC_HOLD_MS` once it stops being asked for, picks up again on the bar it left, asking for a different track crossfades the two over `CROSSFADE_S` (the old one keeps playing as it fades, so a new level is not a cut), and `hushMusic()` stops it at once. Tracks are note data under `music` in each game's `activities/<id>-sfx.js` (`{ bpm, rush, voices, patterns, order }`: pulse, triangle and noise-drum voices, each joining once the intensity reaches its `from`; a step a token, `A4`, `-` to hold, `.` a rest, `A3^037` an arpeggio, drums `k s h o`), read by `compileTrack()` and booked `LOOKAHEAD_S` ahead on the audio clock. The window plays it only while Play sounds, Play game sounds and Play game music (`looks.gameMusic`, off by default) are all on |
|
||||
| `public/activities/snake-sfx.js` · `public/activities/golf-sfx.js` · `public/activities/trails-sfx.js` · `public/activities/bugs-sfx.js` · `public/activities/drive-sfx.js` · `public/activities/stack-sfx.js` · `public/activities/bumper-sfx.js` · `public/activities/rapids-sfx.js` · `public/activities/fuse-sfx.js` · `public/activities/hop-sfx.js` · `public/activities/bounce-sfx.js` · `public/activities/ghoul-sfx.js` | each game's own sound effects as data, `{ tones, hums }` in the shapes `tones.js` documents, every name prefixed with the game id (`driveEngine`, `ghoulMoan`), merged and frozen by `tones.js`; no imports, but for `ghoul-sfx.js`, which merges each Ghoul Rush stage's own `ghoul-sfx-<stage>.js` into its `tones`, `hums` and `music` |
|
||||
| `public/activities/ghoul-sfx-graveyard.js` | The Graveyard's own sounds as data (no imports): `GRAVEYARD_SFX`, its `tones` (the picked `ghoul<Kind><Act>` sounds of the grasping hands, mourners, grave robbers, rotters and their legs, carrion crows and Mother Mourning) and `music` (`ghoulLychgate`, `ghoulGraves`, `ghoulMausoleums`, `ghoulAngel`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own. Every new stage gets its own `ghoul-sfx-<stage>.js`, listed in `STAGE_SFX` there |
|
||||
| `public/activities/ghoul-sfx-grounds.js` | The Grounds' own sounds as data (no imports): `GROUNDS_SFX`, its `tones` (the 32 picked `ghoul<Kind><Act>` sounds of the topiary beasts, rootlings, lantern moths, mulch crawlers, the Groundskeeper and the Hedge shears' snip) and `music` (`ghoulMaze`, `ghoulTopiary`, `ghoulGazebo`, `ghoulYard`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own via `STAGE_SFX` |
|
||||
| `public/activities/snake-sfx.js` · `public/activities/golf-sfx.js` · `public/activities/trails-sfx.js` · `public/activities/bugs-sfx.js` · `public/activities/drive-sfx.js` · `public/activities/stack-sfx.js` · `public/activities/bumper-sfx.js` · `public/activities/rapids-sfx.js` · `public/activities/fuse-sfx.js` · `public/activities/hop-sfx.js` · `public/activities/bounce-sfx.js` · `public/activities/ghoul-rush/sfx/ghoul-sfx.js` | each game's own sound effects as data, `{ tones, hums }` in the shapes `tones.js` documents, every name prefixed with the game id (`driveEngine`, `ghoulMoan`), merged and frozen by `tones.js`; no imports, but for `ghoul-sfx.js`, which merges each Ghoul Rush stage's own `ghoul-sfx-<stage>.js` into its `tones`, `hums` and `music` |
|
||||
| `public/activities/ghoul-rush/stages/graveyard/ghoul-sfx-graveyard.js` | The Graveyard's own sounds as data (no imports): `GRAVEYARD_SFX`, its `tones` (the picked `ghoul<Kind><Act>` sounds of the grasping hands, mourners, grave robbers, rotters and their legs, carrion crows and Mother Mourning) and `music` (`ghoulLychgate`, `ghoulGraves`, `ghoulMausoleums`, `ghoulAngel`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own. Every new stage gets its own `ghoul-sfx-<stage>.js`, listed in `STAGE_SFX` there |
|
||||
| `public/activities/ghoul-rush/stages/grounds/ghoul-sfx-grounds.js` | The Grounds' own sounds as data (no imports): `GROUNDS_SFX`, its `tones` (the 32 picked `ghoul<Kind><Act>` sounds of the topiary beasts, rootlings, lantern moths, mulch crawlers, the Groundskeeper and the Hedge shears' snip) and `music` (`ghoulMaze`, `ghoulTopiary`, `ghoulGazebo`, `ghoulYard`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own via `STAGE_SFX` |
|
||||
| `public/uploads.js` | pictures and documents attached to a note: chips, trays, re-encoding, upload, retry, and the page's shared full-screen picture preview (`openPicview`, the `#picview` dialog every thumbnail opens) |
|
||||
| `public/screens/ask.js` | the Ask chat, the Subagents tab, and attaching files to notes |
|
||||
| `public/screens/cards.js` | question cards: every kind, the pager, settled and in-flight records |
|
||||
@@ -528,11 +543,11 @@ Key design points:
|
||||
- **The Quick question chat is a second, append-only channel beside the card slot.** The page's **Ask** tab (always last, every workflow, still there after a finish) posts to `POST /chat` (a message, or `{ reset: true }` for New conversation) and `POST /chat/decision` (Approve / Decline on an edit the agent proposed). The server is the only writer of `<sid>/chat.ndjson` (one JSON line per `message` / `decision` / `reset`, each with a `seq`; `appendChat()` in `inbox.mjs`); `console.mjs` is the only writer of `<sid>/chat-cursor.json` (the last seq handed over, advanced only after printing) and of the agent's replies in `state.json` → `chat.replies` (merged by `id`, checked by `validateChat()`: real `re`, proposal paths outside the running `specs/<idea>/`). The server never writes chat into `state.json` — `post` read-modify-writes it under `withStateLock()` — and `stateFrame()` merges inbox and replies into the frame's `chat` block (`conversation`, `messages`, `typed`, `limit`, `offline`) in memory. `/chat` never checks `pendingResult()`, so neither channel can block the other. `wait` keeps its exit codes 0/10/20/30: exit 0 gains `chat` (or is `type: "chat"` with no actions), and the instant `console.mjs chat` answers 0/10/20 without touching `result.json`, which builds run after every task. Guards: 10 typed messages per conversation (`409 limit`), 4,000 characters (`400 too-long`), own uploads only, of the right kind (`400 image`, `400 file`), `409 offline` when `chatOffline()` says no agent is there, `409 stale` for an old conversation. A hop through the dashboard keeps the conversation: `switchWorkflow()` carries `chat.replies` across and the page keeps its Ask state, so only New conversation appends a `reset` after the opening one. A lone reset never ends a `wait` slice (`deliverableChat()`); it rides along with the next message.
|
||||
- **`validate()` in `patches.mjs` enforces four workflow rules mechanically**: max three open required questions, no internal vocabulary in a title, one recommended option, and no loop markers or metrics-scraper bait.
|
||||
- **The palette is written twice for dark, and that duplication is the mechanism.** `@media (prefers-color-scheme: dark) :root:not([data-theme="light"])` follows the system; `:root[data-theme="dark"]` is the explicit choice from the colors panel. Drop the `:not()` and a system-dark browser overrides someone who asked for light. A chosen accent is applied as an inline custom property on `:root` (CSSOM, which the CSP allows), and the default is applied by REMOVING that override so the stylesheet's own per-theme values win. The server's `data-looks-accent` stand-in only lasts until `applyLooks()` runs, which removes it first thing — left on, its rule would beat "Back to default".
|
||||
- **Help is in the page, built on first open.** The **?** button (`#btn-about`) opens `<dialog id="help-modal">`, which replaced the old "What this page is" About dialog. Its 20 panels and their icon sheet are hand-written HTML and SVG in `<template id="help-content">` in `index.html` (after `#start-poses`), cloned into `#help-panels` the first time **?** is pressed (except the dashboard topic's card list: `buildHelp()` fills its `.help-cards` from `SKILL_CATALOG` and `CATALOG_GROUPS` at that moment, in the dashboard's order), so first load builds nothing and Help still reads fully once the server is gone. `help.js` supplies the tab list and rules, `screens/help-dialog.js` the wiring (tab buttons, roving focus, `renderAbout()` for the live connection line on tab 1, `lightDismiss()`, and a Ctrl/⌘+Enter guard scoped to this dialog). SVG is styled by class and CSS variables only — a `style=` attribute is dropped by the CSP, and a test fails on one — and every number the prose quotes sits in a `data-fact` span a test checks against the constant it comes from.
|
||||
- **Help is in the page, built on first open.** The **?** button (`#btn-about`) opens `<dialog id="help-modal">`, which replaced the old "What this page is" About dialog. Its 21 panels and their icon sheet are hand-written HTML and SVG in `<template id="help-content">` in `index.html` (after `#start-poses`), cloned into `#help-panels` the first time **?** is pressed (except the dashboard topic's card list: `buildHelp()` fills its `.help-cards` from `SKILL_CATALOG` and `CATALOG_GROUPS` at that moment, in the dashboard's order), so first load builds nothing and Help still reads fully once the server is gone. `help.js` supplies the tab list and rules, `screens/help-dialog.js` the wiring (tab buttons, roving focus, `renderAbout()` for the live connection line on tab 1, `lightDismiss()`, and a Ctrl/⌘+Enter guard scoped to this dialog). SVG is styled by class and CSS variables only — a `style=` attribute is dropped by the CSP, and a test fails on one — and every number the prose quotes sits in a `data-fact` span a test checks against the constant it comes from.
|
||||
- **Stuck sessions are explained twice, in Help and on the status line.** `stuck` ("When something looks stuck") is the second tab in `HELP_TABS`; its panel opens with a `help-callout` ("Check this first": Plan2Code often waits for a permission in the terminal, which the page cannot see) and four You see / Likely cause / Do this rows before the diagram. The quiet and Not running status lines carry a "What to check" button (`openHelpOn("stuck")`) inside the existing `role="status"` element, so it exists only while the symptom shows. Every finished and paused screen gets a "Before you close this" panel from `renderCloseGuide()` in `renderHandoff()` (Safe to close, Start fresh, Carry on). Tests in `scripts/test-web-console-source.mjs` check the tab order, the callout and rows, and the `renderCloseGuide` call.
|
||||
- **Markdown is rendered to DOM nodes, never to an HTML string** (`public/render.js`), so agent-authored text that quotes a hostile source cannot execute. Only `marked.lexer()` is used.
|
||||
|
||||
Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --build-skills`, `parse-check.mjs`, `check-skill-table.mjs`, then one `node --test` over the skill-script tests (`test-skill-scripts.mjs`, `test-script-*.mjs`, `test-git-repo.mjs`), `test-launcher.mjs`, `test-getting-started.mjs` and the web console's `test-web-console-*.mjs`, so they run in parallel, one process each. The console tests are split by area (`-session`, `-lifecycle`, `-logic`, `-server`, `-chat`, `-chat-stress`, `-workspace`, `-subagents`, `-concurrency`, `-source`, `-git`, `-qa`, `-speed`, `-hardening`). Their shared setup is `scripts/web-console-test-helpers.mjs`: importing it gives the file its own console home (so `workspaces.json`, `subagents.json`, `looks.json` and sessions never collide across files) and registers the `stop --all` cleanup. `-session` and `-lifecycle` each run an ordered chain of tests on one session of their own; everything else opens a session per test. A new test goes in the file for its area, after the tests it depends on. The parse check exists because `node --check` parses a `.js` file as a CommonJS script and has already let a browser-fatal string literal through; it imports each shipped module as a real ES module instead. They live in `scripts/`, not `src/web-console/`, because everything under the latter ships into every skill.
|
||||
Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --build-skills`, `parse-check.mjs`, `check-skill-table.mjs`, then one `node --test` over the skill-script tests (`test-skill-scripts.mjs`, `test-script-*.mjs`, `test-git-repo.mjs`), `test-launcher.mjs`, `test-getting-started.mjs` and the web console's `test-web-console-*.mjs`, so they run in parallel, one process each. The console tests are split by area (`-session`, `-lifecycle`, `-logic`, `-server`, `-chat`, `-chat-stress`, `-workspace`, `-subagents`, `-concurrency`, `-source`, `-shape`, `-git`, `-git-board`, `-qa`, `-speed`, `-hardening`, `-embed`, `-handoffs`, `-in-app`, `-loop`, `-notepad`, `-pointers`, `-skills`, `-spec-states`, `-state`, `-tones`), plus the `-page-*` browser suites and the per-game `-activities*` suites. Their shared setup is `scripts/web-console-test-helpers.mjs`: importing it gives the file its own console home (so `workspaces.json`, `subagents.json`, `looks.json` and sessions never collide across files) and registers the `stop --all` cleanup. `-session` and `-lifecycle` each run an ordered chain of tests on one session of their own; everything else opens a session per test. A new test goes in the file for its area, after the tests it depends on. The parse check exists because `node --check` parses a `.js` file as a CommonJS script and has already let a browser-fatal string literal through; it imports each shipped module as a real ES module instead. They live in `scripts/`, not `src/web-console/`, because everything under the latter ships into every skill.
|
||||
|
||||
**Adding a file under `public/`:** a page module needs `SERVABLE` in `static.mjs` and a `<link rel="modulepreload">` in `index.html`. The set is hardcoded rather than a directory lookup so there is nothing to traverse; a module missing from it 404s and the page dies at import with no useful error (the import-fetch test fetches every import and fails naming the file). A module missing its preload still works, but loads serially after `app.js` and slows the first paint. A screen goes in `public/screens/`, imports only `state.js` and the pure modules (never another screen), and is imported by `screens/core.js`; the import guard in `scripts/test-web-console-shape.mjs` fails naming a screen that breaks either rule. A stylesheet goes in `public/styles/` and on `CSS_ORDER` in `static.mjs`, never on `SERVABLE`; the joined-stylesheet test fails when the folder and the list disagree. Every new file also needs its row in the files table above, which the docs-table test (same file) checks.
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
- **`.claude/skills/` is tracked:** a new repo-local skill only needs `git add` (see Architecture → Repo-Local Skills). A correction that is a workflow belongs there as a skill, linked from AGENTS.md, not as a Failure log line.
|
||||
- **Workflow file character limit:** All `src/plan2code-*.md` files (and the dashboard prompt `src/plan2code.md`) must be ≤ 20,000 characters (about 5k tokens, the usual Agent Skills guidance for a SKILL.md body). A husky pre-commit hook enforces this, and `plan2code-metrics` (`improver.ts`, `applier.ts`) applies the same number to proposed prompt edits, so change them together. History: 11,000 originally (headroom under Windsurf's old 12,000-char limit for platform-specific files, gone since 2.1.0's single-format build), 11,500 in 2.4.0, 20,000 in 2.4.1. The limit is now a prompt-size discipline only: the whole SKILL.md loads on every invocation while references load on demand, so situational detail still belongs in a reference file, and anything with one correct answer belongs in a script (see Skill scripts in the architecture doc).
|
||||
- **Keep LF line endings:** `.gitattributes` pins `eol=lf` because `validate-char-count.js` counts the characters on disk, and a CRLF checkout adds about one per line to every prompt. Measure with `node scripts/validate-char-count.js` before trusting a near-limit prompt. Git never writes CRLF here, but tools do (Python writing in text mode on Windows, some editors and generators), so `scripts/fix-line-endings.mjs` puts every text file git sees back to LF: `npm run fix:eol` by hand, `--check` to only list, and it runs by itself as npm's `pretest`, in the husky pre-commit before the char count, and after every Write or Edit through the PostToolUse hook in `.claude/settings.json`. In a Python script that writes repo files, open them with `newline="\n"` (or write bytes) anyway.
|
||||
- **The pre-commit hook runs only the char-count check:** `.husky/pre-commit` is `node scripts/validate-char-count.js` alone. `skills/` drift, parse errors and test failures are caught only by the tests, so run them before committing: the targeted suites for a change that stays in one area, the full `npm test` for shared code or before a PR (see "Targeted tests first" in [Development Commands](./AGENTS-development-commands.md)). Sub-package tests are separate; see [Development Commands](./AGENTS-development-commands.md).
|
||||
- **The pre-commit hook runs the LF fix, then the char-count check:** `.husky/pre-commit` is `node scripts/fix-line-endings.mjs` followed by `node scripts/validate-char-count.js`. `skills/` drift, parse errors and test failures are caught only by the tests, so run them before committing: the targeted suites for a change that stays in one area, the full `npm test` for shared code or before a PR (see "Targeted tests first" in [Development Commands](./AGENTS-development-commands.md)). Sub-package tests are separate; see [Development Commands](./AGENTS-development-commands.md).
|
||||
- **`skills/` is generated build output (gitignored):** edit `src/` only. The installer rebuilds `skills/` on every run, so it is always up to date at install time. `npm test` runs `install.js --build-skills` so a broken `SOURCE_PROMPTS` entry or unreadable source fails CI. Never hand-edit `skills/`; `install.js --verify-skills` can diff a stale tree against `src/` when diagnosing.
|
||||
- **Metrics internal prompts have no char limit:** Files in `plan2code-metrics/src/prompts/` are NOT subject to the 20,000 char limit — only `src/plan2code-*.md` consumer-facing prompts are.
|
||||
- **User Feedback table format:** The `## User Feedback` markdown table in `overview.md` has a strict format the collector regex depends on. Field names must be exactly `Rating`, `Reason`, `Went Well`, `Went Poorly`. Pipe characters in values must be escaped as `\|`.
|
||||
- **User Feedback table format:** The `## User Feedback` markdown table in `overview.md` has a strict format the collector regex depends on. Field names are matched case-insensitively; the house form is `Rating`, `Reason`, `Went Well`, `Went Poorly`, and `Rating` must parse to an integer from 1 to 10. Pipe characters in values must be escaped as `\|`.
|
||||
- **PLAN-DRAFT confidence numbers are scraped by regex:** `collector.ts` scrapes the latest `specs/<feature>/PLAN-DRAFT-*.md` prose. Overall confidence falls back to prose only when `<!-- METRICS_JSON ... -->` lacks `confidence` (`collector.ts:186-196`): `Confidence: 95%`, or a table row `| Confidence | 95` with no `%`. The four *breakdown* patterns (`collector.ts:200-203`) run on every draft, METRICS_JSON or not: `/[Rr]equirements?[:\s|]+(\d{1,2})/` and its siblings match a bare dimension word followed by whitespace, a colon, or a pipe and then digits. So a PLAN-DRAFT written by anything other than `/plan2code-1-plan` Phase 7 must keep `Confidence` followed by a number (with `%`, or as a table row) **and** bare `Requirements` / `Feasibility` / `Integration` / `Risk` followed by a number off the page — including innocent table rows like `| Requirements | 11 |`. Otherwise the metrics pipeline records a planning-step confidence that no planning step produced. `/plan2code-0-pathfinder` works around this by hyphenating the labels (`Requirements-clarity 22/25`), which breaks the character class.
|
||||
- **Web console result-handoff invariant:** `result.json` holds answers a person pressed Send on. **An uncollected result (no `consumedAt`) is never overwritten and never deleted.** `/submit` and `/cancel` return 409 while one is pending, `open` clears the file only when it is already consumed, and `wait` stamps `consumedAt` **after** printing the result, never before, and exits by setting `process.exitCode` rather than calling `process.exit()`. That ordering is deliberate: an agent harness that kills a long shell command must not be able to land between "marked collected" and "handed over", and `process.exit()` can truncate an unflushed pipe. A repeat delivery is recoverable, a lost one is not. Two separate data-loss bugs came from breaking this in different places, and both were silent: the person sees "Sent", the agent never receives it. Any new code path that touches `result.json` must preserve the invariant, and `scripts/test-web-console-lifecycle.mjs` guards it (its "result handoff (regressions)" tests). Related: the server writes each submitted answer onto its item as `submitted`, and `validate()` in `patches.mjs` must keep excluding that field from the completion-marker and metrics-scraper scans, which are meant for agent-authored text only. A person who typed `TASK_COMPLETE` into an answer would otherwise make every later patch unpostable.
|
||||
- **Web console oversized bodies:** `readBody()` and `readRaw()` (the `POST /upload` reader) in `routes.mjs` drain the rest of the body past `MAX_BODY` instead of calling `req.destroy()`, so an oversized body gets a 413 rather than a connection reset, and memory still stays capped. A new body reader must drain the same way.
|
||||
|
||||
@@ -23,6 +23,10 @@ npm run play
|
||||
# dashboard skill-table check, web console + launcher + getting-started node:test suites
|
||||
npm test
|
||||
|
||||
# Put every text file git sees back to LF (also runs by itself as pretest and in
|
||||
# the pre-commit hook); --check only lists
|
||||
npm run fix:eol
|
||||
|
||||
# One web console or launcher test
|
||||
node --test --test-name-pattern "<regex>" scripts/test-web-console-<area>.mjs
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Web Console Contract: the Why
|
||||
> Part of [AGENTS.md](../AGENTS.md): project guidance for AI coding agents.
|
||||
|
||||
Maintainer notes for the agent-facing console docs in `src/web-console/`. Installed skills never ship or load this file (nothing under `.agents-docs/` is in `install.js` `additionalReferences`), and the shipped files carry only what an agent must do. Put an explanation here, not there. If a shipped file starts to explain, move the sentence into this file and keep the instruction.
|
||||
|
||||
The shape: a short card (`console.md`) read once per session, topic files the console names in its own `read` output at the moment each is due, and refusals for the silent slips the console can see. Size budgets in `npm test` stop the docs growing back (Phase 7 of `specs/console-wire-format`).
|
||||
The shape: a short card (`console.md`) read once per session, topic files the console names in its own `read` output at the moment each is due, and refusals for the silent slips the console can see. Size budgets in `npm test` stop the docs growing back (Phase 7 of `specs--completed/console-wire-format`).
|
||||
|
||||
## Why pointers and refusals instead of repeated rules
|
||||
|
||||
@@ -69,6 +70,10 @@ A session handed over by the dashboard is resumed, never re-opened, because a fr
|
||||
|
||||
The meter is advice, not a gate: it tells the person when a fresh session would be sharper. Per-unit work is reported by the agent with `run`; the same `id` is ignored in the same run so a repeat never double counts.
|
||||
|
||||
## console-attachments.md
|
||||
|
||||
Attachments live in the session folder and are swept with it, so a spec file that cites one keeps it first through `keep`: the file is copied under `specs/<idea>/` and the link the console returns is the durable one. Uncited attachments stay with the session on purpose: a picture sent to answer a question was context for it, not a deliverable. A refused `keep` links nothing, because a spec must never point at a path the sweep removes.
|
||||
|
||||
## Wire format (outputs)
|
||||
|
||||
Outputs carry what the agent acts on and nothing else. Anything kept in the session files (`type`, `at`, `rev`, answer actions, full chat entries, structured workspace and subagents objects) is dropped from stdout. The desktop app reads `sid`, `url`, `pid`, `port` and `embed` from `open` in every context, so those stay. See `specs/console-wire-format/overview.md` (API Design) for the table.
|
||||
Outputs carry what the agent acts on and nothing else. Anything kept in the session files (`type`, `at`, `rev`, answer actions, full chat entries, structured workspace and subagents objects) is dropped from stdout. The desktop app reads `sid`, `url`, `pid`, `port` and `embed` from `open` in every context, so those stay. See `specs--completed/console-wire-format/overview.md` (API Design) for the table.
|
||||
+38
-17
@@ -170,7 +170,7 @@ Scroll down for the utilities. Outside a git repository the **Git** card says so
|
||||
turns red if that press was never collected, and goes back to the plain
|
||||
icon once nothing is left, so a console left in a background tab can be
|
||||
checked at a glance.
|
||||
- **Help.** The **?** at the top right opens a Help dialog with 20 topics,
|
||||
- **Help.** The **?** at the top right opens a Help dialog with 21 topics,
|
||||
one per tab down the left (across the top on a narrow window), opening on
|
||||
the one for where you are. It is part of the page itself, so it still reads
|
||||
fully when the page has lost its program.
|
||||
@@ -1302,7 +1302,7 @@ Ghoul Rush at 65).
|
||||
reach the snowbank and you earn three to nine Lucky Dice (hearts left,
|
||||
obstacles passed untouched, things shot and souls and Cocoa taken).
|
||||
**Gallows Bog** is a stage of three walked rooms (the Sunken Boardwalk,
|
||||
Cypress Hollow and the Stilt House), a fan-boat ride and the Drowning Pool.
|
||||
Cypress Hollow and the Stilt House), a bonus round and the Drowning Pool.
|
||||
Its own rule is **mud**: on a span of it Planny sinks the longer he stands,
|
||||
the run sags to a crawl and a jump to a low hop over about two and a half
|
||||
seconds. Dry floor, the air, a board over the mud or **Stilt Boots** (ten
|
||||
@@ -1316,14 +1316,29 @@ Ghoul Rush at 65).
|
||||
six seconds, glows where it will return and then burns again); and the **bog
|
||||
body**, which climbs out of the mud harmless and then shambles. The **Harpoon**
|
||||
is the stage's own weapon (a double tap): it pierces everything in its line
|
||||
and is the one shot that reaches a lurker's eyes under the water. **The Bog
|
||||
Runner** is a fan-boat skim down a black channel with a swarm of leeches
|
||||
boiling up in your wake: switch between the open channel and the mud flats at
|
||||
the banks, jump snags and cypress knees, duck moss veils and low limbs, and
|
||||
shoot the hag's charms and the gas pockets (a pocket's burst pushes the swarm
|
||||
back). Easing off, the mud flats and a fan clogged with mud let the swarm
|
||||
gain, and at your heels it takes a heart. Like the other rides it plays for five
|
||||
hearts of its own and ends with three to nine Lucky Dice. The boss is **Old
|
||||
and is the one shot that reaches a lurker's eyes under the water. **The
|
||||
Drowned Lantern** is the first bonus round that is not a ride: a top-down game
|
||||
on one screen, an island of mossy hummocks and plank walks round Old Mother
|
||||
Bog's pool, which you cross with a lantern to light five wisp shrines (stand
|
||||
on a shrine's stone for two seconds) and then run back to the boat you came
|
||||
in. The arrows walk; Space flares the lantern, a ring of light that bursts
|
||||
every wisp in it and scatters the leeches, at the price of some oil and a bang
|
||||
the Lurker hears from anywhere. The oil burns down and the light shrinks with
|
||||
it; each shrine lit fills it again. Each hunter plays by one rule, shown over
|
||||
it the first time it comes near: the **Bog Lurker** hears steps on the planks
|
||||
(the moss is silent), swims to where it last heard you, then lines up a red
|
||||
lane through that spot and dashes down it (it strikes where it heard you, so
|
||||
step off the lane); a **wisp** circles each unlit shrine and rushes a lantern
|
||||
that comes near it (a flare pops it); the **leeches** follow you at the edge of
|
||||
your light and never come in, until the oil runs out; the **bog bodies** bubble
|
||||
beside the planks and grab only someone who stands still next to them. Old
|
||||
Mother Bog's eyes open a little with every shrine; from the third her hand's
|
||||
shadow finds you now and then (it follows, stops, reddens and slams: keep
|
||||
moving), and the fifth raises her out of the pool for the run to the boat,
|
||||
her slams coming one after another while the Lurker cowers. Like the other
|
||||
bonus rounds it plays for five hearts of its own (with a 90 second clock) and
|
||||
ends with three to nine Lucky Dice (hearts left, hunters that never caught
|
||||
you, wisps popped and close calls, and never letting the flame gutter). The boss is **Old
|
||||
Mother Bog**, who keeps her distance along the planks: she sends a low wave
|
||||
of mud to jump, or spits from her cauldron to leave a muck patch that burns
|
||||
for three seconds (it shows where it will land first). Late in each rest her
|
||||
@@ -1342,8 +1357,11 @@ Ghoul Rush at 65).
|
||||
**1UP**, a **Lucky die** (a white die, dropped by a kill as often as a
|
||||
1UP and never lying in a room; every run starts with three, up to nine are kept for the whole run, shown
|
||||
as a **DICE** pill, and a ninth more is points; when you would lose a life,
|
||||
by any cause but the endless-lives code, one die rolls on the field (the rest
|
||||
are kept). A 4, 5 or 6 brings you back where you fell, or after a pit on the
|
||||
by any cause but the endless-lives code, the game asks **Use a Lucky Die?**
|
||||
(arrows choose Yes or No, Space answers, a click works too; a press in the
|
||||
first moment is ignored so the key you were holding cannot answer). Yes rolls
|
||||
one die on the field (the rest are kept); No keeps every die and loses the
|
||||
life as usual. A 4, 5 or 6 brings you back where you fell, or after a pit on the
|
||||
last ground you stood on, with no life lost and the room as it was: a 5 adds
|
||||
a heart, a 6 a heart and a Garlic shield, and in an ordinary room every
|
||||
monster in view blows apart for its points (in a boss's room nothing does).
|
||||
@@ -1829,11 +1847,14 @@ never the record, `specs/` in your project is.
|
||||
**Or clean up on demand.** *User Preferences → System → Cleanup* → **Find files to
|
||||
clean up** lists, with sizes, everything in `~/.plan2code/` that is not
|
||||
needed: sessions untouched for 30 days (never the one you are in), anything at
|
||||
the top of `~/.plan2code/console/` other than `sessions/`, `looks.json`,
|
||||
`workspaces.json`, `subagents.json`, `console-dir` and `update-check.json`, and anything at the top of `~/.plan2code/` other than
|
||||
`console/`, `bin/`, `launcher.json`, `install.json` (what you installed, which
|
||||
`plan2code update` reads), `models.json`, `handoffs/` (old handoffs go by
|
||||
age, above) and `notepads/`. Each notebook whose newest file is 30 days old or
|
||||
the top of `~/.plan2code/console/` other than `sessions/`, `runtime/`,
|
||||
`looks.json`, `workspaces.json`, `loop-setup.json`, `loop-reports.json`,
|
||||
`subagents.json`, `pr-hosts.json`, `console-dir` and `update-check.json`, and
|
||||
anything at the top of `~/.plan2code/` other than `console/`, `bin/`,
|
||||
`launcher.json`, `install.json` (what you installed, which `plan2code update`
|
||||
reads), `models.json`, `handoffs/` (old handoffs go by age, above),
|
||||
`notepads/`, `app/` and `app.json` (the desktop app and its settings) and
|
||||
`agents.json` (your custom agents). Each notebook whose newest file is 30 days old or
|
||||
more is listed as one item, *Notebook for* its folder, and goes whole; no
|
||||
automatic sweep ever removes one. It also lists each
|
||||
folder in the project's `specs--completed/` whose newest file is more than 30
|
||||
|
||||
@@ -36,7 +36,7 @@ Details: [Architecture](./.agents-docs/AGENTS-architecture.md) (see Status Line
|
||||
|
||||
## Web Console
|
||||
|
||||
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) bundled into every skill via `additionalReferences`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (three tabs, Changes, Branches and Sync, opening on the likely next step; branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (twelve small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road and Ghoul Rush, listed in `public/activities.js` with one module per game under `public/activities/` and a card line (`blurb`) each, a picker page of game cards once two are listed that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run), never shown to the agent), a built-in 20-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, Finalize, Changelog, Git and Handoff) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`), and a Helper strength choice (Balanced, Thrifty, Best, Match my session; rules in `src/shared-references/helper-strength.md`, shipped in the twelve helper skills); the agent hears of it as a standing instruction only when it changes, and reports its helpers in a **Subagents** tab beside Ask (contract in `console-subagents.md`). Per-skill facts live in one list, `public/skills.js`, from which the meter, the resume command, Help's card list and the CLI's workflow list are derived; task files are read through `spec-files.mjs` (shared with the `specs.mjs` skill script), and the rule for which hops startLine truncated
|
||||
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) bundled into every skill via `additionalReferences`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (three tabs, Changes, Branches and Sync, opening on the likely next step; branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (twelve small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road and Ghoul Rush, listed in `public/activities.js` with one module per game under `public/activities/` (Ghoul Rush is its own folder of modules, `public/activities/ghoul-rush/`) and a card line (`blurb`) each, a picker page of game cards once two are listed that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run), never shown to the agent), a built-in 21-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, Finalize, Changelog, Git and Handoff) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`), and a Helper strength choice (Balanced, Thrifty, Best, Match my session; rules in `src/shared-references/helper-strength.md`, shipped in the twelve helper skills); the agent hears of it as a standing instruction only when it changes, and reports its helpers in a **Subagents** tab beside Ask (contract in `console-subagents.md`). Per-skill facts live in one list, `public/skills.js`, from which the meter, the resume command, Help's card list and the CLI's workflow list are derived; task files are read through `spec-files.mjs` (sLine truncated
|
||||
|
||||
One agent list and one lookup rule serve the launcher, the console and the app: `src/launcher/agents.json` (the built-ins and starter templates with per-OS install data) and `src/web-console/agent-lookup.mjs` (`loadAgentList()` and `findAgent()`, both copied by `install.js` into `~/.plan2code/bin/`); the app carries a Rust twin held to the same cases by `scripts/fixtures/agent-lookup-cases.json`.
|
||||
Building or changing an Activities game: follow the game rules in [Architecture](./.agents-docs/AGENTS-architecture.md) ("Building an Activities game": lives in the solid lives pill, the endless-lives code (`cheat(on)`) in every game with lives, banners placed away from the player and see-through over what matters, pausing left to the window).
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"fix:eol": "node scripts/fix-line-endings.mjs",
|
||||
"play": "node scripts/play.mjs",
|
||||
"pretest": "node scripts/fix-line-endings.mjs",
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-bogboat.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gpt-tokenizer": "2.9.0",
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-arms.js";
|
||||
import { rocketArt } from "../src/web-console/public/activities/ghoul-rockets-draw.js";
|
||||
import * as pans from "../src/web-console/public/activities/ghoul-pans.js";
|
||||
import { ARM_DROP, ARM_DROP_OWN, STAGE_ARMS, armDrop, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { ARMS_SFX } from "../src/web-console/public/activities/ghoul-sfx-arms.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { hudLayout, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-arms.js";
|
||||
import { rocketArt } from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-rockets-draw.js";
|
||||
import * as pans from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-pans.js";
|
||||
import { ARM_DROP, ARM_DROP_OWN, STAGE_ARMS, armDrop, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { ARMS_SFX } from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-sfx-arms.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { hudLayout, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-banister.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as bn from "../src/web-console/public/activities/ghoul-banister.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as BAN_LOOKS, VOICES as BAN_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-banister-draw.js";
|
||||
import { BANISTER_SFX } from "../src/web-console/public/activities/ghoul-sfx-banister.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as bn from "../src/web-console/public/activities/ghoul-rush/rides/banister/ghoul-banister.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as BAN_LOOKS, VOICES as BAN_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/banister/ghoul-banister-draw.js";
|
||||
import { BANISTER_SFX } from "../src/web-console/public/activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -743,7 +743,7 @@ test("Ghoul Rush's Grand Banister: off the lip the rider launches, lands on the
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "ballroom");
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
// Pool's boss spec. The monsters' rules, the fight and the ride land in
|
||||
// later phases.
|
||||
import { test } from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as bog from "../src/web-console/public/activities/ghoul-bog.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS, VOICES } from "../src/web-console/public/activities/ghoul-bog-draw.js";
|
||||
import { BOG_SFX } from "../src/web-console/public/activities/ghoul-sfx-bog.js";
|
||||
import { BOSS_INTROS, bossIntroFor } from "../src/web-console/public/activities/ghoul-boss-intros.js";
|
||||
import { INTROS, introFor } from "../src/web-console/public/activities/ghoul-intros.js";
|
||||
import { react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as bog from "../src/web-console/public/activities/ghoul-rush/stages/bog/ghoul-bog.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS, VOICES } from "../src/web-console/public/activities/ghoul-rush/stages/bog/ghoul-bog-draw.js";
|
||||
import { BOG_SFX } from "../src/web-console/public/activities/ghoul-rush/stages/bog/ghoul-sfx-bog.js";
|
||||
import { BOSS_INTROS, bossIntroFor } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-boss-intros.js";
|
||||
import { INTROS, introFor } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-intros.js";
|
||||
import { react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
const ROOM_IDS = ["boardwalk", "hollow", "stilts", "bogboat", "drowning"];
|
||||
const ROOM_IDS = ["boardwalk", "hollow", "stilts", "lantern", "drowning"];
|
||||
|
||||
function through(round) {
|
||||
round.phase = "clear";
|
||||
@@ -85,8 +86,8 @@ test("Ghoul Rush's Gallows Bog is a stage of five rooms ending on the Drowning P
|
||||
});
|
||||
|
||||
test("Ghoul Rush's bog rooms carry the usual pieces: a key, sky treasures, candy, items and a horde in each walked room, mud spans frozen, the ride its own course, the arena the hag's", () => {
|
||||
const [boardwalk, hollow, stilts, bogboat, drowning] = ROOM_IDS.map((id) => ghoul.roomById(id));
|
||||
assert.deepEqual([boardwalk.title, hollow.title, stilts.title, bogboat.title, drowning.title], ["Sunken Boardwalk", "Cypress Hollow", "Stilt House", "The Bog Runner", "The Drowning Pool"]);
|
||||
const [boardwalk, hollow, stilts, lantern, drowning] = ROOM_IDS.map((id) => ghoul.roomById(id));
|
||||
assert.deepEqual([boardwalk.title, hollow.title, stilts.title, lantern.title, drowning.title], ["Sunken Boardwalk", "Cypress Hollow", "Stilt House", "The Drowned Lantern", "The Drowning Pool"]);
|
||||
assert.deepEqual([boardwalk.sub, hollow.sub, stilts.sub, drowning.sub], ["Mind the gaps. Something lives in them", "The moss is breathing", "She has been expecting you", "Keep to the planks, she owns the water"]);
|
||||
for (const room of [boardwalk, hollow, stilts]) {
|
||||
assert.ok(room.key, `${room.id}: a key`);
|
||||
@@ -104,17 +105,18 @@ test("Ghoul Rush's bog rooms carry the usual pieces: a key, sky treasures, candy
|
||||
assert.ok(boardwalk.shelves.some((s) => s[3] === "crumble") && hollow.shelves.some((s) => s[3] === "crumble") && stilts.shelves.some((s) => s[3] === "crumble"), "rotting boards that give way");
|
||||
// The Bog Runner is a stub: a bonus ride with empty obstacle arrays that
|
||||
// Phase 4's deterministic generator fills in.
|
||||
assert.equal(bogboat.bonus, true);
|
||||
assert.equal(bogboat.dark, false);
|
||||
assert.equal(bogboat.key, null);
|
||||
assert.equal(bogboat.boss, null);
|
||||
assert.equal(bogboat.horde.length, 0);
|
||||
assert.equal(bogboat.ride.runner, "bogboat");
|
||||
assert.equal(bogboat.ride.how, "LEFT or RIGHT at a bank: switch lane. UP jump, DOWN duck, SPACE shoot");
|
||||
assert.ok(bogboat.ride.time >= 70000 && bogboat.ride.time <= 120000);
|
||||
assert.ok(bogboat.ride.finish > 0 && bogboat.ride.finish < bogboat.length);
|
||||
assert.ok(bogboat.ride.checks.length >= 1 && bogboat.ride.checks.every((x) => x > 0 && x < bogboat.ride.finish), "checkpoints inside the run");
|
||||
assert.ok(Object.isFrozen(bogboat.ride), "the ride is frozen");
|
||||
assert.equal(lantern.bonus, true);
|
||||
assert.equal(lantern.dark, false);
|
||||
assert.equal(lantern.key, null);
|
||||
assert.equal(lantern.boss, null);
|
||||
assert.equal(lantern.horde.length, 0);
|
||||
assert.equal(lantern.ride.runner, "lantern");
|
||||
assert.equal(lantern.ride.how, "ARROWS walk, SPACE flares. Light 5 shrines, then run to the boat");
|
||||
assert.ok(lantern.ride.time >= 70000 && lantern.ride.time <= 120000);
|
||||
assert.ok(lantern.ride.shrines.length === 5 && lantern.ride.hummocks.length > 5, "an island with five shrines");
|
||||
assert.ok(Object.isFrozen(lantern.ride), "the room is frozen");
|
||||
// The Bog Runner (the fan-boat ride this room replaced) is still defined but no stage lists it.
|
||||
assert.equal(ghoul.roomById("bogboat"), null, "the retired boat is gone");
|
||||
assert.equal(drowning.boss, "motherbog");
|
||||
assert.equal(drowning.key, null);
|
||||
assert.equal(drowning.horde.length, 0);
|
||||
@@ -585,7 +587,7 @@ test("Old Mother Bog's cauldron spit lands a muck patch where you stand after a
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
b.act = "idle";
|
||||
b.attacks = 1;
|
||||
b.plan = "spit";
|
||||
hurry(b);
|
||||
run(round, 8);
|
||||
assert.equal(b.act, "throwWind");
|
||||
@@ -627,7 +629,7 @@ test("Old Mother Bog goes meaner at half her hp: waits shrink to MOTHER_QUICK of
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
Object.assign(b, { raged: true, sank: true, act: "idle", attacks: 1, y: 6, x: 176 });
|
||||
Object.assign(b, { raged: true, sank: true, act: "idle", plan: "spit", y: 6, x: 176 });
|
||||
b.wait = 0;
|
||||
round.you.vx = 20;
|
||||
run(round, 8);
|
||||
@@ -698,9 +700,116 @@ test("Old Mother Bog sinks at half her hp, bubbles where she will rise, rises ne
|
||||
assert.ok(h.wait <= bog.MOTHER_REST_MS * bog.MOTHER_QUICK + 1, "and her next wait is the quick one");
|
||||
});
|
||||
|
||||
test("Old Mother Bog: her guard and weak spot are what the pack says, her touch is the motherbog cause, and her fall clears the field", () => {
|
||||
test("Old Mother Bog is not a pattern: the wave opens, then a weighted pick by phase that never makes one move three times running, keeps the slow moves on a cooldown and summons only under the cap", () => {
|
||||
// A long run of picks, as she would make them.
|
||||
const rolls = (b, n, random, round = null) => Array.from({ length: n }, () => bog.pickAttack(b, random, round));
|
||||
const three = (list) => list.some((m, i) => i > 1 && m === list[i - 1] && m === list[i - 2]);
|
||||
const lcg = (seed) => () => ((seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff);
|
||||
assert.equal(bog.pickAttack({ hp: 100, max: 100 }, () => 0.99), "wave", "the first move is always the wave");
|
||||
const P1 = ["dive", "hands", "shell", "spit", "surge", "wave"];
|
||||
const MORE = [...P1, "brood", "double", "volley"];
|
||||
const P2 = [...MORE, "drowned", "pull", "stomp", "tide"];
|
||||
const P3 = [...P2, "wisps"];
|
||||
const phases = [
|
||||
[{ hp: 100, max: 100 }, P1, "full health: six moves"],
|
||||
[{ hp: 70, max: 100 }, MORE, "under three quarters: the double wave, the volley and the brood join"],
|
||||
[{ hp: 45, max: 100, raged: true, sank: true }, P2, "under half: the stomp, the tide, the pull and the drowned join"],
|
||||
[{ hp: 20, max: 100, raged: true, sank: true, fury: true, sank2: true }, P3, "under a quarter: the wisp lantern joins"],
|
||||
];
|
||||
for (const [b, want, what] of phases) {
|
||||
const seen = rolls(b, 600, lcg(17));
|
||||
assert.deepEqual([...new Set(seen)].sort(), [...want].sort(), what);
|
||||
assert.ok(!three(seen), `never three in a row (${what})`);
|
||||
// A slow move sits out its cooldown.
|
||||
for (const [move, n] of Object.entries(bog.COOLDOWN)) {
|
||||
const at = seen.flatMap((m, i) => (m === move ? [i] : []));
|
||||
assert.ok(at.every((i, j) => j === 0 || i - at[j - 1] > n), `${move} waits ${n} picks (${what})`);
|
||||
}
|
||||
}
|
||||
assert.equal(bog.phaseOf({}), 0);
|
||||
assert.equal(bog.phaseOf({ raged: true }), 1);
|
||||
assert.equal(bog.phaseOf({ raged: true, fury: true }), 2);
|
||||
// At the cap a summon is never picked.
|
||||
const crowd = { monsters: [] };
|
||||
for (let i = 0; i < bog.BROOD_CAP; i++) crowd.monsters.push({ kind: "leech", hag: true });
|
||||
for (let i = 0; i < bog.BODIES_CAP; i++) crowd.monsters.push({ kind: "bogbody", hag: true });
|
||||
for (let i = 0; i < bog.WISPS_CAP; i++) crowd.monsters.push({ kind: "wisp", hag: true });
|
||||
const capped = rolls({ hp: 20, max: 100, raged: true, fury: true, picks: 1 }, 400, lcg(5), crowd);
|
||||
for (const move of ["brood", "drowned", "wisps"]) assert.equal(capped.includes(move), false, `no ${move} at the cap`);
|
||||
const forced = { hp: 100, max: 100, picks: 3, plan: "volley" };
|
||||
assert.equal(bog.pickAttack(forced, () => 0), "volley", "a plan is taken");
|
||||
assert.equal(forced.plan, null, "once");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's double wave sends a second wave DOUBLE_GAP_MS behind the first, and her volley lands three staggered patches", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
Object.assign(b, { act: "idle", plan: "double", attacks: 2 });
|
||||
hurry(b);
|
||||
run(round, 8);
|
||||
assert.equal(b.act, "wind");
|
||||
run(round, bog.MOTHER_WIND_MS + 20);
|
||||
assert.equal(events(round, "mudWave").length, 1, "one wave to start");
|
||||
run(round, bog.DOUBLE_GAP_MS + 30);
|
||||
const waves = events(round, "mudWave");
|
||||
assert.equal(waves.length, 2, "and a second behind it");
|
||||
assert.equal(waves[1].echo, true);
|
||||
const volley = motherFight();
|
||||
standAt(volley, 150);
|
||||
volley.you.safeMs = 1e9;
|
||||
Object.assign(volley.boss, { act: "idle", plan: "volley", attacks: 2 });
|
||||
hurry(volley.boss);
|
||||
run(volley, 8);
|
||||
assert.equal(volley.boss.act, "throwWind");
|
||||
run(volley, bog.SPIT_WIND_MS + 20);
|
||||
assert.ok(volley.hazards.length >= 2 && volley.hazards.length <= 3, `a spread of patches (${volley.hazards.length})`);
|
||||
const warns = volley.hazards.map((h) => h.warn).sort((a, c) => a - c);
|
||||
assert.ok(warns.at(-1) - warns[0] >= bog.VOLLEY_STAGGER_MS - 30, "landing a beat apart");
|
||||
});
|
||||
|
||||
test("Old Mother Bog never stands half out over the water (only a dive, a charge or a leap takes her off the boards), and goes under a second time at a quarter of her hp and comes back furious", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
const half = (x) => [-0.45, 0, 0.45].every((f) => ghoul.groundAt(round.spec, x + f * b.w) === b.y);
|
||||
// Put down over the gap between the planks, she walks onto one that holds her.
|
||||
standAt(round, 160);
|
||||
round.you.safeMs = 1e9;
|
||||
Object.assign(b, { act: "idle", x: 131, wait: 1e9 });
|
||||
until(round, () => half(b.x), 4000);
|
||||
assert.ok(half(b.x), `she settled on the planks (x=${b.x})`);
|
||||
// However she wanders in a long fight, her body is on the boards.
|
||||
Object.assign(b, { act: "idle", wait: 0, plan: "spit" });
|
||||
for (let i = 0; i < 400; i++) {
|
||||
standAt(round, 112 + ((i * 7) % 80));
|
||||
round.you.safeMs = 1e9;
|
||||
if (b.act === "idle") b.wait = Math.min(b.wait, 400);
|
||||
run(round, 50);
|
||||
if (b.hidden || bog.UNSTOOD.includes(b.act)) continue;
|
||||
assert.ok(half(b.x), `on the planks at step ${i} (x=${b.x}, act ${b.act})`);
|
||||
}
|
||||
// A second dive at a quarter.
|
||||
const fight = motherFight();
|
||||
const h = fight.boss;
|
||||
standAt(fight, 150);
|
||||
fight.you.safeMs = 1e9;
|
||||
Object.assign(h, { raged: true, sank: true, act: "idle", wait: 1e9, hp: h.max * bog.MOTHER_FURY_AT - 1 });
|
||||
run(fight, 8);
|
||||
assert.equal(h.sank2, true);
|
||||
assert.equal(h.fury, true);
|
||||
assert.equal(h.act, "sink");
|
||||
assert.equal(h.hidden, true);
|
||||
until(fight, () => h.act === "rest", 4000);
|
||||
assert.ok(h.wait <= bog.MOTHER_REST_MS * bog.MOTHER_FURY + 1, "her waits are the furious ones");
|
||||
assert.equal(events(fight, "motherSink").length, 1);
|
||||
});
|
||||
|
||||
test("Old Mother Bog: her guard and weak spot are what the pack says, her touch is the motherbog cause, and her fall clears the field of every hazard and add she made", () => {
|
||||
assert.equal(bog.BOG.guard.motherbog({ hidden: true }), true);
|
||||
assert.equal(bog.BOG.guard.motherbog({ hidden: false }), false);
|
||||
assert.equal(bog.BOG.guard.motherbog({ hidden: false, act: "shell" }), true, "shelled");
|
||||
assert.equal(bog.BOG.guard.motherbog({ hidden: false, act: "stagger" }), false, "reeling, she is open");
|
||||
assert.equal(bog.BOG.weak.motherbog({ lit: true }), 3);
|
||||
assert.equal(bog.BOG.weak.motherbog({ lit: false }), 1);
|
||||
assert.equal(bog.BOG.cause.motherbog(), "motherbog");
|
||||
@@ -714,8 +823,14 @@ test("Old Mother Bog: her guard and weak spot are what the pack says, her touch
|
||||
const b = round.boss;
|
||||
b.hp = 1;
|
||||
b.sank = true;
|
||||
b.sank2 = true;
|
||||
round.hazards.push({ kind: "muck", x: 150, y: 6, w: bog.MUCK_W, h: bog.MUCK_H, warn: 0, live: 2000, cause: "muck" });
|
||||
round.waves.push({ x: 140, y: 6, dir: -1, life: 6000, kind: "mudwave", cause: "mudwave" });
|
||||
round.hazards.push({ kind: "boghand", x: 160, y: 6, w: bog.HAND_W, h: bog.HAND_H, warn: 0, live: 400, cause: "boghand" });
|
||||
round.hazards.push({ kind: "tide", x: 152, y: 5, w: 104, h: 1.6, x0: 104, x1: 200, warn: 0, live: 2000, cause: "tide" });
|
||||
put(round, "leech", 150, { hag: true });
|
||||
put(round, "bogbody", 160, { hag: true });
|
||||
put(round, "wisp", 150, { hag: true, y: 14 });
|
||||
Object.assign(b, { act: "rest", wait: bog.MOTHER_OPEN_MS - 100 });
|
||||
standAt(round, 120);
|
||||
round.you.safeMs = 1e9;
|
||||
@@ -723,8 +838,594 @@ test("Old Mother Bog: her guard and weak spot are what the pack says, her touch
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(b.state, "down");
|
||||
assert.equal(round.hasKey, true);
|
||||
assert.equal(round.hazards.length, 0);
|
||||
assert.equal(round.hazards.length, 0, "the muck, the hands and the tide are gone");
|
||||
assert.equal(round.waves.length, 0);
|
||||
assert.equal(round.monsters.length, 0, "and so are her adds");
|
||||
});
|
||||
|
||||
// Her next move forced, from idle, as if her wait had run out; `over` sets
|
||||
// her phase or her place first.
|
||||
function force(round, move, over = {}) {
|
||||
const b = round.boss;
|
||||
Object.assign(b, { act: "idle", plan: move, picks: Math.max(3, b.picks || 0) }, over);
|
||||
b.wait = 0;
|
||||
run(round, 8);
|
||||
}
|
||||
const RAGED = { raged: true, sank: true };
|
||||
const FURY = { raged: true, sank: true, fury: true, sank2: true };
|
||||
// A bolt from the left into her middle, one slice later.
|
||||
function shoot(round) {
|
||||
const b = round.boss;
|
||||
round.shots.push({ x: b.x - b.w / 2 - 0.2, y: b.y + b.h * 0.35, vx: 80, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
}
|
||||
// Runs `ms`, jumping whenever `near()` says the threat is about to arrive.
|
||||
function hop(round, ms, near) {
|
||||
for (let t = 0; t < ms; t += 4) {
|
||||
const you = round.you;
|
||||
if (you.state === "run" && near(round) && round.input.jump <= 0) round.input.jump = ghoul.JUMP_BUFFER_MS;
|
||||
ghoul.advance(round, 4, steady);
|
||||
}
|
||||
}
|
||||
// A mud wave rolling at you, within `d`.
|
||||
const waveAt = (round, d = 7.5) => round.waves.some((w) => (round.you.x - w.x) * w.dir > 0 && (round.you.x - w.x) * w.dir < d);
|
||||
const losses = (round) => events(round, "lose");
|
||||
|
||||
test("Old Mother Bog's bog hands: her arms go into the water, ripples warn where you stand and a step either side, a hand bursts up from each (a heart, grabbed), and a step between them costs nothing", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
const lives = round.lives;
|
||||
force(round, "hands");
|
||||
assert.equal(b.act, "hands", "her arms in the water");
|
||||
const wind = events(round, "handsWind")[0];
|
||||
assert.ok(wind, "a wind-up to read");
|
||||
const hands = round.hazards.filter((h) => h.kind === "boghand");
|
||||
assert.equal(hands.length, bog.HANDS_N[0], "two at full health");
|
||||
assert.deepEqual(wind.xs, hands.map((h) => h.x), "the event names every ripple");
|
||||
assert.ok(hands.some((h) => Math.abs(h.x - 150) <= 2), "one where you stand");
|
||||
assert.ok(hands.every((h) => h.live === 0 && h.warn >= bog.HANDS_WIND_MS + bog.HAND_WARN_MS - 10 && h.cause === "boghand"), "each warns first");
|
||||
assert.ok(hands.every((h) => Number.isFinite(ghoul.groundAt(round.spec, h.x))), "out of the planks");
|
||||
run(round, bog.HANDS_WIND_MS + bog.HAND_WARN_MS - 40);
|
||||
assert.equal(losses(round).length, 0, "a ripple does not hurt");
|
||||
run(round, 80);
|
||||
assert.ok(events(round, "handsUp").length >= 1, "up it comes");
|
||||
assert.equal(losses(round)[0]?.cause, "boghand", "standing in it, you are grabbed");
|
||||
assert.equal(round.lives, lives - 1, "a heart");
|
||||
// A step between the ripples, and every hand goes by.
|
||||
const dodge = motherFight();
|
||||
standAt(dodge, 150);
|
||||
force(dodge, "hands");
|
||||
const spots = dodge.hazards.map((h) => h.x).sort((a, c) => a - c);
|
||||
standAt(dodge, spots[0] - 4.5);
|
||||
run(dodge, bog.HANDS_WIND_MS + bog.HAND_WARN_MS + bog.HAND_STAGGER_MS * 3 + bog.HAND_UP_MS + 50);
|
||||
assert.equal(losses(dodge).length, 0, "a clean dodge costs nothing");
|
||||
assert.equal(dodge.hazards.filter((h) => h.kind === "boghand").length, 0, "the hands are gone again");
|
||||
assert.equal(dodge.boss.act, "idle");
|
||||
// More of them as she weakens.
|
||||
for (const [phase, over] of [[1, RAGED], [2, FURY]]) {
|
||||
const more = motherFight();
|
||||
standAt(more, 145);
|
||||
force(more, "hands", over);
|
||||
assert.equal(more.hazards.filter((h) => h.kind === "boghand").length, bog.HANDS_N[phase], `phase ${phase}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("Old Mother Bog's surge: a crouch behind a bow wave, then a waist-deep charge along and past you; standing costs a heart, a jump over her or a shelf costs nothing, and she stops on the planks", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
const lives = round.lives;
|
||||
force(round, "surge");
|
||||
const from = b.x;
|
||||
assert.equal(b.act, "surgeWind");
|
||||
assert.equal(events(round, "surgeWind").length, 1, "a wind-up to read");
|
||||
run(round, bog.SURGE_WIND_MS - 40);
|
||||
assert.equal(b.x, from, "she holds still while she crouches");
|
||||
run(round, 60);
|
||||
assert.equal(b.act, "surge");
|
||||
assert.equal(events(round, "motherSurge").length, 1);
|
||||
assert.equal(b.y, b.floor - bog.SURGE_SINK, "waist deep");
|
||||
assert.ok((150 - b.surgeTo) >= 6, `past you (${b.surgeTo})`);
|
||||
until(round, () => losses(round).length > 0, 2000);
|
||||
assert.equal(losses(round)[0]?.cause, "motherbog", "run down");
|
||||
assert.equal(round.lives, lives - 1);
|
||||
// A jump as she comes clears her.
|
||||
const jumper = motherFight();
|
||||
standAt(jumper, 150);
|
||||
force(jumper, "surge");
|
||||
run(jumper, bog.SURGE_WIND_MS + 20);
|
||||
const jb = jumper.boss;
|
||||
hop(jumper, 1500, () => jb.act === "surge" && jb.x - jb.w / 2 - jumper.you.x - ghoul.HIT_W / 2 < 7.5);
|
||||
assert.equal(losses(jumper).length, 0, "jumped clean");
|
||||
assert.equal(jb.act === "rest" || jb.act === "idle", true, "the charge is over");
|
||||
assert.ok([-0.45, 0, 0.45].every((f) => ghoul.groundAt(jumper.spec, jb.x + f * jb.w) === jb.y), "she stopped on the planks");
|
||||
assert.ok(jb.x < 150, "on your other side: she moved");
|
||||
// Up on a shelf she charges underneath.
|
||||
const shelf = motherFight();
|
||||
standAt(shelf, 118, 0);
|
||||
force(shelf, "surge");
|
||||
run(shelf, bog.SURGE_WIND_MS + 1500);
|
||||
assert.equal(losses(shelf).length, 0, "the shelf is out of her reach");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's mud shell: bolts chip it and not her, SHELL_HP of them break it and leave her reeling with the cauldron open (triple), and left alone she feeds and heals", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "shell");
|
||||
assert.equal(b.act, "shellWind");
|
||||
assert.equal(events(round, "shellWind").length, 1, "a wind-up to read");
|
||||
run(round, bog.SHELL_WIND_MS + 10);
|
||||
assert.equal(b.act, "shell");
|
||||
assert.equal(bog.BOG.guard.motherbog(b), true, "guarded");
|
||||
assert.equal(b.shell, bog.SHELL_HP[0]);
|
||||
const hp = b.hp;
|
||||
for (let i = 0; i < bog.SHELL_HP[0] - 1; i++) shoot(round);
|
||||
assert.equal(b.hp, hp, "the shell takes the bolts");
|
||||
assert.equal(events(round, "shellChip").length, bog.SHELL_HP[0] - 1, "each a chip");
|
||||
assert.equal(b.act, "shell", "still up");
|
||||
shoot(round);
|
||||
assert.equal(events(round, "shellBreak").length, 1, "broken");
|
||||
assert.equal(b.act, "stagger");
|
||||
shoot(round);
|
||||
assert.equal(b.lit, true, "the cauldron is open while she reels");
|
||||
assert.equal(hp - b.hp, 3, "and a bolt counts triple");
|
||||
assert.ok(events(round, "cauldronOpen").length >= 1);
|
||||
run(round, bog.STAGGER_MS + 20);
|
||||
assert.equal(b.act, "idle");
|
||||
// Ignored, she ladles herself a feed.
|
||||
const feed = motherFight();
|
||||
standAt(feed, 150);
|
||||
feed.you.safeMs = 1e9;
|
||||
feed.boss.hp = feed.boss.max - 40;
|
||||
force(feed, "shell");
|
||||
run(feed, bog.SHELL_WIND_MS + bog.SHELL_MS + 20);
|
||||
const fed = events(feed, "motherFeed")[0];
|
||||
assert.ok(fed, "she feeds");
|
||||
assert.equal(fed.heal, bog.SHELL_HEAL);
|
||||
assert.equal(feed.boss.hp, feed.boss.max - 40 + bog.SHELL_HEAL, "and heals");
|
||||
const full = motherFight();
|
||||
full.you.safeMs = 1e9;
|
||||
full.boss.hp = full.boss.max - 3;
|
||||
force(full, "shell");
|
||||
run(full, bog.SHELL_WIND_MS + bog.SHELL_MS + 20);
|
||||
assert.equal(full.boss.hp, full.boss.max, "never past her max");
|
||||
// A stomp on the shell glances off.
|
||||
const stomp = motherFight();
|
||||
stomp.you.safeMs = 1e9;
|
||||
force(stomp, "shell");
|
||||
run(stomp, bog.SHELL_WIND_MS + 10);
|
||||
const sb = stomp.boss;
|
||||
const before = sb.hp;
|
||||
Object.assign(stomp.you, { x: sb.x, y: sb.y + sb.h + 0.3, vy: -20, state: "air", shelf: -1 });
|
||||
run(stomp, 20);
|
||||
assert.equal(sb.hp, before, "a stomp does nothing to the shell");
|
||||
assert.ok(events(stomp, "bossBlock").length >= 1);
|
||||
});
|
||||
|
||||
test("Old Mother Bog's dive: she goes under (shots meet water), bubbles show a new spot on the planks away from you, she rises there hittable, and meaner the rise sends a mud wave each way", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "dive");
|
||||
assert.equal(b.act, "sink");
|
||||
assert.equal(b.hidden, true);
|
||||
assert.equal(b.raged || false, false, "a dive of her own is not the rage");
|
||||
assert.equal(events(round, "motherSink")[0]?.relocate, true);
|
||||
const hp = b.hp;
|
||||
round.shots.push({ x: b.x - 2, y: 7, vx: 80, vy: 0, gone: 0 });
|
||||
run(round, 40);
|
||||
assert.equal(b.hp, hp, "no damage under the water");
|
||||
until(round, () => b.act === "under", 2000);
|
||||
const bubble = events(round, "motherBubble")[0];
|
||||
assert.ok(bubble);
|
||||
assert.ok(Math.abs(b.sinkX - round.you.x) >= 6, "never on top of you");
|
||||
assert.ok([-0.45, 0, 0.45].every((f) => ghoul.groundAt(round.spec, b.sinkX + f * b.w) === b.floor), "on a plank that holds her");
|
||||
until(round, () => b.act === "resurface", 2000);
|
||||
assert.equal(b.x, bubble.x);
|
||||
shoot(round);
|
||||
assert.ok(hp - b.hp >= 1, "hittable once she is up");
|
||||
until(round, () => b.act === "rest", 2000);
|
||||
assert.equal(events(round, "mudWave").length, 0, "calm, no waves");
|
||||
// Meaner, two waves come off her as she stands.
|
||||
const mean = motherFight();
|
||||
standAt(mean, 150);
|
||||
mean.you.safeMs = 1e9;
|
||||
force(mean, "dive", RAGED);
|
||||
until(mean, () => mean.boss.act === "rest", 4000);
|
||||
const waves = events(mean, "mudWave").filter((e) => e.rise);
|
||||
assert.deepEqual(waves.map((w) => w.dir).sort(), [-1, 1], "a wave each way");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's leech brood: she tips the cauldron, a swarm or two pours onto the planks and creeps at you, never more than BROOD_CAP of hers alive; a latch is a heart and two bolts see one off", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 140 + 10);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "brood");
|
||||
assert.equal(b.act, "broodWind");
|
||||
assert.equal(events(round, "broodWind").length, 1, "a wind-up to read");
|
||||
assert.equal(bog.hagAdds(round, "leech"), 0, "nothing out during the tip");
|
||||
run(round, bog.BROOD_WIND_MS + 10);
|
||||
assert.equal(events(round, "broodPour")[0]?.n, bog.BROOD_N);
|
||||
assert.equal(bog.hagAdds(round, "leech"), bog.BROOD_N);
|
||||
const brood = round.monsters.filter((m) => m.hag);
|
||||
assert.ok(brood.every((m) => m.kind === "leech" && Number.isFinite(ghoul.groundAt(round.spec, m.x))), "on the planks");
|
||||
const x0 = brood[0].x;
|
||||
run(round, 300);
|
||||
assert.ok(brood[0].x < x0, "creeping at you");
|
||||
force(round, "brood");
|
||||
run(round, bog.BROOD_WIND_MS + 10);
|
||||
force(round, "brood");
|
||||
run(round, bog.BROOD_WIND_MS + 10);
|
||||
assert.equal(bog.hagAdds(round, "leech"), bog.BROOD_CAP, "capped");
|
||||
// A latch costs a heart.
|
||||
const latch = motherFight();
|
||||
const lives = latch.lives;
|
||||
standAt(latch, 150);
|
||||
put(latch, "leech", 150.5, { hag: true });
|
||||
run(latch, 40);
|
||||
assert.equal(losses(latch)[0]?.cause, "leeches");
|
||||
assert.equal(latch.lives, lives - 1);
|
||||
// Two bolts see one off.
|
||||
const shot = motherFight();
|
||||
standAt(shot, 150);
|
||||
shot.you.safeMs = 1e9;
|
||||
shot.boss.wait = 1e9;
|
||||
const m = put(shot, "leech", 160, { hag: true });
|
||||
bolt(shot, m, m.y + 0.9);
|
||||
bolt(shot, m, m.y + 0.9);
|
||||
shot.shots[1].x -= 3;
|
||||
run(shot, 200);
|
||||
assert.equal(bog.hagAdds(shot, "leech"), 0, "dispersed");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's stomp: a shadow where you stand, a leap and a slam there (a heart if you stayed), then a mud wave each way; out of the shadow and over the wave costs nothing", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
const lives = round.lives;
|
||||
force(round, "stomp", RAGED);
|
||||
assert.equal(b.act, "stompWind");
|
||||
const wind = events(round, "stompWind")[0];
|
||||
assert.ok(wind, "a wind-up to read");
|
||||
assert.ok(Math.abs(wind.landX - 150) <= 1, "the shadow is on you");
|
||||
run(round, bog.STOMP_WIND_MS * bog.MOTHER_QUICK + 10);
|
||||
assert.equal(b.act, "stompAir");
|
||||
assert.equal(events(round, "motherLeap").length, 1);
|
||||
until(round, () => losses(round).length > 0, 2000);
|
||||
assert.equal(losses(round)[0]?.cause, "motherbog", "landed on");
|
||||
assert.equal(round.lives, lives - 1);
|
||||
// Out of the shadow, then over the wave.
|
||||
const dodge = motherFight();
|
||||
standAt(dodge, 150);
|
||||
force(dodge, "stomp", RAGED);
|
||||
standAt(dodge, 185);
|
||||
const db = dodge.boss;
|
||||
until(dodge, () => events(dodge, "motherSlam").length > 0, 3000);
|
||||
assert.equal(db.x, db.landX, "down where the shadow was");
|
||||
assert.ok([-0.45, 0, 0.45].every((f) => ghoul.groundAt(dodge.spec, db.x + f * db.w) === db.y), "on the planks");
|
||||
assert.equal(dodge.waves.length, 0, "the waves wait a beat");
|
||||
hop(dodge, 1300, (r) => waveAt(r));
|
||||
const slams = events(dodge, "mudWave").filter((e) => e.slam);
|
||||
assert.deepEqual(slams.map((w) => w.dir).sort(), [-1, 1], "a wave each way");
|
||||
assert.equal(losses(dodge).length, 0, "a clean dodge costs nothing");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's tide: a long warning, then the water over every plank for TIDE_MS (a heart, drowned); a shelf keeps you dry and it drains away after", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
const lives = round.lives;
|
||||
force(round, "tide", RAGED);
|
||||
assert.equal(b.act, "tideWind");
|
||||
assert.equal(events(round, "tideWarn").length, 1, "a warning to read");
|
||||
const tide = round.hazards.find((h) => h.kind === "tide");
|
||||
assert.ok(tide && tide.warn > bog.TIDE_WARN_MS - 10 && tide.live === 0, "it warns first");
|
||||
run(round, bog.TIDE_WARN_MS - 40);
|
||||
assert.equal(losses(round).length, 0, "the warning does not hurt");
|
||||
run(round, 80);
|
||||
assert.equal(events(round, "tideRise").length, 1);
|
||||
assert.equal(losses(round)[0]?.cause, "tide", "drowned on the planks");
|
||||
assert.equal(round.lives, lives - 1);
|
||||
// On a shelf you stay dry the whole time, and it drains.
|
||||
for (const shelf of [0, 2]) {
|
||||
const dry = motherFight();
|
||||
const [x0, x1] = dry.spec.shelves[shelf];
|
||||
standAt(dry, (x0 + x1) / 2, shelf);
|
||||
force(dry, "tide", RAGED);
|
||||
run(dry, bog.TIDE_WARN_MS + bog.TIDE_MS + 60);
|
||||
assert.equal(losses(dry).length, 0, `shelf ${shelf} is dry`);
|
||||
assert.equal(dry.hazards.filter((h) => h.kind === "tide").length, 0, "the water is gone");
|
||||
assert.notEqual(dry.boss.act, "tideHold");
|
||||
}
|
||||
// Every spot on the arena's planks is near enough a shelf to reach in the warning.
|
||||
const spec = round.spec;
|
||||
const tops = spec.shelves.filter((s) => s[2] === 12);
|
||||
for (let x = spec.arena + ghoul.BOSS_LOCK + 2; x < spec.length - 2; x += 2) {
|
||||
if (!Number.isFinite(ghoul.groundAt(spec, x))) continue;
|
||||
const far = Math.min(...tops.map(([a, c]) => (x < a ? a + 1 - x : x > c ? x - c + 1 : 0)));
|
||||
assert.ok(far / ghoul.RUN_SPEED + 0.35 < bog.TIDE_WARN_MS / 1000, `a shelf within reach of ${x}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("Old Mother Bog's drowning pull: she stirs, then the water drags you along the planks toward her (a heart at her touch); running away, a shelf or the air beats it, and it never drags you off a plank's end", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
const lives = round.lives;
|
||||
force(round, "pull", RAGED);
|
||||
assert.equal(b.act, "pullWind");
|
||||
assert.equal(events(round, "pullWind").length, 1, "a wind-up to read");
|
||||
run(round, bog.PULL_WIND_MS * bog.MOTHER_QUICK - 30);
|
||||
assert.equal(round.you.x, 150, "nothing pulls during the stir");
|
||||
run(round, 40);
|
||||
assert.equal(b.act, "pull");
|
||||
assert.equal(events(round, "motherPull").length, 1);
|
||||
run(round, 400);
|
||||
assert.ok(round.you.x > 150 + 4, `dragged toward her (${round.you.x.toFixed(1)})`);
|
||||
until(round, () => losses(round).length > 0, 3000);
|
||||
assert.equal(losses(round)[0]?.cause, "motherbog");
|
||||
assert.equal(round.lives, lives - 1);
|
||||
// Running away from her beats it.
|
||||
const runner = motherFight();
|
||||
Object.assign(runner.boss, { x: 150 });
|
||||
standAt(runner, 172);
|
||||
force(runner, "pull", RAGED);
|
||||
run(runner, bog.PULL_WIND_MS + bog.PULL_MS + 40, { right: true });
|
||||
assert.equal(losses(runner).length, 0, "outrun");
|
||||
// A shelf is out of its reach.
|
||||
const shelf = motherFight();
|
||||
standAt(shelf, 166, 2);
|
||||
force(shelf, "pull", RAGED);
|
||||
run(shelf, bog.PULL_WIND_MS + 600);
|
||||
assert.equal(shelf.you.x, 166, "not moved on a shelf");
|
||||
// The boards hold you at a plank's end.
|
||||
const edge = motherFight();
|
||||
Object.assign(edge.boss, { x: 120 });
|
||||
standAt(edge, 142);
|
||||
edge.you.safeMs = 1e9;
|
||||
force(edge, "pull", RAGED);
|
||||
run(edge, bog.PULL_WIND_MS + bog.PULL_MS);
|
||||
assert.ok(edge.you.x >= 140 && edge.you.y === 6, `held on the plank (${edge.you.x.toFixed(1)})`);
|
||||
});
|
||||
|
||||
test("Old Mother Bog calls the drowned: mud boils away from you and her, bog bodies climb out (harmless till up), never more than BODIES_CAP of hers alive", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "drowned", RAGED);
|
||||
assert.equal(b.act, "callWind");
|
||||
const wind = events(round, "callWind")[0];
|
||||
assert.ok(wind && wind.xs.length === bog.BODIES_CAP, "a wind-up naming where they come");
|
||||
for (const x of wind.xs) {
|
||||
assert.ok(Math.abs(x - 150) >= 6 && Math.abs(x - b.x) >= b.w, `away from you and her (${x})`);
|
||||
assert.ok(Number.isFinite(ghoul.groundAt(round.spec, x)), "on a plank");
|
||||
}
|
||||
assert.equal(bog.hagAdds(round, "bogbody"), 0, "nothing yet");
|
||||
run(round, bog.CALL_WIND_MS * bog.MOTHER_QUICK + 10);
|
||||
assert.equal(events(round, "motherCall").length, 1);
|
||||
assert.equal(bog.hagAdds(round, "bogbody"), bog.BODIES_CAP);
|
||||
run(round, 20);
|
||||
assert.equal(events(round, "bogRise").length, bog.BODIES_CAP, "they climb out");
|
||||
assert.ok(round.monsters.every((m) => !ghoul.solid(m)), "harmless while they rise");
|
||||
force(round, "drowned", RAGED);
|
||||
assert.deepEqual(events(round, "callWind").at(-1).xs, [], "at the cap nothing boils");
|
||||
run(round, bog.CALL_WIND_MS + 10);
|
||||
assert.equal(bog.hagAdds(round, "bogbody"), bog.BODIES_CAP, "capped");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's wisp lantern, furious only: she raises it and two wisps of hers drift at you; a bolt puts one out for good, never more than WISPS_CAP", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
standAt(round, 150);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "wisps", FURY);
|
||||
assert.equal(b.act, "lanternWind");
|
||||
assert.equal(events(round, "lanternWind").length, 1, "a wind-up to read");
|
||||
run(round, bog.LANTERN_WIND_MS * bog.MOTHER_FURY + 10);
|
||||
assert.equal(events(round, "motherLantern").length, 1);
|
||||
assert.equal(bog.hagAdds(round, "wisp"), bog.WISPS_N);
|
||||
const w = round.monsters.find((m) => m.hag && m.kind === "wisp");
|
||||
bolt(round, w, w.y + w.h / 2);
|
||||
round.shots.at(-1).x = w.x - 0.5;
|
||||
run(round, 20);
|
||||
assert.equal(bog.hagAdds(round, "wisp"), bog.WISPS_N - 1, "one put out for good");
|
||||
force(round, "wisps", FURY);
|
||||
run(round, bog.LANTERN_WIND_MS + 10);
|
||||
force(round, "wisps", FURY);
|
||||
run(round, bog.LANTERN_WIND_MS + 10);
|
||||
assert.equal(bog.hagAdds(round, "wisp"), bog.WISPS_CAP, "capped");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's combo, furious only: a move that ends in an idle may go straight into the next after her eye flares, never twice running; calm she never does", () => {
|
||||
const low = () => 0.1;
|
||||
const MOVE = /Wind$|^tideWarn$|^motherSink$/;
|
||||
// Runs `ms`, noting when each combo and each move's telegraph came.
|
||||
const log = (round, ms) => {
|
||||
const out = [];
|
||||
for (let t = 0; t < ms; t += 4) {
|
||||
ghoul.advance(round, 4, low);
|
||||
for (const e of round.events) if (e.type === "motherCombo" || MOVE.test(e.type)) out.push([e.type, t]);
|
||||
round.events.length = 0;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const round = motherFight();
|
||||
standAt(round, 120);
|
||||
round.you.safeMs = 1e9;
|
||||
force(round, "hands", FURY);
|
||||
const seen = log(round, 6000);
|
||||
const i = seen.findIndex(([type]) => type === "motherCombo");
|
||||
assert.ok(i >= 0, "a combo");
|
||||
assert.ok(seen[i + 1] && MOVE.test(seen[i + 1][0]), "and straight into a move");
|
||||
assert.ok(seen[i + 1][1] - seen[i][1] <= bog.COMBO_GAP_MS + 8, `with only the short gap between (${seen[i + 1][1] - seen[i][1]} ms)`);
|
||||
const types = seen.map(([type]) => type);
|
||||
assert.ok(!types.some((t, j) => t === "motherCombo" && types[j + 2] === "motherCombo"), "never two combos running");
|
||||
const calm = motherFight();
|
||||
standAt(calm, 120);
|
||||
calm.you.safeMs = 1e9;
|
||||
force(calm, "hands");
|
||||
assert.equal(log(calm, 6000).filter(([type]) => type === "motherCombo").length, 0, "calm, never");
|
||||
});
|
||||
|
||||
test("Old Mother Bog's phases: the moves she uses change at half and a quarter of her hp, and a long fight goes through them all", () => {
|
||||
const round = motherFight();
|
||||
const b = round.boss;
|
||||
round.infinite = true;
|
||||
let seed = 3;
|
||||
const random = () => ((seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff);
|
||||
const seen = [new Set(), new Set(), new Set()];
|
||||
for (let t = 0; t < 150000 && b.state === "fight"; t += 4) {
|
||||
round.you.safeMs = 1e9;
|
||||
// Her hp falls steadily, so every phase gets its turn.
|
||||
if (t % 400 === 0 && b.hp > 1 && !b.hidden && b.act !== "shell") b.hp -= 1;
|
||||
const before = b.picks || 0;
|
||||
ghoul.advance(round, 4, random);
|
||||
if ((b.picks || 0) > before) seen[bog.phaseOf(b)].add(b.last);
|
||||
round.events.length = 0;
|
||||
}
|
||||
for (const m of ["stomp", "tide", "pull", "drowned", "wisps"]) assert.equal(seen[0].has(m), false, `no ${m} at full health`);
|
||||
assert.equal(seen[1].has("wisps"), false, "no wisps before she is furious");
|
||||
assert.ok(["stomp", "tide", "pull", "drowned"].filter((m) => seen[1].has(m) || seen[2].has(m)).length >= 3, `the second phase's moves (${[...seen[1]]})`);
|
||||
assert.ok(seen[0].size >= 5 && seen[1].size >= 6, `a varied fight (${[...seen[0]]} / ${[...seen[1]]} / ${[...seen[2]]})`);
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------ the whole fight */
|
||||
|
||||
// A player who plays the fight sensibly: keeps a fair distance facing her,
|
||||
// fires in bursts that keep the blaster cool, steps off ripples, shadows and
|
||||
// muck, jumps waves and her charge, climbs a shelf for the tide and the pull,
|
||||
// and hops a leech rather than walking into it.
|
||||
function skilledKeys(round, mem) {
|
||||
const you = round.you;
|
||||
const b = round.boss;
|
||||
const spec = round.spec;
|
||||
const k = { left: false, right: false, fire: false, down: false, jump: false };
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
const onGround = you.state === "run" && you.shelf < 0;
|
||||
const lo = spec.arena + ghoul.BOSS_LOCK + 2;
|
||||
const hi = spec.length - 3;
|
||||
let goal = null;
|
||||
const climb = () => {
|
||||
if (you.shelf >= 0) {
|
||||
const s = spec.shelves[you.shelf];
|
||||
goal = clamp(you.x, s[0] + 1.5, s[1] - 1.5);
|
||||
return;
|
||||
}
|
||||
const tops = spec.shelves.filter((s) => s[2] === 12);
|
||||
const s = tops.reduce((a, c) => (Math.abs((c[0] + c[1]) / 2 - you.x) < Math.abs((a[0] + a[1]) / 2 - you.x) ? c : a));
|
||||
goal = (s[0] + s[1]) / 2;
|
||||
if (onGround && you.x > s[0] + 1 && you.x < s[1] - 1) k.jump = true;
|
||||
};
|
||||
const danger = (x) => {
|
||||
for (const h of round.hazards) {
|
||||
if (h.kind === "muck" && (h.live > 0 || h.warn < 500) && Math.abs(x - h.x) < (h.w + ghoul.HIT_W) / 2 + 0.6) return true;
|
||||
if (h.kind === "boghand" && Math.abs(x - h.x) < (h.w + ghoul.HIT_W) / 2 + 0.6) return true;
|
||||
}
|
||||
if ((b.act === "stompWind" || b.act === "stompAir") && Math.abs(x - b.landX) < (b.w + ghoul.HIT_W) / 2 + 2) return true;
|
||||
if (!b.hidden && b.act !== "stompAir" && Math.abs(x - b.x) < (b.w + ghoul.HIT_W) / 2 + 1.5) return true;
|
||||
return !Number.isFinite(ghoul.groundAt(spec, x));
|
||||
};
|
||||
if (b && b.state === "fight") {
|
||||
const side = Math.sign(you.x - b.x) || 1;
|
||||
goal = clamp(b.x + side * 15, lo, hi);
|
||||
if (Math.abs(goal - b.x) < 10) goal = clamp(b.x - side * 15, lo, hi);
|
||||
if (round.hazards.some((h) => h.kind === "tide") || b.act === "pull" || b.act === "pullWind") climb();
|
||||
else if (danger(you.x) && onGround) {
|
||||
for (let d = 0.5; d < 16; d += 0.5) {
|
||||
const c = [you.x + d, you.x - d].find((x) => x > lo && x < hi && !danger(x));
|
||||
if (c !== undefined) {
|
||||
goal = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (danger(goal)) goal = you.x;
|
||||
for (const w of round.waves) {
|
||||
const d = (you.x - w.x) * w.dir;
|
||||
if (onGround && d > 0 && d < 7.5 && Math.abs(w.y - you.y) < 1) k.jump = true;
|
||||
}
|
||||
if (b.act === "surge" || b.act === "surgeWind") goal = you.x;
|
||||
if (b.act === "surge") {
|
||||
const d = (you.x - b.x) * Math.sign(b.surgeTo - b.x) - b.w / 2 - ghoul.HIT_W / 2;
|
||||
if (onGround && d > -1 && d < 7.5) k.jump = true;
|
||||
}
|
||||
for (const m of round.monsters) if (m.kind === "leech" && onGround && Math.abs(m.x - you.x) < 4.5 && Math.abs(m.y - you.y) < 2) k.jump = true;
|
||||
}
|
||||
if (goal !== null && Math.abs(goal - you.x) > 0.6) {
|
||||
const dir = goal > you.x ? 1 : -1;
|
||||
dir > 0 ? (k.right = true) : (k.left = true);
|
||||
if (onGround && !Number.isFinite(ghoul.groundAt(spec, you.x + dir * 2.2))) k.jump = true;
|
||||
} else if (b && b.state === "fight") {
|
||||
const want = Math.sign(b.x - you.x) || 1;
|
||||
if (you.face !== want) want > 0 ? (k.right = true) : (k.left = true);
|
||||
}
|
||||
// Up where bolts fly over her head (and no tide to wait out): drop down.
|
||||
const tide = round.hazards.some((h) => h.kind === "tide");
|
||||
if (b && b.state === "fight" && you.state === "run" && you.shelf >= 0 && !tide && b.act !== "pull" && you.y + ghoul.SHOT_Y > b.y + b.h - 0.5) {
|
||||
k.left = false;
|
||||
k.right = false;
|
||||
k.down = true;
|
||||
}
|
||||
if (mem.cool && round.heat < 4) mem.cool = false;
|
||||
if (!mem.cool && round.heat >= 28) mem.cool = true;
|
||||
k.fire = !mem.cool;
|
||||
return k;
|
||||
}
|
||||
|
||||
// The whole fight from the arena door, real hearts and a seeded draw: how long
|
||||
// it took (seconds from the fight's start) and how it went.
|
||||
function wholeFight(keys, seed) {
|
||||
const round = bogRound("drowning");
|
||||
standAt(round, round.spec.arena + ghoul.BOSS_LOCK + 2);
|
||||
const random = () => ((seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff);
|
||||
const mem = {};
|
||||
let start = -1;
|
||||
const causes = [];
|
||||
let t = 0;
|
||||
for (; t < 240000 && !round.over; t += 4) {
|
||||
// No Lucky dice: a die picked up off an add would stop the round to ask.
|
||||
round.dice = 0;
|
||||
const k = keys(round, mem);
|
||||
Object.assign(round.input, { left: k.left, right: k.right, fire: k.fire, down: k.down });
|
||||
if (k.jump && round.input.jump <= 0) round.input.jump = ghoul.JUMP_BUFFER_MS;
|
||||
ghoul.advance(round, 4, random);
|
||||
for (const e of round.events) {
|
||||
if (e.type === "bossGo" && start < 0) start = t;
|
||||
if (e.type === "lose") causes.push(e.cause);
|
||||
}
|
||||
const down = round.events.some((e) => e.type === "bossDown");
|
||||
round.events.length = 0;
|
||||
if (down) return { won: true, secs: (t - start) / 1000, causes, round };
|
||||
}
|
||||
return { won: false, secs: (t - start) / 1000, causes, round };
|
||||
}
|
||||
|
||||
test("Old Mother Bog takes a skilled player a real fight: a bot that plays sensibly kills her in 60 to 120 seconds on every seed, losing a heart or a few, never all", () => {
|
||||
const times = [];
|
||||
for (const seed of [7, 11, 23, 71]) {
|
||||
const fight = wholeFight(skilledKeys, seed);
|
||||
assert.ok(fight.won, `seed ${seed}: she fell (${fight.causes}; ${fight.secs.toFixed(1)} s, ${fight.round.lives} lives, phase ${fight.round.phase}, hp ${fight.round.boss?.hp})`);
|
||||
assert.ok(fight.secs >= 60 && fight.secs <= 120, `seed ${seed}: ${fight.secs.toFixed(1)} s of fight`);
|
||||
assert.ok(fight.round.lives > 0, "with hearts to spare");
|
||||
const known = new Set([...Object.keys(LOSE_WORDS), "pit", "zombie", "crawler"]);
|
||||
for (const c of fight.causes) assert.ok(known.has(c), `${c} has words`);
|
||||
times.push(fight.secs);
|
||||
}
|
||||
assert.ok(Math.max(...times) - Math.min(...times) > 3, `not the same fight every time (${times.map((t) => t.toFixed(1))})`);
|
||||
});
|
||||
|
||||
test("Old Mother Bog kills a player who stands still: an idle bot loses every heart while she is barely scratched", () => {
|
||||
const fight = wholeFight(() => ({}), 7);
|
||||
assert.equal(fight.won, false);
|
||||
assert.ok(fight.round.over, "game over");
|
||||
assert.ok(fight.round.boss.hp > fight.round.boss.max * 0.9, "she is barely scratched");
|
||||
assert.ok(fight.secs < 120, `down in ${fight.secs.toFixed(1)} s`);
|
||||
assert.ok(new Set(fight.causes).size >= 2, `by more than one move (${fight.causes})`);
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------ voices, words, cards */
|
||||
@@ -738,7 +1439,7 @@ const heard = (e, extra = {}) => {
|
||||
};
|
||||
|
||||
test("Ghoul Rush's bog: every new kind has a voice for every act, every new event plays exactly one picked sound, and the tones are the stage's own", () => {
|
||||
const own = { lurker: ["appear", "snap", "sink", "hurt", "die"], leech: ["appear", "latch", "hurt", "die"], wisp: ["appear", "out", "relight", "on", "hurt", "die"], bogbody: ["appear", "rise", "hurt", "die"], motherbog: ["wake", "wind", "wave", "spitWind", "spit", "open", "sink", "bubble", "rise", "muck", "hurt", "weak", "die"] };
|
||||
const own = { lurker: ["appear", "snap", "sink", "hurt", "die"], leech: ["appear", "latch", "hurt", "die"], wisp: ["appear", "out", "relight", "on", "hurt", "die"], bogbody: ["appear", "rise", "hurt", "die"], motherbog: ["wake", "wind", "wave", "spitWind", "spit", "open", "sink", "bubble", "rise", "muck", "hurt", "weak", "die", "handsWind", "handsUp", "surgeWind", "surge", "shellWind", "chip", "shellBreak", "feed", "broodWind", "pour", "stompWind", "leap", "slam", "tideWarn", "tide", "pullWind", "pull", "callWind", "call", "lanternWind", "lantern", "combo"] };
|
||||
assert.deepEqual(Object.keys(VOICES).sort(), Object.keys(own).sort(), "a voice table for each new kind and the boss");
|
||||
for (const [kind, acts] of Object.entries(own)) assert.deepEqual(Object.keys(VOICES[kind]).sort(), [...acts].sort(), `${kind}: every act`);
|
||||
const names = Object.values(VOICES).flatMap((v) => Object.values(v));
|
||||
@@ -760,6 +1461,28 @@ test("Ghoul Rush's bog: every new kind has a voice for every act, every new even
|
||||
[{ type: "motherSink", kind: "motherbog" }, "motherbog", "sink"],
|
||||
[{ type: "motherBubble", kind: "motherbog" }, "motherbog", "bubble"],
|
||||
[{ type: "motherRise", kind: "motherbog" }, "motherbog", "rise"],
|
||||
[{ type: "handsWind", kind: "motherbog", xs: [12, 19] }, "motherbog", "handsWind"],
|
||||
[{ type: "handsUp", kind: "motherbog" }, "motherbog", "handsUp"],
|
||||
[{ type: "surgeWind", kind: "motherbog" }, "motherbog", "surgeWind"],
|
||||
[{ type: "motherSurge", kind: "motherbog" }, "motherbog", "surge"],
|
||||
[{ type: "shellWind", kind: "motherbog" }, "motherbog", "shellWind"],
|
||||
[{ type: "shellChip", kind: "motherbog" }, "motherbog", "chip"],
|
||||
[{ type: "shellBreak", kind: "motherbog" }, "motherbog", "shellBreak"],
|
||||
[{ type: "motherFeed", kind: "motherbog", heal: 14 }, "motherbog", "feed"],
|
||||
[{ type: "broodWind", kind: "motherbog" }, "motherbog", "broodWind"],
|
||||
[{ type: "broodPour", kind: "motherbog", n: 2 }, "motherbog", "pour"],
|
||||
[{ type: "stompWind", kind: "motherbog", landX: 14 }, "motherbog", "stompWind"],
|
||||
[{ type: "motherLeap", kind: "motherbog" }, "motherbog", "leap"],
|
||||
[{ type: "motherSlam", kind: "motherbog" }, "motherbog", "slam"],
|
||||
[{ type: "tideWarn", kind: "motherbog" }, "motherbog", "tideWarn"],
|
||||
[{ type: "tideRise", kind: "motherbog" }, "motherbog", "tide"],
|
||||
[{ type: "pullWind", kind: "motherbog" }, "motherbog", "pullWind"],
|
||||
[{ type: "motherPull", kind: "motherbog" }, "motherbog", "pull"],
|
||||
[{ type: "callWind", kind: "motherbog", xs: [12, 30] }, "motherbog", "callWind"],
|
||||
[{ type: "motherCall", kind: "motherbog", xs: [12, 30] }, "motherbog", "call"],
|
||||
[{ type: "lanternWind", kind: "motherbog" }, "motherbog", "lanternWind"],
|
||||
[{ type: "motherLantern", kind: "motherbog", n: 2 }, "motherbog", "lantern"],
|
||||
[{ type: "motherCombo", kind: "motherbog" }, "motherbog", "combo"],
|
||||
[{ type: "bossWake", kind: "motherbog" }, "motherbog", "wake"],
|
||||
[{ type: "bossHit", kind: "motherbog", how: "shot" }, "motherbog", "hurt"],
|
||||
[{ type: "bossHit", kind: "motherbog", how: "weak", weak: true }, "motherbog", "weak"],
|
||||
@@ -789,19 +1512,27 @@ test("Ghoul Rush's bog: every new kind has a voice for every act, every new even
|
||||
assert.equal(heard({ ...at, type: "bossHit", kind: "motherbog", how: "shot" }).includes(VOICES.motherbog.weak), false, "a plain shot is not weak");
|
||||
// Events that are only looks (the pull of the lure, a swarm coming apart) say nothing the voices own.
|
||||
for (const type of ["wispLure", "leechDie"]) assert.equal(heard({ ...at, type, kind: "leech" }).filter((n) => names.includes(n)).length, 0, `${type} is visual`);
|
||||
// Every picked tone exists in the merged tones, lives in the stage's file and is named by kind and act.
|
||||
// Every event the hag's rules raise is one of the cases above (so none is left without a voice).
|
||||
const raised = new Set();
|
||||
const src = readFileSync(new URL("../src/web-console/public/activities/ghoul-rush/stages/bog/ghoul-bog.js", import.meta.url), "utf8");
|
||||
for (const [, type] of src.matchAll(/type: "([a-zA-Z]+)"/g)) raised.add(type);
|
||||
for (const [, type] of src.matchAll(/ev\("([a-zA-Z]+)"/g)) raised.add(type);
|
||||
const covered = new Set([...cases.map(([e]) => e.type), "wispLure", "leechDie", "harpoonHit"]);
|
||||
for (const type of raised) assert.ok(covered.has(type), `${type} has a reaction checked here`);
|
||||
// Every picked tone exists in the merged tones, lives in the stage's file, is short and is named by kind and act.
|
||||
const merged = ghoulSfx.default.tones;
|
||||
for (const [kind, acts] of Object.entries(VOICES)) {
|
||||
for (const [act, name] of Object.entries(acts)) {
|
||||
assert.ok(merged[name]?.layers?.length, `${kind}.${act}: ${name} is in the merged tones`);
|
||||
assert.ok(BOG_SFX.tones[name], `${name} lives in ghoul-sfx-bog.js`);
|
||||
for (const l of BOG_SFX.tones[name].layers) assert.ok(l.seconds > 0 && l.seconds + (l.delay || 0) <= 1.2 + 1e-9, `${name} is over within 1.2 s`);
|
||||
assert.equal(name, `ghoul${kind === "motherbog" ? "Mother" : kind[0].toUpperCase() + kind.slice(1)}${act[0].toUpperCase()}${act.slice(1)}`, "named by kind and act");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("Ghoul Rush's bog: every new way to die has its words and its own sound, and endless lives spare the heart for each", () => {
|
||||
const causes = ["lurker", "leeches", "wisp", "bogbody", "mudwave", "muck", "motherbog"];
|
||||
const causes = ["lurker", "leeches", "wisp", "bogbody", "mudwave", "muck", "boghand", "tide", "motherbog"];
|
||||
assert.deepEqual(Object.keys(LOSE_WORDS).sort(), [...causes].sort(), "words for exactly these");
|
||||
assert.deepEqual(Object.keys(LOSE_SOUNDS).sort(), [...causes].sort(), "a sound for exactly these");
|
||||
for (const cause of causes) {
|
||||
@@ -818,7 +1549,7 @@ test("Ghoul Rush's bog: every new way to die has its words and its own sound, an
|
||||
assert.equal(normal.lives, had - 1, `${cause} costs a heart otherwise`);
|
||||
}
|
||||
// The real causes the stage raises are all among them.
|
||||
for (const cause of ["leeches", "mudwave", "muck", "motherbog"]) assert.ok(LOSE_WORDS[cause]);
|
||||
for (const cause of ["leeches", "mudwave", "muck", "boghand", "tide", "motherbog"]) assert.ok(LOSE_WORDS[cause]);
|
||||
assert.equal(bog.BOG.cause.motherbog(), "motherbog");
|
||||
});
|
||||
|
||||
@@ -857,14 +1588,14 @@ test("Ghoul Rush's bog round flow: the stage card opens before the Sunken Boardw
|
||||
assert.equal(r.phase, "ready");
|
||||
ghoul.advance(r, ghoul.READY_MS + 20, steady);
|
||||
assert.equal(r.phase, "play");
|
||||
for (const id of ["hollow", "stilts", "bogboat"]) {
|
||||
for (const id of ["hollow", "stilts", "lantern"]) {
|
||||
r.events.length = 0;
|
||||
through(r);
|
||||
assert.equal(r.spec.id, id);
|
||||
assert.notEqual(r.phase, "bossintro", `${id}: no boss card`);
|
||||
assert.equal(r.events.some((e) => e.type === "bossIntro"), false);
|
||||
}
|
||||
assert.ok(ghoul.roomById("bogboat").bonus, "the ride comes right before the boss");
|
||||
assert.ok(ghoul.roomById("lantern").bonus, "the bonus round comes right before the boss");
|
||||
r.events.length = 0;
|
||||
through(r);
|
||||
assert.equal(r.spec.id, "drowning");
|
||||
@@ -918,22 +1649,25 @@ test("Ghoul Rush's bog draws: every walked room and the arena, every monster in
|
||||
if (r.boss) {
|
||||
ghoul.advance(r, ghoul.BOSS_INTRO_MS + 16, steady);
|
||||
for (const hidden of [false, true]) {
|
||||
for (const act of ["idle", "wind", "rest", "throwWind", "sink", "under", "resurface"]) {
|
||||
Object.assign(r.boss, { act, wait: 400, dir: -1, lit: act === "rest", hidden: hidden && (act === "sink" || act === "under"), sinkX: r.boss.x - 10, home: 6 });
|
||||
for (const act of ["idle", "wind", "rest", "throwWind", "sink", "under", "resurface", "hands", "surgeWind", "surge", "shellWind", "shell", "stagger", "broodWind", "stompWind", "stompAir", "tideWind", "tideHold", "pullWind", "pull", "callWind", "lanternWind"]) {
|
||||
Object.assign(r.boss, { act, wait: 400, dir: -1, lit: act === "rest" || act === "stagger", hidden: hidden && (act === "sink" || act === "under"), sinkX: r.boss.x - 10, home: 6, floor: 6, y: act === "surge" ? 6 - bog.SURGE_SINK : act === "stompAir" ? 14 : 6, landX: r.boss.x - 12, airMs: 300, callXs: [r.boss.x - 12, r.boss.x - 24], shell: 5, shellMax: bog.SHELL_HP[0], comboMs: hidden ? 200 : 0 });
|
||||
g.tick(16);
|
||||
drew++;
|
||||
}
|
||||
Object.assign(r.boss, { y: 6, comboMs: 0 });
|
||||
}
|
||||
Object.assign(r.boss, { hidden: false, act: "rest", wait: 1e9 });
|
||||
r.hazards.push({ kind: "muck", x: r.you.x + 10, y: 6, w: bog.MUCK_W, h: bog.MUCK_H, warn: 400, live: 0, cause: "muck", sx: r.boss.x, sy: 9 }, { kind: "muck", x: r.you.x + 20, y: 6, w: bog.MUCK_W, h: bog.MUCK_H, warn: 0, live: 1500, cause: "muck" });
|
||||
r.waves.push({ x: r.you.x + 8, y: 6, dir: -1, life: 6000, kind: "mudwave", cause: "mudwave" });
|
||||
r.hazards.push({ kind: "boghand", x: r.you.x + 14, y: 6, w: bog.HAND_W, h: bog.HAND_H, warn: 500, full: 1200, live: 0, cause: "boghand" }, { kind: "boghand", x: r.you.x + 18, y: 6, w: bog.HAND_W, h: bog.HAND_H, warn: 0, live: 300, cause: "boghand" });
|
||||
r.hazards.push({ kind: "tide", x: 152, y: 5, w: 104, h: 1.6, x0: 104, x1: 200, warn: 600, live: 0, cause: "tide" }, { kind: "tide", x: 152, y: 5, w: 104, h: 1.6, x0: 104, x1: 200, warn: 0, live: 2000, cause: "tide" });
|
||||
}
|
||||
for (let k = 0; k < 20; k++) g.tick(16);
|
||||
r.you.safeMs = 1e9;
|
||||
drew++;
|
||||
}
|
||||
}
|
||||
assert.ok(drew >= 8 + 14, "drew a lot");
|
||||
assert.ok(drew >= 8 + 44, "drew a lot");
|
||||
assert.equal(r.spec.id, "drowning", "got to the pool and drew it");
|
||||
});
|
||||
|
||||
|
||||
@@ -1,945 +0,0 @@
|
||||
// Web console tests, Ghoul Rush's Bog Runner (Gallows Bog's bonus round, between the Stilt House and the Drowning Pool): its shape (two lanes, the banks, every thing spaced for a player), the boat's motion (a steady speed on the channel, slower on the flats, a jump, a duck, a hop between lanes only at a bank), each obstacle and its cost (snag, knee, veil, limb), the fan's clog and stall, the swarm in the wake and its catch, the charms and gas pockets shot for points and a cover burst, 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-bogboat.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as bz from "../src/web-console/public/activities/ghoul-bogboat.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOOKS as BOAT_LOOKS, LOSE_SOUNDS, LOSE_WORDS, TELEGRAPH_WORDS, VOICES as BOAT_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-bogboat-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { BOGBOAT_SFX } from "../src/web-console/public/activities/ghoul-sfx-bogboat.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
const never = () => {
|
||||
throw new Error("the bog runner drew a random number");
|
||||
};
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
function through(round) {
|
||||
round.phase = "clear";
|
||||
round.phaseMs = 1;
|
||||
ghoul.advance(round, 4, steady);
|
||||
}
|
||||
|
||||
// A round in the Bog Runner reached the way play reaches it, nothing woken, the clocks long,
|
||||
// the bonus round on (five hearts).
|
||||
function boatRound(seed = 5) {
|
||||
const round = ghoul.newRound(seed);
|
||||
round.lives = 3;
|
||||
round.dice = 0;
|
||||
through(round);
|
||||
round.offer = ["bog"];
|
||||
round.phaseMs = 0;
|
||||
ghoul.pickStage(round, 0);
|
||||
while (round.spec.id !== "bogboat") through(round);
|
||||
round.phase = "play";
|
||||
for (const st of round.spawns) st.over = true;
|
||||
round.monsters.length = 0;
|
||||
round.hordeMs = Infinity;
|
||||
round.timeMs = 1e9;
|
||||
round.bonus = 1e9;
|
||||
round.events.length = 0;
|
||||
return round;
|
||||
}
|
||||
|
||||
const NONE = { runner: "bogboat", time: 1e9, finish: 1e6, banks: [], snags: [], knees: [], veils: [], limbs: [], props: [], gas: [], checks: [] };
|
||||
// The same round over a ride of its own (a plain channel to measure the boat on).
|
||||
function synth(ride) {
|
||||
const round = boatRound();
|
||||
round.spec = { ...round.spec, start: 10, ground: [[0, 1e6, 9]], ride: { ...NONE, ...ride } };
|
||||
round.runner = null;
|
||||
bz.BOGBOAT.place[0](round, {});
|
||||
return round;
|
||||
}
|
||||
|
||||
// The boat at `x` in `lane`, on the water.
|
||||
function at(round, x, lane = 0, { safe = false } = {}) {
|
||||
Object.assign(round.runner, { lane, from: lane, swMs: 0, h: 0, vy: 0, air: false, v: lane ? bz.FLATS_V : bz.BOGBOAT_V, stall: 0, clog: 0 });
|
||||
Object.assign(round.you, { x, y: bz.LANE_Y[lane], vy: 0, state: "run", shelf: -1, face: 1, out: 0, safeMs: safe ? 1e9 : 0, ducking: false });
|
||||
round.camX = Math.max(0, Math.min(round.spec.length - ghoul.FIELD_W, x - 24));
|
||||
}
|
||||
|
||||
function run(round, ms, keys = {}, random = steady) {
|
||||
Object.assign(round.input, keys);
|
||||
for (let t = 0; t < ms; t += 4) ghoul.advance(round, 4, random);
|
||||
for (const k of Object.keys(keys)) round.input[k] = typeof keys[k] === "number" ? 0 : false;
|
||||
}
|
||||
|
||||
function until(round, done, ms = 6000, random = steady) {
|
||||
let t = 0;
|
||||
for (; t < ms && !done(); t += 4) ghoul.advance(round, 4, random);
|
||||
return t;
|
||||
}
|
||||
|
||||
const press = (round) => {
|
||||
round.input.jump = ghoul.JUMP_BUFFER_MS;
|
||||
round.input.up = true;
|
||||
};
|
||||
|
||||
const heard = (e, extra = {}) => {
|
||||
const played = [];
|
||||
const noop = () => {};
|
||||
const kit = { tone: (name) => played.push(name), burst: noop, float: noop, ring: noop, banner: () => null, shake: noop, flash: noop, glow: noop, splat: noop, fx: { clock: 1e6 }, monsters: ghoul.MONSTERS, powers: ghoul.POWERS, bosses: ghoul.BOSSES, g: {}, floorAt: () => 6, ...extra };
|
||||
react({ x: 10, y: 9, tx: 20, ty: 9, ...e }, kit);
|
||||
return { played };
|
||||
};
|
||||
|
||||
const ROOM = ghoul.roomById("bogboat");
|
||||
const R = ROOM.ride;
|
||||
const V = bz.BOGBOAT_V;
|
||||
const things = () => [
|
||||
...R.snags.map(([x, lane], i) => ({ id: `s${i}`, kind: "snag", lane, x })),
|
||||
...R.knees.map(([x, lane], i) => ({ id: `k${i}`, kind: "knee", lane, x })),
|
||||
...R.veils.map(([x0, x1, lane], i) => ({ id: `v${i}`, kind: "veil", lane, x: (x0 + x1) / 2 })),
|
||||
...R.limbs.map(([x0, x1, lane], i) => ({ id: `l${i}`, kind: "limb", lane, x: (x0 + x1) / 2 })),
|
||||
...R.props.map(([x, lane], i) => ({ id: `p${i}`, kind: "prop", lane, x })),
|
||||
...R.gas.map(([x, lane], i) => ({ id: `g${i}`, kind: "gas", lane, x })),
|
||||
];
|
||||
const HARMFUL = new Set(["snag", "knee", "veil", "limb"]);
|
||||
|
||||
/* -------------------------------------------------------------- the room */
|
||||
|
||||
test("Ghoul Rush's Bog Runner is Gallows Bog's fourth room, between the Stilt House and the Drowning Pool: lit, no key, no boss, a ride about a minute long, a bonus round that plays its own track", () => {
|
||||
const st = ghoul.stageById("bog");
|
||||
assert.deepEqual(st.rooms, ["boardwalk", "hollow", "stilts", "bogboat", "drowning"]);
|
||||
assert.deepEqual([ROOM.title, ROOM.sub], ["The Bog Runner", "Something swims in your wake"]);
|
||||
assert.equal(ROOM.dark, false, "a moonlit night, always lit");
|
||||
assert.equal(ROOM.key, null);
|
||||
assert.equal(ROOM.boss, null);
|
||||
assert.equal(ROOM.bonus, true, "a bonus round");
|
||||
assert.equal(R.runner, "bogboat");
|
||||
assert.ok(ROOM.length >= 2400 && ROOM.length <= 3000, `${ROOM.length} units long`);
|
||||
assert.equal(ghoul.ROOM_MUSIC.bogboat, "ghoulBoatRide");
|
||||
assert.ok(ghoulSfx.default.music.ghoulBoatRide, "its own track");
|
||||
assert.deepEqual(Object.keys(bz.BOGBOAT.monsters), [], "no new monster kinds");
|
||||
assert.equal(LOOKS.bogboat, BOAT_LOOKS.bogboat);
|
||||
assert.equal(LOOKS.bogboat.pack, "bogboat");
|
||||
assert.ok(Object.isFrozen(R) && Object.isFrozen(R.snags) && Object.isFrozen(R.snags[0]), "frozen all the way down");
|
||||
assert.ok(ROOM.horde.length === 0 && ROOM.spawns.length === 0 && ROOM.items.length === 0, "no monsters or pickups: the things on the water are the pack's own");
|
||||
assert.deepEqual(ROOM.ground.map((g) => g.slice()), [[0, ROOM.length, bz.LANE_Y[0]]], "one flat floor under the water");
|
||||
assert.ok(R.finish < ROOM.door && ROOM.door > ROOM.length - 20, "the door at the room's end, past the finish");
|
||||
assert.ok(ghoul.groundAt(ROOM, ROOM.door - 2) > -Infinity, "floor to walk out on");
|
||||
const secs = (R.finish - ROOM.start) / V;
|
||||
assert.ok(secs >= 56 && secs <= 80, `${secs.toFixed(1)} s at BOGBOAT_V`);
|
||||
assert.equal(ghoul.timeFor(ROOM), R.time, "its own clock");
|
||||
assert.ok(R.time / 1000 > secs * 1.4, "a clock with room to spare");
|
||||
assert.equal(ghoul.STAGES.find((s) => s.id === "bog").rooms.length, 5);
|
||||
assert.equal(R.banks.length, 11);
|
||||
assert.equal(R.checks.length, 4);
|
||||
assert.ok(R.props.length >= 16 && R.gas.length >= 14, "enough to shoot");
|
||||
assert.ok(R.snags.length && R.knees.length && R.veils.length && R.limbs.length, "one of each thing to dodge");
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: every thing is in lane 0 or 1, off the ends, spaced for a player, and clear of the banks", () => {
|
||||
const all = things();
|
||||
assert.ok(all.length >= 70 && all.length <= 130, `${all.length} things`);
|
||||
for (const t of all) {
|
||||
assert.ok(t.lane === 0 || t.lane === 1, `${t.id} lane`);
|
||||
assert.ok(t.x >= 120 && t.x < R.finish - 40, `${t.id} at ${t.x}`);
|
||||
}
|
||||
for (const lane of [0, 1]) assert.ok(all.filter((t) => t.lane === lane && HARMFUL.has(t.kind)).length >= 12, `plenty to dodge in lane ${lane}`);
|
||||
// The same lane: 36 between any two (a jump and a duck need 38 at the full speed, so the slots never share).
|
||||
for (const lane of [0, 1]) {
|
||||
const xs = all.filter((t) => t.lane === lane).map((t) => t.x).sort((a, b) => a - b);
|
||||
for (let i = 1; i < xs.length; i++) assert.ok(xs[i] - xs[i - 1] >= 36, `lane ${lane}: ${xs[i - 1]} and ${xs[i]}`);
|
||||
}
|
||||
// Banks: 16 wide, 200 apart, in order, and nothing within the hop of one.
|
||||
R.banks.forEach(([a, b], i) => {
|
||||
assert.equal(b - a, 16);
|
||||
if (i) assert.equal(a - R.banks[i - 1][0], 200, "banks are spaced out");
|
||||
for (const t of all) assert.ok(t.x < a - 6 || t.x > b + 22, `${t.id} at ${t.x} is near the bank ${a}`);
|
||||
});
|
||||
for (const [x0, x1] of R.veils) assert.equal(x1 - x0, 8);
|
||||
for (const [x0, x1] of R.limbs) assert.equal(x1 - x0, 6);
|
||||
// The channel is the thicker lane and the flats hold most of the gas.
|
||||
const dense = (lane) => all.filter((t) => t.lane === lane && HARMFUL.has(t.kind)).length;
|
||||
assert.ok(dense(0) > dense(1) * 1.5, `${dense(0)} to dodge in the channel, ${dense(1)} on the flats`);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: every jump is clearable and every duck passable, at the speed of either lane, and the checkpoints sit clear of the banks", () => {
|
||||
const clearFor = (h, speed) => (2 * Math.sqrt(bz.JUMP_V ** 2 - 2 * bz.GRAVITY * h) / bz.GRAVITY) * speed;
|
||||
for (const speed of [bz.BOGBOAT_V, bz.FLATS_V]) {
|
||||
assert.ok(clearFor(bz.SNAG_H, speed) >= bz.SNAG_W + ghoul.HIT_W + 8, `a snag at ${speed}`);
|
||||
assert.ok(clearFor(bz.KNEE_H, speed) >= bz.KNEE_W + ghoul.HIT_W + 8, `knees at ${speed}`);
|
||||
}
|
||||
assert.ok(bz.SNAG_H < (bz.JUMP_V ** 2) / (2 * bz.GRAVITY) - 4, "a snag is well under the jump's peak");
|
||||
assert.ok(ghoul.DUCK_H < bz.LOW_Y && ghoul.HIT_H > bz.LOW_Y, "a ducked Planny fits under a low and a standing one does not");
|
||||
R.checks.forEach((x, i) => {
|
||||
if (i) assert.ok(x - R.checks[i - 1] >= 400);
|
||||
assert.ok(R.banks.every(([a, b]) => x < a - 4 || x > b + 4));
|
||||
});
|
||||
});
|
||||
|
||||
/* ---------------------------------------------------------------- the boat */
|
||||
|
||||
test("Ghoul Rush's Bog Runner rolls at BOGBOAT_V on the channel whatever is pressed, slower on the flats, and DOWN eases the throttle in either; the camera leads it", () => {
|
||||
const round = synth({});
|
||||
assert.equal(round.runner.id, "bogboat");
|
||||
assert.equal(round.camLead, bz.CAM_AHEAD);
|
||||
assert.equal(round.you.y, bz.LANE_Y[0]);
|
||||
const x0 = round.you.x;
|
||||
run(round, 1000);
|
||||
assert.ok(Math.abs(round.you.x - x0 - V) < 0.5, `${round.you.x - x0} in a second`);
|
||||
for (const keys of [{ left: true }, { fire: true }]) {
|
||||
const a = round.you.x;
|
||||
run(round, 500, keys);
|
||||
assert.ok(Math.abs(round.you.x - a - V / 2) < 0.5, JSON.stringify(keys));
|
||||
}
|
||||
assert.equal(round.you.face, 1);
|
||||
// Left and right do nothing off a bank.
|
||||
run(round, 400, { right: true });
|
||||
assert.equal(round.runner.lane, 0);
|
||||
assert.equal(round.you.y, bz.LANE_Y[0]);
|
||||
const speedOf = (lane, keys) => {
|
||||
const r = synth({});
|
||||
at(r, 100, lane);
|
||||
run(r, 1500, keys);
|
||||
return r.runner.v;
|
||||
};
|
||||
assert.ok(Math.abs(speedOf(0, {}) - bz.BOGBOAT_V) < 0.3);
|
||||
assert.ok(Math.abs(speedOf(0, { down: true }) - bz.EASE_V) < 0.3);
|
||||
assert.ok(Math.abs(speedOf(1, {}) - bz.FLATS_V) < 0.3);
|
||||
assert.ok(Math.abs(speedOf(1, { down: true }) - bz.FLATS_EASE_V) < 0.3);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner jumps about 13 high for about three quarters of a second, a press saved for a landing jumps on it, and it cannot jump in the air", () => {
|
||||
const round = synth({});
|
||||
at(round, 100, 0, { safe: true });
|
||||
let peak = 0;
|
||||
let ms = 0;
|
||||
press(round);
|
||||
ghoul.advance(round, 4, steady);
|
||||
round.input.up = false;
|
||||
assert.equal(round.runner.air, true);
|
||||
while (round.runner.air && ms < 2000) {
|
||||
ghoul.advance(round, 4, steady);
|
||||
peak = Math.max(peak, round.you.y - bz.LANE_Y[0]);
|
||||
ms += 4;
|
||||
}
|
||||
assert.ok(peak > 12 && peak < 15, `${peak} high`);
|
||||
assert.ok(ms > 650 && ms < 850, `${ms} ms`);
|
||||
assert.equal(round.you.y, bz.LANE_Y[0]);
|
||||
assert.equal(events(round, "bogboatJump").length, 1);
|
||||
assert.equal(events(round, "bogboatLand").length, 1);
|
||||
// A press in the air does not double jump, but waits for the landing.
|
||||
const again = synth({});
|
||||
at(again, 100, 0, { safe: true });
|
||||
press(again);
|
||||
ghoul.advance(again, 4, steady);
|
||||
run(again, 400);
|
||||
press(again);
|
||||
run(again, 100);
|
||||
assert.ok(again.runner.vy <= 0 || again.runner.air, "no second jump in mid-air");
|
||||
until(again, () => !again.runner.air, 1000);
|
||||
press(again);
|
||||
ghoul.advance(again, 4, steady);
|
||||
assert.equal(again.runner.air, true, "a press saved for the landing jumps on it");
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: DOWN ducks, a ducked Planny passes under a veil or a limb and a standing one hits it (causes veil and limb), at the cost of a heart", () => {
|
||||
for (const [key, cause, ride] of [["veils", "veil", { veils: [[300, 308, 0]] }], ["limbs", "limb", { limbs: [[300, 306, 0]] }]]) {
|
||||
const standing = synth(ride);
|
||||
at(standing, 270, 0);
|
||||
run(standing, 1500);
|
||||
assert.equal(standing.bonusRound.hearts, 4, `${key}: a standing boat is hit`);
|
||||
assert.equal(events(standing, "lose").map((e) => e.cause).join(), cause);
|
||||
const ducked = synth(ride);
|
||||
at(ducked, 270, 0);
|
||||
run(ducked, 1500, { down: true });
|
||||
assert.equal(ducked.bonusRound.hearts, 5, `${key}: a ducked boat passes`);
|
||||
assert.equal(events(ducked, "bogboatDuck").length, 1);
|
||||
assert.equal(events(ducked, "lose").length, 0);
|
||||
}
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: a snag or cypress knees stop a boat that does not jump (causes snag and knee); a jump clears each; each costs only once", () => {
|
||||
for (const [cause, ride] of [["snag", { snags: [[300, 0]] }], ["knee", { knees: [[300, 0]] }]]) {
|
||||
const hit = synth(ride);
|
||||
at(hit, 270, 0);
|
||||
run(hit, 1500);
|
||||
assert.equal(hit.bonusRound.hearts, 4, cause);
|
||||
assert.equal(events(hit, "lose").map((e) => e.cause).join(), cause, "one heart, once");
|
||||
assert.equal(events(hit, "bogboatCrash").length, 1);
|
||||
const jumped = synth(ride);
|
||||
at(jumped, 270, 0);
|
||||
let pressed = false;
|
||||
until(jumped, () => {
|
||||
if (!pressed && jumped.you.x >= 300 - 14) {
|
||||
press(jumped);
|
||||
pressed = true;
|
||||
}
|
||||
return jumped.you.x > 340;
|
||||
}, 3000);
|
||||
assert.equal(jumped.bonusRound.hearts, 5, `${cause}: a jump clears it`);
|
||||
assert.equal(jumped.bonusRound.perf.hits.length, 0);
|
||||
}
|
||||
// The things in the other lane do not touch a boat.
|
||||
const other = synth({ snags: [[300, 1]], knees: [[300, 1]], veils: [[330, 338, 1]], limbs: [[360, 366, 1]] });
|
||||
at(other, 270, 0);
|
||||
run(other, 2400);
|
||||
assert.equal(other.bonusRound.hearts, 5);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner switches lanes only inside a bank: LEFT is the channel, RIGHT the flats, in SWITCH_MS, with no jump or duck in the hop; the boat slows to the flats' speed and comes back up to the channel's", () => {
|
||||
const round = synth({ banks: [[300, 316], [500, 516]] });
|
||||
at(round, 301, 0, { safe: true });
|
||||
run(round, 200, { right: true });
|
||||
assert.equal(round.runner.lane, 1);
|
||||
assert.equal(events(round, "bogboatSwitch").length, 1);
|
||||
assert.equal(events(round, "bogboatSwitch")[0].to, 1);
|
||||
assert.ok(round.runner.swMs > 0, "mid-hop");
|
||||
assert.equal(round.you.state, "run");
|
||||
// No jump or duck in the hop.
|
||||
press(round);
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.runner.air, false);
|
||||
round.input.up = false;
|
||||
run(round, bz.SWITCH_MS);
|
||||
assert.equal(round.runner.swMs, 0);
|
||||
assert.equal(round.you.y, bz.LANE_Y[1], "up on the flats");
|
||||
assert.ok(round.runner.v < bz.BOGBOAT_V - 5, "slowed");
|
||||
// Not outside a bank.
|
||||
run(round, 400, { left: true });
|
||||
assert.equal(round.runner.lane, 1, "off a bank nothing changes");
|
||||
// Back down at the next one.
|
||||
at(round, 496, 1, { safe: true });
|
||||
run(round, 600, { left: true });
|
||||
assert.equal(round.runner.lane, 0);
|
||||
assert.equal(round.you.y, bz.LANE_Y[0]);
|
||||
// Not in the air.
|
||||
const air = synth({ banks: [[300, 316]] });
|
||||
at(air, 304, 0, { safe: true });
|
||||
press(air);
|
||||
run(air, 40);
|
||||
run(air, 40, { right: true });
|
||||
assert.equal(air.runner.lane, 0, "no switch in the air");
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: the fan clogs on the flats at full throttle (a warning at CLOG_WARN, a stall at CLOG_MAX that stops the boat for STALL_MS), an ease or the channel clears it", () => {
|
||||
const round = synth({});
|
||||
at(round, 100, 1, { safe: true });
|
||||
run(round, 1000);
|
||||
assert.ok(Math.abs(round.runner.clog - bz.CLOG_RISE) < 2, `${round.runner.clog} after a second`);
|
||||
until(round, () => events(round, "bogboatClog").length > 0, 4000);
|
||||
assert.ok(round.runner.clog >= bz.CLOG_WARN - 1);
|
||||
until(round, () => round.runner.stall > 0, 4000);
|
||||
assert.equal(events(round, "bogboatStall").length, 1);
|
||||
run(round, 800);
|
||||
assert.ok(round.runner.v < 3, `coasting to a stop (${round.runner.v})`);
|
||||
const x = round.you.x;
|
||||
until(round, () => round.runner.stall === 0, 2000);
|
||||
assert.equal(round.runner.stall, 0);
|
||||
assert.ok(round.runner.clog >= bz.CLOG_RESTART && round.runner.clog < bz.CLOG_WARN, `restarted at ${round.runner.clog}`);
|
||||
assert.ok(round.you.x - x < 6, "hardly moved while stalled");
|
||||
// Eased, the flats cool the fan.
|
||||
const eased = synth({});
|
||||
at(eased, 100, 1, { safe: true });
|
||||
run(eased, 1200);
|
||||
const hot = eased.runner.clog;
|
||||
run(eased, 1000, { down: true });
|
||||
assert.ok(eased.runner.clog < hot, "an ease cools it");
|
||||
// And the channel does.
|
||||
const channel = synth({});
|
||||
at(channel, 100, 0, { safe: true });
|
||||
channel.runner.clog = 80;
|
||||
run(channel, 1000);
|
||||
assert.ok(Math.abs(channel.runner.clog - (80 - bz.CLOG_COOL)) < 0.5, `${channel.runner.clog}`);
|
||||
// A stalled fan stops the boat, so the swarm gains on it.
|
||||
const lost = synth({});
|
||||
at(lost, 100, 1, { safe: true });
|
||||
Object.assign(lost.runner, { clog: bz.CLOG_MAX - 0.1, gap: bz.GAP_MAX });
|
||||
until(lost, () => lost.runner.stall > 0, 1000);
|
||||
const gap = lost.runner.gap;
|
||||
run(lost, 1000);
|
||||
assert.ok(lost.runner.gap < gap - 10, `${gap} to ${lost.runner.gap}`);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner's wake: it opens on clean riding, closes when the boat is eased or on the flats, a hit shoves it HIT_CLOSE closer, and PANIC_ON boils it until PANIC_OFF", () => {
|
||||
const round = synth({});
|
||||
at(round, 100, 0, { safe: true });
|
||||
run(round, 500);
|
||||
assert.ok(round.runner.gap > bz.GAP_START, "opening");
|
||||
run(round, 2000);
|
||||
assert.equal(round.runner.gap, bz.GAP_MAX, "never over GAP_MAX");
|
||||
const eased = synth({});
|
||||
at(eased, 100, 0, { safe: true });
|
||||
eased.runner.gap = 30;
|
||||
run(eased, 2000, { down: true });
|
||||
assert.ok(eased.runner.gap < 30, "the ease loses ground");
|
||||
const flats = synth({});
|
||||
at(flats, 100, 1, { safe: true });
|
||||
flats.runner.gap = 30;
|
||||
run(flats, 500, { down: true });
|
||||
assert.ok(flats.runner.gap < 30, "the eased flats lose ground");
|
||||
// A hit shoves it closer.
|
||||
const hit = synth({ snags: [[300, 0]] });
|
||||
at(hit, 280, 0);
|
||||
hit.runner.gap = 30;
|
||||
run(hit, 500);
|
||||
assert.ok(hit.runner.gap <= 30 - bz.HIT_CLOSE + (V - bz.WAKE_V) * 0.5 + 1, `${hit.runner.gap}`);
|
||||
assert.equal(hit.bonusRound.hearts, 4);
|
||||
// PANIC_ON: the swarm boils (an event, once), PANIC_OFF puts it out and it can boil again.
|
||||
const panic = synth({});
|
||||
at(panic, 100, 0, { safe: true });
|
||||
panic.runner.gap = bz.PANIC_ON + 0.5;
|
||||
panic.runner.v = 20;
|
||||
run(panic, 200, { down: true });
|
||||
assert.equal(panic.runner.panic, true);
|
||||
assert.equal(events(panic, "bogboatPanic").length, 1);
|
||||
run(panic, 4000);
|
||||
assert.equal(panic.runner.panic, false);
|
||||
assert.equal(panic.bonusRound.perf.steady, false, "a swarm that boiled loses the steady die");
|
||||
assert.equal(panic.runner.panicked, true);
|
||||
const clean = synth({});
|
||||
at(clean, 100, 0, { safe: true });
|
||||
run(clean, 3000);
|
||||
assert.equal(clean.bonusRound.perf.steady, true);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: at WAKE_CATCH the swarm has you, a heart (cause wake), and it falls back to WAKE_FALLBACK, once; a blinking boat is caught for free; the catch is counted for the grade", () => {
|
||||
const round = synth({});
|
||||
at(round, 100, 0);
|
||||
round.runner.v = 20;
|
||||
round.runner.gap = bz.WAKE_CATCH + 0.2;
|
||||
run(round, 200, { down: true });
|
||||
assert.equal(round.bonusRound.hearts, 4);
|
||||
assert.equal(events(round, "lose").map((e) => e.cause).join(), "wake");
|
||||
assert.equal(events(round, "bogboatCatch").length, 1);
|
||||
assert.ok(round.runner.gap > bz.WAKE_FALLBACK - 3 && round.runner.gap <= bz.WAKE_FALLBACK + 2, `${round.runner.gap}`);
|
||||
assert.equal(round.runner.catches, 1);
|
||||
assert.equal(round.bonusRound.perf.total, 1);
|
||||
assert.deepEqual(round.bonusRound.perf.hits, ["w1"]);
|
||||
assert.equal(round.phase, "play", "the ride goes on");
|
||||
const free = synth({});
|
||||
at(free, 100, 0, { safe: true });
|
||||
free.runner.v = 20;
|
||||
free.runner.gap = bz.WAKE_CATCH + 0.2;
|
||||
run(free, 200, { down: true });
|
||||
assert.equal(free.bonusRound.hearts, 5);
|
||||
assert.equal(events(free, "bogboatCatch").length, 1);
|
||||
assert.equal(free.runner.gap > bz.WAKE_CATCH + 10, true, "still falls back");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------ shooting */
|
||||
|
||||
test("Ghoul Rush's Bog Runner: one bolt breaks a charm (60 points) and one bursts a gas pocket (90 points, the wake pushed back GAS_PUSH), each an act for the grade; a bolt at another height flies on; a pocket stays burst across a re-seat", () => {
|
||||
const round = synth({ props: [[330, 0, 0], [380, 1, 1]], gas: [[420, 0], [470, 1]] });
|
||||
at(round, 300, 0, { safe: true });
|
||||
round.runner.gap = 20;
|
||||
const score = round.score;
|
||||
round.shots.push({ x: 328, y: bz.LANE_Y[0] + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.runner.props[0].state, "broken");
|
||||
assert.equal(round.score - score, bz.PROP_POINTS);
|
||||
assert.equal(round.bonusRound.perf.acts, 1);
|
||||
assert.equal(events(round, "bogboatProp").length, 1);
|
||||
assert.equal(events(round, "bogboatProp")[0].points, bz.PROP_POINTS);
|
||||
// A bolt too high flies on, one in the wrong lane too.
|
||||
round.shots.push({ x: 418, y: bz.LANE_Y[0] + 9, vx: 130, vy: 0, gone: 0 });
|
||||
round.shots.push({ x: 468, y: bz.LANE_Y[0] + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.runner.gas[0].state, "up");
|
||||
assert.equal(round.runner.gas[1].state, "up", "the flats' pocket needs a bolt at the flats' height");
|
||||
const gap = round.runner.gap;
|
||||
round.shots.push({ x: 418, y: bz.LANE_Y[0] + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.runner.gas[0].state, "burst");
|
||||
assert.ok(round.runner.gap - gap >= bz.GAS_PUSH - 0.5, `pushed back ${round.runner.gap - gap}`);
|
||||
assert.equal(round.bonusRound.perf.acts, 2);
|
||||
assert.equal(events(round, "bogboatGas")[0].points, bz.GAS_POINTS);
|
||||
// Burst, then spent; a second bolt through the cloud does nothing.
|
||||
run(round, bz.GAS_BURST_MS + 20);
|
||||
assert.equal(round.runner.gas[0].state, "spent");
|
||||
const acts = round.bonusRound.perf.acts;
|
||||
round.shots.push({ x: 418, y: bz.LANE_Y[0] + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.bonusRound.perf.acts, acts);
|
||||
// A charm hit in the flats' height.
|
||||
at(round, 340, 1, { safe: true });
|
||||
round.shots.push({ x: 378, y: bz.LANE_Y[1] + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.runner.props[1].state, "broken");
|
||||
// What was shot stays shot when the boat is put back (a re-seat in the same room), a pocket still bursting too.
|
||||
Object.assign(round.runner.gas[1], { state: "burst", t: 300 });
|
||||
bz.BOGBOAT.place[0](round, {});
|
||||
assert.equal(round.runner.gas[0].state, "spent");
|
||||
assert.equal(round.runner.props[0].state, "broken");
|
||||
assert.equal(round.runner.props[1].state, "broken");
|
||||
assert.equal(round.runner.gas[1].state, "spent", "a burst pocket is not revived");
|
||||
const fresh = synth({ gas: [[420, 0]] });
|
||||
assert.equal(fresh.runner.gas[0].state, "up");
|
||||
});
|
||||
|
||||
/* --------------------------------------------------------------- the round */
|
||||
|
||||
test("Ghoul Rush's Bog Runner: the last heart gone ends the round with nothing at once (no life lost, the dice in hand kept) and the run goes on to the Drowning Pool", () => {
|
||||
const round = boatRound();
|
||||
round.dice = 2;
|
||||
round.bonusRound.hearts = 1;
|
||||
const first = things().filter((t) => t.lane === 0 && HARMFUL.has(t.kind)).sort((a, b) => a.x - b.x)[0];
|
||||
at(round, first.x - 12, 0);
|
||||
until(round, () => round.phase === "clear", 8000);
|
||||
assert.equal(round.bonusRound.hearts, 0);
|
||||
assert.equal(round.bonusRound.over, true);
|
||||
assert.equal(round.bonusRound.won, false);
|
||||
const end = events(round, "bonusEnd");
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, false);
|
||||
assert.equal(end[0].dice, 0);
|
||||
assert.equal(round.over, false, "no game over");
|
||||
assert.equal(round.lives, 3);
|
||||
assert.equal(round.dice, 2);
|
||||
run(round, ghoul.CARD_LOST_MS + 100);
|
||||
assert.equal(round.spec.id, "drowning");
|
||||
assert.equal(round.bonusRound, null);
|
||||
assert.equal(round.runner, null);
|
||||
assert.equal(round.lives, 3);
|
||||
assert.equal(round.dice, 2);
|
||||
skipBossIntro(ghoul, round);
|
||||
assert.equal(round.phase, "ready");
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: the checkpoints are passed in order (an event each) and the ride goes back to the last one after the last heart", () => {
|
||||
const round = boatRound();
|
||||
at(round, R.checks[0] - 6, 0, { safe: true });
|
||||
until(round, () => round.runner.check >= 0, 3000);
|
||||
assert.deepEqual(events(round, "bogboatCheck").map((e) => e.n).slice(0, 1), [1]);
|
||||
const c0 = round.runner.check;
|
||||
round.you.x = 1;
|
||||
bz.BOGBOAT.place[0](round, {});
|
||||
assert.equal(round.you.x, R.checks[c0]);
|
||||
assert.equal(round.runner.check, c0);
|
||||
assert.equal(round.runner.lane, 0);
|
||||
assert.equal(round.camLead, bz.CAM_AHEAD);
|
||||
const fresh = boatRound();
|
||||
assert.equal(fresh.you.x, ROOM.start);
|
||||
assert.equal(fresh.runner.check, -1);
|
||||
// Past all four on a long ride.
|
||||
const long = synth({ checks: R.checks });
|
||||
long.you.safeMs = 1e9;
|
||||
long.timeMs = 1e9;
|
||||
run(long, 62000);
|
||||
assert.equal(long.runner.check, R.checks.length - 1);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: at the finish the fan is cut, the door opens, and walking out ends the round with 3 to 9 Lucky dice", () => {
|
||||
const round = boatRound();
|
||||
round.dice = 1;
|
||||
at(round, R.finish - 8, 1, { safe: true });
|
||||
until(round, () => round.runner.done, 3000);
|
||||
assert.equal(round.runner.done, true);
|
||||
assert.equal(events(round, "bogboatFinish").length, 1);
|
||||
assert.equal(round.you.y, ghoul.groundAt(ROOM, round.you.x), "back down on the water's floor, from either lane");
|
||||
assert.equal(round.hasKey, true, "the door opens");
|
||||
assert.equal(round.bonusRound.hearts, 5);
|
||||
assert.equal(round.phase, "play");
|
||||
round.input.right = true;
|
||||
until(round, () => round.phase === "clear", 20000);
|
||||
round.input.right = false;
|
||||
assert.equal(round.phase, "clear");
|
||||
const end = events(round, "bonusEnd");
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "drowning");
|
||||
assert.equal(round.runner, null);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: no random number is drawn in the room (a ride of 20 seconds, jumping, switching and shooting, on a draw that throws)", () => {
|
||||
const round = boatRound();
|
||||
round.you.safeMs = 1e9;
|
||||
for (let t = 0; t < 20000; t += 16) {
|
||||
round.input.fire = true;
|
||||
round.input.right = t % 6000 < 3000;
|
||||
round.input.left = !round.input.right;
|
||||
round.input.down = t % 2500 < 400;
|
||||
if (t % 1500 === 0) press(round);
|
||||
ghoul.advance(round, 16, never);
|
||||
round.input.up = false;
|
||||
round.events.length = 0;
|
||||
}
|
||||
assert.ok(round.you.x > 300);
|
||||
});
|
||||
|
||||
/* ----------------------------------------------------------- grade and dice */
|
||||
|
||||
test("Ghoul Rush's Bog Runner's grade: the obstacles the boat faced are the total, one passed in its lane counts and one dodged by a lane does not, shooting 8 things is the die, a swarm that never boiled is the die", () => {
|
||||
const ride = { banks: [[300, 316]], snags: [[400, 0]], knees: [[460, 0], [460, 1]], gas: [[600, 1]] };
|
||||
const round = synth(ride);
|
||||
at(round, 250, 0, { safe: true });
|
||||
assert.equal(round.bonusRound.perf.total, 0);
|
||||
assert.equal(round.bonusRound.perf.goal, bz.ACTS_GOAL);
|
||||
// Stay in the channel: the snag and the channel's knees are faced, not the flats' knees.
|
||||
until(round, () => round.you.x > 480, 6000);
|
||||
assert.equal(round.bonusRound.perf.total, 2);
|
||||
// Switch away at the bank: the channel's things are dodged by the lane and not counted; the flats' are.
|
||||
const away = synth(ride);
|
||||
at(away, 296, 0, { safe: true });
|
||||
away.input.right = true;
|
||||
run(away, 500);
|
||||
away.input.right = false;
|
||||
assert.equal(away.runner.lane, 1);
|
||||
until(away, () => away.you.x > 480, 8000);
|
||||
const faced = Object.keys(away.runner.faced).filter((id) => id[0] !== "w");
|
||||
assert.deepEqual(faced, ["k1"], "the flats' knees only: the channel's things were dodged by a lane");
|
||||
assert.equal(away.bonusRound.perf.hits.filter((id) => id[0] !== "w").length, 0);
|
||||
// A faced thing that cost a heart is a hit, counted once.
|
||||
const hit = synth(ride);
|
||||
at(hit, 385, 0);
|
||||
run(hit, 800);
|
||||
assert.deepEqual(hit.bonusRound.perf.hits, ["s0"]);
|
||||
assert.equal(hit.bonusRound.perf.total, 1);
|
||||
// The dice: the floor, hearts, clean passes, acts, a swarm that never boiled.
|
||||
const b = makeBonus({ stats: { kills: 0 } });
|
||||
b.perf = { total: 20, hits: [], acts: 0, goal: bz.ACTS_GOAL, steady: false, kills0: 0 };
|
||||
assert.equal(diceFor(b), BONUS_FLOOR + 2 + 2);
|
||||
b.perf.steady = true;
|
||||
assert.equal(diceFor(b), 9 - 1);
|
||||
b.perf.acts = bz.ACTS_GOAL;
|
||||
assert.equal(diceFor(b), 9);
|
||||
b.perf.acts = bz.ACTS_GOAL - 1;
|
||||
assert.equal(diceFor(b), 8);
|
||||
b.hearts = 1;
|
||||
assert.equal(diceFor(b), 6);
|
||||
b.perf.hits = Array.from({ length: 20 }, (_, i) => `x${i}`);
|
||||
assert.equal(diceFor(b), BONUS_FLOOR + 0 + 0 + 0 + 1);
|
||||
b.perf.steady = false;
|
||||
assert.equal(diceFor(b), BONUS_FLOOR);
|
||||
});
|
||||
|
||||
const CAUSES = {
|
||||
snag: { snags: [[300, 0]] },
|
||||
knee: { knees: [[300, 0]] },
|
||||
veil: { veils: [[300, 308, 0]] },
|
||||
limb: { limbs: [[300, 306, 0]] },
|
||||
};
|
||||
|
||||
test("Ghoul Rush's Bog Runner: endless lives (round.infinite) spare the hearts for every cause, through the same lose path", () => {
|
||||
for (const [cause, ride] of Object.entries(CAUSES)) {
|
||||
const round = synth(ride);
|
||||
round.infinite = true;
|
||||
at(round, 270, 0);
|
||||
run(round, 1800);
|
||||
assert.ok(events(round, "lose").some((e) => e.cause === cause), `${cause} was lost to`);
|
||||
assert.equal(round.bonusRound.hearts, 5, `${cause} cost nothing`);
|
||||
assert.equal(round.lives, 3);
|
||||
assert.equal(round.phase, "play");
|
||||
}
|
||||
const wake = synth({});
|
||||
wake.infinite = true;
|
||||
at(wake, 100, 0);
|
||||
wake.runner.v = 20;
|
||||
wake.runner.gap = bz.WAKE_CATCH + 0.2;
|
||||
run(wake, 200, { down: true });
|
||||
assert.ok(events(wake, "lose").some((e) => e.cause === "wake"), "the wake was lost to");
|
||||
assert.equal(wake.bonusRound.hearts, 5);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: every cause costs exactly one heart", () => {
|
||||
for (const [cause, ride] of Object.entries(CAUSES)) {
|
||||
const round = synth(ride);
|
||||
at(round, 270, 0);
|
||||
run(round, 1800);
|
||||
assert.equal(round.bonusRound.hearts, 4, cause);
|
||||
assert.equal(events(round, "lose").map((e) => e.cause).join(), cause);
|
||||
assert.equal(round.lives, 3);
|
||||
}
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: the Garlic shield takes a hit instead of a heart", () => {
|
||||
const round = synth({ snags: [[300, 0]] });
|
||||
round.you.garlic = true;
|
||||
at(round, 285, 0);
|
||||
round.you.garlic = true;
|
||||
run(round, 800);
|
||||
assert.equal(round.bonusRound.hearts, 5);
|
||||
assert.equal(round.you.garlic, false);
|
||||
});
|
||||
|
||||
/* ---------------------------------------------------------------- voices */
|
||||
|
||||
test("Ghoul Rush's Bog Runner: every event has a voice that plays, every cause has words and a sound, and the voices are tones that exist (none over 1.2 s)", () => {
|
||||
assert.deepEqual(Object.keys(EVENT_VOICE).sort(), [...bz.EVENTS].sort(), "a voice for every event and no more");
|
||||
const tones = ghoulSfx.default.tones;
|
||||
for (const [event, [kind, act]] of Object.entries(EVENT_VOICE)) {
|
||||
const name = BOAT_VOICES[kind] && BOAT_VOICES[kind][act];
|
||||
assert.ok(name, `${event} has a ${kind}.${act} voice`);
|
||||
assert.ok(tones[name], `${name} exists`);
|
||||
assert.equal(VOICES[kind][act], name, "joined to the game's voices");
|
||||
const played = heard({ type: event, what: "snag", kind: 0, points: 50, to: 1 }).played;
|
||||
assert.ok(played.includes(name), `${event} plays ${name}`);
|
||||
}
|
||||
for (const [name, def] of Object.entries(BOGBOAT_SFX.tones)) {
|
||||
assert.ok(tones[name], name);
|
||||
for (const l of def.layers) assert.ok(l.seconds > 0 && l.seconds + (l.delay || 0) <= 1.2, `${name} is short`);
|
||||
}
|
||||
for (const cause of ["snag", "knee", "veil", "limb", "wake"]) {
|
||||
assert.ok(LOSE_WORDS[cause], `${cause} has words`);
|
||||
assert.ok(LOSE_SOUNDS[cause] && LOSE_SOUNDS[cause].length === 3, `${cause} has a sound`);
|
||||
assert.ok(heard({ type: "lose", cause, hearts: 3 }).played.length > 0, `${cause} sounds`);
|
||||
}
|
||||
assert.equal(heard({ type: "bogboatJump" }).played.length, 1);
|
||||
assert.equal(heard({ type: "bogboatGas", points: 90 }).played.length, 1);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: its music has the room's level of voices, bars of sixteen steps, and a track for the room", () => {
|
||||
const track = ghoulSfx.default.music.ghoulBoatRide;
|
||||
assert.equal(track, BOGBOAT_SFX.music.ghoulBoatRide);
|
||||
const playing = Object.entries(track.voices).filter(([, v]) => (v.from ?? 0) <= 0.7);
|
||||
assert.ok(playing.length >= 4);
|
||||
for (const [name, p] of Object.entries(track.patterns)) {
|
||||
for (const [voice, line] of Object.entries(p)) {
|
||||
assert.ok(track.voices[voice], `${name}.${voice} is a voice`);
|
||||
for (const bar of line.split("|")) assert.equal(bar.trim().split(/\s+/).length, 16, `${name}.${voice}`);
|
||||
}
|
||||
}
|
||||
for (const name of track.order) assert.ok(track.patterns[name]);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: the room's own names do not collide with the game's (hazards, events, kinds)", () => {
|
||||
for (const e of bz.EVENTS) assert.ok(e.startsWith("bogboat"), e);
|
||||
assert.ok(!bz.EVENTS.some((e) => e.startsWith("bogboatboat")), "no bogboatboat names");
|
||||
assert.deepEqual(Object.keys(bz.BOGBOAT).filter((key) => ["hazards", "bosses", "boss"].includes(key)), []);
|
||||
assert.equal(typeof ghoul.ROOM_MUSIC.bogboat, "string");
|
||||
assert.equal(ghoul.roomById("bogboat").ride.runner, "bogboat");
|
||||
for (const kind of Object.keys(BOAT_VOICES)) assert.ok(kind.startsWith("bogboat"), kind);
|
||||
});
|
||||
|
||||
/* --------------------------------------------------------------- drawing */
|
||||
|
||||
test("Ghoul Rush's Bog Runner draws: the room in a lit and a dark one, the boat on each lane, in the air, ducking and switching, each thing in each state, the swarm far and close, the clog and the stall, a crash, the finish and the cards", () => {
|
||||
const ctx = new Proxy({}, { get: (t, name) => (name in t ? t[name] : () => {}), set: (t, name, value) => ((t[name] = value), true) });
|
||||
const g = ghoul.default.create({ canvas: { width: 0, height: 0, getContext: () => ctx } });
|
||||
g.resize(900, 900);
|
||||
g.key("action");
|
||||
g.tick(16);
|
||||
const r = g.round;
|
||||
through(r);
|
||||
r.offer = ["bog"];
|
||||
r.phaseMs = 0;
|
||||
ghoul.pickStage(r, 0);
|
||||
while (r.spec.id !== "bogboat") through(r);
|
||||
r.lives = 99;
|
||||
const spots = [ROOM.start + 40, R.snags[0][0] - 10, R.limbs[0][0] - 5, R.veils[0][0] - 5, R.gas[0][0] - 10, R.checks[0], R.banks[0][0] + 2, R.finish - 40];
|
||||
for (const dark of [true, false]) {
|
||||
for (const x of spots) {
|
||||
r.dark = dark;
|
||||
r.phase = "play";
|
||||
for (const st of r.spawns) st.over = true;
|
||||
r.hordeMs = Infinity;
|
||||
r.monsters.length = 0;
|
||||
for (const lane of [0, 1]) {
|
||||
at(r, x, lane, { safe: true });
|
||||
r.runner.props = r.runner.props.map((p, i) => ({ ...p, state: i % 3 ? "up" : "broken" }));
|
||||
r.runner.gas = r.runner.gas.map((p, i) => ({ ...p, state: ["up", "burst", "spent"][i % 3], t: 300 }));
|
||||
for (const air of [false, true]) {
|
||||
if (air) Object.assign(r.runner, { air: true, h: 5, vy: 20, gap: 12, panic: true, clog: 90 });
|
||||
if (air) Object.assign(r.you, { state: "air", vy: 20, y: r.you.y + 5 });
|
||||
if (!air) Object.assign(r.runner, { gap: 30, panic: false, clog: 20 });
|
||||
r.you.ducking = !air && lane === 0;
|
||||
r.runner.stall = air ? 800 : 0;
|
||||
r.shots.push({ x: x + 6, y: r.you.y + 2.4, vx: 130, vy: 0, gone: 0 });
|
||||
for (let k = 0; k < 4; k++) g.tick(16);
|
||||
r.monsters.length = 0;
|
||||
r.you.safeMs = 1e9;
|
||||
at(r, x, lane, { safe: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// A switch in progress, mid-hop.
|
||||
at(r, R.banks[0][0] + 2, 0, { safe: true });
|
||||
r.input.right = true;
|
||||
for (let k = 0; k < 12; k++) g.tick(16);
|
||||
r.input.right = false;
|
||||
assert.equal(r.spec.id, "bogboat");
|
||||
// Crashes: a snag.
|
||||
r.you.safeMs = 0;
|
||||
at(r, R.snags[0][0] - 3, R.snags[0][1]);
|
||||
for (let k = 0; k < 30; k++) g.tick(16);
|
||||
assert.ok(r.bonusRound.hearts < r.bonusRound.max || r.phase !== "play", "the crash draws too");
|
||||
const done = ghoul.default.create({ canvas: { width: 0, height: 0, getContext: () => ctx } });
|
||||
done.resize(900, 900);
|
||||
done.key("action");
|
||||
done.tick(16);
|
||||
const d = done.round;
|
||||
through(d);
|
||||
d.offer = ["bog"];
|
||||
d.phaseMs = 0;
|
||||
ghoul.pickStage(d, 0);
|
||||
while (d.spec.id !== "bogboat") through(d);
|
||||
d.phase = "play";
|
||||
d.runner.done = true;
|
||||
d.runner.restX = R.finish + 10;
|
||||
Object.assign(d.you, { x: R.finish + 20, y: 9, state: "run" });
|
||||
d.camX = R.finish - 40;
|
||||
for (let k = 0; k < 10; k++) done.tick(16);
|
||||
for (const won of [true, false]) {
|
||||
endBonus(d, won, { ROOM_POINTS: 300, award: (rd, pts) => (rd.score += pts) });
|
||||
d.bonusRound.over = true;
|
||||
for (let k = 0; k < 10; k++) {
|
||||
done.tick(16);
|
||||
bonusTick(d, { tone() {}, fx: {} });
|
||||
}
|
||||
d.bonusRound.over = false;
|
||||
}
|
||||
// The stage select goes straight into it.
|
||||
const pick = ghoul.default.create({ canvas: { width: 0, height: 0, getContext: () => ctx } });
|
||||
pick.resize(900, 900);
|
||||
pick.stageSelect();
|
||||
const p = pick.round;
|
||||
const at2 = ghoul.STAGES.findIndex((s) => s.id === "bog");
|
||||
for (let i = 0; i < at2; i++) ghoul.steerSelect(p, 1, 0);
|
||||
for (let i = 0; i < 3; i++) ghoul.steerSelect(p, 0, 1);
|
||||
assert.equal(p.select.room, 3);
|
||||
pick.tick(16);
|
||||
ghoul.takeSelect(p);
|
||||
assert.equal(p.spec.id, "bogboat");
|
||||
assert.equal(p.runner.lane, 0);
|
||||
assert.equal(p.you.y, bz.LANE_Y[0]);
|
||||
pick.tick(16);
|
||||
});
|
||||
|
||||
/* ----------------------------------------------------------- the bots */
|
||||
|
||||
// A bot that rides well: it keeps to the channel, jumps 9 to 15 short of a snag or cypress knees, ducks under
|
||||
// every veil and limb, and holds the blaster. `miss` is the share of things it fails to dodge (by a hash).
|
||||
const mix = (a, b) => {
|
||||
let h = Math.imul(a + 0x9e37, 0x85ebca6b) ^ Math.imul(b + 0x7f4a, 0xc2b2ae35);
|
||||
h ^= h >>> 13;
|
||||
h = Math.imul(h, 0x5bd1e995);
|
||||
h ^= h >>> 15;
|
||||
return (h >>> 0) / 4294967296;
|
||||
};
|
||||
function goodBot(round, seed, miss = 0.04, shoot = true) {
|
||||
const { you, runner: c, input: inp } = round;
|
||||
inp.left = inp.right = inp.down = false;
|
||||
inp.fire = shoot;
|
||||
if (round.phase !== "play" || !c || c.done) {
|
||||
inp.up = false;
|
||||
return;
|
||||
}
|
||||
const ok = (x) => mix(seed, Math.round(x)) >= miss;
|
||||
const look = 9 + (seed % 7);
|
||||
const lane = c.lane;
|
||||
const bank = R.banks.find(([a, b]) => you.x >= a && you.x <= b);
|
||||
if (bank) inp.left = true;
|
||||
let jump = false;
|
||||
const ahead = (x) => x - you.x > 6 && x - you.x < look;
|
||||
for (const [x, l] of R.snags) if (l === lane && ahead(x) && ok(x)) jump = true;
|
||||
for (const [x, l] of R.knees) if (l === lane && ahead(x) && ok(x)) jump = true;
|
||||
for (const [x0, x1, l] of [...R.veils, ...R.limbs]) if (l === lane && you.x > x0 - 10 && you.x < x1 + 3 && ok(x0)) inp.down = true;
|
||||
if (jump && !inp.down && !c.air) press(round);
|
||||
else inp.up = false;
|
||||
}
|
||||
function idleBot(round) {
|
||||
const inp = round.input;
|
||||
inp.left = inp.right = inp.down = false;
|
||||
inp.up = false;
|
||||
inp.fire = true;
|
||||
}
|
||||
function rideWith(seed, bot, limit = 100000) {
|
||||
const round = boatRound(seed);
|
||||
const lost = [];
|
||||
let t = 0;
|
||||
for (; t < limit && round.phase !== "clear" && !round.over; t += 16) {
|
||||
bot(round);
|
||||
if (round.runner && round.runner.done && round.phase === "play") round.input.right = true;
|
||||
ghoul.advance(round, 16, steady);
|
||||
for (const e of round.events) if (e.type === "lose") lost.push(e.cause);
|
||||
if (round.runner && !round.runner.done) {
|
||||
const off = round.you.x - round.camX;
|
||||
assert.ok(off > 4 && off < 70, `the boat stays in view (${off.toFixed(1)} from the left edge at ${round.you.x.toFixed(0)})`);
|
||||
}
|
||||
round.events.length = 0;
|
||||
}
|
||||
return { round, lost, ms: t };
|
||||
}
|
||||
|
||||
test("Ghoul Rush's Bog Runner: a bot that rides well finishes the whole channel in 57 to 75 seconds, with 5 to 9 dice, a few hearts lost at most, past every checkpoint", () => {
|
||||
const dice = [];
|
||||
const gone = [];
|
||||
for (let seed = 1; seed <= 12; seed++) {
|
||||
const { round, lost, ms } = rideWith(seed, (r) => goodBot(r, seed));
|
||||
const b = round.bonusRound;
|
||||
assert.equal(b.won, true, `seed ${seed} finished (lost ${lost.join(",")})`);
|
||||
assert.ok(ms > 57000 && ms < 76000, `${ms} ms`);
|
||||
assert.ok(b.dice >= 5 && b.dice <= ghoul.MAX_DICE, `${b.dice} dice`);
|
||||
assert.equal(round.lives, 3, "never a run life");
|
||||
dice.push(b.dice);
|
||||
gone.push(lost.length);
|
||||
}
|
||||
assert.ok(dice.reduce((a, b) => a + b, 0) / dice.length >= 5.5, `${dice.join(",")}`);
|
||||
assert.ok(gone.every((n) => n <= 4), `${gone.join(",")}`);
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner: a bot that misses a quarter of the things loses, and a bot that never dodges (holding fire) loses all five hearts before 40% of the room, ends with 0 dice and the run goes on", () => {
|
||||
let finished = 0;
|
||||
for (let seed = 1; seed <= 6; seed++) if (rideWith(seed, (r) => goodBot(r, seed, 0.25)).round.bonusRound.won) finished++;
|
||||
assert.ok(finished <= 3, `${finished} of 6 finished missing a quarter`);
|
||||
for (let seed = 1; seed <= 6; seed++) {
|
||||
const { round, lost } = rideWith(seed, idleBot);
|
||||
const b = round.bonusRound;
|
||||
assert.equal(b.won, false, "never finishes");
|
||||
assert.equal(b.dice, 0);
|
||||
assert.equal(b.hearts, 0);
|
||||
assert.equal(lost.length, 5);
|
||||
assert.ok(round.you.x < ROOM.length * 0.4, `out at ${round.you.x}`);
|
||||
assert.equal(round.lives, 3);
|
||||
assert.equal(round.over, false);
|
||||
}
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------ telegraphs */
|
||||
|
||||
test("Ghoul Rush's Bog Runner telegraphs: JUMP over snags and knees, DUCK under veils and limbs, SHOOT at the first gas pockets, for the boat's lane only, words on the first three of each kind, the same every time", () => {
|
||||
const marks = telegraphMarks(R);
|
||||
const gasMarks = marks.filter((m) => m.kind === "gas");
|
||||
assert.ok(gasMarks.length >= 1 && gasMarks.length < R.gas.length, "only the first pockets are marked");
|
||||
assert.equal(marks.length, R.snags.length + R.knees.length + R.veils.length + R.limbs.length + gasMarks.length);
|
||||
for (const m of marks) assert.equal(m.answer, ANSWERS[m.kind], m.kind);
|
||||
assert.equal(ANSWERS.snag, "JUMP");
|
||||
assert.equal(ANSWERS.knee, "JUMP");
|
||||
assert.equal(ANSWERS.veil, "DUCK");
|
||||
assert.equal(ANSWERS.limb, "DUCK");
|
||||
assert.equal(ANSWERS.gas, "SHOOT");
|
||||
const first = R.limbs[0];
|
||||
const m = marks.find((q) => q.kind === "limb" && q.x === (first[0] + first[1]) / 2);
|
||||
const lane = first[2];
|
||||
const xs = [m.lead - 45, m.lead - 41, m.lead - 36, m.lead - 30, m.lead - 10, m.lead, m.lead + 3, m.lead + 7];
|
||||
const alphaOf = (x) => (telegraphs(R, x, lane).find((t) => t.kind === "limb" && t.lead === m.lead) || { alpha: 0 }).alpha;
|
||||
const a = xs.map(alphaOf);
|
||||
assert.equal(a[0], 0, "not yet in view");
|
||||
assert.ok(a[2] > 0 && a[2] < 1, "fading in 40 to 30 ahead");
|
||||
assert.equal(a[3], 1);
|
||||
assert.equal(a[4], 1);
|
||||
assert.ok(a[6] > 0 && a[6] < 1, "fading as it passes");
|
||||
assert.equal(a[7], 0, "gone once passed");
|
||||
assert.deepEqual(telegraphs(R, m.lead - 33, lane), telegraphs(R, m.lead - 33, lane), "deterministic");
|
||||
for (const kind of ["snag", "knee", "veil", "limb", "gas"]) {
|
||||
const of = marks.filter((q) => q.kind === kind).sort((p, q) => p.lead - q.lead);
|
||||
assert.ok(of.length >= 1, kind);
|
||||
of.forEach((q, i) => {
|
||||
assert.equal(q.n, kind === "gas" ? q.n : i);
|
||||
const shown = telegraphs(R, q.lead - 32, q.lane).find((t) => t.lead === q.lead && t.kind === kind);
|
||||
assert.ok(shown, `${kind} ${i} shows`);
|
||||
assert.equal(shown.words, q.n < TELEGRAPH_WORDS, `${kind} ${i}`);
|
||||
});
|
||||
}
|
||||
// In the other lane a thing shows nothing.
|
||||
const s = marks.find((q) => q.kind === "snag");
|
||||
assert.ok(!telegraphs(R, s.lead - 32, 1 - s.lane).some((t) => t.lead === s.lead && t.kind === "snag"));
|
||||
});
|
||||
|
||||
test("Ghoul Rush's Bog Runner's intro banner says the controls plainly", () => {
|
||||
assert.match(R.how, /LEFT or RIGHT at a bank/);
|
||||
assert.match(R.how, /UP jump, DOWN duck/);
|
||||
assert.match(R.how, /SPACE shoot/);
|
||||
assert.ok(R.how.length <= 72);
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as bn from "../src/web-console/public/activities/ghoul-bones.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-bones-draw.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as bn from "../src/web-console/public/activities/ghoul-rush/stages/wing/ghoul-bones.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/wing/ghoul-bones-draw.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { BOSS_INTROS, MAX_EPITHET, bossIntroFor } from "../src/web-console/public/activities/ghoul-boss-intros.js";
|
||||
import { BOSS_HINT, BOSS_TITLE, beatAt, landAt, shakeAt, bossIntroArt } from "../src/web-console/public/activities/ghoul-bossintro-draw.js";
|
||||
import { INTROS } from "../src/web-console/public/activities/ghoul-intros.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { BOSS_INTROS, MAX_EPITHET, bossIntroFor } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-boss-intros.js";
|
||||
import { BOSS_HINT, BOSS_TITLE, beatAt, landAt, shakeAt, bossIntroArt } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-bossintro-draw.js";
|
||||
import { INTROS } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-intros.js";
|
||||
import { toneNames } from "../src/web-console/public/tones.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as cv from "../src/web-console/public/activities/ghoul-carnival.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-arms.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-carnival-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-village.js";
|
||||
import { MINE } from "../src/web-console/public/activities/ghoul-mine.js";
|
||||
import { CART } from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as cv from "../src/web-console/public/activities/ghoul-rush/stages/carnival/ghoul-carnival.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-arms.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-rush/stages/wing/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-rush/stages/village/ghoul-village.js";
|
||||
import { MINE } from "../src/web-console/public/activities/ghoul-rush/stages/mine/ghoul-mine.js";
|
||||
import { CART } from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-cart.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as CART_LOOKS, VOICES as CART_VOICES } from "../src/web-console/public/activities/ghoul-cart-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, hudLayout, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, BONUS_HEARTS, diceFor, endBonus, heartsText, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as CART_LOOKS, VOICES as CART_VOICES } from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, hudLayout, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, BONUS_HEARTS, diceFor, endBonus, heartsText, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -1125,6 +1125,9 @@ test("Ghoul Rush's bonus round: the fifth lost heart ends it with no dice and no
|
||||
// A life lost there is a run life as always, and the dice roll for it.
|
||||
round.phase = "play";
|
||||
ghoul.lose(round, "zombie");
|
||||
assert.equal(round.phase, "ask", "the carried dice are offered");
|
||||
round.ask.t = ghoul.ASK_GUARD_MS;
|
||||
ghoul.answerDie(round, true);
|
||||
assert.equal(round.phase, "roll", "the carried dice are rolled");
|
||||
});
|
||||
|
||||
@@ -1198,14 +1201,14 @@ test("Ghoul Rush's bonus round: the dice formula (floor 3, up to six more by hea
|
||||
assert.equal(diceFor(mk(5, { hits: [], acts: 0, total: 0 })), 3 + 2 + 0 + 0 + 1, "no obstacles counted");
|
||||
// Kills count with the acts.
|
||||
assert.equal(diceFor(mk(5, { hits: [], acts: 4, goal: 8 }), 4), 9);
|
||||
// The cap on the run's dice: eight in hand and a nine-die ride leaves nine.
|
||||
// No cap on the run's dice: eight in hand and a nine-die ride leaves seventeen.
|
||||
const round = bonusCart();
|
||||
round.dice = 8;
|
||||
Object.assign(round.bonusRound.perf, { hits: [], acts: 8 });
|
||||
assert.equal(endBonus(round, true, awardKit), true);
|
||||
assert.equal(round.dice, ghoul.MAX_DICE);
|
||||
assert.equal(round.dice, 17);
|
||||
assert.equal(round.bonusRound.dice, 9, "earned nine");
|
||||
assert.equal(round.bonusRound.gained, 1, "one more fits");
|
||||
assert.equal(round.bonusRound.gained, 9, "all nine kept");
|
||||
assert.equal(endBonus(round, true, awardKit), false, "ends once");
|
||||
// Braking: a short brake is fine, too long is no steady hand.
|
||||
const brake = bonusCart();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ch from "../src/web-console/public/activities/ghoul-chapel.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-chapel-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import * as sfxChapel from "../src/web-console/public/activities/ghoul-sfx-chapel.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as ch from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-chapel.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import * as sfxChapel from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-sfx-chapel.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { toneNames } from "../src/web-console/public/tones.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// Answer "Use a Lucky Die?" once the guard is past (nothing happens when no question is up).
|
||||
const accept = (round, yes = true) => {
|
||||
if (round.phase !== "ask") return false;
|
||||
round.ask.t = ghoul.ASK_GUARD_MS;
|
||||
return ghoul.answerDie(round, yes);
|
||||
};
|
||||
// A life lost, the question answered Yes: the old automatic roll.
|
||||
const lose = (round, cause) => {
|
||||
const r = ghoul.lose(round, cause);
|
||||
accept(round);
|
||||
return r;
|
||||
};
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
// A random that plays `values` in order, then 0.5.
|
||||
const rolls = (...values) => {
|
||||
@@ -99,12 +111,11 @@ test("Ghoul Rush: picking up Lucky dice stacks them to nine, then pays points li
|
||||
assert.equal(round.drops.length, 0);
|
||||
assert.equal(events(round, "power")[0].kind, "die");
|
||||
for (let k = 0; k < 8; k++) ghoul.applyPower(round, "die");
|
||||
assert.equal(round.dice, ghoul.MAX_DICE);
|
||||
assert.equal(ghoul.MAX_DICE, 9);
|
||||
assert.equal(round.dice, 9);
|
||||
const score = round.score;
|
||||
ghoul.applyPower(round, "die");
|
||||
assert.equal(round.dice, 9, "capped");
|
||||
assert.equal(round.score - score, ghoul.POWER_POINTS * 10, "points instead");
|
||||
assert.equal(round.dice, 10, "no cap");
|
||||
assert.equal(round.score, score, "no points instead");
|
||||
const canvas = { getContext: () => null };
|
||||
const game = ghoul.default.create({ canvas });
|
||||
game.start();
|
||||
@@ -140,7 +151,7 @@ test("Ghoul Rush: a fresh run holds 3 Lucky dice, a lost life with one in hand s
|
||||
round.monsters.length = 0;
|
||||
round.hordeMs = Infinity;
|
||||
stand(round, 100);
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
assert.equal(round.phase, "roll", "a lost life with a die in hand rolls");
|
||||
assert.equal(round.dice, 2, "the roll spends one");
|
||||
const next = ghoul.newRound(5);
|
||||
@@ -159,7 +170,7 @@ test("Ghoul Rush: a death with dice holds and rolls just one; a six saves Planny
|
||||
const far = zombie(round, round.camX + ghoul.FIELD_W + 40);
|
||||
far.hp = 3;
|
||||
const x = round.you.x;
|
||||
assert.equal(ghoul.lose(round, "zombie"), true);
|
||||
assert.equal(lose(round, "zombie"), true);
|
||||
assert.equal(round.phase, "roll");
|
||||
assert.equal(round.lives, 3, "no life lost yet");
|
||||
assert.equal(round.dice, 2, "the die is in hand");
|
||||
@@ -201,7 +212,7 @@ test("Ghoul Rush: a death with dice holds and rolls just one; a six saves Planny
|
||||
test("Ghoul Rush: the same random rolls the same face, and each slice of the die lands on its face", () => {
|
||||
const face = (value) => {
|
||||
const round = hall(5);
|
||||
ghoul.lose(round, "bone");
|
||||
lose(round, "bone");
|
||||
ghoul.advance(round, ghoul.ROLL_MS, rolls(value));
|
||||
return events(round, "diceFace").map((e) => e.face);
|
||||
};
|
||||
@@ -209,15 +220,15 @@ test("Ghoul Rush: the same random rolls the same face, and each slice of the die
|
||||
assert.deepEqual([ONE, 0.2, 0.4, 0.6, 0.8, SIX].flatMap(face), [1, 2, 3, 4, 5, 6]);
|
||||
});
|
||||
|
||||
test("Ghoul Rush: a 5 saves him with a heart and no shield, a 4 just saves him, and a heart past the cap is points", () => {
|
||||
test("Ghoul Rush: a 5 saves him with a heart and no shield, a 4 just saves him, and a heart has no cap", () => {
|
||||
const five = hall(1);
|
||||
ghoul.lose(five, "zombie");
|
||||
lose(five, "zombie");
|
||||
ghoul.advance(five, ghoul.ROLL_MS + 8, rolls(FIVE));
|
||||
assert.equal(five.phase, "play");
|
||||
assert.equal(five.lives, 4);
|
||||
assert.equal(five.you.garlic, false);
|
||||
const four = hall(1);
|
||||
ghoul.lose(four, "zombie");
|
||||
lose(four, "zombie");
|
||||
ghoul.advance(four, ghoul.ROLL_MS + 8, rolls(FOUR));
|
||||
assert.equal(four.phase, "play");
|
||||
assert.equal(four.lives, 3);
|
||||
@@ -225,16 +236,16 @@ test("Ghoul Rush: a 5 saves him with a heart and no shield, a 4 just saves him,
|
||||
assert.ok(four.you.safeMs > 0, "still safe a moment");
|
||||
const held = hall(1);
|
||||
held.you.garlic = true;
|
||||
ghoul.lose(held, "pit");
|
||||
lose(held, "pit");
|
||||
ghoul.advance(held, ghoul.ROLL_MS + 8, rolls(FOUR));
|
||||
assert.equal(held.you.garlic, true, "a shield he already held stays");
|
||||
const full = hall(1);
|
||||
full.lives = 9;
|
||||
const score = full.score;
|
||||
ghoul.lose(full, "zombie");
|
||||
lose(full, "zombie");
|
||||
ghoul.advance(full, ghoul.ROLL_MS + 8, rolls(FIVE));
|
||||
assert.equal(full.lives, 9, "capped");
|
||||
assert.ok(full.score > score, "points instead");
|
||||
assert.equal(full.lives, 10, "no cap");
|
||||
assert.equal(full.score, score, "no points instead");
|
||||
});
|
||||
|
||||
test("Ghoul Rush: a 3 costs the life and he comes back with Rapid fire and a Garlic shield, a 2 with Bottle Rockets and a Garlic shield", () => {
|
||||
@@ -243,7 +254,7 @@ test("Ghoul Rush: a 3 costs the life and he comes back with Rapid fire and a Gar
|
||||
[TWO, (round) => assert.deepEqual(round.arms.map((a) => [a.kind, a.n]), [["rocket", ghoul.POWERS.rocket.sticks]])],
|
||||
]) {
|
||||
const round = hall(2);
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
ghoul.advance(round, ghoul.ROLL_MS + 8, rolls(value));
|
||||
assert.equal(round.phase, "crash", "the life is lost");
|
||||
assert.equal(round.lives, 2);
|
||||
@@ -262,7 +273,7 @@ test("Ghoul Rush: a 3 costs the life and he comes back with Rapid fire and a Gar
|
||||
round.phase = "play";
|
||||
round.you.garlic = false;
|
||||
round.you.safeMs = 0;
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
ghoul.advance(round, ghoul.CRASH_MS + 8, steady);
|
||||
assert.equal(round.you.garlic, false, "the gift comes once");
|
||||
assert.equal(events(round, "diceGift").length, 1);
|
||||
@@ -272,7 +283,7 @@ test("Ghoul Rush: a 3 costs the life and he comes back with Rapid fire and a Gar
|
||||
|
||||
test("Ghoul Rush: a 1 costs the life and leaves nothing, with its laugh and its words", () => {
|
||||
const round = hall(2);
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
ghoul.advance(round, ghoul.ROLL_MS - 8, rolls(ONE));
|
||||
assert.equal(round.phase, "roll", "the beat has not finished");
|
||||
ghoul.advance(round, 16, steady);
|
||||
@@ -294,7 +305,7 @@ test("Ghoul Rush: a 1 costs the life and leaves nothing, with its laugh and its
|
||||
test("Ghoul Rush: on the last heart a 5 or 6 saves him in place, a 2, 3 or 4 pays one heart and he respawns as usual, a 1 loses the run", () => {
|
||||
const saved = hall(1);
|
||||
saved.lives = 1;
|
||||
ghoul.lose(saved, "zombie");
|
||||
lose(saved, "zombie");
|
||||
ghoul.advance(saved, ghoul.ROLL_MS + 8, rolls(FIVE));
|
||||
assert.equal(saved.lives, 2, "saved in place, with the 5's heart");
|
||||
assert.equal(saved.over, false);
|
||||
@@ -302,7 +313,7 @@ test("Ghoul Rush: on the last heart a 5 or 6 saves him in place, a 2, 3 or 4 pay
|
||||
for (const face of [TWO, THREE, FOUR]) {
|
||||
const mercy = hall(1);
|
||||
mercy.lives = 1;
|
||||
ghoul.lose(mercy, "zombie");
|
||||
lose(mercy, "zombie");
|
||||
ghoul.advance(mercy, ghoul.ROLL_MS + 8, rolls(face));
|
||||
assert.equal(events(mercy, "diceHeart").length, 1, "a heart is paid");
|
||||
assert.equal(mercy.phase, "crash", "the loss goes ahead");
|
||||
@@ -316,13 +327,13 @@ test("Ghoul Rush: on the last heart a 5 or 6 saves him in place, a 2, 3 or 4 pay
|
||||
// Not on the last heart: a 3 is a gift, a 4 a save, as ever.
|
||||
const plenty = hall(1);
|
||||
plenty.lives = 2;
|
||||
ghoul.lose(plenty, "zombie");
|
||||
lose(plenty, "zombie");
|
||||
ghoul.advance(plenty, ghoul.ROLL_MS + 8, rolls(FOUR));
|
||||
assert.equal(plenty.lives, 2);
|
||||
assert.equal(events(plenty, "diceHeart").length, 0);
|
||||
const lost = hall(1);
|
||||
lost.lives = 1;
|
||||
ghoul.lose(lost, "zombie");
|
||||
lose(lost, "zombie");
|
||||
ghoul.advance(lost, ghoul.ROLL_MS + ghoul.CRASH_MS + 40, rolls(ONE));
|
||||
assert.equal(lost.lives, 0);
|
||||
assert.equal(lost.over, true);
|
||||
@@ -331,7 +342,7 @@ test("Ghoul Rush: on the last heart a 5 or 6 saves him in place, a 2, 3 or 4 pay
|
||||
test("Ghoul Rush: endless lives never roll the dice", () => {
|
||||
const round = hall(3);
|
||||
round.infinite = true;
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
assert.equal(round.phase, "crash");
|
||||
assert.equal(round.dice, 3, "kept");
|
||||
assert.equal(round.lives, 3);
|
||||
@@ -342,6 +353,8 @@ test("Ghoul Rush: the clock running out can be saved too, with some time back",
|
||||
const round = hall(1);
|
||||
round.timeMs = 5;
|
||||
ghoul.advance(round, 8, steady);
|
||||
assert.equal(round.phase, "ask", "the clock running out asks too");
|
||||
accept(round);
|
||||
assert.equal(round.phase, "roll");
|
||||
ghoul.advance(round, ghoul.ROLL_MS + 8, rolls(SIX));
|
||||
assert.equal(round.phase, "play");
|
||||
@@ -369,6 +382,8 @@ test("Ghoul Rush: a pit fall rolls too, and a save puts Planny back on the last
|
||||
round.input.right = false;
|
||||
round.you.safeMs = 1e9;
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.phase, "ask", "a pit asks too");
|
||||
accept(round);
|
||||
assert.equal(round.phase, "roll");
|
||||
assert.equal(events(round, "diceStart")[0].cause, "pit");
|
||||
assert.equal(round.lives, 3);
|
||||
@@ -388,6 +403,7 @@ test("Ghoul Rush: a pit fall rolls too, and a save puts Planny back on the last
|
||||
lost.lives = 3;
|
||||
lost.you.safeMs = 1e9;
|
||||
ghoul.advance(lost, 4, steady);
|
||||
accept(lost);
|
||||
ghoul.advance(lost, ghoul.ROLL_MS + 8, rolls(0.2));
|
||||
assert.equal(lost.lives, 2);
|
||||
assert.equal(lost.phase, "crash");
|
||||
@@ -399,7 +415,7 @@ test("Ghoul Rush: in an ordinary room a saved life blows apart every monster in
|
||||
const near = [zombie(round, 110), zombie(round, 130), zombie(round, round.camX + 5)];
|
||||
const far = zombie(round, round.camX + ghoul.FIELD_W + 40);
|
||||
const score = round.score;
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
ghoul.advance(round, ghoul.ROLL_MS + 8, rolls(SIX));
|
||||
assert.equal(round.phase, "play");
|
||||
assert.ok(near.every((m) => m.dead), "all in view are dead");
|
||||
@@ -414,7 +430,7 @@ test("Ghoul Rush: in an ordinary room a saved life blows apart every monster in
|
||||
// Any saving face blows them apart, not only a six.
|
||||
const four = hall(1);
|
||||
const by = zombie(four, 110);
|
||||
ghoul.lose(four, "zombie");
|
||||
lose(four, "zombie");
|
||||
ghoul.advance(four, ghoul.ROLL_MS + 8, rolls(FOUR));
|
||||
assert.ok(by.dead);
|
||||
});
|
||||
@@ -428,7 +444,7 @@ test("Ghoul Rush: in a boss's room a saved life blows nothing apart, and the bos
|
||||
const m = ghoul.spawnMonster(round, "zombie", round.you.x + 6, ghoul.groundAt(round.spec, round.you.x + 6), { rise: 0, awake: true });
|
||||
round.dice = 1;
|
||||
round.events.length = 0;
|
||||
ghoul.lose(round, "bones");
|
||||
lose(round, "bones");
|
||||
ghoul.advance(round, ghoul.ROLL_MS + 8, rolls(SIX));
|
||||
assert.equal(round.phase, "play");
|
||||
assert.ok(!m.dead && round.monsters.includes(m), "the monster stands");
|
||||
@@ -443,7 +459,7 @@ test("Ghoul Rush: in a boss's room a saved life blows nothing apart, and the bos
|
||||
test("Ghoul Rush: every step of the roll has a look and a sound, and the revive's jingle plays once", () => {
|
||||
const round = hall(3);
|
||||
zombie(round, 110);
|
||||
ghoul.lose(round, "zombie");
|
||||
lose(round, "zombie");
|
||||
ghoul.advance(round, ghoul.ROLL_MS + 8, rolls(SIX));
|
||||
const played = [];
|
||||
const fx = {};
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as fz from "../src/web-console/public/activities/ghoul-frozen.js";
|
||||
import * as fl from "../src/web-console/public/activities/ghoul-flare.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-arms.js";
|
||||
import { PILL_WORDS, STAGE_ARMS, armDrop, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-village.js";
|
||||
import { MINE } from "../src/web-console/public/activities/ghoul-mine.js";
|
||||
import { CART } from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { CARNIVAL } from "../src/web-console/public/activities/ghoul-carnival.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, SILENT } from "../src/web-console/public/activities/ghoul-frozen-draw.js";
|
||||
import { FROZEN_SFX } from "../src/web-console/public/activities/ghoul-sfx-frozen.js";
|
||||
import { SLED_SFX } from "../src/web-console/public/activities/ghoul-sfx-sled.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as fz from "../src/web-console/public/activities/ghoul-rush/stages/frozen/ghoul-frozen.js";
|
||||
import * as fl from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-flare.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-arms.js";
|
||||
import { PILL_WORDS, STAGE_ARMS, armDrop, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-rush/stages/wing/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-rush/stages/village/ghoul-village.js";
|
||||
import { MINE } from "../src/web-console/public/activities/ghoul-rush/stages/mine/ghoul-mine.js";
|
||||
import { CART } from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { CARNIVAL } from "../src/web-console/public/activities/ghoul-rush/stages/carnival/ghoul-carnival.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, SILENT } from "../src/web-console/public/activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js";
|
||||
import { FROZEN_SFX } from "../src/web-console/public/activities/ghoul-rush/stages/frozen/ghoul-sfx-frozen.js";
|
||||
import { SLED_SFX } from "../src/web-console/public/activities/ghoul-rush/rides/sled/ghoul-sfx-sled.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { skipStory } from "../src/web-console/public/activities/ghoul-story.js";
|
||||
import { dropAt, gameOverBanner, OVER_WORD } from "../src/web-console/public/activities/ghoul-gameover-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipStory } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-story.js";
|
||||
import { dropAt, gameOverBanner, OVER_WORD } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-gameover-draw.js";
|
||||
import { toneNames } from "../src/web-console/public/tones.js";
|
||||
|
||||
function fakeCtx(texts) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as gy from "../src/web-console/public/activities/ghoul-graveyard.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as gy from "../src/web-console/public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as gr from "../src/web-console/public/activities/ghoul-grounds.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-grounds-draw.js";
|
||||
import { PILL_WORDS } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import * as sfxGrounds from "../src/web-console/public/activities/ghoul-sfx-grounds.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as gr from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-grounds.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js";
|
||||
import { PILL_WORDS } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import * as sfxGrounds from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-sfx-grounds.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-gurney.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as gn from "../src/web-console/public/activities/ghoul-gurney.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as GURNEY_LOOKS, VOICES as GURNEY_VOICES, gurneyArt, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-gurney-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as gn from "../src/web-console/public/activities/ghoul-rush/rides/gurney/ghoul-gurney.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as GURNEY_LOOKS, VOICES as GURNEY_VOICES, gurneyArt, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -633,7 +633,7 @@ test("Ghoul Rush's Code Blue: off the ramp the gurney launches, lands on the bay
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "ward");
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-hearse.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as hz from "../src/web-console/public/activities/ghoul-hearse.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOOKS as HEARSE_LOOKS, LOSE_SOUNDS, LOSE_WORDS, VOICES as HEARSE_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-hearse-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { HEARSE_SFX } from "../src/web-console/public/activities/ghoul-sfx-hearse.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as hz from "../src/web-console/public/activities/ghoul-rush/rides/hearse/ghoul-hearse.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOOKS as HEARSE_LOOKS, LOSE_SOUNDS, LOSE_WORDS, VOICES as HEARSE_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { HEARSE_SFX } from "../src/web-console/public/activities/ghoul-rush/rides/hearse/ghoul-sfx-hearse.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -732,7 +732,7 @@ test("Ghoul Rush's Midnight Hearse: at the finish the hearse brakes, the door op
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "angel");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { INTROS, MAX_LINE, introFor } from "../src/web-console/public/activities/ghoul-intros.js";
|
||||
import { INTRO_HINT, LINE_SIZE, TITLE_SIZE, dropAt, titleLayout } from "../src/web-console/public/activities/ghoul-intro-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { INTROS, MAX_LINE, introFor } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-intros.js";
|
||||
import { INTRO_HINT, LINE_SIZE, TITLE_SIZE, dropAt, titleLayout } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-intro-draw.js";
|
||||
import { toneNames } from "../src/web-console/public/tones.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,19 +1,19 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as mn from "../src/web-console/public/activities/ghoul-mine.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-arms.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-mine-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-village.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as mn from "../src/web-console/public/activities/ghoul-rush/stages/mine/ghoul-mine.js";
|
||||
import * as arm from "../src/web-console/public/activities/ghoul-rush/arms/ghoul-arms.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/mine/ghoul-mine-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import { BONES } from "../src/web-console/public/activities/ghoul-rush/stages/wing/ghoul-bones.js";
|
||||
import { GRAVEYARD } from "../src/web-console/public/activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../src/web-console/public/activities/ghoul-rush/stages/grounds/ghoul-grounds.js";
|
||||
import { CHAPEL } from "../src/web-console/public/activities/ghoul-rush/stages/chapel/ghoul-chapel.js";
|
||||
import { SANATORIUM } from "../src/web-console/public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../src/web-console/public/activities/ghoul-rush/stages/village/ghoul-village.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-mower.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as mw from "../src/web-console/public/activities/ghoul-mower.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as MOWER_LOOKS, VOICES as MOWER_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-mower-draw.js";
|
||||
import { MOWER_SFX } from "../src/web-console/public/activities/ghoul-sfx-mower.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as mw from "../src/web-console/public/activities/ghoul-rush/rides/mower/ghoul-mower.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as MOWER_LOOKS, VOICES as MOWER_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/mower/ghoul-mower-draw.js";
|
||||
import { MOWER_SFX } from "../src/web-console/public/activities/ghoul-rush/rides/mower/ghoul-sfx-mower.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -586,7 +586,7 @@ test("Ghoul Rush's Gardener's Revenge: rolling onto the lawn's end stops the mow
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "yard");
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-pew.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as pew from "../src/web-console/public/activities/ghoul-pew.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as PEW_LOOKS, VOICES as PEW_VOICES } from "../src/web-console/public/activities/ghoul-pew-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import { BPM, pulse } from "../src/web-console/public/activities/ghoul-pew-world.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as pew from "../src/web-console/public/activities/ghoul-rush/rides/pew/ghoul-pew.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as PEW_LOOKS, VOICES as PEW_VOICES } from "../src/web-console/public/activities/ghoul-rush/rides/pew/ghoul-pew-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
import { BPM, pulse } from "../src/web-console/public/activities/ghoul-rush/rides/pew/ghoul-pew-world.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { skipStory as storySkip } from "../src/web-console/public/activities/ghoul-story.js";
|
||||
import { MERCY_FAR, MERCY_NEAR, mercyKind, mercySpot, mix3 } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipStory as storySkip } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-story.js";
|
||||
import { MERCY_FAR, MERCY_NEAR, mercyKind, mercySpot, mix3 } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const mercies = (round) => round.drops.filter((d) => d.mercy);
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-ride.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as rt from "../src/web-console/public/activities/ghoul-ride.js";
|
||||
import { SCENES, END_P } from "../src/web-console/public/activities/ghoul-ride-scenes.js";
|
||||
import { CAR_X, DUCK_OFF, DUCK_ON, bindG } from "../src/web-console/public/activities/ghoul-ride-core.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as RIDE_LOOKS, VOICES as RIDE_VOICES } from "../src/web-console/public/activities/ghoul-ride-voices.js";
|
||||
import { CARNIVAL_ROOMS } from "../src/web-console/public/activities/ghoul-carnival.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { endBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import { rideArt } from "../src/web-console/public/activities/ghoul-ride-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as rt from "../src/web-console/public/activities/ghoul-rush/rides/dark-ride/ghoul-ride.js";
|
||||
import { SCENES, END_P } from "../src/web-console/public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-scenes.js";
|
||||
import { CAR_X, DUCK_OFF, DUCK_ON, bindG } from "../src/web-console/public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-core.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as RIDE_LOOKS, VOICES as RIDE_VOICES } from "../src/web-console/public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-voices.js";
|
||||
import { CARNIVAL_ROOMS } from "../src/web-console/public/activities/ghoul-rush/stages/carnival/ghoul-carnival.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { endBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
import { rideArt } from "../src/web-console/public/activities/ghoul-rush/rides/dark-ride/ghoul-ride-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
@@ -249,7 +249,7 @@ test("Ghoul Rush ride: under the endless-lives code a hit costs nothing", () =>
|
||||
|
||||
/* ---------------------------------------------------------------- dice */
|
||||
|
||||
test("Ghoul Rush ride: the dice rule is 5 to 9 by performance, a perfect ride is 9, and the bonus adds them under the cap of 9", () => {
|
||||
test("Ghoul Rush ride: the dice rule is 5 to 9 by performance, a perfect ride is 9, and the bonus adds them with no cap on the dice in hand", () => {
|
||||
const base = { shots: 100, hits: 100, kills: 50, missed: 0, hp: 5, ducksOK: 4, best: 20, innoHits: 0 };
|
||||
assert.equal(rt.gradeOf(base).dice, 9);
|
||||
assert.equal(rt.gradeOf(base).grade, "S");
|
||||
@@ -264,15 +264,15 @@ test("Ghoul Rush ride: the dice rule is 5 to 9 by performance, a perfect ride is
|
||||
assert.ok(rt.gradeOf({ ...base, hp: 1 }).dice <= rt.gradeOf({ ...base, hp: 5 }).dice);
|
||||
// A guest shot costs.
|
||||
assert.ok(rt.gradeOf({ ...base, innoHits: 10 }).perf < rt.gradeOf(base).perf);
|
||||
// The bonus uses the ride's own number and caps the dice in hand at 9.
|
||||
// The bonus uses the ride's own number and adds them all to the dice in hand.
|
||||
const round = playing();
|
||||
round.dice = 6;
|
||||
round.bonusRound.perf.dice = 8;
|
||||
round.bonusRound.perf.cardMs = 7000;
|
||||
endBonus(round, true, { award: (r, p) => (r.score += p), ROOM_POINTS: 100 });
|
||||
assert.equal(round.bonusRound.dice, 8);
|
||||
assert.equal(round.bonusRound.gained, 3, "6 + 8 caps at 9");
|
||||
assert.equal(round.dice, 9);
|
||||
assert.equal(round.bonusRound.gained, 8, "6 + 8 is 14");
|
||||
assert.equal(round.dice, 14);
|
||||
assert.equal(round.bonusRound.cardMs, 7000);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as sn from "../src/web-console/public/activities/ghoul-sanatorium.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-sanatorium-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as sn from "../src/web-console/public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js";
|
||||
import { LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
const events = (round, type) => round.events.filter((e) => e.type === type);
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-sled.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as sl from "../src/web-console/public/activities/ghoul-sled.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as SLED_LOOKS, VOICES as SLED_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-sled-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as sl from "../src/web-console/public/activities/ghoul-rush/rides/sled/ghoul-sled.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as SLED_LOOKS, VOICES as SLED_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/sled/ghoul-sled-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -594,7 +594,7 @@ test("Ghoul Rush's Coffin Sled: off the lip the sled launches, lands on the snow
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "widow");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { INTROS } from "../src/web-console/public/activities/ghoul-intros.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { INTROS } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-intros.js";
|
||||
import {
|
||||
CHAR_MS,
|
||||
FINALE_TITLE,
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
stepStory,
|
||||
takeStory,
|
||||
typed,
|
||||
} from "../src/web-console/public/activities/ghoul-story.js";
|
||||
import { SCENE_H, TEXT_SIZE } from "../src/web-console/public/activities/ghoul-story-draw.js";
|
||||
} from "../src/web-console/public/activities/ghoul-rush/story/ghoul-story.js";
|
||||
import { SCENE_H, TEXT_SIZE } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-story-draw.js";
|
||||
import { toneNames } from "../src/web-console/public/tones.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-tray.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipBossIntro } from "./ghoul-test-helpers.mjs";
|
||||
import * as tr from "../src/web-console/public/activities/ghoul-tray.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import * as sl from "../src/web-console/public/activities/ghoul-sled.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as TRAY_LOOKS, VOICES as TRAY_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-tray-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as tr from "../src/web-console/public/activities/ghoul-rush/rides/tray/ghoul-tray.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import * as sl from "../src/web-console/public/activities/ghoul-rush/rides/sled/ghoul-sled.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as TRAY_LOOKS, VOICES as TRAY_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/tray/ghoul-tray-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -554,7 +554,7 @@ test("Ghoul Rush's Servants' Back Stairs: off the lip the tray launches, lands o
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "crypt");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// 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 { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as vl from "../src/web-console/public/activities/ghoul-village.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-village-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-powers.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as vl from "../src/web-console/public/activities/ghoul-rush/stages/village/ghoul-village.js";
|
||||
import { EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS } from "../src/web-console/public/activities/ghoul-rush/stages/village/ghoul-village-draw.js";
|
||||
import { PILL_WORDS, pickPower } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-powers.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-wagon.mjs
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as wg from "../src/web-console/public/activities/ghoul-wagon.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-cart.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as WAGON_LOOKS, VOICES as WAGON_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-wagon-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-bonus.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import * as wg from "../src/web-console/public/activities/ghoul-rush/rides/wagon/ghoul-wagon.js";
|
||||
import * as ct from "../src/web-console/public/activities/ghoul-rush/rides/cart/ghoul-cart.js";
|
||||
import { ANSWERS, EVENT_VOICE, LOSE_SOUNDS, LOSE_WORDS, LOOKS as WAGON_LOOKS, VOICES as WAGON_VOICES, telegraphMarks, telegraphs } from "../src/web-console/public/activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js";
|
||||
import * as ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LOOKS, VOICES, bonusTick, react } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { BONUS_FLOOR, diceFor, endBonus, makeBonus } from "../src/web-console/public/activities/ghoul-rush/core/ghoul-bonus.js";
|
||||
|
||||
const steady = () => 0.5;
|
||||
// The pack draws no random number: a run on this fails on the first draw.
|
||||
@@ -770,7 +770,7 @@ test("Ghoul Rush's Torch Mob: off the lip the wagon launches, lands on the green
|
||||
assert.equal(end.length, 1);
|
||||
assert.equal(end[0].won, true);
|
||||
assert.ok(end[0].dice >= BONUS_FLOOR && end[0].dice <= ghoul.MAX_DICE, `${end[0].dice} dice`);
|
||||
assert.equal(round.dice, Math.min(ghoul.MAX_DICE, 1 + end[0].dice));
|
||||
assert.equal(round.dice, 1 + end[0].dice);
|
||||
assert.equal(round.lives, 3);
|
||||
run(round, ghoul.CARD_MS + 100);
|
||||
assert.equal(round.spec.id, "green");
|
||||
|
||||
@@ -10,12 +10,12 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import { skipStory as storySkip } from "../src/web-console/public/activities/ghoul-story.js";
|
||||
import { BANNER_SHADE, CHUNK, GAUGE_COOL, GAUGE_HOT, GAUGE_WARM, LOOKS, SEAM, VOICES, contrast, gaugeColor, hudLayout, labelSpot, limbInk } from "../src/web-console/public/activities/ghoul-draw.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { skipStory as storySkip } from "../src/web-console/public/activities/ghoul-rush/story/ghoul-story.js";
|
||||
import { BANNER_SHADE, CHUNK, GAUGE_COOL, GAUGE_HOT, GAUGE_WARM, LOOKS, SEAM, VOICES, contrast, gaugeColor, hudLayout, labelSpot, limbInk } from "../src/web-console/public/activities/ghoul-rush/draw/ghoul-draw.js";
|
||||
import { ACCENTS } from "../src/web-console/public/palette.js";
|
||||
import { humNames, toneNames } from "../src/web-console/public/tones.js";
|
||||
import ghoulSfx from "../src/web-console/public/activities/ghoul-sfx.js";
|
||||
import ghoulSfx from "../src/web-console/public/activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import { LIVES, LIVES_BACK, LIVES_INK, livesText } from "../src/web-console/public/activities/pills.js";
|
||||
|
||||
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
@@ -189,7 +189,10 @@ function ghoulRound(id = "foyer", depth = 0) {
|
||||
const round = ghoul.newRound(5);
|
||||
round.dice = 0;
|
||||
for (let i = 0; i < depth; i++) round.cleared.push(`cleared${i}`);
|
||||
if (id !== "hall") {
|
||||
const listed = id === "hall" || ghoul.STAGES.some((s) => s.rooms.includes(id));
|
||||
// A room no stage lists (the retired Bog Runner) is set up directly; every other room is reached the way a run reaches it.
|
||||
if (!listed) ghoul.setupRoom(round, id);
|
||||
else if (id !== "hall") {
|
||||
const st = ghoul.STAGES.find((s) => s.rooms.includes(id));
|
||||
through(round);
|
||||
assert.equal(round.phase, "pick");
|
||||
@@ -421,7 +424,7 @@ test("Ghoul Rush: held fire shoots a bolt every FIRE_MS the way you face (RAPID_
|
||||
assert.equal(plain.shots, Math.ceil(1020 / ghoul.FIRE_MS), "a bolt every FIRE_MS");
|
||||
assert.ok(plain.round.shots.every((s) => s.vx > 0), "facing right, they fly right");
|
||||
const rapid = count((r) => ghoul.applyPower(r, "rapid"));
|
||||
assert.equal(rapid.shots, Math.ceil(1020 / ghoul.RAPID_MS), "twice as often with Rapid fire");
|
||||
assert.equal(rapid.shots, Math.ceil(1020 / ghoul.RAPID_MS), "about 1.65 times as often with Rapid fire");
|
||||
const left = count((r) => (r.you.face = -1));
|
||||
assert.ok(left.round.shots.every((s) => s.vx < 0), "facing left, they fly left");
|
||||
const round = ghoulRound();
|
||||
@@ -1031,7 +1034,7 @@ test("Ghoul Rush: a timed power-up taken while the same one runs adds its time t
|
||||
assert.equal(events(round, "expire").filter((e) => e.kind === "rapid").length, 1, "one run, one expiry");
|
||||
});
|
||||
|
||||
test("Ghoul Rush: Spread shot and Rapid fire run out after their time, the Garlic shield takes one hit and sees off what touched you, a 1UP is a life up to MAX_LIVES, and kills sometimes leave candy or a power-up", () => {
|
||||
test("Ghoul Rush: Spread shot and Rapid fire run out after their time, the Garlic shield takes one hit and sees off what touched you, a 1UP is a life with no limit, and kills sometimes leave candy or a power-up", () => {
|
||||
const round = ghoulRound();
|
||||
standAt(round, 30);
|
||||
ghoul.applyPower(round, "spread");
|
||||
@@ -1047,11 +1050,11 @@ test("Ghoul Rush: Spread shot and Rapid fire run out after their time, the Garli
|
||||
assert.ok(round.you.safeMs > 0);
|
||||
ghoul.applyPower(round, "life");
|
||||
assert.equal(round.lives, ghoul.START_LIVES + 1);
|
||||
round.lives = ghoul.MAX_LIVES;
|
||||
round.lives = 9;
|
||||
const score = round.score;
|
||||
ghoul.applyPower(round, "life");
|
||||
assert.equal(round.lives, ghoul.MAX_LIVES, "never past MAX_LIVES");
|
||||
assert.ok(round.score > score, "points instead");
|
||||
assert.equal(round.lives, 10, "no limit");
|
||||
assert.equal(round.score, score, "no points instead");
|
||||
// Placed power-ups are taken by touching them, and drops fall to the floor.
|
||||
const r2 = ghoulRound();
|
||||
const [kind, x, y] = r2.spec.items[0];
|
||||
@@ -1708,6 +1711,7 @@ test("Ghoul Rush: each stage is three rooms and a boss's, every room in one stag
|
||||
assert.equal(ghoul.ROOMS[0].boss, null);
|
||||
const placed = ghoul.STAGES.flatMap((st) => st.rooms);
|
||||
assert.equal(new Set(placed).size, placed.length, "no room in two stages");
|
||||
// Every room but the hall is in a stage; one in none is a room forgotten.
|
||||
assert.deepEqual([...placed].sort(), ghoul.ROOMS.slice(1).map((r) => r.id).sort(), "every room but the hall in a stage");
|
||||
for (const st of ghoul.STAGES) {
|
||||
// Four rooms; the Mine's Runaway Cart makes it five.
|
||||
@@ -1804,16 +1808,15 @@ test("Ghoul Rush: clearing every stage wins the run, and its end says so", () =>
|
||||
assert.equal(ghoul.advance(round, 16, steady), "over");
|
||||
});
|
||||
|
||||
test("Ghoul Rush: a boss always gives a life (up to MAX_LIVES, 9), and the 1UP turns up a little more often than before", () => {
|
||||
assert.equal(ghoul.MAX_LIVES, 9);
|
||||
test("Ghoul Rush: a boss always gives a life (no limit), and the 1UP turns up a little more often than before", () => {
|
||||
assert.equal(ghoul.POWERS.life.weight, 1.5);
|
||||
const round = bossFight("ballroom");
|
||||
const b = round.boss;
|
||||
round.lives = ghoul.MAX_LIVES - 1;
|
||||
round.lives = 9;
|
||||
b.hp = 1;
|
||||
round.shots.push({ x: b.x - b.w / 2 - 0.2, y: b.y + 2, vx: 80, vy: 0, gone: 0 });
|
||||
ghoul.advance(round, 4, steady);
|
||||
assert.equal(round.lives, ghoul.MAX_LIVES);
|
||||
assert.equal(round.lives, 10);
|
||||
assert.equal(events(round, "bossDown")[0].life, true);
|
||||
});
|
||||
|
||||
@@ -2141,6 +2144,11 @@ function makeBot(G, skill, random) {
|
||||
let venting = false;
|
||||
const missed = new Set();
|
||||
return (round) => {
|
||||
// "Use a Lucky Die?": the bot always says yes, once the guard is past.
|
||||
if (round.phase === "ask") {
|
||||
round.ask.t = G.ASK_GUARD_MS;
|
||||
G.answerDie(round, true);
|
||||
}
|
||||
const { you, input: inp, spec } = round;
|
||||
const dt = last < 0 ? 16 : Math.max(0, round.clock - last);
|
||||
last = round.clock;
|
||||
@@ -2436,8 +2444,9 @@ test("Ghoul Rush: of ten runs a sharp bot gets nearly all through the hall and t
|
||||
round.events.length = 0;
|
||||
}
|
||||
// The Garlic gift for a quick loss can carry a masher out of the hall; it
|
||||
// then waits on the stage pick, since it never picks, and goes no further.
|
||||
assert.ok((round.over || round.phase === "pick") && round.room <= 2, `a masher (seed ${seed}) is dead, or stuck on the pick, by the Gallery (room ${round.room}, ${round.phase})`);
|
||||
// then waits on the stage pick, since it never picks, and goes no further (nor does it
|
||||
// ever answer "Use a Lucky Die?", so it may be waiting there).
|
||||
assert.ok((round.over || round.phase === "pick" || round.phase === "ask") && round.room <= 2, `a masher (seed ${seed}) is dead, or stuck on the pick or the Lucky die question, by the Gallery (room ${round.room}, ${round.phase})`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2736,6 +2745,120 @@ test("Ghoul Rush game: every tone it plays is one tones.js has, its own blips am
|
||||
for (const name of ["ghoulBlast", "zombiePop", "ghoulCandy", "doorUnlock", "doorThrough", "hop"]) assert.ok(heard.has(name), `${name} played`);
|
||||
});
|
||||
|
||||
// A started game with the hall's dice in hand, ready to lose a life.
|
||||
function askGame(dice = 2) {
|
||||
const heard = [];
|
||||
const g = ghoul.default.create({ canvas: stubCanvas().canvas, tone: (name) => heard.push(name) });
|
||||
g.resize(900, 900);
|
||||
g.key("action");
|
||||
skipStory(g);
|
||||
const r = g.round;
|
||||
for (const st of r.spawns) st.over = true;
|
||||
r.monsters.length = 0;
|
||||
r.hordeMs = Infinity;
|
||||
r.phase = "play";
|
||||
r.lives = 3;
|
||||
r.dice = dice;
|
||||
standAt(r, 100);
|
||||
r.events.length = 0;
|
||||
return { g, r, heard };
|
||||
}
|
||||
|
||||
test("Ghoul Rush: a lost life with Lucky dice in hand asks \"Use a Lucky Die?\" first, and nothing rolls, spends or ticks until the player answers", () => {
|
||||
const { g, r } = askGame(2);
|
||||
assert.equal(ghoul.lose(r, "zombie"), true);
|
||||
assert.equal(r.phase, "ask");
|
||||
assert.equal(r.ask.cause, "zombie");
|
||||
assert.equal(r.ask.yes, true, "Yes is lit first");
|
||||
assert.equal(r.dice, 2, "asking spends nothing");
|
||||
assert.equal(r.lives, 3, "and costs nothing");
|
||||
assert.equal(r.events.filter((e) => e.type === "diceAsk").length, 1);
|
||||
const time = r.timeMs;
|
||||
// It waits as long as it likes: no roll, no loss, the clock held.
|
||||
for (let i = 0; i < 400; i++) g.tick(16);
|
||||
assert.equal(r.phase, "ask");
|
||||
assert.equal(r.timeMs, time, "the room's clock holds while asking");
|
||||
assert.equal(r.roll, null);
|
||||
assert.equal(r.lives, 3);
|
||||
});
|
||||
|
||||
test("Ghoul Rush: the Lucky die question ignores a press inside its guard and any key repeat, left and up light Yes, right and down No, and Yes spends one die and rolls", () => {
|
||||
const { g, r } = askGame(2);
|
||||
ghoul.lose(r, "zombie");
|
||||
// The key held or mashed as Planny died must not answer.
|
||||
g.key("action");
|
||||
assert.equal(r.phase, "ask", "inside the guard, a press does nothing");
|
||||
assert.equal(r.dice, 2);
|
||||
g.release("action");
|
||||
for (let t = 0; t < ghoul.ASK_GUARD_MS + 16; t += 16) g.tick(16);
|
||||
g.key("action", true);
|
||||
assert.equal(r.phase, "ask", "a held key repeating never answers");
|
||||
g.key("right");
|
||||
assert.equal(r.ask.yes, false);
|
||||
g.key("left");
|
||||
assert.equal(r.ask.yes, true);
|
||||
g.key("down");
|
||||
assert.equal(r.ask.yes, false);
|
||||
g.key("up");
|
||||
assert.equal(r.ask.yes, true);
|
||||
assert.equal(r.phase, "ask", "steering alone never answers");
|
||||
g.key("action");
|
||||
assert.equal(r.phase, "roll", "Yes starts the roll");
|
||||
assert.equal(r.dice, 1, "and spends one die");
|
||||
assert.equal(r.ask, null);
|
||||
assert.equal(r.events.filter((e) => e.type === "diceStart").length, 1);
|
||||
});
|
||||
|
||||
test("Ghoul Rush: answering No to the Lucky die question keeps every die and lets the loss go ahead", () => {
|
||||
const { g, r, heard } = askGame(2);
|
||||
ghoul.lose(r, "zombie");
|
||||
for (let t = 0; t < ghoul.ASK_GUARD_MS + 16; t += 16) g.tick(16);
|
||||
g.key("right");
|
||||
g.key("action");
|
||||
assert.equal(r.ask, null);
|
||||
assert.equal(r.dice, 2, "both dice are kept for later");
|
||||
assert.equal(r.lives, 2, "the life is lost");
|
||||
assert.equal(r.phase, "crash", "and the fall plays as without dice");
|
||||
assert.equal(r.roll, null, "no roll");
|
||||
assert.equal(r.events.filter((e) => e.type === "diceKeep").length, 1);
|
||||
assert.equal(r.events.filter((e) => e.type === "diceStart").length, 0);
|
||||
assert.ok(heard.length > 0);
|
||||
// A kept die is asked about again at the next loss.
|
||||
for (let t = 0; t < 4000 && r.phase !== "play"; t += 16) g.tick(16);
|
||||
r.you.safeMs = 0;
|
||||
ghoul.lose(r, "zombie");
|
||||
assert.equal(r.phase, "ask", "asked again");
|
||||
assert.equal(r.dice, 2);
|
||||
});
|
||||
|
||||
test("Ghoul Rush: a click on the Lucky die question lights its half (Yes left, No right), and a click on the lit half answers; endless lives and a bonus room never ask", () => {
|
||||
const { g, r } = askGame(1);
|
||||
ghoul.lose(r, "zombie");
|
||||
for (let t = 0; t < ghoul.ASK_GUARD_MS + 16; t += 16) g.tick(16);
|
||||
assert.equal(r.ask.yes, true);
|
||||
assert.equal(g.pointer("down", 850, 400), true);
|
||||
assert.equal(r.phase, "ask", "a click on the unlit half lights it");
|
||||
assert.equal(r.ask.yes, false);
|
||||
g.pointer("down", 850, 400);
|
||||
assert.equal(r.phase, "crash", "a click on the lit No answers it");
|
||||
assert.equal(r.dice, 1);
|
||||
const again = askGame(1);
|
||||
ghoul.lose(again.r, "zombie");
|
||||
for (let t = 0; t < ghoul.ASK_GUARD_MS + 16; t += 16) again.g.tick(16);
|
||||
assert.equal(again.r.ask.yes, true);
|
||||
again.g.pointer("down", 30, 400);
|
||||
assert.equal(again.r.phase, "roll", "a click on the lit Yes answers it");
|
||||
const endless = askGame(2);
|
||||
endless.r.infinite = true;
|
||||
ghoul.lose(endless.r, "zombie");
|
||||
assert.equal(endless.r.phase !== "ask" && endless.r.phase !== "roll", true, "endless lives never ask");
|
||||
const bonus = askGame(2);
|
||||
bonus.r.bonusRound = { hearts: 5, max: 5, dice: 0, over: false, won: false, perf: { total: 0, hits: [], acts: 0, goal: 0, steady: true } };
|
||||
ghoul.lose(bonus.r, "zombie");
|
||||
assert.notEqual(bonus.r.phase, "ask", "a bonus room's hearts are its own: no question");
|
||||
assert.equal(bonus.r.dice, 2);
|
||||
});
|
||||
|
||||
test("Ghoul Rush game: its own sounds keep its prefix, and a run holds a monster's hum (and no drone under the music), steps on the boards, and tolls at the end", () => {
|
||||
for (const name of [...Object.keys(ghoulSfx.tones), ...Object.keys(ghoulSfx.hums)]) assert.match(name, /^ghoul/, `${name} keeps to this game's prefix`);
|
||||
const known = new Set(toneNames());
|
||||
@@ -2934,7 +3057,7 @@ test("Ghoul Rush: the top bar names the stage (or the hall) and counts the stage
|
||||
const box = (p, h) => [p.x, p.y, p.x + p.w, p.y + h];
|
||||
for (const h of [Math.max(12 / ghoul.MIN_CELL, 2.4), 2.4]) {
|
||||
const hud = { room: "THE GRAND OPERA HOUSE", stage: "STAGE 20 OF 21", time: 80, timeLow: false, bonus: ghoul.BONUS_START, chain: ghoul.MAX_MULT, chainFill: 0.5, key: true, effects: ["SPREAD", "RAPID", "GARLIC"].map((text) => ({ text, color: "#ffffff", fill: 0.5 })), gauge: { fill: 0.5, free: 0.6, rapid: null } };
|
||||
const laid = hudLayout(h, ghoul.W, ghoul.MAX_LIVES, hud, ghoul.HUD_H);
|
||||
const laid = hudLayout(h, ghoul.W, 9, hud, ghoul.HUD_H);
|
||||
assert.ok(laid.every((p) => p.h >= h * 0.6), "shrunk no more than it must");
|
||||
const placed = laid.map((p) => box(p, p.h));
|
||||
// A pill 2.4 units tall is every board but the smallest: one row, in the strip.
|
||||
@@ -3128,7 +3251,9 @@ test("Ghoul Rush game: every room and boss draws, and each pick of stage, throug
|
||||
g.resize(900, 900);
|
||||
g.key("action");
|
||||
skipStory(g);
|
||||
for (let n = 1; n <= ghoul.ROOMS.length; n++) {
|
||||
// Every room a run can reach: the hall and each stage's, not the retired Bog Runner.
|
||||
const LIVE = 1 + ghoul.STAGES.flatMap((st) => st.rooms).length;
|
||||
for (let n = 1; n <= LIVE; n++) {
|
||||
const r = g.round;
|
||||
r.lives = 99;
|
||||
const bot = makeBot(ghoul, 1, ghoul.seeded(n));
|
||||
@@ -3149,6 +3274,10 @@ test("Ghoul Rush game: every room and boss draws, and each pick of stage, throug
|
||||
r.monsters.length = 0;
|
||||
standAt(r, r.spec.door);
|
||||
}
|
||||
if (r.phase === "ask") {
|
||||
r.ask.t = ghoul.ASK_GUARD_MS;
|
||||
ghoul.answerDie(r, true);
|
||||
}
|
||||
if (r.phase === "pick") {
|
||||
const before = calls.count;
|
||||
g.tick(16);
|
||||
@@ -3158,7 +3287,7 @@ test("Ghoul Rush game: every room and boss draws, and each pick of stage, throug
|
||||
}
|
||||
g.tick(16);
|
||||
}
|
||||
if (n === ghoul.ROOMS.length) break;
|
||||
if (n === LIVE) break;
|
||||
leaveIntro(g);
|
||||
for (let ms = 0; ms < ghoul.READY_MS + 100; ms += 16) g.tick(16);
|
||||
assert.equal(g.round.room, n + 1);
|
||||
|
||||
@@ -28,7 +28,7 @@ import * as hop from "../src/web-console/public/activities/hop.js";
|
||||
import { hudLayout as hopHudLayout, labelSpot as hopLabelSpot, LANES as HOP_LANES, limbInk as hopLimbInk, contrast as hopContrast } from "../src/web-console/public/activities/hop-draw.js";
|
||||
import * as bounce from "../src/web-console/public/activities/bounce.js";
|
||||
import * as rapids from "../src/web-console/public/activities/rapids.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul.js";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
import { ACCENTS } from "../src/web-console/public/palette.js";
|
||||
import { LIVES, LIVES_BACK, LIVES_INK, livesText, pillContrast } from "../src/web-console/public/activities/pills.js";
|
||||
|
||||
@@ -277,7 +277,7 @@ test("the list names Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Sta
|
||||
assert.equal(ACTIVITIES[11].title, "Ghoul Rush");
|
||||
for (const a of ACTIVITIES) {
|
||||
assert.ok(Object.isFrozen(a), `${a.id} is frozen`);
|
||||
assert.equal(a.module, `/activities/${a.id}.js`);
|
||||
assert.equal(a.module, a.id === "ghoul" ? "/activities/ghoul-rush/ghoul.js" : `/activities/${a.id}.js`);
|
||||
assert.equal(typeof a.title, "string");
|
||||
assert.ok(typeof a.blurb === "string" && a.blurb.length > 10, `${a.id} has a line for its picker card`);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, drawn, itemCard , boxValue} from "./page-test-helpers.mjs";
|
||||
import { pageSuite, openSession, drawn, itemCard, boxValue, fillBox } from "./page-test-helpers.mjs";
|
||||
import { until, HOME } from "./web-console-test-helpers.mjs";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
@@ -861,7 +861,7 @@ test("the stage code typed on Ghoul Rush's board opens its stage select, the arr
|
||||
await s.page.evaluate(async () => {
|
||||
const m = await import("/screens/activities.js");
|
||||
const { ACTIVITIES } = await import("/activities.js");
|
||||
const ghoul = (await import("/activities/ghoul.js")).default;
|
||||
const ghoul = (await import("/activities/ghoul-rush/ghoul.js")).default;
|
||||
const watched = { ...ghoul, create: (opts) => (window.__ghoul = ghoul.create(opts)) };
|
||||
m.setActivityList(ACTIVITIES.map((e) => (e.id === "ghoul" ? { ...e, game: watched } : e)));
|
||||
});
|
||||
@@ -897,7 +897,7 @@ test("Ghoul Rush's secondary weapon, with real keys in the window: a double tap
|
||||
await s.page.evaluate(async () => {
|
||||
const m = await import("/screens/activities.js");
|
||||
const { ACTIVITIES } = await import("/activities.js");
|
||||
const ghoul = (await import("/activities/ghoul.js")).default;
|
||||
const ghoul = (await import("/activities/ghoul-rush/ghoul.js")).default;
|
||||
const watched = { ...ghoul, create: (opts) => (window.__ghoul = ghoul.create(opts)) };
|
||||
m.setActivityList(ACTIVITIES.map((e) => (e.id === "ghoul" ? { ...e, game: watched } : e)));
|
||||
});
|
||||
@@ -2365,7 +2365,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
await s.page.evaluate(async () => {
|
||||
const m = await import("/screens/activities.js");
|
||||
const { ACTIVITIES } = await import("/activities.js");
|
||||
const ghoul = (await import("/activities/ghoul.js")).default;
|
||||
const ghoul = (await import("/activities/ghoul-rush/ghoul.js")).default;
|
||||
window.__calm = true;
|
||||
const watched = {
|
||||
...ghoul,
|
||||
@@ -2389,7 +2389,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
await openActivities(s, "ghoul");
|
||||
assert.equal(await overlay(s), "Press space or click to start");
|
||||
const { W, H, YOU_H } = await s.page.evaluate(async () => {
|
||||
const { W, H, YOU_H } = await import("/activities/ghoul.js");
|
||||
const { W, H, YOU_H } = await import("/activities/ghoul-rush/ghoul.js");
|
||||
return { W, H, YOU_H };
|
||||
});
|
||||
const box = await s.page.locator("#activities-canvas").boundingBox();
|
||||
@@ -2477,7 +2477,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
// one stage cleared), and lose the last life.
|
||||
const outOf = (last) =>
|
||||
s.page.evaluate(async (last) => {
|
||||
const { groundAt, stageById } = await import("/activities/ghoul.js");
|
||||
const { groundAt, stageById } = await import("/activities/ghoul-rush/ghoul.js");
|
||||
const r = window.__ghoul.round;
|
||||
if (last) r.stageAt = stageById(r.stage).rooms.length - 1;
|
||||
r.hasKey = true;
|
||||
@@ -2494,7 +2494,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
await outOf(true);
|
||||
await until(async () => (await you()).phase === "pick" || (await step(s, 10, 50), false), 5000);
|
||||
await s.page.evaluate(async () => {
|
||||
const { lose } = await import("/activities/ghoul.js");
|
||||
const { lose } = await import("/activities/ghoul-rush/ghoul.js");
|
||||
window.__calm = false;
|
||||
const r = window.__ghoul.round;
|
||||
r.lives = 1;
|
||||
@@ -2515,7 +2515,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
test("the server serves the activities' scripts, golf's seventeen, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring's two, Rapids Run's two, Hot Potato's two, Crossing Rush's two, Bounce Road's seven, Ghoul Rush's eighty-three, every game's sound effects and the shared pills included", () => {
|
||||
const server = fs.readFileSync(new URL("../src/web-console/static.mjs", import.meta.url), "utf8");
|
||||
const servable = server.slice(server.indexOf("const SERVABLE = new Set(["), server.indexOf("]);", server.indexOf("const SERVABLE = new Set([")));
|
||||
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul.js", "activities/ghoul-draw.js", "activities/ghoul-rooms.js", "activities/ghoul-bones.js", "activities/ghoul-bones-draw.js", "activities/ghoul-graveyard.js", "activities/ghoul-graveyard-draw.js", "activities/ghoul-grounds.js", "activities/ghoul-grounds-draw.js", "activities/ghoul-chapel.js", "activities/ghoul-chapel-draw.js", "activities/ghoul-sanatorium.js", "activities/ghoul-sanatorium-draw.js", "activities/ghoul-village.js", "activities/ghoul-village-draw.js", "activities/ghoul-village-world.js", "activities/ghoul-village-wolf.js", "activities/ghoul-mine.js", "activities/ghoul-mine-draw.js", "activities/ghoul-mine-world.js", "activities/ghoul-mine-tommy.js", "activities/ghoul-cart.js", "activities/ghoul-cart-draw.js", "activities/ghoul-sled.js", "activities/ghoul-sled-draw.js", "activities/ghoul-gurney.js", "activities/ghoul-gurney-draw.js", "activities/ghoul-banister.js", "activities/ghoul-banister-draw.js", "activities/ghoul-sfx-banister.js", "activities/ghoul-hearse.js", "activities/ghoul-hearse-draw.js", "activities/ghoul-wagon.js", "activities/ghoul-wagon-draw.js", "activities/ghoul-pew.js", "activities/ghoul-pew-draw.js", "activities/ghoul-pew-course.js", "activities/ghoul-pew-world.js", "activities/ghoul-mower.js", "activities/ghoul-mower-draw.js", "activities/ghoul-tray.js", "activities/ghoul-tray-draw.js", "activities/ghoul-carnival.js", "activities/ghoul-carnival-draw.js", "activities/ghoul-carnival-world.js", "activities/ghoul-frozen.js", "activities/ghoul-frozen-draw.js", "activities/ghoul-frozen-world.js", "activities/ghoul-flare.js", "activities/ghoul-bog.js", "activities/ghoul-bog-draw.js", "activities/ghoul-bogboat.js", "activities/ghoul-bogboat-draw.js", "activities/ghoul-picker-draw.js", "activities/ghoul-powers.js", "activities/ghoul-arms.js", "activities/ghoul-arms-draw.js", "activities/ghoul-rockets.js", "activities/ghoul-rockets-draw.js", "activities/ghoul-pans.js", "activities/ghoul-sfx-arms.js", "activities/ghoul-run.js", "activities/ghoul-dice.js", "activities/ghoul-dice-draw.js", "activities/ghoul-gameover-draw.js", "activities/ghoul-intros.js", "activities/ghoul-intro-draw.js", "activities/ghoul-boss-intros.js", "activities/ghoul-bossintro-draw.js", "activities/ghoul-story.js", "activities/ghoul-story-draw.js", "activities/ghoul-sfx-story.js", "activities/ghoul-bonus.js", "activities/ghoul-bonus-draw.js", "activities/ghoul-monsters-draw.js", "activities/pills.js", "activities/snake-sfx.js", "activities/golf-sfx.js", "activities/trails-sfx.js", "activities/bugs-sfx.js", "activities/drive-sfx.js", "activities/stack-sfx.js", "activities/bumper-sfx.js", "activities/rapids-sfx.js", "activities/fuse-sfx.js", "activities/hop-sfx.js", "activities/bounce-sfx.js", "activities/ghoul-sfx.js", "activities/ghoul-sfx-graveyard.js", "activities/ghoul-sfx-grounds.js", "activities/ghoul-sfx-chapel.js", "activities/ghoul-sfx-sanatorium.js", "activities/ghoul-sfx-village.js", "activities/ghoul-sfx-mine.js", "activities/ghoul-sfx-carnival.js", "activities/ghoul-sfx-frozen.js", "activities/ghoul-sfx-sled.js", "activities/ghoul-sfx-gurney.js", "activities/ghoul-sfx-hearse.js", "activities/ghoul-sfx-bog.js", "activities/ghoul-sfx-bogboat.js", "activities/ghoul-sfx-wagon.js", "activities/ghoul-sfx-pew.js", "activities/ghoul-sfx-mower.js", "activities/ghoul-sfx-tray.js", "activities/ghoul-ride-core.js", "activities/ghoul-ride-scenes.js", "activities/ghoul-ride.js", "activities/ghoul-ride-gfx.js", "activities/ghoul-ride-draw-kinds.js", "activities/ghoul-ride-draw-sets.js", "activities/ghoul-ride-draw-hud.js", "activities/ghoul-ride-draw.js", "activities/ghoul-ride-voices.js", "activities/ghoul-sfx-ride.js"]) {
|
||||
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul-rush/ghoul.js", "activities/ghoul-rush/draw/ghoul-draw.js", "activities/ghoul-rush/core/ghoul-rooms.js", "activities/ghoul-rush/stages/wing/ghoul-bones.js", "activities/ghoul-rush/stages/wing/ghoul-bones-draw.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js", "activities/ghoul-rush/stages/village/ghoul-village.js", "activities/ghoul-rush/stages/village/ghoul-village-draw.js", "activities/ghoul-rush/stages/village/ghoul-village-world.js", "activities/ghoul-rush/stages/village/ghoul-village-wolf.js", "activities/ghoul-rush/stages/mine/ghoul-mine.js", "activities/ghoul-rush/stages/mine/ghoul-mine-draw.js", "activities/ghoul-rush/stages/mine/ghoul-mine-world.js", "activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js", "activities/ghoul-rush/rides/cart/ghoul-cart.js", "activities/ghoul-rush/rides/cart/ghoul-cart-draw.js", "activities/ghoul-rush/rides/sled/ghoul-sled.js", "activities/ghoul-rush/rides/sled/ghoul-sled-draw.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js", "activities/ghoul-rush/rides/banister/ghoul-banister.js", "activities/ghoul-rush/rides/banister/ghoul-banister-draw.js", "activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew.js", "activities/ghoul-rush/rides/pew/ghoul-pew-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew-course.js", "activities/ghoul-rush/rides/pew/ghoul-pew-world.js", "activities/ghoul-rush/rides/mower/ghoul-mower.js", "activities/ghoul-rush/rides/mower/ghoul-mower-draw.js", "activities/ghoul-rush/rides/tray/ghoul-tray.js", "activities/ghoul-rush/rides/tray/ghoul-tray-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js", "activities/ghoul-rush/arms/ghoul-flare.js", "activities/ghoul-rush/stages/bog/ghoul-bog.js", "activities/ghoul-rush/stages/bog/ghoul-bog-draw.js", "activities/ghoul-rush/draw/ghoul-picker-draw.js", "activities/ghoul-rush/core/ghoul-powers.js", "activities/ghoul-rush/arms/ghoul-arms.js", "activities/ghoul-rush/arms/ghoul-arms-draw.js", "activities/ghoul-rush/arms/ghoul-rockets.js", "activities/ghoul-rush/arms/ghoul-rockets-draw.js", "activities/ghoul-rush/arms/ghoul-pans.js", "activities/ghoul-rush/arms/ghoul-sfx-arms.js", "activities/ghoul-rush/core/ghoul-run.js", "activities/ghoul-rush/core/ghoul-dice.js", "activities/ghoul-rush/core/ghoul-dice-draw.js", "activities/ghoul-rush/story/ghoul-gameover-draw.js", "activities/ghoul-rush/story/ghoul-intros.js", "activities/ghoul-rush/story/ghoul-intro-draw.js", "activities/ghoul-rush/story/ghoul-boss-intros.js", "activities/ghoul-rush/story/ghoul-bossintro-draw.js", "activities/ghoul-rush/story/ghoul-story.js", "activities/ghoul-rush/story/ghoul-story-draw.js", "activities/ghoul-rush/story/ghoul-sfx-story.js", "activities/ghoul-rush/core/ghoul-bonus.js", "activities/ghoul-rush/core/ghoul-bonus-drLine truncated
|
||||
assert.ok(servable.includes(`"${file}"`), `SERVABLE includes ${file}`);
|
||||
}
|
||||
});
|
||||
@@ -84,7 +84,8 @@ test("every tone is well formed: a known wave or noise, a sane length, a filter
|
||||
assert.ok(Object.isFrozen(spec), `${name} is frozen`);
|
||||
for (const p of partsOf(spec)) {
|
||||
assert.ok(WAVES.has(p.type) || (spec.layers && NOISES.has(p.type)), `${name}: ${p.type} is a wave, or a noise in a layered tone`);
|
||||
assert.ok(p.seconds > 0 && p.seconds + (p.delay || 0) <= 1.2, `${name} is over within 1.2 s`);
|
||||
// (a tiny tolerance: 0.1 + 1.1 is 1.2000000000000002 in floating point)
|
||||
assert.ok(p.seconds > 0 && p.seconds + (p.delay || 0) <= 1.2 + 1e-9, `${name} is over within 1.2 s`);
|
||||
if (WAVES.has(p.type)) assert.ok(p.notes ? p.notes.every((f) => f > 0) : p.from > 0 && p.to > 0, `${name} has its pitches`);
|
||||
if (p.filter) assert.ok(FILTERS.has(p.filter.type) && p.filter.from > 0, `${name}'s filter is known`);
|
||||
if (p.gain !== undefined) assert.ok(p.gain > 0 && p.gain <= 1, `${name}'s part gain is a share`);
|
||||
|
||||
@@ -43,7 +43,7 @@ export const ACTIVITIES = Object.freeze([
|
||||
entry("fuse", "Hot Potato", "Pass the bomb before it blows. Last one standing wins."),
|
||||
entry("hop", "Crossing Rush", "Hop through traffic and rivers. Race your rivals to the top."),
|
||||
entry("bounce", "Bounce Road", "Ten wild stages of toy-car mayhem. Jump, stomp and outrun the Monster truck."),
|
||||
entry("ghoul", "Ghoul Rush", "Run and gun through a pitch-dark haunted house. Keep moving.", { music: 65 }),
|
||||
entry("ghoul", "Ghoul Rush", "Run and gun through a pitch-dark haunted house. Keep moving.", { music: 65, module: "/activities/ghoul-rush/ghoul.js" }),
|
||||
]);
|
||||
|
||||
const cap = (word) => word[0].toUpperCase() + word.slice(1);
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Gallows Bog stage, its rules: the monsters that haunt it (a lurker's eyes in the water, a drifting leech swarm, a will-o'-wisp whose light lures the rest toward you, and a bog body risen from the muck) and its boss, Old Mother Bog, as a stage pack that ghoul.js plugs in.
|
||||
//
|
||||
// No imports: ghoul.js hands every rule here a kit `k` of its own helpers
|
||||
// (walk, throwBone, spawnMonster, groundAt, struck, hurt and the numbers they
|
||||
// need), so this file never reaches back into it. A pack is plain data and
|
||||
// functions:
|
||||
//
|
||||
// - `monsters`: each kind's numbers, as in ghoul.js's MONSTERS (`perch`: its
|
||||
// spawn names the height it waits at; `flies`: a horde one comes in high).
|
||||
// - `walkers`, `zombies`: kinds that join ghoul.js's sets of the same names
|
||||
// (a bog body is a zombie in every way but how it rises).
|
||||
// - `act`: what a kind starts out doing; `solid`: whether one can hurt and be
|
||||
// hit just now; `swoops`: whether a kind is diving low enough to duck
|
||||
// under; `unseen`: kinds out of sight just now, so shots go through and a
|
||||
// touch does nothing; `harmless`: kinds that never hurt by touch (the leech
|
||||
// latches instead); `move`: one slice of a kind's moving; `kill`: what a
|
||||
// death leaves; `horde`: what a kind comes in from the edge with.
|
||||
// - `tick`: the stage's own twist, run each slice (the wisp's lure).
|
||||
// - `shot`: what a bolt that hit a monster does besides its damage (a bright
|
||||
// wisp is shot out, never hit); `target`: what else a bolt can strike (a
|
||||
// harpoon finds a lurker's eyes under the water).
|
||||
// - `bosses`, `boss` (one slice of a boss's fight), `guard` (true while
|
||||
// shots and stomps glance off), `weak` (the damage multiplier of a shot
|
||||
// that has just hit), `cause` (what its touch is called) and `hazards` (by
|
||||
// kind, one slice of something it left on the field).
|
||||
//
|
||||
// A lurker is two eyes at the waterline until you cross it: then it snaps
|
||||
// out of the water, solid and lunging, and sinks back. A leech swarm drifts
|
||||
// through the wet spans toward you and latches on contact, one heart and it
|
||||
// drops off. A wisp is a drifting light: near it the dead pull toward you a
|
||||
// step quicker (the lure), until a bolt puts it out and it rekindles
|
||||
// somewhere else. A bog body rises out of the mud and walks.
|
||||
//
|
||||
// Old Mother Bog drifts along her planks keeping her distance, winds up and
|
||||
// sends a low wave of mud down the boards to jump, or spits from her
|
||||
// cauldron to where you stand, leaving a muck patch that burns. The
|
||||
// cauldron opens late in her rests: a shot into her then counts triple. At
|
||||
// half her hp she goes under, bubbles show where she comes back up, and she
|
||||
// fights on with shorter waits and a second patch aimed ahead of your feet.
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
|
||||
export const MONSTERS = freeze({
|
||||
lurker: freeze({ name: "Lurker", w: 3.4, h: 2.6, hp: 3, speed: 16, points: 150, stomp: true, head: false, color: "#2a3a18" }),
|
||||
leech: freeze({ name: "Leech Swarm", w: 3, h: 1.8, hp: 2, speed: 9, points: 90, stomp: true, head: false, color: "#3d2a24" }),
|
||||
wisp: freeze({ name: "Will-o'-Wisp", w: 1.6, h: 1.6, hp: 1, speed: 12, points: 70, stomp: false, head: false, perch: true, flies: true, color: "#9adfc0" }),
|
||||
bogbody: freeze({ name: "Bog Body", w: 3, h: 5, hp: 4, speed: 7, lurch: 14, points: 120, stomp: true, head: true, color: "#4a3a22" }),
|
||||
});
|
||||
|
||||
export const BOSSES = freeze({
|
||||
motherbog: freeze({ name: "Old Mother Bog", sub: "Keep to the planks, she owns the water", w: 7, h: 10, hp: 95, points: 3000, color: "#5a4a2a" }),
|
||||
});
|
||||
|
||||
// A lurker's eyes snap when you are within SNAP_RANGE across (and SNAP_HIGH
|
||||
// up or down): it lunges at SNAP_V for SNAP_MS, then sinks for LURKER_SINK_MS
|
||||
// back to eyes.
|
||||
export const SNAP_RANGE = 9;
|
||||
export const SNAP_HIGH = 5;
|
||||
export const SNAP_V = 34;
|
||||
export const SNAP_MS = 900;
|
||||
export const LURKER_SINK_MS = 500;
|
||||
// A latched leech swarm costs one heart, then it drops off for
|
||||
// LEECH_DROP_MS and cannot latch again for LEECH_AGAIN_MS.
|
||||
export const LEECH_DROP_MS = 350;
|
||||
export const LEECH_AGAIN_MS = 1400;
|
||||
// A bog body takes BOG_RISE_MS to climb out of the mud (one out of the
|
||||
// horde's edge, or out of a door, is already up), then lurches like a zombie
|
||||
// inside LURCH_RANGE.
|
||||
export const BOG_RISE_MS = 600;
|
||||
const LURCH_RANGE = 20;
|
||||
// A wisp put out stays dim for WISP_RELIGHT_MS, then glows at its seeded
|
||||
// spot for WISP_REKINDLE_MS before it burns bright again. While it is
|
||||
// bright, every monster within WISP_LURE of it is pulled toward you and
|
||||
// runs at WISP_HASTE times its speed.
|
||||
export const WISP_RELIGHT_MS = 6000;
|
||||
export const WISP_REKINDLE_MS = 600;
|
||||
export const WISP_LURE = 10;
|
||||
export const WISP_HASTE = 1.2;
|
||||
const LURE_HOLD_MS = 120;
|
||||
// Old Mother Bog keeps MOTHER_KEEP of plank between you, drifting at
|
||||
// MOTHER_WALK. Between moves she idles MOTHER_IDLE_MS; the mud wave winds up
|
||||
// MOTHER_WIND_MS and rests MOTHER_REST_MS after, its cauldron open for the
|
||||
// last MOTHER_OPEN_MS; the spit winds up SPIT_WIND_MS and lands MUCK_LAND_MS
|
||||
// later, a patch MUCK_W wide and MUCK_H high burning for MUCK_MS. At
|
||||
// MOTHER_RAGE of her hp she sinks for MOTHER_SINK_MS, bubbles for
|
||||
// BUBBLE_MS where she will surface, and rises over RESURFACE_MS near you
|
||||
// (RESURFACE_NEAR or further); after it her waits are MOTHER_QUICK times as
|
||||
// long and the spit also lands a patch MUCK_LEAD ahead of where you run.
|
||||
export const MOTHER_KEEP = 14;
|
||||
export const MOTHER_WALK = 6;
|
||||
export const MOTHER_IDLE_MS = 1400;
|
||||
export const MOTHER_WIND_MS = 600;
|
||||
export const MOTHER_REST_MS = 1500;
|
||||
export const MOTHER_OPEN_MS = 540;
|
||||
export const SPIT_WIND_MS = 550;
|
||||
export const MUCK_LAND_MS = 750;
|
||||
export const MUCK_MS = 3000;
|
||||
export const MUCK_W = 5;
|
||||
export const MUCK_H = 3;
|
||||
export const MUCK_LEAD = 11;
|
||||
export const MOTHER_RAGE = 0.5;
|
||||
export const MOTHER_QUICK = 0.7;
|
||||
export const MOTHER_SINK_MS = 600;
|
||||
export const BUBBLE_MS = 700;
|
||||
export const RESURFACE_MS = 450;
|
||||
const RESURFACE_NEAR = 14;
|
||||
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
|
||||
/* ------------------------------------------------------------ monsters */
|
||||
|
||||
// Two eyes at the waterline: unseen till you cross it, then a snap out of
|
||||
// the water, solid and lunging, and a sink back to eyes.
|
||||
function moveLurker(round, m, ms, k) {
|
||||
const you = round.you;
|
||||
const dt = ms / 1000;
|
||||
if (m.act === "snap") {
|
||||
m.wait = Math.max(0, m.wait - ms);
|
||||
k.walk(round, m, k.towardYou(round, m), SNAP_V * round.spec.pace, dt);
|
||||
if (m.wait) return;
|
||||
m.act = "sink";
|
||||
m.wait = LURKER_SINK_MS;
|
||||
round.events.push({ type: "lurkerSink", kind: m.kind, x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
if (m.act === "sink") {
|
||||
m.wait = Math.max(0, m.wait - ms);
|
||||
if (m.wait) return;
|
||||
m.act = "eyes";
|
||||
return;
|
||||
}
|
||||
m.dir = k.towardYou(round, m);
|
||||
if (Math.abs(you.x - m.x) < SNAP_RANGE && Math.abs(you.y - m.y) < SNAP_HIGH && you.out <= 0) {
|
||||
m.act = "snap";
|
||||
m.wait = SNAP_MS;
|
||||
round.events.push({ type: "lurkerSnap", kind: m.kind, x: m.x, y: m.y + 1, dir: m.dir });
|
||||
}
|
||||
}
|
||||
|
||||
// Drifting along its floor toward you; contact is a latch (one heart, cause
|
||||
// `leeches`, then it drops off and drifts again once it can).
|
||||
function moveLeech(round, m, ms, k) {
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const dt = ms / 1000;
|
||||
m.latchIn = Math.max(0, (m.latchIn || 0) - ms);
|
||||
if (m.act === "drop") {
|
||||
m.wait = Math.max(0, m.wait - ms);
|
||||
if (m.wait) return;
|
||||
m.act = "drift";
|
||||
return;
|
||||
}
|
||||
const hitH = you.ducking ? k.DUCK_H : k.HIT_H;
|
||||
const touch = Math.abs(you.x - m.x) < (k.HIT_W + m.w * 0.8) / 2 && you.y < m.y + m.h * 0.9 && you.y + hitH > m.y + m.h * 0.1;
|
||||
if (touch && !(m.latchIn > 0) && you.out <= 0) {
|
||||
m.act = "drop";
|
||||
m.wait = LEECH_DROP_MS;
|
||||
m.latchIn = LEECH_AGAIN_MS;
|
||||
round.events.push({ type: "leechLatch", kind: m.kind, x: m.x, y: m.y });
|
||||
k.struck(round, "leeches");
|
||||
return;
|
||||
}
|
||||
const dir = k.towardYou(round, m);
|
||||
k.walk(round, m, dir, MONSTERS.leech.speed * spec.pace, dt);
|
||||
m.dir = dir;
|
||||
}
|
||||
|
||||
// A mud-caked riser: it climbs out of the muck (harmless till up, the
|
||||
// zombie rule), then shambles and lurches like one. A horde one, or one out
|
||||
// of a door, is already up.
|
||||
function moveBogbody(round, m, ms, k) {
|
||||
const you = round.you;
|
||||
if (m.act === "rise") {
|
||||
if (m.horde) {
|
||||
m.act = "walk";
|
||||
} else {
|
||||
if (!(m.rise > 0)) {
|
||||
m.rise = BOG_RISE_MS;
|
||||
round.events.push({ type: "bogRise", kind: m.kind, x: m.x, y: m.y });
|
||||
}
|
||||
m.rise = Math.max(0, m.rise - ms);
|
||||
if (!m.rise) m.act = "walk";
|
||||
return;
|
||||
}
|
||||
}
|
||||
const near = Math.abs(you.x - m.x) < LURCH_RANGE && Math.abs(you.y - m.y) < 6;
|
||||
k.walk(round, m, k.towardYou(round, m), (near ? MONSTERS.bogbody.lurch : MONSTERS.bogbody.speed) * round.spec.pace, ms / 1000);
|
||||
m.lurching = near;
|
||||
}
|
||||
|
||||
// A drifting light: while bright it wanders toward your chest (its dips are
|
||||
// duckable), while dim it sinks and waits out its relight, and while
|
||||
// rekindling it glows where it will burn again.
|
||||
function moveWisp(round, m, ms, k) {
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const dt = ms / 1000;
|
||||
if (m.act === "dim") {
|
||||
m.wait = Math.max(0, m.wait - ms);
|
||||
const floor = k.groundAt(spec, m.x);
|
||||
if (Number.isFinite(floor)) m.y = Math.max(floor + 0.6, m.y - 18 * dt);
|
||||
if (m.wait) return;
|
||||
if (m.relight) {
|
||||
m.x = m.relight.x;
|
||||
m.y = m.relight.y;
|
||||
}
|
||||
m.act = "rekindle";
|
||||
m.wait = WISP_REKINDLE_MS;
|
||||
round.events.push({ type: "wispRelight", kind: m.kind, x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
if (m.act === "rekindle") {
|
||||
m.wait = Math.max(0, m.wait - ms);
|
||||
if (m.wait) return;
|
||||
m.act = "bright";
|
||||
round.events.push({ type: "wispOn", kind: m.kind, x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
const speed = MONSTERS.wisp.speed * spec.pace;
|
||||
const ty = you.y + k.SHOT_Y - m.h / 2;
|
||||
const dx = you.x - m.x;
|
||||
const dy = ty - m.y;
|
||||
const d = Math.hypot(dx, dy) || 1;
|
||||
m.x += (dx / d) * speed * dt;
|
||||
m.y += (dy / d) * speed * dt;
|
||||
m.y += Math.sin(m.t / 190 + m.id) * 4 * dt;
|
||||
m.dir = Math.sign(dx) || m.dir;
|
||||
m.y = Math.max(k.groundAt(spec, m.x) + 0.6, Math.min(k.CHANDELIER_Y, m.y));
|
||||
}
|
||||
|
||||
// A bolt puts a bright wisp out (never hurt: it is light), starting its
|
||||
// rekindle clock and seeding the spot it will burn again from its id.
|
||||
function wispShot(round, m, s, k) {
|
||||
if (m.kind !== "wisp" || m.act !== "bright") return 1;
|
||||
m.act = "dim";
|
||||
m.wait = WISP_RELIGHT_MS;
|
||||
m.vx = 0;
|
||||
m.vy = 0;
|
||||
const spec = round.spec;
|
||||
const rx = clamp(m.x + (((m.id * 37) % 23) - 11), 4, spec.length - 4);
|
||||
m.relight = { x: rx, y: Math.min(k.CHANDELIER_Y, Math.max(k.groundAt(spec, rx) + 7, 10)) };
|
||||
round.events.push({ type: "wispOut", kind: m.kind, x: m.x, y: m.y + m.h / 2 });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A dispersed swarm is told so (its voice lands with the art).
|
||||
function leechDies(round, m) {
|
||||
round.events.push({ type: "leechDie", kind: m.kind, x: m.x, y: m.y + m.h / 2 });
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- the wisp lure */
|
||||
|
||||
// The stage's twist, run each slice: the dead inside a bright wisp's light
|
||||
// are pulled toward you and run quicker, till the wisp dims or they drift
|
||||
// out of it. In another stage's room it never touches `lure` or `hasteMs`:
|
||||
// those fields are another pack's there (the grounds' moth call).
|
||||
function bogTick(round, ms) {
|
||||
if (round.stage !== "bog") return;
|
||||
const wisps = [];
|
||||
for (const w of round.monsters) if (!w.dead && w.kind === "wisp" && w.act === "bright") wisps.push(w);
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || m.kind === "wisp") continue;
|
||||
let near = false;
|
||||
for (const w of wisps) {
|
||||
if (Math.hypot(m.x - w.x, m.y - w.y) <= WISP_LURE) {
|
||||
near = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (near) {
|
||||
if (!(m.lure > 0)) round.events.push({ type: "wispLure", kind: m.kind, x: m.x, y: m.y + m.h });
|
||||
m.lure = LURE_HOLD_MS;
|
||||
m.hasteMs = LURE_HOLD_MS;
|
||||
m.haste = WISP_HASTE;
|
||||
} else if (m.lure > 0) {
|
||||
m.lure = 0;
|
||||
m.hasteMs = 0;
|
||||
m.haste = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ the hag */
|
||||
|
||||
const motherWait = (round, b, v) => (v * (b.raged ? MOTHER_QUICK : 1)) / round.spec.pace;
|
||||
|
||||
// The plank nearest `x` within reach, as { x, y }, or null over open water.
|
||||
function plankAt(spec, x, k) {
|
||||
for (const d of [0, 2, -2, 4, -4, 6, -6]) {
|
||||
const g = k.groundAt(spec, x + d);
|
||||
if (Number.isFinite(g)) return { x: x + d, y: g };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function moveMother(round, b, ms, random, k) {
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const dt = ms / 1000;
|
||||
const wait = (v) => motherWait(round, b, v);
|
||||
if (!b.act) {
|
||||
b.act = "idle";
|
||||
b.wait = wait(MOTHER_IDLE_MS);
|
||||
}
|
||||
b.wait -= ms;
|
||||
if (b.act !== "sink" && b.act !== "under" && b.act !== "resurface") b.dir = Math.sign(you.x - b.x) || b.dir;
|
||||
// At half her hp she goes under once, and comes back up meaner.
|
||||
if (!b.sank && b.hp <= b.max * MOTHER_RAGE) {
|
||||
b.sank = true;
|
||||
b.raged = true;
|
||||
b.home = b.y;
|
||||
b.act = "sink";
|
||||
b.wait = MOTHER_SINK_MS;
|
||||
b.hidden = true;
|
||||
// Down at once: a box she slides through you with while nothing can hurt
|
||||
// her is a hit you could not answer.
|
||||
b.y = b.home - (b.h + 4);
|
||||
round.events.push({ type: "motherSink", kind: b.kind, x: b.x, y: b.home });
|
||||
return;
|
||||
}
|
||||
// The cauldron opens late in a rest: a shot then counts triple (see `weak`).
|
||||
const open = b.act === "rest" && b.wait <= MOTHER_OPEN_MS;
|
||||
if (open && !b.lit) round.events.push({ type: "cauldronOpen", kind: b.kind, x: b.x + b.dir * b.w * 0.3, y: b.y + b.h * 0.35 });
|
||||
b.lit = open;
|
||||
if (b.act === "idle") {
|
||||
// She drifts to keep about MOTHER_KEEP of plank between her and you,
|
||||
// never stepping off the boards onto open water.
|
||||
const side = Math.sign(b.x - you.x) || 1;
|
||||
const goal = clamp(you.x + side * MOTHER_KEEP, k.arenaMin(round, b), k.arenaMax(round, b));
|
||||
if (Math.abs(goal - b.x) > 1 && k.groundAt(spec, goal) === b.y) {
|
||||
const nx = b.x + Math.sign(goal - b.x) * MOTHER_WALK * spec.pace * dt;
|
||||
if (k.groundAt(spec, nx) === b.y) b.x = nx;
|
||||
}
|
||||
if (b.wait > 0) return;
|
||||
// The mud wave and the cauldron in turn.
|
||||
b.attacks++;
|
||||
if (b.attacks % 2) {
|
||||
b.act = "wind";
|
||||
b.wait = wait(MOTHER_WIND_MS);
|
||||
round.events.push({ type: "motherWind", kind: b.kind, x: b.x, y: b.y + b.h * 0.6, dir: b.dir });
|
||||
} else {
|
||||
b.act = "throwWind";
|
||||
b.wait = wait(SPIT_WIND_MS);
|
||||
round.events.push({ type: "spitWind", kind: b.kind, x: b.x + b.dir * b.w * 0.3, y: b.y + b.h * 0.55, dir: b.dir });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (b.act === "wind") {
|
||||
if (b.wait > 0) return;
|
||||
const floor = k.groundAt(spec, b.x);
|
||||
round.waves.push({ x: b.x + b.dir * (b.w / 2), y: floor, dir: b.dir, life: 6000, kind: "mudwave", cause: "mudwave" });
|
||||
round.events.push({ type: "mudWave", kind: b.kind, x: b.x + b.dir * (b.w / 2), y: floor, dir: b.dir });
|
||||
b.act = "rest";
|
||||
b.wait = wait(MOTHER_REST_MS);
|
||||
return;
|
||||
}
|
||||
if (b.act === "throwWind") {
|
||||
if (b.wait > 0) return;
|
||||
const sx = b.x + b.dir * b.w * 0.35;
|
||||
const sy = b.y + b.h * 0.55;
|
||||
const at = { type: "cauldronSpit", kind: b.kind, x: sx, y: sy };
|
||||
const x = clamp(you.x, spec.arena + 2, spec.length - 2);
|
||||
const spot = plankAt(spec, x, k);
|
||||
if (spot) {
|
||||
round.hazards.push({ kind: "muck", x: spot.x, y: spot.y, w: MUCK_W, h: MUCK_H, warn: MUCK_LAND_MS, live: 0, cause: "muck", sx, sy });
|
||||
Object.assign(at, { tx: spot.x, ty: spot.y });
|
||||
}
|
||||
// Meaner: a second patch lands ahead of where you run.
|
||||
if (b.raged) {
|
||||
let ahead = (Math.sign(you.vx) || you.face || 1) * MUCK_LEAD;
|
||||
let x2 = clamp(x + ahead, spec.arena + 2, spec.length - 2);
|
||||
if (Math.abs(x2 - x) < MUCK_W) x2 = clamp(x - ahead, spec.arena + 2, spec.length - 2);
|
||||
const spot2 = plankAt(spec, x2, k);
|
||||
if (spot2 && (!spot || spot2.x !== spot.x)) {
|
||||
round.hazards.push({ kind: "muck", x: spot2.x, y: spot2.y, w: MUCK_W, h: MUCK_H, warn: MUCK_LAND_MS, live: 0, cause: "muck", sx, sy });
|
||||
Object.assign(at, { tx2: spot2.x, ty2: spot2.y });
|
||||
}
|
||||
}
|
||||
round.events.push(at);
|
||||
b.act = "idle";
|
||||
b.wait = wait(MOTHER_REST_MS);
|
||||
return;
|
||||
}
|
||||
if (b.act === "rest") {
|
||||
if (b.wait > 0) return;
|
||||
b.act = "idle";
|
||||
b.wait = wait(MOTHER_IDLE_MS);
|
||||
return;
|
||||
}
|
||||
if (b.act === "sink") {
|
||||
if (b.wait > 0) return;
|
||||
// Where she comes back up: on a plank near you, never on top of you.
|
||||
const lo = spec.arena + 4 + b.w / 2;
|
||||
const hi = spec.length - 4 - b.w / 2;
|
||||
let spot = null;
|
||||
for (const d of [RESURFACE_NEAR, -RESURFACE_NEAR, RESURFACE_NEAR * 1.7, -RESURFACE_NEAR * 1.7, RESURFACE_NEAR * 2.4, -RESURFACE_NEAR * 2.4]) {
|
||||
const x = clamp(you.x + d, lo, hi);
|
||||
if (Math.abs(x - you.x) >= 6 && k.groundAt(spec, x) === b.home) {
|
||||
spot = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (spot === null) for (const d of [0, 8, -8]) {
|
||||
const x = clamp(b.x + d, lo, hi);
|
||||
if (Math.abs(x - you.x) >= 6 && k.groundAt(spec, x) === b.home) {
|
||||
spot = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
b.sinkX = spot ?? clamp(b.x, lo, hi);
|
||||
b.act = "under";
|
||||
b.wait = BUBBLE_MS;
|
||||
round.events.push({ type: "motherBubble", kind: b.kind, x: b.sinkX, y: b.home });
|
||||
return;
|
||||
}
|
||||
if (b.act === "under") {
|
||||
if (b.wait > 0) return;
|
||||
// Up at once where the bubbles showed, touchable and hittable again.
|
||||
b.x = b.sinkX;
|
||||
b.y = b.home;
|
||||
b.hidden = false;
|
||||
b.act = "resurface";
|
||||
b.wait = RESURFACE_MS;
|
||||
round.events.push({ type: "motherRise", kind: b.kind, x: b.x, y: b.home });
|
||||
return;
|
||||
}
|
||||
if (b.act === "resurface") {
|
||||
if (b.wait > 0) return;
|
||||
b.act = "rest";
|
||||
b.wait = wait(MOTHER_REST_MS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// A muck patch: a glob in the air for `warn`, then burning for MUCK_MS
|
||||
// where it came down. Returns whether it is still on the field.
|
||||
function stepMuck(round, h, ms) {
|
||||
if (h.warn > 0) {
|
||||
h.warn = Math.max(0, h.warn - ms);
|
||||
if (h.warn > 0) return true;
|
||||
h.live = MUCK_MS;
|
||||
round.events.push({ type: "muckLand", x: h.x, y: h.y });
|
||||
return true;
|
||||
}
|
||||
h.live -= ms;
|
||||
return h.live > 0;
|
||||
}
|
||||
|
||||
// A harpoon is the one bolt that reaches a lurker's eyes under the water:
|
||||
// every other shot goes through them (they are `unseen`).
|
||||
function harpoonShot(round, s, k) {
|
||||
if (s.arm !== "harpoon") return false;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || m.kind !== "lurker" || !m.unseen || (s.hit || []).includes(m.id)) continue;
|
||||
if (Math.abs(s.x - m.x) > m.w / 2 + 0.5 || s.y < m.y - 0.5 || s.y > m.y + m.h + 0.5) continue;
|
||||
s.hit = [...(s.hit || []), m.id];
|
||||
k.hurt(round, m, s.dmg || 1, "harpoon");
|
||||
round.events.push({ type: "harpoonHit", kind: m.kind, x: s.x, y: s.y });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const BOG = freeze({
|
||||
id: "bog",
|
||||
monsters: MONSTERS,
|
||||
walkers: freeze(["lurker", "leech"]),
|
||||
zombies: freeze(["bogbody"]),
|
||||
stackers: freeze(["bogbody"]),
|
||||
climbers: freeze(["bogbody"]),
|
||||
act: freeze({ lurker: "eyes", leech: "drift", wisp: "bright", bogbody: "rise" }),
|
||||
swoops: freeze({ wisp: (m) => m.act === "bright" }),
|
||||
// A lurker can hurt and be hit only while it is snapping; a dim or
|
||||
// rekindling wisp can do neither.
|
||||
solid: freeze({
|
||||
lurker: (m) => m.act === "snap",
|
||||
wisp: (m) => m.act === "bright",
|
||||
}),
|
||||
// A lurker's eyes are never solid: a stomp or a bolt passes over them.
|
||||
unseen: freeze({ lurker: (round, m) => m.act !== "snap" }),
|
||||
// The swarm never hurts by touch: it latches instead (see moveLeech).
|
||||
harmless: freeze({ leech: () => true }),
|
||||
move: freeze({ lurker: moveLurker, leech: moveLeech, wisp: moveWisp, bogbody: moveBogbody }),
|
||||
kill: freeze({ leech: leechDies }),
|
||||
horde: freeze({}),
|
||||
tick: freeze([bogTick]),
|
||||
shot: wispShot,
|
||||
target: harpoonShot,
|
||||
bosses: BOSSES,
|
||||
boss: freeze({ motherbog: moveMother }),
|
||||
// She is gone while she is under: shots and stomps meet only water.
|
||||
guard: freeze({ motherbog: (b) => Boolean(b.hidden) }),
|
||||
// A shot into the open cauldron counts triple.
|
||||
weak: freeze({ motherbog: (b) => (b.lit ? 3 : 1) }),
|
||||
cause: freeze({ motherbog: () => "motherbog" }),
|
||||
hazards: freeze({ muck: stepMuck }),
|
||||
});
|
||||
@@ -1,949 +0,0 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Bog Runner, its drawing: a fan-boat skim down a black channel through the night swamp. A pale low moon and a few stars, drowned cypress trees that scroll by at their own speeds, mist, the black water of the channel in front and the raised mud flats behind it (joined by a mud ramp at each bank), sunken snags, cypress knees, moss veils and low limbs, the hag's charms hanging on strings, gas pockets bubbling up, the fan boat with its caged propeller and the leech swarm that boils in its wake.
|
||||
//
|
||||
// ghoul-draw.js plugs it in. LOOKS, VOICES, EVENT_VOICE, LOSE_WORDS and LOSE_SOUNDS are plain
|
||||
// data (the voices are the room's own tones, in ghoul-sfx-bogboat.js); bogboatArt(d) takes
|
||||
// ghoul-draw.js's drawing helpers (`d`) and hands back the drawing by kind, so this file never
|
||||
// reaches back into it. Drawn in room units, the way ghoul-draw.js draws: y counted down from
|
||||
// the field's top, so a world height `y` is drawn at `FIELD_H - y`. The still layers are only
|
||||
// the sky's color: the world is drawn by `moving` (every frame, over them; no cached layers, no
|
||||
// random numbers: everything comes from a hash), the lows, the bow, the mist, the signs and the
|
||||
// two gauges in front of Planny by `front`. What the art reads off the rules (ghoul-bogboat.js):
|
||||
//
|
||||
// - the room: `spec.ride` ({ banks, snags, knees, veils, limbs, props, gas, checks, finish }),
|
||||
// the flat floor in `spec.ground`.
|
||||
// - `round.runner` (id "bogboat"; null in any other room): `lane`, `from`, `swMs`, `h`, `air`,
|
||||
// `v`, `gap`, `panic`, `clog`, `stall`, `done`, `restX`, `check`, `props` [{ state "up" |
|
||||
// "broken" }], `gas` [{ state "up" | "burst" | "spent", t }].
|
||||
// - Planny: `you.x`, `you.y`, `you.vy`, `you.ducking`.
|
||||
// - events leave short-lived bits in the view's `fx` (`bogboatBits`, `bogboatLand`).
|
||||
|
||||
import { CLOG_MAX, CLOG_WARN, GAP_MAX, GAS_BURST_MS, GAS_H, GAS_UP, GAS_W, KNEE_W, LANE_Y, LOW_Y, PANIC_ON, PROP_H, PROP_UP, SNAG_W, WAKE_CATCH, baseOf, laneNow } from "./ghoul-bogboat.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const TAU = Math.PI * 2;
|
||||
const clamp = (x, lo, hi) => Math.min(hi, Math.max(lo, x));
|
||||
|
||||
const water = (o) => freeze({ pack: "bogboat", custom: true, noMoon: true, pit: "#010303", ...o });
|
||||
export const LOOKS = freeze({
|
||||
bogboat: water({ wallTop: "#04080c", wallLow: "#0d1a22", paper: "#16262e", wainscot: "#0a1216", floorTop: "#2c3a3e", floor: "#182226", floorEdge: "#060a0c", shelf: "#242c28", shelfTop: "#3c4a42", window: "#bcd6d0", decor: "plants", color: "#8aa8b4", dark: 0.5 }),
|
||||
});
|
||||
|
||||
// How each new kind sounds, by act (the room's own tones, ghoul-sfx-bogboat.js).
|
||||
export const VOICES = freeze({
|
||||
bogboat: freeze({ jump: "ghoulBogboatJump", land: "ghoulBogboatLand", duck: "ghoulBogboatDuck", switch: "ghoulBogboatSwitch", crash: "ghoulBogboatCrash", check: "ghoulBogboatCheck", finish: "ghoulBogboatFinish" }),
|
||||
bogboatwake: freeze({ panic: "ghoulBogboatPanic", catch: "ghoulBogboatCatch" }),
|
||||
bogboatfan: freeze({ clog: "ghoulBogboatClog", stall: "ghoulBogboatStall" }),
|
||||
bogboatshot: freeze({ gas: "ghoulBogboatGas", prop: "ghoulBogboatProp" }),
|
||||
});
|
||||
|
||||
// What each of the pack's events plays: [kind, act], once.
|
||||
export const EVENT_VOICE = freeze({
|
||||
bogboatJump: ["bogboat", "jump"],
|
||||
bogboatLand: ["bogboat", "land"],
|
||||
bogboatDuck: ["bogboat", "duck"],
|
||||
bogboatSwitch: ["bogboat", "switch"],
|
||||
bogboatCrash: ["bogboat", "crash"],
|
||||
bogboatCheck: ["bogboat", "check"],
|
||||
bogboatFinish: ["bogboat", "finish"],
|
||||
bogboatPanic: ["bogboatwake", "panic"],
|
||||
bogboatCatch: ["bogboatwake", "catch"],
|
||||
bogboatClog: ["bogboatfan", "clog"],
|
||||
bogboatStall: ["bogboatfan", "stall"],
|
||||
bogboatGas: ["bogboatshot", "gas"],
|
||||
bogboatProp: ["bogboatshot", "prop"],
|
||||
});
|
||||
export const LOSE_WORDS = freeze({ snag: "Ran onto a snag", knee: "Hit the cypress knees", veil: "Tangled in moss", limb: "Ducked too late", wake: "Swarmed" });
|
||||
export const LOSE_SOUNDS = freeze({
|
||||
snag: ["smash", 0.6, 0.7],
|
||||
knee: ["clank", 0.5, 0.6],
|
||||
veil: ["squish", 0.45, 0.8],
|
||||
limb: ["clank", 0.5, 0.8],
|
||||
wake: ["squish", 0.5, 0.7],
|
||||
});
|
||||
|
||||
const FW = 96;
|
||||
const WATER_Y = LANE_Y[0];
|
||||
const FLATS_Y = LANE_Y[1];
|
||||
let FH = 54;
|
||||
const MOSS = "#3a5a34";
|
||||
const MOSS_D = "#223a22";
|
||||
const MUD = "#3a2d1c";
|
||||
const MUD_D = "#1c150c";
|
||||
const MUD_LIT = "#6a5632";
|
||||
const WOOD = "#3a2e1e";
|
||||
const WOOD_D = "#1e160e";
|
||||
const HULL = "#2e3a3a";
|
||||
const HULL_LIT = "#52666a";
|
||||
const RUST = "#7a3a1e";
|
||||
const SWARM = "#1a1210";
|
||||
const GAS = "#c8f06a";
|
||||
const BONE = "#d8d0b8";
|
||||
|
||||
// A number in 0..1 from two integers, the same every time (no random draws).
|
||||
const rnd = (a, b = 0) => {
|
||||
let h = Math.imul((a | 0) + 0x9e37, 0x85ebca6b) ^ Math.imul((b | 0) + 0x7f4a, 0xc2b2ae35);
|
||||
h ^= h >>> 13;
|
||||
h = Math.imul(h, 0x5bd1e995);
|
||||
h ^= h >>> 15;
|
||||
return (h >>> 0) / 4294967296;
|
||||
};
|
||||
const poly = (c, pts) => {
|
||||
c.beginPath();
|
||||
pts.forEach(([x, y], i) => (i ? c.lineTo(x, y) : c.moveTo(x, y)));
|
||||
c.closePath();
|
||||
};
|
||||
const seg = (c, x0, y0, x1, y1) => {
|
||||
c.beginPath();
|
||||
c.moveTo(x0, y0);
|
||||
c.lineTo(x1, y1);
|
||||
c.stroke();
|
||||
};
|
||||
const disc = (c, x, y, r) => {
|
||||
c.beginPath();
|
||||
c.arc(x, y, r, 0, TAU);
|
||||
c.fill();
|
||||
};
|
||||
const grad = (make, stops) => {
|
||||
const g = make ? make() : null;
|
||||
if (!g || typeof g.addColorStop !== "function") return stops[stops.length >> 1][1];
|
||||
for (const [o, col] of stops) g.addColorStop(o, col);
|
||||
return g;
|
||||
};
|
||||
const vgrad = (c, y0, y1, stops) => grad(c.createLinearGradient && (() => c.createLinearGradient(0, y0, 0, y1)), stops);
|
||||
const rgrad = (c, x, y, r, stops) => grad(c.createRadialGradient && (() => c.createRadialGradient(x, y, 0, x, y, r)), stops);
|
||||
const Y = (y) => FH - y;
|
||||
// A soft glow: a radial gradient, a flat disc where the canvas cannot do one.
|
||||
function halo(ctx, x, y, r, color, alpha) {
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.fillStyle = rgrad(ctx, x, y, r, [[0, color], [1, "rgba(0,0,0,0)"]]);
|
||||
ctx.fillRect(x - r, y - r, r * 2, r * 2);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- telegraphs */
|
||||
|
||||
// What to do about each obstacle, shown as a glyph that fades in ahead of it, for the lane the
|
||||
// boat is in: JUMP (an arrow up, cyan) over snags and cypress knees, DUCK (an arrow down, amber)
|
||||
// under moss veils and limbs, SHOOT (a crosshair, red) at the first gas pockets. Everything comes
|
||||
// from the room's `ride` fields and where the boat is (no random numbers, no rules).
|
||||
export const TELEGRAPH_SEE = 40;
|
||||
export const TELEGRAPH_FULL = 30;
|
||||
export const TELEGRAPH_WORDS = 3;
|
||||
export const TELEGRAPH_ALPHA = 0.78;
|
||||
export const SHOOT_GLYPHS = 4;
|
||||
export const ANSWERS = freeze({ snag: "JUMP", knee: "JUMP", veil: "DUCK", limb: "DUCK", gas: "SHOOT" });
|
||||
export const ANSWER_COLORS = freeze({ JUMP: "#5fe3ff", DUCK: "#ffb02e", SHOOT: "#ff6a6a" });
|
||||
|
||||
const marks = new WeakMap();
|
||||
// Every obstacle that wants a glyph: { kind, lane, lead (where it begins), x (its middle), up (height of
|
||||
// the glyph's anchor), n (which of its kind), answer }, in the room's order. Only the first SHOOT_GLYPHS
|
||||
// gas pockets of the ride are marked: the lesson, then the player knows.
|
||||
export function telegraphMarks(R) {
|
||||
if (marks.has(R)) return marks.get(R);
|
||||
const out = [];
|
||||
const count = {};
|
||||
const add = (kind, lane, lead, x, up) => {
|
||||
const n = count[kind] || 0;
|
||||
count[kind] = n + 1;
|
||||
out.push({ kind, lane, lead, x, up: LANE_Y[lane] + up, n, answer: ANSWERS[kind] });
|
||||
};
|
||||
for (const [x, lane] of R.snags) add("snag", lane, x - 3, x, 7.6);
|
||||
for (const [x, lane] of R.knees) add("knee", lane, x - 3.4, x, 6.2);
|
||||
for (const [x0, x1, lane] of R.veils) add("veil", lane, x0 - 3.2, (x0 + x1) / 2, 7.4);
|
||||
for (const [x0, x1, lane] of R.limbs) add("limb", lane, x0 - 3.2, (x0 + x1) / 2, 7.4);
|
||||
for (const [x, lane] of R.gas) add("gas", lane, x - 2, x, 8);
|
||||
out.sort((p, q) => p.lead - q.lead);
|
||||
marks.set(R, out.filter((m) => m.kind !== "gas" || m.n < SHOOT_GLYPHS));
|
||||
return marks.get(R);
|
||||
}
|
||||
|
||||
// The glyphs showing with the boat at `x` in `lane`: { ...mark, alpha (0..1, before the pulse), words }.
|
||||
export function telegraphs(R, x, lane) {
|
||||
const out = [];
|
||||
for (const m of telegraphMarks(R)) {
|
||||
if (m.lane !== lane) continue;
|
||||
const d = m.lead - x;
|
||||
if (d > TELEGRAPH_SEE || d < -6) continue;
|
||||
const alpha = Math.min(clamp((TELEGRAPH_SEE - d) / (TELEGRAPH_SEE - TELEGRAPH_FULL), 0, 1), clamp((d + 4) / 6, 0, 1));
|
||||
if (alpha > 0.01) out.push({ ...m, alpha, words: m.n < TELEGRAPH_WORDS });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- art */
|
||||
|
||||
export function bogboatArt(d) {
|
||||
const { ellipse, say, label, GOLD } = d;
|
||||
const ride = (v) => (v.spec && v.spec.ride && v.spec.ride.runner === "bogboat" ? v.spec.ride : null);
|
||||
const runner = (v) => (v.round && v.round.runner && v.round.runner.id === "bogboat" ? v.round.runner : null);
|
||||
|
||||
// The still layers get only the sky's color; `moving` draws the world.
|
||||
function backdrop(ctx, v, look, x0, x1) {
|
||||
ctx.fillStyle = look.wallLow;
|
||||
ctx.fillRect(x0, 0, x1 - x0, v.g.FIELD_H);
|
||||
}
|
||||
function ground() {}
|
||||
function shelf() {}
|
||||
|
||||
/* ---------------------------------------------------------- the sky and far scenery */
|
||||
|
||||
function sky(ctx, v, cam) {
|
||||
ctx.fillStyle = vgrad(ctx, 0, FH, [[0, "#03070a"], [0.55, "#0c1a20"], [1, "#1c3036"]]);
|
||||
ctx.fillRect(cam - 1, 0, FW + 2, FH);
|
||||
for (let k = 0; k < 34; k++) {
|
||||
const x = cam + ((((rnd(k, 1) * FW - cam * 0.02) % FW) + FW) % FW);
|
||||
ctx.globalAlpha = 0.18 + 0.4 * rnd(k, 3) * (0.7 + 0.3 * Math.sin(v.clock / 600 + k));
|
||||
ctx.fillStyle = "#cfe2dc";
|
||||
ctx.fillRect(x, rnd(k, 2) * 24, 0.2, 0.2);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
// The moon: low, pale green and smeared by mist, riding with the view.
|
||||
const mx = cam + 68;
|
||||
halo(ctx, mx, 11, 15, "rgba(170,215,200,0.5)", 0.5);
|
||||
ctx.fillStyle = "#d4ece4";
|
||||
disc(ctx, mx, 11, 3.8);
|
||||
ctx.fillStyle = "rgba(120,160,150,0.45)";
|
||||
disc(ctx, mx - 1.1, 10.4, 0.9);
|
||||
disc(ctx, mx + 1, 12, 0.6);
|
||||
ctx.fillStyle = "rgba(10,22,26,0.5)";
|
||||
for (let k = 0; k < 3; k++) ellipse(ctx, cam + ((((rnd(k, 9) * 140 - v.clock / 110 - cam * 0.05) % 140) + 140) % 140) - 20, 9 + k * 2.6, 12 + rnd(k, 4) * 6, 0.55);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
// Drowned cypresses at a slow parallax: a trunk, flared foot, a few bare limbs and a hanging rag of moss.
|
||||
function trees(ctx, cam, par, base, scale, color, seed) {
|
||||
const u0 = cam * par;
|
||||
const gap = 17;
|
||||
for (let slot = Math.floor((u0 - 6) / gap); slot <= Math.floor((u0 + FW + 8) / gap); slot++) {
|
||||
const r = rnd(slot, seed);
|
||||
if (r < 0.18) continue;
|
||||
const x = cam + (slot * gap - u0) + r * 7;
|
||||
const h = (9 + rnd(slot, seed + 1) * 9) * scale;
|
||||
ctx.fillStyle = color;
|
||||
ctx.strokeStyle = color;
|
||||
poly(ctx, [[x - 1.1 * scale, base], [x - 0.35 * scale, base - h], [x + 0.35 * scale, base - h], [x + 1.1 * scale, base]]);
|
||||
ctx.fill();
|
||||
ctx.lineWidth = 0.3 * scale;
|
||||
for (let k = 0; k < 3; k++) {
|
||||
const dir = (k + slot) % 2 ? 1 : -1;
|
||||
seg(ctx, x, base - h * (0.5 + k * 0.17), x + dir * (2.6 - k * 0.5) * scale, base - h * (0.6 + k * 0.17));
|
||||
}
|
||||
ctx.lineWidth = 0.16 * scale;
|
||||
for (let k = 0; k < 3; k++) seg(ctx, x + (k - 1) * 0.9 * scale, base - h * 0.62, x + (k - 1) * 0.95 * scale, base - h * 0.62 + (2 + rnd(slot, k + 5) * 2) * scale);
|
||||
}
|
||||
}
|
||||
|
||||
// Mist: low soft bands drifting along the water.
|
||||
function mist(ctx, v, cam, alpha) {
|
||||
for (let k = 0; k < 5; k++) {
|
||||
const x = cam + ((((rnd(k, 21) * FW * 1.4 - v.clock / (900 + k * 150) - cam * 0.1) % (FW * 1.4)) + FW * 1.4) % (FW * 1.4)) - 14;
|
||||
ctx.globalAlpha = alpha * (0.6 + 0.4 * rnd(k, 22));
|
||||
ctx.fillStyle = "#9cb8b0";
|
||||
ellipse(ctx, x, Y(WATER_Y + 1.2 + k * 1.6), 16 + rnd(k, 23) * 8, 1.1 + k * 0.25);
|
||||
ctx.fill();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- the water and the flats */
|
||||
|
||||
// The channel: black water with the moon's sheen sliding by and the raised mud flats behind it.
|
||||
function channel(ctx, v, cam, R) {
|
||||
const top = Y(WATER_Y);
|
||||
ctx.fillStyle = vgrad(ctx, top, FH, [[0, "#0c1e22"], [0.25, "#061014"], [1, "#020608"]]);
|
||||
ctx.fillRect(cam - 1, top, FW + 2, WATER_Y + 1);
|
||||
ctx.fillStyle = "rgba(150,200,190,0.16)";
|
||||
for (let k = Math.floor(cam / 3.2); k < Math.floor((cam + FW) / 3.2) + 1; k++) {
|
||||
if (rnd(k, 31) < 0.4) continue;
|
||||
ctx.fillRect(k * 3.2 + Math.sin(v.clock / 700 + k) * 0.6, top + 0.5 + rnd(k, 34) * 6, 0.9 + rnd(k, 35) * 1.6, 0.18);
|
||||
}
|
||||
// The flats: a raised terrace of mud behind the channel, gleaming, reeds along its top.
|
||||
const fy = Y(FLATS_Y);
|
||||
ctx.fillStyle = vgrad(ctx, fy, top, [[0, MUD_LIT], [0.1, MUD], [1, MUD_D]]);
|
||||
ctx.fillRect(cam - 1, fy, FW + 2, top - fy + 0.1);
|
||||
ctx.fillStyle = "rgba(180,170,120,0.22)";
|
||||
for (let k = Math.floor(cam / 4); k < Math.floor((cam + FW) / 4) + 1; k++) ctx.fillRect(k * 4 + rnd(k, 41) * 2, fy + 0.5 + rnd(k, 42) * 3.4, 1.6 + rnd(k, 43), 0.2);
|
||||
ctx.fillStyle = "#4a5a34";
|
||||
ctx.fillRect(cam - 1, fy, FW + 2, 0.35);
|
||||
ctx.strokeStyle = "#5a6a3a";
|
||||
ctx.lineWidth = 0.14;
|
||||
for (let k = Math.floor(cam / 2.2); k < Math.floor((cam + FW) / 2.2) + 1; k++) {
|
||||
if (rnd(k, 44) < 0.4) continue;
|
||||
const h = 1.4 + rnd(k, 45) * 1.6;
|
||||
seg(ctx, k * 2.2, fy + 0.2, k * 2.2 + Math.sin(v.clock / 900 + k) * 0.3, fy - h);
|
||||
}
|
||||
ctx.fillStyle = "#14201c";
|
||||
ctx.fillRect(cam - 1, top - 0.9, FW + 2, 0.9);
|
||||
ctx.fillStyle = "#2c4a44";
|
||||
ctx.fillRect(cam - 1, top - 0.9, FW + 2, 0.18);
|
||||
// At each bank the edge is a mud ramp, with chevrons pointing up it.
|
||||
for (const [a, b] of R.banks) {
|
||||
if (b < cam - 4 || a > cam + FW + 4) continue;
|
||||
ctx.fillStyle = "#2a2012";
|
||||
poly(ctx, [[a, top], [a, fy], [b, fy]]);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = "#6a5632";
|
||||
ctx.lineWidth = 0.35;
|
||||
seg(ctx, a, top, b, fy);
|
||||
ctx.strokeStyle = "rgba(200,230,170,0.55)";
|
||||
ctx.lineWidth = 0.22;
|
||||
for (let k = 0; k < 3; k++) {
|
||||
const cx = a + 3 + k * 4.2;
|
||||
const cy = top - ((cx - a) / (b - a)) * (top - fy) - 0.6;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(cx - 0.8, cy + 0.6);
|
||||
ctx.lineTo(cx, cy);
|
||||
ctx.lineTo(cx - 0.8, cy - 0.6);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A bank's posts: a leaning stake with a dim green lantern at each end of the ramp.
|
||||
function bankPosts(ctx, v, a, b) {
|
||||
for (const [px, lit] of [[a - 0.4, 1], [b + 0.4, 0]]) {
|
||||
ctx.fillStyle = WOOD;
|
||||
ctx.fillRect(px - 0.4, Y(WATER_Y + 4.4), 0.8, 4.4);
|
||||
ctx.fillStyle = "#7dffa0";
|
||||
ctx.globalAlpha = 0.65 + 0.25 * Math.sin(v.clock / 330 + lit);
|
||||
disc(ctx, px, Y(WATER_Y + 5.1), 0.5);
|
||||
ctx.globalAlpha = 1;
|
||||
halo(ctx, px, Y(WATER_Y + 5.1), 4, "rgba(125,255,160,0.8)", 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- the things */
|
||||
|
||||
// A sunken snag: a rotting log lying across the lane, a broken stub up, weed on it.
|
||||
function snag(ctx, x, lane, i) {
|
||||
const y = Y(LANE_Y[lane]);
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.35)";
|
||||
ellipse(ctx, 0, 0.05, SNAG_W * 0.9, 0.3);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = WOOD;
|
||||
poly(ctx, [[-1.7, 0], [-1.5, -1.2], [-0.4, -1.5], [0.6, -3.8], [1.3, -3.9], [1.4, -1.6], [1.8, -1.0], [1.7, 0]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = WOOD_D;
|
||||
ctx.fillRect(-1.7, -0.5, 3.4, 0.5);
|
||||
ctx.fillStyle = "#5a4a32";
|
||||
ctx.fillRect(0.7, -3.8, 0.35, 2.4);
|
||||
ctx.strokeStyle = MOSS;
|
||||
ctx.lineWidth = 0.14;
|
||||
for (let k = 0; k < 3; k++) seg(ctx, -1.2 + k * 1.1, -1.3, -1.2 + k * 1.1 + Math.sin(i + k) * 0.4, -2.3 - rnd(i, k) * 0.6);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// Cypress knees: three gray cones breaking the surface, wet at the foot.
|
||||
function knees(ctx, x, lane, i) {
|
||||
const y = Y(LANE_Y[lane]);
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.35)";
|
||||
ellipse(ctx, 0, 0.05, KNEE_W * 0.6, 0.3);
|
||||
ctx.fill();
|
||||
[[-1.6, 1.7, 1.2], [0, 2.4, 1.5], [1.7, 1.5, 1.1]].forEach(([dx, h, w], k) => {
|
||||
ctx.fillStyle = k % 2 ? "#5a5a48" : "#4a4a3a";
|
||||
poly(ctx, [[dx - w / 2, 0], [dx - w * 0.15, -h], [dx + w * 0.15, -h * 0.95], [dx + w / 2, 0]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "rgba(180,200,190,0.18)";
|
||||
ctx.fillRect(dx - w / 2, -0.3, w, 0.3);
|
||||
});
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// A curtain of moss hung from a cypress limb: its underside LOW_Y over the lane.
|
||||
function veil(ctx, v, x0, x1, lane, i) {
|
||||
const under = Y(LANE_Y[lane]) - LOW_Y;
|
||||
const tx = x1 + 3;
|
||||
ctx.lineCap = "round";
|
||||
ctx.strokeStyle = "#0e0a06";
|
||||
ctx.lineWidth = 0.9;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tx, FH + 1);
|
||||
ctx.quadraticCurveTo(tx + 0.5, under + 6, tx - 0.3, under - 3);
|
||||
ctx.stroke();
|
||||
ctx.lineWidth = 0.7;
|
||||
seg(ctx, tx - 0.2, under - 1.8, x0 - 2, under - 1.2);
|
||||
ctx.lineCap = "butt";
|
||||
for (let k = 0; k < 11; k++) {
|
||||
const hx = x0 - 1.5 + (k * (x1 - x0 + 3)) / 10;
|
||||
const len = 1.0 + rnd(i * 13 + k, 2) * 2.2;
|
||||
const sway = Math.sin(v.clock / 520 + hx) * 0.35;
|
||||
ctx.strokeStyle = k % 2 ? MOSS : MOSS_D;
|
||||
ctx.lineWidth = 0.3;
|
||||
seg(ctx, hx, under - 1.2, hx + sway, under + len);
|
||||
}
|
||||
}
|
||||
|
||||
// A low cypress limb: twisted, bare, with a few moss rags.
|
||||
function limb(ctx, v, x0, x1, lane, i) {
|
||||
const under = Y(LANE_Y[lane]) - LOW_Y;
|
||||
const tx = x1 + 3.4;
|
||||
ctx.lineCap = "round";
|
||||
for (const [col, extra] of [["rgba(150,190,180,0.35)", 0.3], ["#0e0a06", 0]]) {
|
||||
ctx.strokeStyle = col;
|
||||
ctx.lineWidth = 0.8 + extra;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tx, FH + 1);
|
||||
ctx.quadraticCurveTo(tx + 0.6, under + 6, tx - 0.4, under - 2.4);
|
||||
ctx.stroke();
|
||||
ctx.lineWidth = 0.95 + extra;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tx - 0.2, under - 1);
|
||||
ctx.quadraticCurveTo(x1 - 1, under - 1.8, x0 - 2.4, under - 0.5);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.strokeStyle = "#0e0a06";
|
||||
ctx.lineWidth = 0.4;
|
||||
seg(ctx, x0 + 1.2, under - 0.8, x0 - 0.2, under + 0.6);
|
||||
ctx.lineCap = "butt";
|
||||
for (let k = 0; k < 4; k++) {
|
||||
const hx = x0 - 1.4 + k * ((x1 - x0 + 3) / 3);
|
||||
ctx.strokeStyle = k % 2 ? MOSS : MOSS_D;
|
||||
ctx.lineWidth = 0.22;
|
||||
seg(ctx, hx, under - 0.3, hx + Math.sin(v.clock / 480 + hx) * 0.25, under + 0.8 + rnd(i * 7 + k, 3) * 1.4);
|
||||
}
|
||||
}
|
||||
|
||||
// One of the hag's charms on a string from a bent pole: a skull (kind 0) or a blue bottle (kind 1).
|
||||
function prop(ctx, v, x, lane, kind, p, i) {
|
||||
const base = Y(LANE_Y[lane]);
|
||||
const sway = Math.sin(v.clock / 600 + i * 1.7) * 0.45;
|
||||
const top = base - PROP_UP - PROP_H - 3.2;
|
||||
ctx.strokeStyle = WOOD;
|
||||
ctx.lineWidth = 0.3;
|
||||
seg(ctx, x + 3, base + 0.4, x + 3, top);
|
||||
seg(ctx, x + 3, top, x + sway * 0.3, top - 0.4);
|
||||
ctx.strokeStyle = "#8a7a5a";
|
||||
ctx.lineWidth = 0.1;
|
||||
seg(ctx, x + sway * 0.3, top - 0.4, x + sway, base - PROP_UP - PROP_H - 0.2);
|
||||
if (p.state === "broken") return;
|
||||
const cy = base - PROP_UP - PROP_H / 2;
|
||||
if (kind === 0) {
|
||||
ctx.fillStyle = BONE;
|
||||
disc(ctx, x + sway, cy - 0.2, 1.05);
|
||||
ctx.fillRect(x + sway - 0.6, cy + 0.6, 1.2, 0.8);
|
||||
ctx.fillStyle = "#14100c";
|
||||
ctx.fillRect(x + sway - 0.55, cy - 0.45, 0.4, 0.45);
|
||||
ctx.fillRect(x + sway + 0.15, cy - 0.45, 0.4, 0.45);
|
||||
} else {
|
||||
ctx.fillStyle = "#4a8cc8";
|
||||
poly(ctx, [[x + sway - 0.4, cy - 1.2], [x + sway + 0.4, cy - 1.2], [x + sway + 0.4, cy - 0.4], [x + sway + 1.0, cy + 0.2], [x + sway + 1.0, cy + 1.2], [x + sway - 1.0, cy + 1.2], [x + sway - 1.0, cy + 0.2], [x + sway - 0.4, cy - 0.4]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "rgba(255,255,255,0.45)";
|
||||
ctx.fillRect(x + sway - 0.7, cy + 0.1, 0.25, 0.9);
|
||||
}
|
||||
halo(ctx, x + sway, cy, 3, "rgba(190,230,255,0.8)", 0.22);
|
||||
}
|
||||
|
||||
// A gas pocket: a cluster of sickly bubbles rising over the lane; once shot, a cloud that spreads and thins.
|
||||
function gasPocket(ctx, v, x, lane, g, i) {
|
||||
const cy = Y(LANE_Y[lane] + GAS_UP + GAS_H / 2);
|
||||
if (g.state === "spent") return;
|
||||
if (g.state === "burst") {
|
||||
const p = 1 - g.t / GAS_BURST_MS;
|
||||
ctx.fillStyle = GAS;
|
||||
for (let k = 0; k < 9; k++) {
|
||||
ctx.globalAlpha = (1 - p) * 0.42;
|
||||
disc(ctx, x + (rnd(k, 51) - 0.5) * (3 + p * 11), cy + (rnd(k, 52) - 0.6) * (2 + p * 4), 1.2 + p * 2.2);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
return;
|
||||
}
|
||||
halo(ctx, x, cy, 4.4, "rgba(200,240,100,0.9)", 0.3 + 0.1 * Math.sin(v.clock / 260 + i));
|
||||
for (let k = 0; k < 6; k++) {
|
||||
const ph = ((v.clock / 1300 + rnd(i, k + 60)) % 1);
|
||||
const bx = x + (rnd(i * 5 + k, 53) - 0.5) * GAS_W * 0.8;
|
||||
const by = cy + GAS_H * 0.5 - ph * GAS_H;
|
||||
ctx.globalAlpha = 0.85 * Math.sin(ph * Math.PI);
|
||||
ctx.strokeStyle = GAS;
|
||||
ctx.lineWidth = 0.14;
|
||||
ctx.beginPath();
|
||||
ctx.arc(bx, by, 0.5 + rnd(i * 3 + k, 54) * 0.7, 0, TAU);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A checkpoint: a stake across the channel with a black pennant and a gold star, lit once passed.
|
||||
function checkpoint(ctx, v, x, passed) {
|
||||
const top = Y(30);
|
||||
ctx.fillStyle = WOOD;
|
||||
ctx.fillRect(x - 0.3, top, 0.6, Y(WATER_Y) - top);
|
||||
ctx.fillStyle = passed ? "#244a30" : "#10181a";
|
||||
poly(ctx, [[x + 0.3, top + 0.4], [x + 6, top + 0.4 + Math.sin(v.clock / 300) * 0.3], [x + 5, top + 3.4], [x + 6, top + 6.2], [x + 0.3, top + 6.2]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = passed ? "#7dffa0" : GOLD;
|
||||
const sx = x + 3;
|
||||
const sy = top + 3.2;
|
||||
ctx.beginPath();
|
||||
for (let k = 0; k < 10; k++) {
|
||||
const r = k % 2 ? 0.5 : 1.3;
|
||||
ctx.lineTo(sx + Math.sin((k * Math.PI) / 5) * r, sy - Math.cos((k * Math.PI) / 5) * r);
|
||||
}
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
halo(ctx, sx, sy, 5, passed ? "rgba(125,255,160,0.8)" : "rgba(255,210,90,0.8)", 0.3);
|
||||
}
|
||||
|
||||
// The landing at the end of the channel: a plank pier on stilts with two lantern posts and the stilt shack's door.
|
||||
function landing(ctx, v, x) {
|
||||
const gy = Y(WATER_Y);
|
||||
ctx.fillStyle = WOOD;
|
||||
ctx.fillRect(x - 12, gy - 0.9, 28, 0.9);
|
||||
ctx.fillStyle = WOOD_D;
|
||||
for (let k = -3; k <= 3; k++) ctx.fillRect(x + k * 4, gy, 0.7, 4);
|
||||
for (const px of [x - 6, x + 8]) {
|
||||
ctx.fillStyle = WOOD;
|
||||
ctx.fillRect(px - 0.4, gy - 8, 0.8, 7.1);
|
||||
ctx.fillStyle = "#ffcf5a";
|
||||
ctx.globalAlpha = 0.8 + 0.15 * Math.sin(v.clock / 200 + px);
|
||||
disc(ctx, px, gy - 8.6, 0.7);
|
||||
ctx.globalAlpha = 1;
|
||||
halo(ctx, px, gy - 8.6, 6, "rgba(255,200,90,0.9)", 0.35);
|
||||
}
|
||||
ctx.fillStyle = "#1c150c";
|
||||
ctx.fillRect(x + 1, gy - 12, 6, 11.1);
|
||||
ctx.fillStyle = "#6a4a28";
|
||||
ctx.fillRect(x + 2.2, gy - 9.6, 3.6, 8.7);
|
||||
ctx.fillStyle = "#ffcf5a";
|
||||
ctx.fillRect(x + 4.8, gy - 5, 0.5, 0.5);
|
||||
poly(ctx, [[x, gy - 12], [x + 4, gy - 15.4], [x + 8, gy - 12]]);
|
||||
ctx.fillStyle = "#2a2012";
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ the swarm */
|
||||
|
||||
// The leech swarm boiling in the wake: dark blobs and flicking tails just under the surface, `gap` units
|
||||
// behind the boat, thicker and higher the closer it is, red eyes once it is close.
|
||||
function swarm(ctx, v, c, x, base) {
|
||||
const near = clamp(1 - (c.gap - WAKE_CATCH) / (GAP_MAX - WAKE_CATCH), 0, 1);
|
||||
const sx = x - c.gap;
|
||||
const n = 9 + Math.round(near * 16);
|
||||
const boil = c.panic ? 1 : 0.35;
|
||||
ctx.fillStyle = SWARM;
|
||||
for (let k = 0; k < n; k++) {
|
||||
const wob = Math.sin(v.clock / (110 + k * 17) + k * 2.3);
|
||||
const bx = sx + (rnd(k, 71) - 0.5) * (6 + near * 10) + wob * 0.9 * boil;
|
||||
const by = base + 0.6 - Math.abs(Math.sin(v.clock / (170 + k * 23) + k)) * (0.8 + near * 2.2) * boil;
|
||||
ellipse(ctx, bx, by, 1.3 + rnd(k, 72) * 1.1, 0.55 + rnd(k, 73) * 0.4);
|
||||
ctx.fill();
|
||||
if (c.panic && k % 3 === 0) {
|
||||
ctx.fillStyle = "#ff4a3a";
|
||||
ctx.fillRect(bx + 0.3, by - 0.3, 0.32, 0.32);
|
||||
ctx.fillStyle = SWARM;
|
||||
}
|
||||
}
|
||||
ctx.strokeStyle = "rgba(150,200,190,0.5)";
|
||||
ctx.lineWidth = 0.14;
|
||||
for (let k = 0; k < 4; k++) {
|
||||
const p = (v.clock / 600 + k / 4) % 1;
|
||||
ctx.globalAlpha = (1 - p) * (0.3 + near * 0.4);
|
||||
ctx.beginPath();
|
||||
ctx.arc(sx + (k - 1.5) * 1.8, base + 0.2, 0.6 + p * 2.2, Math.PI, TAU);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- the boat */
|
||||
|
||||
// The boat's transform: at Planny's feet (the water under it), tilted nose up on the way up, a gentle bob.
|
||||
function place(ctx, v, c, fn) {
|
||||
const you = v.round.you;
|
||||
const x = c.done ? c.restX : you.x;
|
||||
const y = c.done ? WATER_Y : you.y;
|
||||
const tilt = c.air ? clamp(c.vy / 320, -0.16, 0.16) : 0;
|
||||
const bob = !c.done && !c.air ? Math.sin(v.clock / 260) * 0.12 : 0;
|
||||
ctx.save();
|
||||
ctx.translate(x, Y(y) + bob);
|
||||
ctx.rotate(-tilt);
|
||||
fn(x);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// The back: the hull, the fan's cage on its mast with the blades turning, the spray it throws, the lantern.
|
||||
function boatBack(ctx, v, c, x) {
|
||||
const speed = clamp(c.v / 40, 0, 1.2);
|
||||
// The spray and the wake behind the stern.
|
||||
if (!c.done) {
|
||||
for (let k = 0; k < 7; k++) {
|
||||
const p = (v.clock / 480 + k / 7) % 1;
|
||||
ctx.fillStyle = `rgba(190,225,215,${(1 - p) * 0.42 * speed})`;
|
||||
disc(ctx, -9.5 - p * 8 * speed - 1, 0.1 - Math.sin(p * Math.PI) * (1 + speed * 1.4), 0.3 + p * 0.8);
|
||||
}
|
||||
ctx.strokeStyle = "rgba(190,225,215,0.35)";
|
||||
ctx.lineWidth = 0.16;
|
||||
seg(ctx, -8, 0.15, -8 - 12 * speed, 0.3);
|
||||
seg(ctx, -7, 0.55, -7 - 8 * speed, 0.7);
|
||||
}
|
||||
ctx.fillStyle = "rgba(0,0,0,0.35)";
|
||||
ellipse(ctx, -2, 0.1, 8, 0.4);
|
||||
ctx.fill();
|
||||
// The flat hull: a long dark tub with a rusted patch and a pale gunwale line.
|
||||
ctx.fillStyle = HULL;
|
||||
poly(ctx, [[-8.6, -0.1], [-8.6, -2.1], [-7.2, -2.7], [4.6, -2.7], [6.2, -1.9], [6.4, -0.1]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "#1c2626";
|
||||
ctx.fillRect(-8.6, -0.7, 15, 0.7);
|
||||
ctx.fillStyle = RUST;
|
||||
ctx.fillRect(-3.8, -2.0, 2.1, 0.9);
|
||||
ctx.fillStyle = HULL_LIT;
|
||||
ctx.fillRect(-7.2, -2.8, 11.8, 0.3);
|
||||
// The fan's mast and cage at the stern, the blades a flicker of spokes.
|
||||
ctx.fillStyle = "#2a3030";
|
||||
ctx.fillRect(-8.4, -7.4, 0.8, 4.8);
|
||||
ctx.fillRect(-9.2, -2.9, 2.4, 0.5);
|
||||
ctx.strokeStyle = "#7a8a86";
|
||||
ctx.lineWidth = 0.14;
|
||||
ctx.beginPath();
|
||||
ctx.arc(-8, -6.1, 2.4, 0, TAU);
|
||||
ctx.stroke();
|
||||
const a = c.done || c.stall > 0 ? 0 : v.clock / 28;
|
||||
ctx.lineWidth = 0.22;
|
||||
for (let k = 0; k < 3; k++) seg(ctx, -8, -6.1, -8 + Math.cos(a + (k * TAU) / 3) * 2.2 * 0.3, -6.1 + Math.sin(a + (k * TAU) / 3) * 2.2);
|
||||
ctx.fillStyle = "#4a5a58";
|
||||
disc(ctx, -8, -6.1, 0.35);
|
||||
if (c.stall > 0 && !c.done) {
|
||||
ctx.fillStyle = MUD;
|
||||
disc(ctx, -8, -6.1, 1.1);
|
||||
ctx.fillStyle = "rgba(60,46,28,0.7)";
|
||||
disc(ctx, -9.2, -4.6, 0.7);
|
||||
}
|
||||
// A lantern on a post at the bow, glowing.
|
||||
ctx.fillStyle = "#2a3030";
|
||||
ctx.fillRect(5.2, -4.8, 0.4, 2.2);
|
||||
ctx.fillStyle = "#e8ffb0";
|
||||
disc(ctx, 5.4, -5.1, 0.6);
|
||||
halo(ctx, 5.4, -5.1, 7, "rgba(210,255,150,0.9)", 0.4);
|
||||
}
|
||||
|
||||
// The front: the gunwale over Planny's legs and the low windshield.
|
||||
function boatFront(ctx) {
|
||||
ctx.fillStyle = HULL;
|
||||
poly(ctx, [[-2.6, -0.4], [4.4, -0.4], [4.4, -2.1], [3.6, -2.4], [-2.6, -2.4]]);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = HULL_LIT;
|
||||
ctx.fillRect(-2.5, -2.45, 6.1, 0.22);
|
||||
ctx.fillStyle = "#1c2626";
|
||||
ctx.fillRect(-2.6, -0.9, 7, 0.5);
|
||||
ctx.strokeStyle = "#7a8a86";
|
||||
ctx.lineWidth = 0.22;
|
||||
seg(ctx, 3.6, -2.4, 3.2, -4.4);
|
||||
ctx.fillStyle = "rgba(150,200,210,0.2)";
|
||||
poly(ctx, [[3.4, -2.5], [3.1, -4.2], [2.2, -4.2], [2.5, -2.5]]);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- mist and signs */
|
||||
|
||||
// A see-through glyph over an obstacle: chevrons or a crosshair, and (for the first few) the word.
|
||||
function glyph(ctx, v, t) {
|
||||
const col = ANSWER_COLORS[t.answer];
|
||||
const pulse = 0.85 + 0.15 * Math.sin(v.clock / 260 + t.lead);
|
||||
const cy = Math.min(FH - 7, FH - t.up) + Math.sin(v.clock / 260 + t.lead) * 0.35;
|
||||
ctx.save();
|
||||
ctx.globalAlpha = t.alpha * pulse * TELEGRAPH_ALPHA;
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
if (t.answer === "SHOOT") {
|
||||
for (const [w, c] of [[1.2, "rgba(2,8,10,0.8)"], [0.5, col]]) {
|
||||
ctx.strokeStyle = c;
|
||||
ctx.lineWidth = w;
|
||||
ctx.beginPath();
|
||||
ctx.arc(t.x, cy - 1.2, 1.5, 0, TAU);
|
||||
ctx.stroke();
|
||||
seg(ctx, t.x - 2.4, cy - 1.2, t.x - 0.6, cy - 1.2);
|
||||
seg(ctx, t.x + 0.6, cy - 1.2, t.x + 2.4, cy - 1.2);
|
||||
seg(ctx, t.x, cy - 3.6, t.x, cy - 1.8);
|
||||
seg(ctx, t.x, cy - 0.6, t.x, cy + 1.2);
|
||||
}
|
||||
if (t.words) label(ctx, "SHOOT", t.x, cy + 2.4, 2.1, col, "center");
|
||||
} else {
|
||||
const up = t.answer === "JUMP";
|
||||
const dir = up ? -1 : 1;
|
||||
const ay = cy + (up ? -2.6 : 2.6);
|
||||
for (const [w, c] of [[1.3, "rgba(2,8,10,0.8)"], [0.6, col]]) {
|
||||
ctx.strokeStyle = c;
|
||||
ctx.lineWidth = w;
|
||||
for (let k = 0; k < 2; k++) {
|
||||
const oy = ay + (k - 0.5) * 1.5 * dir - dir * 0.2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(t.x - 1.7, oy - dir * 0.9);
|
||||
ctx.lineTo(t.x, oy + dir * 0.9);
|
||||
ctx.lineTo(t.x + 1.7, oy - dir * 0.9);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
if (t.words) label(ctx, t.answer, t.x, cy + (up ? 1.2 : -1.2), 2.3, col, "center");
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// The wake meter across the top (the swarm at one end, the boat at the other, red as they close,
|
||||
// THEY ARE CLOSE inside PANIC_ON) and the fan's clog gauge beside it.
|
||||
function gauges(ctx, v, c, cam) {
|
||||
const x = cam + 2.4;
|
||||
const y = 3.2;
|
||||
const W = 34;
|
||||
const p = clamp((c.gap - WAKE_CATCH) / (GAP_MAX - WAKE_CATCH), 0, 1);
|
||||
ctx.fillStyle = "rgba(2,8,10,0.72)";
|
||||
ctx.fillRect(x - 0.6, y - 1, W + 1.2, 8.2);
|
||||
ctx.fillStyle = "#16222a";
|
||||
ctx.fillRect(x + 6, y + 0.2, W - 12, 1.7);
|
||||
const close = c.gap < PANIC_ON;
|
||||
const pulse = close ? 0.65 + 0.35 * Math.sin(v.clock / 110) : 1;
|
||||
ctx.globalAlpha = pulse;
|
||||
ctx.fillStyle = close ? "#ff4a3a" : p < 0.55 ? "#ffb02e" : "#7dffa0";
|
||||
ctx.fillRect(x + 6, y + 0.2, (W - 12) * p, 1.7);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = SWARM;
|
||||
ellipse(ctx, x + 2.4, y + 1.1, 1.6, 0.75);
|
||||
ctx.fill();
|
||||
if (close) {
|
||||
ctx.fillStyle = "#ff4a3a";
|
||||
ctx.fillRect(x + 2.9, y + 0.7, 0.3, 0.3);
|
||||
}
|
||||
ctx.fillStyle = HULL_LIT;
|
||||
poly(ctx, [[x + W - 5, y + 1.8], [x + W - 4.4, y + 0.5], [x + W - 1.4, y + 0.5], [x + W - 0.6, y + 1.8]]);
|
||||
ctx.fill();
|
||||
label(ctx, close ? "THEY ARE CLOSE" : "WAKE", x + 6, y + 4, 1.5, close ? "#ff6a6a" : "#bcd6d0", "left");
|
||||
// The clog gauge.
|
||||
const q = c.clog / CLOG_MAX;
|
||||
const hot = c.clog >= CLOG_WARN || c.stall > 0;
|
||||
ctx.fillStyle = "#16222a";
|
||||
ctx.fillRect(x + 6, y + 5.3, W - 12, 1.3);
|
||||
ctx.globalAlpha = hot ? 0.6 + 0.4 * Math.sin(v.clock / 100) : 1;
|
||||
ctx.fillStyle = hot ? "#ff5a3a" : q > 0.4 ? "#ffb02e" : "#9ac8b8";
|
||||
ctx.fillRect(x + 6, y + 5.3, (W - 12) * q, 1.3);
|
||||
ctx.globalAlpha = 1;
|
||||
label(ctx, c.stall > 0 ? "STALLED" : "FAN", x, y + 6.6, 1.3, c.stall > 0 ? "#ff6a6a" : "#bcd6d0", "left");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- the room */
|
||||
|
||||
const lanePass = (ctx, v, R, c, cam, lane) => {
|
||||
const lo = cam - 12;
|
||||
const hi = cam + FW + 12;
|
||||
R.snags.forEach(([x, l], i) => {
|
||||
if (l === lane && x > lo && x < hi) snag(ctx, x, l, i);
|
||||
});
|
||||
R.knees.forEach(([x, l], i) => {
|
||||
if (l === lane && x > lo && x < hi) knees(ctx, x, l, i);
|
||||
});
|
||||
R.props.forEach(([x, l, kind], i) => {
|
||||
if (l === lane && x > lo && x < hi) prop(ctx, v, x, l, kind, c.props[i], i);
|
||||
});
|
||||
R.gas.forEach(([x, l], i) => {
|
||||
if (l === lane && x > lo && x < hi) gasPocket(ctx, v, x, l, c.gas[i], i);
|
||||
});
|
||||
};
|
||||
|
||||
// The whole world, over the still layers: sky, trees, water and flats, the things by lane, the boat, the swarm.
|
||||
function moving(ctx, v, cam) {
|
||||
const R = ride(v);
|
||||
const c = runner(v);
|
||||
if (!R || !c) return;
|
||||
FH = v.g.FIELD_H;
|
||||
sky(ctx, v, cam);
|
||||
trees(ctx, cam, 0.14, Y(FLATS_Y + 1), 0.8, "#0a161a", 3);
|
||||
trees(ctx, cam, 0.3, Y(FLATS_Y + 0.6), 1.15, "#0e1e22", 7);
|
||||
mist(ctx, v, cam, 0.16);
|
||||
channel(ctx, v, cam, R);
|
||||
R.banks.forEach(([a, b]) => {
|
||||
if (b > cam - 4 && a < cam + FW + 4) bankPosts(ctx, v, a, b);
|
||||
});
|
||||
R.checks.forEach((x, i) => {
|
||||
if (x > cam - 8 && x < cam + FW + 8) checkpoint(ctx, v, x, i <= c.check);
|
||||
});
|
||||
if (R.finish > cam - 20 && R.finish < cam + FW + 20) landing(ctx, v, R.finish + 16);
|
||||
const here = laneNow(c);
|
||||
const inWater = c.done || here === 0;
|
||||
lanePass(ctx, v, R, c, cam, 1);
|
||||
if (!inWater) swarm(ctx, v, c, v.round.you.x, Y(baseOf(c)));
|
||||
if (!inWater) place(ctx, v, c, (x) => boatBack(ctx, v, c, x));
|
||||
lanePass(ctx, v, R, c, cam, 0);
|
||||
if (inWater && !c.done) swarm(ctx, v, c, v.round.you.x, Y(baseOf(c)));
|
||||
if (inWater) place(ctx, v, c, (x) => boatBack(ctx, v, c, x));
|
||||
// A landing's splash.
|
||||
const fx = v.fx;
|
||||
const land = fx && fx.bogboatLand !== undefined ? fx.clock - fx.bogboatLand.t0 : 1e9;
|
||||
if (land < 380) {
|
||||
const p = land / 380;
|
||||
ctx.fillStyle = `rgba(170,210,200,${(1 - p) * 0.7})`;
|
||||
for (let k = 0; k < 8; k++) disc(ctx, v.round.you.x + (k - 3.5) * 1.1 * (0.6 + p * 1.5), Y(baseOf(c)) - 0.3 - p * (0.8 + rnd(k, 4) * 1.4), 0.3 + p * 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
// In front of Planny: the gunwale, the lows (veils and limbs), the splinters, the mist, the signs, the gauges.
|
||||
function front(ctx, v) {
|
||||
const R = ride(v);
|
||||
const c = runner(v);
|
||||
if (!R || !c) return;
|
||||
FH = v.g.FIELD_H;
|
||||
const round = v.round;
|
||||
const cam = Math.round(round.camX * 8) / 8;
|
||||
place(ctx, v, c, () => boatFront(ctx));
|
||||
R.veils.forEach(([x0, x1, lane], i) => {
|
||||
if (x1 >= cam - 10 && x0 <= cam + FW + 10) veil(ctx, v, x0, x1, lane, i);
|
||||
});
|
||||
R.limbs.forEach(([x0, x1, lane], i) => {
|
||||
if (x1 >= cam - 10 && x0 <= cam + FW + 10) limb(ctx, v, x0, x1, lane, i);
|
||||
});
|
||||
mist(ctx, v, cam, 0.12);
|
||||
if (!c.done) for (const t of telegraphs(R, round.you.x, laneNow(c))) glyph(ctx, v, t);
|
||||
const bits = v.fx && v.fx.bogboatBits;
|
||||
if (bits) {
|
||||
for (const b of bits) {
|
||||
const t = (v.fx.clock - b.t0) / 1000;
|
||||
if (t < 0 || t > 0.9) continue;
|
||||
ctx.save();
|
||||
ctx.translate(b.x + b.vx * t, FH - (b.y + b.vy * t - 30 * t * t));
|
||||
ctx.rotate(b.rot + b.vr * t);
|
||||
ctx.globalAlpha = clamp(1.6 - t * 1.6, 0, 1);
|
||||
ctx.fillStyle = b.c;
|
||||
ctx.fillRect(-b.w / 2, -0.12, b.w, 0.24);
|
||||
ctx.restore();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
gauges(ctx, v, c, cam);
|
||||
}
|
||||
|
||||
const dim = () => 0;
|
||||
|
||||
/* -------------------------------------------------------------- lights */
|
||||
|
||||
function lights(v, add) {
|
||||
const R = ride(v);
|
||||
const c = runner(v);
|
||||
if (!R || !c) return;
|
||||
const round = v.round;
|
||||
const you = round.you;
|
||||
const lo = round.camX - 10;
|
||||
const hi = round.camX + FW + 10;
|
||||
// The bow lantern's pool on the water ahead and its warmth over the boat.
|
||||
add(you.x + 6, you.y + 2.4, 14, 0.7);
|
||||
add(you.x - 3, you.y + 3, 8, 0.4);
|
||||
R.checks.forEach((x, i) => {
|
||||
if (x > lo && x < hi) add(x + 3, 26, 9, i <= c.check ? 0.55 : 0.4);
|
||||
});
|
||||
R.banks.forEach(([a, b]) => {
|
||||
if (b > lo && a < hi) {
|
||||
add(a - 0.4, WATER_Y + 5, 5, 0.35);
|
||||
add(b + 0.4, WATER_Y + 5, 5, 0.35);
|
||||
}
|
||||
});
|
||||
R.gas.forEach(([x, lane], i) => {
|
||||
if (x > lo && x < hi && c.gas[i].state === "up") add(x, LANE_Y[lane] + GAS_UP + 1.6, 5, 0.4);
|
||||
});
|
||||
if (R.finish > lo - 20 && R.finish < hi) add(R.finish + 16, 18, 14, 0.6);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- events */
|
||||
|
||||
// A throttle on a repeating cue.
|
||||
function gateOnce(fx, key, ms) {
|
||||
if ((fx[key] || 0) > fx.clock) return false;
|
||||
fx[key] = fx.clock + ms;
|
||||
return true;
|
||||
}
|
||||
// Splinters of wood and weed flying out of a spot.
|
||||
function splinter(fx, x, y, colors) {
|
||||
fx.bogboatBits = (fx.bogboatBits || []).filter((b) => fx.clock - b.t0 < 1000);
|
||||
for (let k = 0; k < 9; k++) fx.bogboatBits.push({ x, y, t0: fx.clock, vx: (rnd(k, 1) - 0.5) * 22, vy: 8 + rnd(k, 2) * 14, rot: rnd(k, 3) * TAU, vr: (rnd(k, 4) - 0.5) * 22, w: 0.5 + rnd(k, 5) * 0.9, c: colors[k % colors.length] });
|
||||
}
|
||||
|
||||
// What the pack's events look and sound like; true when the event is its own. Each of its
|
||||
// sounds plays once, from EVENT_VOICE.
|
||||
function react(e, k) {
|
||||
const { shake, flash, burst, float, ring, fx } = k;
|
||||
const voice = EVENT_VOICE[e.type];
|
||||
if (!voice) return false;
|
||||
if (e.type === "bogboatDuck" && !gateOnce(fx, "bogboatDuckMs", 160)) return true;
|
||||
say(k.tone, voice[0], voice[1], 0.5);
|
||||
const SPRAY = "#9cc4b8";
|
||||
switch (e.type) {
|
||||
case "bogboatJump":
|
||||
burst(e.x, e.y, SPRAY, 5, 7, 300);
|
||||
break;
|
||||
case "bogboatLand":
|
||||
fx.bogboatLand = { t0: fx.clock, big: Boolean(e.big) };
|
||||
burst(e.x, e.y, SPRAY, e.big ? 14 : 6, e.big ? 12 : 8, 360);
|
||||
if (e.big) shake(180, 0.45);
|
||||
break;
|
||||
case "bogboatSwitch":
|
||||
burst(e.x, e.y, MUD_LIT, 6, 8, 320);
|
||||
float(e.x, e.y + 6, e.to ? "Flats" : "Channel", "#7dffa0", 2);
|
||||
break;
|
||||
case "bogboatCrash":
|
||||
shake(320, 1);
|
||||
flash("#b8e0d0", 200);
|
||||
burst(e.x, e.y + 1, e.what === "veil" ? MOSS : "#6a5a3a", 18, 17, 520);
|
||||
burst(e.x, e.y + 1, SPRAY, 8, 14, 360);
|
||||
splinter(fx, e.x, e.y + 2, e.what === "veil" ? [MOSS, MOSS_D] : ["#2a1e14", "#4a3c28", "#5a5a48"]);
|
||||
break;
|
||||
case "bogboatCheck":
|
||||
float(e.x, e.y + 5, "Checkpoint", GOLD, 2.2);
|
||||
ring(e.x, e.y + 3, "#7dffa0", 1, 8, 500);
|
||||
break;
|
||||
case "bogboatFinish":
|
||||
shake(240, 0.6);
|
||||
burst(e.x, e.y, SPRAY, 14, 13, 560);
|
||||
float(e.x, e.y + 6, "Made it!", GOLD, 2.6);
|
||||
break;
|
||||
case "bogboatPanic":
|
||||
flash("#102018", 220);
|
||||
float(e.x, e.y + 8, "They are close!", "#ff6a6a", 2.4);
|
||||
break;
|
||||
case "bogboatCatch":
|
||||
shake(300, 0.9);
|
||||
flash("#3a0a0a", 240);
|
||||
burst(e.x - 8, e.y, SWARM, 14, 12, 460);
|
||||
float(e.x, e.y + 7, "Swarmed!", "#ff6a6a", 2.4);
|
||||
break;
|
||||
case "bogboatClog":
|
||||
float(e.x, e.y + 8, "The fan is clogging", "#ffb02e", 2.2);
|
||||
break;
|
||||
case "bogboatStall":
|
||||
shake(200, 0.5);
|
||||
burst(e.x - 8, e.y + 3, MUD, 10, 9, 420);
|
||||
float(e.x, e.y + 8, "Stalled!", "#ff6a6a", 2.4);
|
||||
break;
|
||||
case "bogboatGas":
|
||||
flash("#e8ff9a", 140);
|
||||
burst(e.x, e.y, GAS, 14, 13, 520);
|
||||
ring(e.x, e.y, GAS, 1, 9, 420);
|
||||
float(e.x, e.y + 3, `+${e.points}`, GOLD, 2);
|
||||
break;
|
||||
case "bogboatProp":
|
||||
burst(e.x, e.y, e.kind ? "#4a8cc8" : BONE, 12, 12, 440);
|
||||
splinter(fx, e.x, e.y, e.kind ? ["#4a8cc8", "#9cd0ff"] : [BONE, "#8a7a5a"]);
|
||||
float(e.x, e.y + 3, `+${e.points}`, GOLD, 2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return freeze({
|
||||
looks: LOOKS,
|
||||
backdrop,
|
||||
ground,
|
||||
shelf,
|
||||
front,
|
||||
moving,
|
||||
dim,
|
||||
monsters: freeze({}),
|
||||
bosses: freeze({}),
|
||||
missiles: freeze({}),
|
||||
hazards: freeze({}),
|
||||
powers: freeze({}),
|
||||
lights,
|
||||
react,
|
||||
});
|
||||
}
|
||||
@@ -1,420 +0,0 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Bog Runner, its rules: Gallows Bog's bonus round. YOU skim a fan boat down a black channel through the swamp at night, with something swimming in your wake: jump the sunken snags and cypress knees, duck the moss veils and low limbs, shoot the hag's charms for points and the gas pockets for a cover burst, and switch between the open channel and the mud flats at the banks, as a stage pack that ghoul.js plugs in.
|
||||
//
|
||||
// Modeled on the Midnight Hearse (ghoul-hearse.js: read its header first) for the lanes and
|
||||
// on the Torch Mob (ghoul-wagon.js) for the pursuit meter, and, like them, handed a kit `k`
|
||||
// of ghoul.js's own helpers, so this file never imports ghoul.js. Pack fields used: `ride`
|
||||
// (a hook that moves Planny himself, so no key walks him), `place` (Planny put down in a
|
||||
// room: a room set up or a respawn) and `target` (a bolt strikes something that is no
|
||||
// monster: a charm, a gas pocket). It adds no monster, boss or hazard kind, so there is
|
||||
// nothing to merge by name, and it draws NO random number. Its state is `round.runner`
|
||||
// (the shared slot for a rolling bonus ride, with `id: "bogboat"`; null in any other room)
|
||||
// and the room's `ride.runner` is "bogboat". Every event it puts on the field starts with
|
||||
// `bogboat`.
|
||||
//
|
||||
// THE TWIST: THE WAKE. A swarm of leeches boils up in the fan's wake, `gap` units back
|
||||
// (GAP_START at the start, never over GAP_MAX). It swims at WAKE_V, the boat at its own
|
||||
// speed: clean riding on open water (BOGBOAT_V) wins ground and everything else loses it:
|
||||
// DOWN held (an ease of the throttle, and a duck) holds the boat at EASE_V, the mud flats
|
||||
// slow it (FLATS_V, and FLATS_EASE_V when eased), a fan stalled in the mud stops it dead,
|
||||
// and a hit shoves the swarm HIT_CLOSE closer. A gas pocket shot pushes it back GAS_PUSH.
|
||||
// Inside PANIC_ON the swarm boils (the art shows it and the wake meter reads THEY ARE
|
||||
// CLOSE) until PANIC_OFF. At WAKE_CATCH it has you: a heart (cause "wake"), and it falls
|
||||
// back to WAKE_FALLBACK.
|
||||
//
|
||||
// THE ROOM (spec.ride, see ghoul-rooms.js): the ground is one flat floor under the water;
|
||||
// there are two LANES, the open channel (lane 0, LANE_Y[0]) and the mud flats beside it
|
||||
// (lane 1, LANE_Y[1], a raised bank), and every obstacle stands in one of them, [x, lane,
|
||||
// ...]:
|
||||
//
|
||||
// - `banks` [x0, x1]: the banks, where the channel's edge shelves down into the flats;
|
||||
// inside one, LEFT puts the boat in the channel and RIGHT on the flats (SWITCH_MS to
|
||||
// hop the shelf). The art draws them as mud ramps. Nothing stands in a lane near one.
|
||||
// - `snags` [x, lane]: a sunken log, SNAG_W by SNAG_H: jump (cause "snag").
|
||||
// - `knees` [x, lane]: a cluster of cypress knees, KNEE_W by KNEE_H: jump (cause "knee").
|
||||
// - `veils` [x0, x1, lane]: a curtain of moss, its underside LOW_Y over the lane: duck
|
||||
// (cause "veil").
|
||||
// - `limbs` [x0, x1, lane]: a low cypress limb, its underside LOW_Y over the lane: duck
|
||||
// (cause "limb").
|
||||
// - `props` [x, lane, kind]: one of the hag's charms (kind 0 a skull on a string, kind 1
|
||||
// a blue bottle) hung at chest height. It never hurts; shoot it (one bolt) for
|
||||
// PROP_POINTS and an act.
|
||||
// - `gas` [x, lane]: a pocket of marsh gas bubbling up. It never hurts; shoot it for
|
||||
// GAS_POINTS, an act and a cover burst that pushes the wake back GAS_PUSH.
|
||||
// - `checks` (x positions of the checkpoints), `finish` (where the ride ends: the boat
|
||||
// cuts its fan and Planny steps out to the door) and `time` (the room's clock, ms).
|
||||
//
|
||||
// THE BOAT (`round.runner`): { id, room, check, lane (where it is bound), from (the lane
|
||||
// it left), swMs (switch time left), h (height over the lane), air, vy, v, gap, panic,
|
||||
// clog, stall, faced, props, gas, done, restX, ... }. It runs at the speed its lane and
|
||||
// throttle ask (eased toward it at RELAX a second); UP jumps at JUMP_V against GRAVITY
|
||||
// (about 13 high, 0.75 s), DOWN ducks and eases; a switch cannot be made in the air and a
|
||||
// jump or a duck cannot be made in one. A bolt flies level.
|
||||
//
|
||||
// THE CLOG: on the flats the fan sucks mud: the `clog` gauge rises CLOG_RISE a second at
|
||||
// full throttle and cools CLOG_COOL a second eased (and on the channel). At CLOG_WARN the
|
||||
// art flashes it; at CLOG_MAX the fan STALLS for STALL_MS (the boat coasts to a stop and
|
||||
// the wake gains), then starts again at CLOG_RESTART.
|
||||
//
|
||||
// A hit costs one of the round's five hearts (ghoul-bonus.js), not a life, and the boat
|
||||
// rolls on, Planny blinking safe BONUS_SAFE_MS; the last heart gone ends the round with
|
||||
// nothing, at once. Causes: "snag", "knee", "veil", "limb", "wake". The grade's
|
||||
// `perf.total` is the obstacles the boat FACED (passed in their lane; a lane switched away
|
||||
// from is dodged and not counted, a catch adds one of its own), each id once in
|
||||
// `perf.hits` if it ever cost a heart. Shooting a charm or a gas pocket counts for
|
||||
// `perf.acts` (the goal is ACTS_GOAL, 8 of them) and the points below. The steady die is a
|
||||
// swarm that never boiled (the wake never reached PANIC_ON).
|
||||
//
|
||||
// Checkpoints are passed at their x (`bogboatCheck`); a restart after the last heart goes
|
||||
// back to the last one passed (that ends the round, as the sled's does).
|
||||
//
|
||||
// WHAT THE ART READS: `spec.ride` (above), `round.runner` { lane, from, swMs, h, air, v,
|
||||
// gap, panic, clog, stall, done, restX, check, props: [{ state "up"|"broken" }], gas: [{
|
||||
// state "up"|"burst"|"spent", t }] }, `round.you` (`state`, `vy`, `ducking`), the events in
|
||||
// EVENTS.
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
|
||||
export const MONSTERS = freeze({});
|
||||
|
||||
// Every event this pack puts on the field, for the art and the sounds to answer.
|
||||
export const EVENTS = freeze([
|
||||
"bogboatJump", "bogboatLand", "bogboatDuck", "bogboatSwitch", "bogboatCrash", "bogboatCheck", "bogboatFinish",
|
||||
"bogboatPanic", "bogboatCatch", "bogboatClog", "bogboatStall", "bogboatGas", "bogboatProp",
|
||||
]);
|
||||
|
||||
// The boat. Speeds are units across a second, GRAVITY units a second squared.
|
||||
export const BOGBOAT_V = 40;
|
||||
export const EASE_V = 24;
|
||||
export const FLATS_V = 28;
|
||||
export const FLATS_EASE_V = 22;
|
||||
export const RELAX = 5;
|
||||
export const JUMP_V = 74;
|
||||
export const GRAVITY = 200;
|
||||
export const BIG_LAND = 9;
|
||||
export const LANE_Y = freeze([9, 15]);
|
||||
export const SWITCH_MS = 360;
|
||||
export const SWITCH_HOP = 1.6;
|
||||
export const CAM_AHEAD = 12;
|
||||
// Obstacles.
|
||||
export const SNAG_W = 3.2;
|
||||
export const SNAG_H = 3.8;
|
||||
export const KNEE_W = 4.6;
|
||||
export const KNEE_H = 2.4;
|
||||
export const LOW_Y = 3.0;
|
||||
export const PROP_W = 2.2;
|
||||
export const PROP_H = 2.4;
|
||||
export const PROP_UP = 1.6;
|
||||
export const GAS_W = 3.6;
|
||||
export const GAS_H = 3.2;
|
||||
export const GAS_UP = 1.2;
|
||||
export const GAS_BURST_MS = 700;
|
||||
export const PROP_POINTS = 60;
|
||||
export const GAS_POINTS = 90;
|
||||
const SHOT_R = 0.5;
|
||||
// The wake.
|
||||
export const WAKE_V = 28;
|
||||
export const GAP_START = 28;
|
||||
export const GAP_MAX = 36;
|
||||
export const WAKE_CATCH = 8;
|
||||
export const WAKE_FALLBACK = 24;
|
||||
export const PANIC_ON = 18;
|
||||
export const PANIC_OFF = 22;
|
||||
export const HIT_CLOSE = 8;
|
||||
export const GAS_PUSH = 8;
|
||||
// The clog.
|
||||
export const CLOG_MAX = 100;
|
||||
export const CLOG_WARN = 70;
|
||||
export const CLOG_RISE = 30;
|
||||
export const CLOG_COOL = 40;
|
||||
export const CLOG_RESTART = 35;
|
||||
export const STALL_MS = 1400;
|
||||
// The shots at things (charms, gas pockets) worth a die.
|
||||
export const ACTS_GOAL = 8;
|
||||
|
||||
const mine = (round) => (round.runner && round.runner.id === "bogboat" ? round.runner : null);
|
||||
const duckH = (k, you) => (you.ducking ? k.DUCK_H : k.HIT_H);
|
||||
const boxHit = (k, you, x, y0, w, h) => Math.abs(you.x - x) < (k.HIT_W + w) / 2 && you.y < y0 + h && you.y + duckH(k, you) > y0;
|
||||
const smooth = (p) => p * p * (3 - 2 * p);
|
||||
|
||||
// The lane the boat counts as being in: the one it left until half way through a switch.
|
||||
export const laneNow = (c) => (c.swMs > 0 && 1 - c.swMs / SWITCH_MS < 0.5 ? c.from : c.lane);
|
||||
// The height of the water under the boat (its lane's, eased across a switch, with a little hop).
|
||||
export function baseOf(c) {
|
||||
if (c.swMs <= 0) return LANE_Y[c.lane];
|
||||
const p = 1 - c.swMs / SWITCH_MS;
|
||||
return LANE_Y[c.from] + (LANE_Y[c.lane] - LANE_Y[c.from]) * smooth(p) + Math.sin(p * Math.PI) * SWITCH_HOP;
|
||||
}
|
||||
|
||||
// Notes for a bonus round that obstacle `id` was faced (counted for the grade) and, with
|
||||
// `cost`, that it cost a heart (once each).
|
||||
function face(round, c, id, cost = false) {
|
||||
const b = round.bonusRound;
|
||||
if (!b) return;
|
||||
if (!c.faced[id]) {
|
||||
c.faced[id] = true;
|
||||
b.perf.total++;
|
||||
}
|
||||
if (cost && !b.perf.hits.includes(id)) b.perf.hits.push(id);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- placing */
|
||||
|
||||
// A fresh set of the room's things, each charm hanging and each pocket full. What was shot
|
||||
// stays shot (`old`, the boat of an earlier try in the same room).
|
||||
function things(R, old) {
|
||||
const was = (list, i, state) => (old && old[list] && old[list][i] && old[list][i].state === state ? state : null);
|
||||
return {
|
||||
props: R.props.map((p, i) => ({ state: was("props", i, "broken") || "up" })),
|
||||
gas: R.gas.map((g, i) => ({ state: was("gas", i, "spent") || was("gas", i, "burst") ? "spent" : "up", t: 0 })),
|
||||
};
|
||||
}
|
||||
|
||||
// Planny put down in the room: at the helm at the start of a ride, or at the last
|
||||
// checkpoint passed after the last heart (the same room).
|
||||
function place(round, k) {
|
||||
const R = round.spec.ride;
|
||||
// (The Cart's `place` runs first, leaves a ride with a `runner` alone and has already zeroed `round.camLead`.)
|
||||
if (!R || R.runner !== "bogboat") {
|
||||
if (mine(round)) round.runner = null;
|
||||
return;
|
||||
}
|
||||
const old = mine(round);
|
||||
const again = old && old.room === round.room;
|
||||
const check = again ? old.check : -1;
|
||||
const you = round.you;
|
||||
const x = check >= 0 ? R.checks[check] : round.spec.start;
|
||||
Object.assign(you, { x, y: LANE_Y[0], vy: 0, state: "run", shelf: -1, face: 1, ducking: false, coyote: 0, drop: -1 });
|
||||
round.runner = {
|
||||
id: "bogboat", room: round.room, check, lane: 0, from: 0, swMs: 0, h: 0, vy: 0, air: false, peak: 0, v: BOGBOAT_V,
|
||||
gap: GAP_START, panic: false, panicked: again ? old.panicked : false, clog: 0, warned: false, stall: 0,
|
||||
faced: again ? old.faced : {}, catches: again ? old.catches : 0, done: false, restX: 0, ...things(R, again ? old : null),
|
||||
};
|
||||
round.camLead = CAM_AHEAD;
|
||||
const b = round.bonusRound;
|
||||
if (b) {
|
||||
b.perf.goal = ACTS_GOAL;
|
||||
if (!again) b.perf.total = 0;
|
||||
if (round.runner.panicked) b.perf.steady = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ the ride */
|
||||
|
||||
// The boat's motion for one slice. Returns true once it has moved Planny (every slice of
|
||||
// a ride); false outside a ride and once he has stepped out.
|
||||
function ride(round, ms, k) {
|
||||
const R = round.spec.ride;
|
||||
const c = mine(round);
|
||||
if (!R || R.runner !== "bogboat" || !c || c.done) return false;
|
||||
const you = round.you;
|
||||
const inp = round.input;
|
||||
const dt = ms / 1000;
|
||||
const ev = (type, extra = {}) => round.events.push({ type, x: you.x, y: you.y, ...extra });
|
||||
if (you.x >= R.finish) return finish(round, c, R, k);
|
||||
// The throttle: the lane and DOWN set the speed it eases toward, a stalled fan none.
|
||||
const ease = Boolean(inp.down) && !c.air;
|
||||
const flats = c.lane === 1;
|
||||
const target = c.stall > 0 ? 0 : flats ? (ease ? FLATS_EASE_V : FLATS_V) : ease ? EASE_V : BOGBOAT_V;
|
||||
c.v = c.stall > 0 && c.v < 0.5 ? 0 : c.v + (target - c.v) * Math.min(1, RELAX * dt);
|
||||
you.x += c.v * dt;
|
||||
// The banks: LEFT is the channel, RIGHT the flats.
|
||||
const want = inp.left && !inp.right ? 0 : inp.right && !inp.left ? 1 : -1;
|
||||
const bank = R.banks.some(([a, b]) => you.x >= a && you.x <= b);
|
||||
if (bank && !c.air && c.swMs <= 0 && want >= 0 && want !== c.lane) startSwitch(c, want, ev, you);
|
||||
if (c.swMs > 0) {
|
||||
c.swMs = Math.max(0, c.swMs - ms);
|
||||
you.ducking = false;
|
||||
you.state = "run";
|
||||
you.vy = 0;
|
||||
} else {
|
||||
// On the water: jump, duck, or in the air.
|
||||
const jump = inp.jump > 0;
|
||||
if (!c.air && jump) {
|
||||
inp.jump = 0;
|
||||
c.air = true;
|
||||
c.h = 0.001;
|
||||
c.vy = JUMP_V;
|
||||
c.peak = 0;
|
||||
you.ducking = false;
|
||||
ev("bogboatJump");
|
||||
} else if (!c.air) {
|
||||
const duck = Boolean(inp.down);
|
||||
if (duck && !you.ducking) ev("bogboatDuck");
|
||||
you.ducking = duck;
|
||||
}
|
||||
if (c.air) {
|
||||
c.vy -= GRAVITY * dt;
|
||||
c.h += c.vy * dt;
|
||||
c.peak = Math.max(c.peak, c.h);
|
||||
you.ducking = false;
|
||||
if (c.h <= 0) {
|
||||
ev("bogboatLand", { big: c.peak >= BIG_LAND });
|
||||
Object.assign(c, { air: false, h: 0, vy: 0 });
|
||||
}
|
||||
}
|
||||
you.state = c.air ? "air" : "run";
|
||||
you.vy = c.air ? c.vy : 0;
|
||||
}
|
||||
you.y = baseOf(c) + (c.swMs > 0 ? 0 : c.h);
|
||||
// A press nothing took waits a moment for a landing, then goes.
|
||||
if (inp.jump > 0) inp.jump = Math.max(0, inp.jump - ms);
|
||||
while (c.check + 1 < R.checks.length && you.x >= R.checks[c.check + 1]) {
|
||||
c.check++;
|
||||
ev("bogboatCheck", { n: c.check + 1 });
|
||||
}
|
||||
round.camLead = CAM_AHEAD;
|
||||
clogging(round, c, ms, ev, ease);
|
||||
if (obstacles(round, c, R, k)) return true;
|
||||
wake(round, c, ms, ev, k);
|
||||
return true;
|
||||
}
|
||||
|
||||
function startSwitch(c, to, ev, you) {
|
||||
Object.assign(c, { from: c.lane, lane: to, swMs: SWITCH_MS, air: false, h: 0, vy: 0 });
|
||||
ev("bogboatSwitch", { to, y: LANE_Y[to], x: you.x });
|
||||
}
|
||||
|
||||
// The ride is over: the boat cuts its fan at the finish, the door opens, Planny steps out.
|
||||
function finish(round, c, R, k) {
|
||||
const you = round.you;
|
||||
c.done = true;
|
||||
c.restX = you.x;
|
||||
Object.assign(c, { air: false, h: 0, vy: 0, swMs: 0 });
|
||||
Object.assign(you, { y: k.groundAt(round.spec, you.x), vy: 0, state: "run", shelf: -1, ducking: false });
|
||||
round.hasKey = true;
|
||||
round.camLead = 0;
|
||||
round.events.push({ type: "bogboatFinish", x: you.x, y: you.y });
|
||||
return false;
|
||||
}
|
||||
|
||||
// The fan on the flats: mud clogs it while it runs full, an ease or open water clears it,
|
||||
// and a clogged fan stalls the boat for STALL_MS.
|
||||
function clogging(round, c, ms, ev, ease) {
|
||||
const dt = ms / 1000;
|
||||
if (c.stall > 0) {
|
||||
c.stall -= ms;
|
||||
if (c.stall <= 0) Object.assign(c, { stall: 0, clog: CLOG_RESTART, warned: false });
|
||||
return;
|
||||
}
|
||||
const flats = laneNow(c) === 1 && c.swMs <= 0;
|
||||
c.clog = clamp(c.clog + (flats && !ease ? CLOG_RISE : -CLOG_COOL) * dt, 0, CLOG_MAX);
|
||||
if (c.clog >= CLOG_WARN && !c.warned) {
|
||||
c.warned = true;
|
||||
ev("bogboatClog");
|
||||
} else if (c.clog < CLOG_WARN - 15) c.warned = false;
|
||||
if (c.clog >= CLOG_MAX) {
|
||||
c.stall = STALL_MS;
|
||||
ev("bogboatStall");
|
||||
}
|
||||
}
|
||||
|
||||
// A heart lost on obstacle `id`: it was faced and cost, the wake closes, and the crash is
|
||||
// an event. Returns true.
|
||||
function cost(round, c, id, what, x) {
|
||||
face(round, c, id, true);
|
||||
c.gap = Math.max(WAKE_CATCH + 1, c.gap - HIT_CLOSE);
|
||||
round.events.push({ type: "bogboatCrash", what, x, y: round.you.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
// What the boat runs into: a snag, cypress knees, a moss veil or a limb. Returns whether it
|
||||
// cost a heart. (Nothing counts while it hops between lanes: the banks keep their
|
||||
// neighborhood clear.)
|
||||
function obstacles(round, c, R, k) {
|
||||
const you = round.you;
|
||||
if (c.swMs > 0) return false;
|
||||
const lane = c.lane;
|
||||
const base = LANE_Y[lane];
|
||||
const hh = duckH(k, you);
|
||||
const seen = (id, x) => {
|
||||
if (you.x >= x && !c.faced[id]) face(round, c, id);
|
||||
};
|
||||
for (const [i, [x, l]] of R.snags.entries()) {
|
||||
if (l !== lane) continue;
|
||||
seen(`s${i}`, x);
|
||||
if (Math.abs(you.x - x) <= 6 && boxHit(k, you, x, base, SNAG_W, SNAG_H) && k.struck(round, "snag")) return cost(round, c, `s${i}`, "snag", x);
|
||||
}
|
||||
for (const [i, [x, l]] of R.knees.entries()) {
|
||||
if (l !== lane) continue;
|
||||
seen(`k${i}`, x);
|
||||
if (Math.abs(you.x - x) <= 6 && boxHit(k, you, x, base, KNEE_W, KNEE_H) && k.struck(round, "knee")) return cost(round, c, `k${i}`, "knee", x);
|
||||
}
|
||||
for (const [list, key, cause, what] of [[R.veils, "v", "veil", "veil"], [R.limbs, "l", "limb", "limb"]]) {
|
||||
for (const [i, [x0, x1, l]] of list.entries()) {
|
||||
if (l !== lane) continue;
|
||||
seen(`${key}${i}`, (x0 + x1) / 2);
|
||||
if (you.x > x0 - k.HIT_W / 2 && you.x < x1 + k.HIT_W / 2 && you.y + hh > base + LOW_Y && k.struck(round, cause)) return cost(round, c, `${key}${i}`, what, you.x);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// The wake: its gap, the panic, the grade's steady die, and a catch at WAKE_CATCH.
|
||||
function wake(round, c, ms, ev, k) {
|
||||
const dt = ms / 1000;
|
||||
c.gap = clamp(c.gap + (c.v - WAKE_V) * dt, 0, GAP_MAX);
|
||||
if (!c.panic && c.gap < PANIC_ON) {
|
||||
c.panic = true;
|
||||
c.panicked = true;
|
||||
if (round.bonusRound) round.bonusRound.perf.steady = false;
|
||||
ev("bogboatPanic");
|
||||
} else if (c.panic && c.gap >= PANIC_OFF) c.panic = false;
|
||||
for (const g of c.gas) if (g.state === "burst" && (g.t -= ms) <= 0) g.state = "spent";
|
||||
if (c.gap > WAKE_CATCH) return;
|
||||
c.gap = WAKE_FALLBACK;
|
||||
c.panic = false;
|
||||
c.catches++;
|
||||
face(round, c, `w${c.catches}`, true);
|
||||
ev("bogboatCatch");
|
||||
k.struck(round, "wake");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- targets */
|
||||
|
||||
// A bolt into something to shoot: a charm, a gas pocket. True when one took it (the bolt is
|
||||
// spent).
|
||||
function bogboatShot(round, s) {
|
||||
const R = round.spec.ride;
|
||||
const c = mine(round);
|
||||
if (!R || R.runner !== "bogboat" || !c) return false;
|
||||
const hit = (x, y0, w, h) => Math.abs(s.x - x) <= w / 2 + SHOT_R && s.y >= y0 - SHOT_R && s.y <= y0 + h + SHOT_R;
|
||||
const score = (n) => {
|
||||
round.score += n;
|
||||
if (round.bonusRound) round.bonusRound.perf.acts++;
|
||||
};
|
||||
for (let i = 0; i < R.gas.length; i++) {
|
||||
const g = c.gas[i];
|
||||
const [x, lane] = R.gas[i];
|
||||
if (g.state !== "up" || !hit(x, LANE_Y[lane] + GAS_UP, GAS_W, GAS_H)) continue;
|
||||
Object.assign(g, { state: "burst", t: GAS_BURST_MS });
|
||||
c.gap = Math.min(GAP_MAX, c.gap + GAS_PUSH);
|
||||
score(GAS_POINTS);
|
||||
round.events.push({ type: "bogboatGas", x, y: LANE_Y[lane] + GAS_UP + GAS_H / 2, points: GAS_POINTS });
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < R.props.length; i++) {
|
||||
const p = c.props[i];
|
||||
const [x, lane, kind] = R.props[i];
|
||||
if (p.state !== "up" || !hit(x, LANE_Y[lane] + PROP_UP, PROP_W, PROP_H)) continue;
|
||||
p.state = "broken";
|
||||
score(PROP_POINTS);
|
||||
round.events.push({ type: "bogboatProp", x, y: LANE_Y[lane] + PROP_UP + PROP_H / 2, kind, points: PROP_POINTS });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const BOGBOAT = freeze({
|
||||
id: "bogboat",
|
||||
monsters: MONSTERS,
|
||||
walkers: freeze([]),
|
||||
zombies: freeze([]),
|
||||
stackers: freeze([]),
|
||||
climbers: freeze([]),
|
||||
act: freeze({}),
|
||||
horde: freeze({}),
|
||||
ride: freeze([ride]),
|
||||
place: freeze([place]),
|
||||
target: bogboatShot,
|
||||
});
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// `shot`, drawing a thrown weapon in `round.shots` (drawShots hands it any shot
|
||||
// with `arm`), and `pill`, the HUD's icon, count and the "TAP TAP" prompt.
|
||||
|
||||
import { pillInk, PILL } from "./pills.js";
|
||||
import { pillInk, PILL } from "../../pills.js";
|
||||
import { panAngle, panRadius } from "./ghoul-pans.js";
|
||||
import { rocketArt } from "./ghoul-rockets-draw.js";
|
||||
|
||||
+10
-7
@@ -48,7 +48,7 @@
|
||||
// but never wins the fight. No fight needs one. If a boss is at half hp and your
|
||||
// bag is empty, one of its stage's weapons falls near you, once a fight.
|
||||
|
||||
import { ARM_POP_MS, POWERS, STAGE_ARMS, addArm } from "./ghoul-powers.js";
|
||||
import { ARM_POP_MS, POWERS, STAGE_ARMS, addArm } from "../core/ghoul-powers.js";
|
||||
import { stepPans, usePans } from "./ghoul-pans.js";
|
||||
import { FLARE_VX, FLARE_VY, stepFlareFly, stepRoadFire, useFlare } from "./ghoul-flare.js";
|
||||
import { stepBoom, stepMuzzle, stepRocket, useRockets } from "./ghoul-rockets.js";
|
||||
@@ -238,7 +238,7 @@ export const armOnTop = (round) => (round.spec.ride ? round.arms.find((a) => !NE
|
||||
// Whether a weapon can come out just now: not while frozen, held, thrown or down.
|
||||
export function canUseArm(round) {
|
||||
const you = round.you;
|
||||
return round.phase === "play" && you.out <= 0 && !(round.stunMs > 0) && !(you.heldMs > 0) && !(you.flingMs > 0) && !you.lift && !(round.armCool > 0) && Boolean(armOnTop(round));
|
||||
return round.phase === "play" && you.out <= 0 && !(round.runner && round.runner.id === "lantern") && !(round.stunMs > 0) && !(you.heldMs > 0) && !(you.flingMs > 0) && !you.lift && !(round.armCool > 0) && Boolean(armOnTop(round));
|
||||
}
|
||||
|
||||
// The top of the bag, used. Bolts held through it pick up ARM_GAP_MS later.
|
||||
@@ -286,9 +286,12 @@ function armShot(round, k, arm, speed, over) {
|
||||
export const LOB_GROUP = 9;
|
||||
const LOB_MIN_VX = 6;
|
||||
const LOB_MAX_VX = 70;
|
||||
// Grave Salt aims this far ahead of a monster along the way it walks, so the line
|
||||
// lands where it will be, not where it was.
|
||||
export const SALT_LEAD = 3;
|
||||
|
||||
// `also` names kinds that count though they cannot be shot (the buried hands the salt is for).
|
||||
export function lobTarget(round, k, also = []) {
|
||||
export function lobTarget(round, k, also = [], lead = 0) {
|
||||
const you = round.you;
|
||||
const lo = round.camX;
|
||||
const hi = round.camX + k.FIELD_W;
|
||||
@@ -298,11 +301,11 @@ export function lobTarget(round, k, also = []) {
|
||||
if (!ahead.length) return null;
|
||||
const first = ahead[0];
|
||||
const group = ahead.filter((m) => Math.abs(m.x - first.x) <= LOB_GROUP);
|
||||
return group.reduce((sum, m) => sum + m.x, 0) / group.length;
|
||||
return group.reduce((sum, m) => sum + m.x + (m.dir || -you.face) * lead, 0) / group.length;
|
||||
}
|
||||
|
||||
export function lobVx(round, k, vy, fixed, also) {
|
||||
const tx = lobTarget(round, k, also);
|
||||
export function lobVx(round, k, vy, fixed, also, lead = 0) {
|
||||
const tx = lobTarget(round, k, also, lead);
|
||||
if (tx === null) return round.you.face * fixed;
|
||||
const at = hand(round, k);
|
||||
const dy = k.groundAt(round.spec, tx) - at.y;
|
||||
@@ -323,7 +326,7 @@ function lobStick(round, k) {
|
||||
function lobPod(round, k, pay, aimed = false) {
|
||||
const you = round.you;
|
||||
const at = hand(round, k);
|
||||
round.hazards.push({ kind: "armPod", pay, x: at.x, y: at.y, vx: aimed ? lobVx(round, k, POD_VY, POD_VX, ["hands"]) : you.face * POD_VX, vy: POD_VY, spin: 0, w: 0.8, h: 0.8, live: 0, cause: "" });
|
||||
round.hazards.push({ kind: "armPod", pay, x: at.x, y: at.y, vx: aimed ? lobVx(round, k, POD_VY, POD_VX, ["hands"], pay === "salt" ? SALT_LEAD : 0) : you.face * POD_VX, vy: POD_VY, spin: 0, w: 0.8, h: 0.8, live: 0, cause: "" });
|
||||
}
|
||||
|
||||
function lobPie(round, k) {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -65,7 +65,7 @@ export function bonusArt(d, die) {
|
||||
const face = landed ? 6 : 1 + (Math.floor(since / 60) + i) % 5;
|
||||
die(ctx, x0 + i * step, y0 + drop + bounce, size, face, landed ? 0 : (1 - p) * 9 * (i % 2 ? -1 : 1), landed ? "#b8860b" : "#1d1a17");
|
||||
}
|
||||
const tail = b.gained < b.dice ? `${round.dice} of 9 in hand (full)` : `${round.dice} in hand`;
|
||||
const tail = `${round.dice} in hand`;
|
||||
label(ctx, tail, cx, cy + 12, 2.4, t > LAND_FIRST_MS + (b.dice - 1) * LAND_STEP_MS ? GOLD : "rgba(255,255,255,0.5)", "center", w - 4);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
// game over), and the run carries on to the next room. A room that is finished
|
||||
// alive ends it with Lucky dice (`endBonus(round, true)`): `dice` is how many
|
||||
// the round earned (BONUS_FLOOR at least, MAX_DICE at most, see `diceFor`) and
|
||||
// they are added to `round.dice`, capped at MAX_DICE.
|
||||
// they are added to `round.dice`, which has no limit.
|
||||
//
|
||||
// A room with its own grade (the dark ride) sets `perf.dice` (dice earned) and
|
||||
// `perf.cardMs` (its card's length) before it finishes; `diceFor` is then not used.
|
||||
@@ -86,7 +86,7 @@ export function endBonus(round, won, kit) {
|
||||
// A room that grades itself (the dark ride) sets `perf.dice` and `perf.cardMs`.
|
||||
b.dice = b.perf.dice !== undefined ? b.perf.dice : diceFor(b, round.stats.kills);
|
||||
const had = round.dice;
|
||||
round.dice = Math.min(MAX_DICE, round.dice + b.dice);
|
||||
round.dice += b.dice;
|
||||
points = kit.ROOM_POINTS * round.room;
|
||||
kit.award(round, points);
|
||||
round.stats.rooms++;
|
||||
+48
-3
@@ -6,7 +6,7 @@
|
||||
// file never reaches back into it. Everything is drawn in field units, y
|
||||
// counted down from the field's top.
|
||||
|
||||
import { DICE_FACES, LEAD_MS, TUMBLE_MS } from "./ghoul-dice.js";
|
||||
import { ASK_GUARD_MS, DICE_FACES, LEAD_MS, TUMBLE_MS } from "./ghoul-dice.js";
|
||||
|
||||
const BODY = "#f4f1e8";
|
||||
const EDGE = "#8f8a7d";
|
||||
@@ -212,11 +212,56 @@ export function diceArt(d) {
|
||||
}
|
||||
}
|
||||
|
||||
// The question before a roll: "Use a Lucky Die?" with Yes and No, the lit one
|
||||
// gold, on the same panel the roll uses, and how many dice are in hand.
|
||||
function ask(ctx, v) {
|
||||
const a = v.round.ask;
|
||||
if (!a) return;
|
||||
const { x, y } = panelAt(v, a);
|
||||
const fit = panelFit(v.g);
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.scale(fit, fit);
|
||||
ctx.translate(-x, -y);
|
||||
ctx.fillStyle = "rgba(0, 0, 0, 0.7)";
|
||||
roundRect(ctx, x - PANEL_W / 2, y - PANEL_H / 2, PANEL_W, PANEL_H, 2.5);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = GOLD;
|
||||
ctx.lineWidth = 0.5;
|
||||
ctx.stroke();
|
||||
die(ctx, x, y - 10.5, 8.5, 1 + (Math.floor(a.t / 900) * 2) % 6, 0.12 * Math.sin(v.clock / 300));
|
||||
label(ctx, "Use a Lucky Die?", x, y - 1.6, 3.4, "#ffffff", "center", PANEL_W - 3);
|
||||
const n = v.round.dice;
|
||||
label(ctx, `You have ${n} Lucky ${n === 1 ? "Die" : "Dice"}`, x, y + 3.4, 2.2, "#8fd8ff", "center", PANEL_W - 3);
|
||||
const ready = a.t >= ASK_GUARD_MS;
|
||||
for (const [word, yes, bx] of [["YES", true, x - 10.5], ["NO", false, x + 10.5]]) {
|
||||
const lit = a.yes === yes;
|
||||
ctx.globalAlpha = ready ? 1 : 0.45;
|
||||
ctx.fillStyle = lit ? GOLD : "rgba(255, 255, 255, 0.12)";
|
||||
roundRect(ctx, bx - 8.5, y + 7, 17, 7, 1.6);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = lit ? "#fffbe8" : "rgba(255, 255, 255, 0.4)";
|
||||
ctx.lineWidth = lit ? 0.5 : 0.25;
|
||||
ctx.stroke();
|
||||
label(ctx, word, bx, y + 12.4, 3.4, lit ? INK : "#ffffff", "center");
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
label(ctx, "Keep it to save it for later", x, y + 17.5, 1.9, "#b9b4a6", "center", PANEL_W - 3);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// What each step of the roll looks and sounds like (house tones for now);
|
||||
// whether `e` was one of them.
|
||||
function react(e, k) {
|
||||
const { tone, burst, float, ring, flash, glow, shake, banner, fx, powers: POWERS } = k;
|
||||
if (e.type === "diceStart") {
|
||||
if (e.type === "diceAsk") {
|
||||
tone("heartbeat", 0.4);
|
||||
tone("click", 0.3, 0.8);
|
||||
ring(e.x, e.y + 2.5, BODY, 2, 8, 500);
|
||||
} else if (e.type === "diceKeep") {
|
||||
tone("click", 0.3, 0.7);
|
||||
float(e.x, e.y + 8, "Die kept", "#8fd8ff", 2.4);
|
||||
} else if (e.type === "diceStart") {
|
||||
tone("ghoulDiceDrone", 0.6);
|
||||
tone("heartbeat", 0.45);
|
||||
ring(e.x, e.y + 2.5, BODY, 2, 8, 500);
|
||||
@@ -289,5 +334,5 @@ export function diceArt(d) {
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
return { drop, roll, lucky, react, die };
|
||||
return { drop, roll, ask, lucky, react, die };
|
||||
}
|
||||
+44
-7
@@ -5,9 +5,11 @@
|
||||
// ghoul-powers.js its POWER_KIT, so this file never reaches back into it.
|
||||
//
|
||||
// A Lucky die turns up only as a drop from a kill (see ghoul-powers.js) and
|
||||
// is kept, up to MAX_DICE, through every room and stage until used. When
|
||||
// is kept, with no limit, through every room and stage until used. When
|
||||
// Planny would lose a life, whatever the cause (a pit, the clock and the
|
||||
// last life included), a round with dice holds in the phase "roll" and rolls
|
||||
// last life included), a round with dice holds in the phase "ask" and asks
|
||||
// "Use a Lucky Die?" (Yes spends one, No keeps them all and lets the loss go
|
||||
// ahead); on Yes it holds in the phase "roll" and rolls
|
||||
// one on screen, for ROLL_MS: tumbling for TUMBLE_MS, then landing on its face
|
||||
// for a beat to read. One die a death; the others are kept. DICE_FACES says
|
||||
// what each face does. A 4, 5 or 6 saves him: he comes back where he died
|
||||
@@ -21,6 +23,7 @@
|
||||
// The faces come from the `random` handed to advance(), so a seed plays the
|
||||
// same. Endless lives never roll.
|
||||
|
||||
// The most one bonus round or ride can pay (a cap on what is earned, not on what is held).
|
||||
export const MAX_DICE = 9;
|
||||
// Every run starts with these dice in hand.
|
||||
export const START_DICE = 3;
|
||||
@@ -85,16 +88,50 @@ export function reviveSpot(round, kit) {
|
||||
}
|
||||
|
||||
// A life about to be lost: with dice in hand (and no endless lives) the round
|
||||
// holds to roll them instead. Whether it did.
|
||||
// holds and ASKS whether to use one ("Use a Lucky Die?", the phase "ask"), since
|
||||
// the player may want to keep it for later. Whether it did hold.
|
||||
export function beginRoll(round, cause, kit) {
|
||||
if (round.infinite || !(round.dice > 0)) return false;
|
||||
const at = reviveSpot(round, kit);
|
||||
round.dice--;
|
||||
round.roll = { cause, t: 0, face: 0, landed: false, x: at.x, y: at.y, shelf: at.shelf, pit: at.pit };
|
||||
round.phase = "roll";
|
||||
round.ask = { cause, yes: true, t: 0, x: at.x, y: at.y, shelf: at.shelf, pit: at.pit };
|
||||
round.phase = "ask";
|
||||
round.phaseMs = 0;
|
||||
round.input.jump = 0;
|
||||
round.events.push({ type: "diceStart", cause, n: round.dice, x: at.x, y: at.y });
|
||||
round.events.push({ type: "diceAsk", cause, n: round.dice, x: at.x, y: at.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
// A press in the first ASK_GUARD_MS does nothing: the key that was held or
|
||||
// mashed as Planny died must not answer for the player.
|
||||
export const ASK_GUARD_MS = 600;
|
||||
|
||||
// One slice of the question: only its clock moves.
|
||||
export function askStep(round, ms) {
|
||||
if (round.ask) round.ask.t += ms;
|
||||
}
|
||||
|
||||
// Which answer is lit: true for "Yes", false for "No".
|
||||
export function steerAsk(round, yes) {
|
||||
if (round.ask) round.ask.yes = yes;
|
||||
}
|
||||
|
||||
// The answer. Yes spends a die and starts the roll; No keeps every die and
|
||||
// lets the loss go ahead. Whether the answer was taken (not inside the guard).
|
||||
export function answerAsk(round, yes, kit) {
|
||||
const a = round.ask;
|
||||
if (!a || a.t < ASK_GUARD_MS) return false;
|
||||
round.ask = null;
|
||||
round.phaseMs = 0;
|
||||
if (!yes) {
|
||||
round.phase = "play";
|
||||
round.events.push({ type: "diceKeep", cause: a.cause, n: round.dice, x: a.x, y: a.y });
|
||||
kit.takeLife(round, a.cause);
|
||||
return true;
|
||||
}
|
||||
round.dice--;
|
||||
round.roll = { cause: a.cause, t: 0, face: 0, landed: false, x: a.x, y: a.y, shelf: a.shelf, pit: a.pit };
|
||||
round.phase = "roll";
|
||||
round.events.push({ type: "diceStart", cause: a.cause, n: round.dice, x: a.x, y: a.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's bosses and damage: a boss's fight and fall, hurting and killing a monster, and losing a life.
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { BONUS_SAFE_MS } from "./ghoul-bonus.js";
|
||||
import { answerAsk, beginRoll } from "./ghoul-dice.js";
|
||||
import { ARM_DROP, POWERS, applyPower as applyPowerWith, armDrop, pickPower } from "./ghoul-powers.js";
|
||||
import { FIELD_W } from "./ghoul-rooms.js";
|
||||
import { BOSS_MOVERS, HAZARDS, ON_KILL, nextSerial, spawnMonster, throwBone } from "./ghoul-monsters.js";
|
||||
import { footing, groundAt, landing, leftEdge, rightEdge } from "./ghoul-planny.js";
|
||||
import { KIT } from "./ghoul-kit.js";
|
||||
import { BOSSES, BOSS_INTRO_MS, CHAIN_MS, CRASH_MS, DROP_CANDY, DROP_MS, DROP_POWER, FALL_MAX, GARLIC_SAFE_MS, GOURD_ACTS, GOURD_BIG_V, GOURD_HOP_V, GOURD_QUAKE_V, GOURD_SPIT, GOURD_SPIT_MS, GOURD_WAIT_MS, GRAVITY, HIT_H, HIT_W, MAX_SEEDS, MONSTERS, PIT_Y, QUICK_LOSS_MS, SAFE_MS, STRAY_FADE, STRAY_MIN, chainMult, clamp, seeded } from "./ghoul-tables.js";
|
||||
|
||||
/* --------------------------------------------------------------- bosses */
|
||||
|
||||
// One slice of each hazard by its kind's rule; gone once its rule says so.
|
||||
export function moveHazards(round, ms) {
|
||||
if (!round.hazards.length) return;
|
||||
let n = 0;
|
||||
for (const h of round.hazards) if (HAZARDS[h.kind] && HAZARDS[h.kind](round, h, ms, KIT)) round.hazards[n++] = h;
|
||||
// A hazard that felled the boss has just emptied the list.
|
||||
round.hazards.length = Math.min(n, round.hazards.length);
|
||||
}
|
||||
|
||||
export function makeBoss(round) {
|
||||
const spec = round.spec;
|
||||
const def = BOSSES[spec.boss];
|
||||
const x = spec.length - 24;
|
||||
return { kind: spec.boss, x, y: groundAt(spec, x), vx: 0, vy: 0, w: def.w, h: def.h, hp: spec.bossHp, max: spec.bossHp, state: "sleep", t: 0, wait: GOURD_WAIT_MS, hops: 0, attacks: 0, windup: 0, act: "", run: 0, landX: x, hurt: 0, dir: -1 };
|
||||
}
|
||||
|
||||
// The arena's ends for the boss: it keeps ARENA_POCKET clear of each, so
|
||||
// a corner is always somewhere a hop cannot land on you.
|
||||
export const ARENA_POCKET = 6;
|
||||
export const arenaMin = (round, b) => round.spec.arena + ARENA_POCKET + b.w / 2;
|
||||
export const arenaMax = (round, b) => round.spec.length - ARENA_POCKET - b.w / 2;
|
||||
|
||||
// The Gourd's next move: any of GOURD_ACTS at random, but never one three
|
||||
// times running (and only a spit at you up on a balcony over its head).
|
||||
export function gourdAct(b, random) {
|
||||
let act = GOURD_ACTS[Math.floor(random() * GOURD_ACTS.length) % GOURD_ACTS.length];
|
||||
if (act === b.act && b.run >= 2) act = GOURD_ACTS[(GOURD_ACTS.indexOf(act) + 1 + Math.floor(random() * 2)) % GOURD_ACTS.length];
|
||||
b.run = act === b.act ? b.run + 1 : 1;
|
||||
return act;
|
||||
}
|
||||
|
||||
export function moveBoss(round, ms, random) {
|
||||
const b = round.boss;
|
||||
if (!b || b.state === "sleep") return;
|
||||
if (b.state === "down") {
|
||||
b.t += ms;
|
||||
return;
|
||||
}
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const pace = spec.pace;
|
||||
b.t += ms;
|
||||
b.hurt = Math.max(0, b.hurt - ms);
|
||||
if (b.state === "intro") {
|
||||
if (b.t >= BOSS_INTRO_MS) {
|
||||
b.state = "fight";
|
||||
round.events.push({ type: "bossGo", kind: b.kind });
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Dazed by Flash Powder or pinned by a Bear Trap (ghoul-arms.js).
|
||||
if (b.stunMs > 0) {
|
||||
b.stunMs -= ms;
|
||||
return;
|
||||
}
|
||||
if (BOSS_MOVERS[b.kind]) return BOSS_MOVERS[b.kind](round, b, ms, random, KIT);
|
||||
const floor = groundAt(spec, b.x);
|
||||
if (b.kind === "gourd") {
|
||||
if (b.vy !== 0 || b.y > floor) {
|
||||
b.vy -= GRAVITY * dt;
|
||||
const py = b.y;
|
||||
b.x = clamp(b.x + b.vx * dt, arenaMin(round, b), arenaMax(round, b));
|
||||
b.y += b.vy * dt;
|
||||
if (b.vy < 0 && py >= floor && b.y <= floor) {
|
||||
b.y = floor;
|
||||
b.vy = 0;
|
||||
b.vx = 0;
|
||||
b.wait = GOURD_WAIT_MS / pace;
|
||||
if (b.act === "quake") {
|
||||
for (const d of [-1, 1]) round.waves.push({ x: b.x + d * (b.w / 2), y: floor, dir: d, life: 6000, kind: "gourd" });
|
||||
round.events.push({ type: "slam", kind: "gourd", x: b.x, y: b.y, big: true });
|
||||
return;
|
||||
}
|
||||
const big = b.hops % 3 === 0;
|
||||
round.events.push({ type: "slam", kind: "gourd", x: b.x, y: b.y, big });
|
||||
const seeds = round.monsters.filter((m) => m.kind === "seed").length;
|
||||
for (let k = 0; k < (big ? 2 : 1) && seeds + k < MAX_SEEDS; k++) {
|
||||
const side = k % 2 ? 1 : -1;
|
||||
spawnMonster(round, "seed", b.x + side * (b.w / 2), b.y + 4, { vx: side * (8 + random() * 10), vy: 26 + random() * 14, dir: side, force: true });
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
b.dir = Math.sign(you.x - b.x) || b.dir;
|
||||
if (b.windup > 0) {
|
||||
b.windup = Math.max(0, b.windup - ms);
|
||||
if (b.windup > 0) return;
|
||||
for (const s of GOURD_SPIT) throwBone(round, b.x + b.dir * b.w * 0.3, b.y + b.h * 0.6, s, "acid", b.kind);
|
||||
round.events.push({ type: "spit", kind: b.kind, x: b.x, y: b.y + b.h * 0.6 });
|
||||
b.wait = GOURD_WAIT_MS / pace;
|
||||
return;
|
||||
}
|
||||
b.wait -= ms;
|
||||
if (b.wait > 0) return;
|
||||
// Up on a balcony over its head, you are out of a hop's reach: it spits.
|
||||
const high = you.state === "run" && you.shelf >= 0 && you.y >= floor + b.h + 2;
|
||||
b.act = high ? "spit" : gourdAct(b, random);
|
||||
if (high) b.run = 0;
|
||||
if (b.act === "spit") {
|
||||
b.windup = GOURD_SPIT_MS / pace;
|
||||
round.events.push({ type: "windup", x: b.x, y: b.y, boss: true, act: b.act });
|
||||
return;
|
||||
}
|
||||
if (b.act === "quake") {
|
||||
b.vx = 0;
|
||||
b.vy = GOURD_QUAKE_V;
|
||||
b.y += 0.01;
|
||||
round.events.push({ type: "hop", kind: "gourd", x: b.x, y: b.y, landX: b.x });
|
||||
return;
|
||||
}
|
||||
b.hops++;
|
||||
const v = b.hops % 3 === 0 ? GOURD_BIG_V : GOURD_HOP_V;
|
||||
const air = (2 * v) / GRAVITY;
|
||||
b.landX = clamp(you.x, arenaMin(round, b), arenaMax(round, b));
|
||||
b.vx = (b.landX - b.x) / air;
|
||||
b.vy = v;
|
||||
b.y += 0.01;
|
||||
round.events.push({ type: "hop", kind: "gourd", x: b.x, y: b.y, landX: b.landX });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Damage to the boss; at none it falls and the door opens.
|
||||
export function hurtBoss(round, dmg, how) {
|
||||
const b = round.boss;
|
||||
if (!b || b.state !== "fight") return false;
|
||||
b.hp = Math.max(0, b.hp - dmg);
|
||||
b.hurt = 120;
|
||||
round.events.push({ type: "bossHit", kind: b.kind, x: b.x, y: b.y + b.h / 2, how, weak: how === "weak" });
|
||||
if (b.hp > 0) return true;
|
||||
b.state = "down";
|
||||
b.t = 0;
|
||||
const points = round.spec.bossPoints;
|
||||
award(round, points);
|
||||
round.stats.bosses++;
|
||||
round.hasKey = true;
|
||||
const life = true;
|
||||
round.lives++;
|
||||
for (const m of round.monsters) round.events.push({ type: "poof", kind: m.kind, x: m.x, y: m.y + m.h / 2 });
|
||||
round.monsters.length = 0;
|
||||
round.bones.length = 0;
|
||||
round.waves.length = 0;
|
||||
round.puddles.length = 0;
|
||||
round.hazards.length = 0;
|
||||
round.events.push({ type: "bossDown", kind: b.kind, x: b.x, y: b.y + b.h / 2, points, life });
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- hits, kills */
|
||||
|
||||
export const award = (round, points) => {
|
||||
round.score += points;
|
||||
};
|
||||
|
||||
// A shot, a stomp or a chandelier on monster `m`: hp off, and at none a kill.
|
||||
export function hurt(round, m, dmg, how, random = Math.random) {
|
||||
if (m.dead) return false;
|
||||
m.hp -= dmg;
|
||||
m.hurt = 110;
|
||||
if (m.hp > 0) {
|
||||
round.events.push({ type: "hit", kind: m.kind, x: m.x, y: m.y + m.h / 2, how });
|
||||
return false;
|
||||
}
|
||||
kill(round, m, how, random);
|
||||
return true;
|
||||
}
|
||||
|
||||
// A monster gone: its points times the chain, doubled for a headshot, a
|
||||
// stomp or a chandelier, and now and then candy or a power-up left behind.
|
||||
export function kill(round, m, how = "shot", random = Math.random) {
|
||||
m.dead = true;
|
||||
round.chain = round.chainMs > 0 ? round.chain + 1 : 1;
|
||||
round.chainMs = CHAIN_MS;
|
||||
const mult = chainMult(round.chain);
|
||||
const bonus = how === "head" || how === "stomp" || how === "crush" ? 2 : 1;
|
||||
const fade = m.horde ? Math.max(STRAY_MIN, STRAY_FADE ** round.strays++) : 1;
|
||||
const points = Math.round(MONSTERS[m.kind].points * mult * bonus * fade);
|
||||
award(round, points);
|
||||
round.stats.kills++;
|
||||
if (how === "head") round.stats.headshots++;
|
||||
if (how === "stomp") round.stats.stomps++;
|
||||
round.stats.bestChain = Math.max(round.stats.bestChain, round.chain);
|
||||
round.events.push({ type: "kill", kind: m.kind, x: m.x, y: m.y + m.h / 2, points, mult, how });
|
||||
// A bloater bursts in a harmless splash: only the acid it spits burns.
|
||||
if (m.kind === "spitter") round.events.push({ type: "burst", x: m.x, y: m.y + m.h / 2 });
|
||||
if (ON_KILL[m.kind]) ON_KILL[m.kind](round, m, how, KIT);
|
||||
if (m.horde) return points;
|
||||
const r = random();
|
||||
if (r < DROP_POWER) dropItem(round, pickPower(random, round, "", true), m.x, m.y + m.h / 2);
|
||||
else if (r < DROP_POWER + DROP_CANDY) dropItem(round, "candy", m.x, m.y + m.h / 2);
|
||||
// A weapon: its own band of the same roll, so no later roll shifts (ghoul-powers.js).
|
||||
else if (r < DROP_POWER + DROP_CANDY + ARM_DROP) dropItem(round, armDrop(round, (r - DROP_POWER - DROP_CANDY) / ARM_DROP), m.x, m.y + m.h / 2);
|
||||
return points;
|
||||
}
|
||||
|
||||
// A weapon's drop takes no monster serial, so it shifts nothing later (a monster's id sets how long it ponders).
|
||||
export function dropItem(round, kind, x, y) {
|
||||
round.drops.push({ id: POWERS[kind]?.arm ? 0 : nextSerial(), kind, x, y, vx: 0, vy: 22, life: DROP_MS, rest: false });
|
||||
}
|
||||
|
||||
// A life lost: with Lucky dice in hand the round first holds to roll one
|
||||
// (ghoul-dice.js); else, or when it lands on 3 or lower, it holds while Planny
|
||||
// tumbles, then puts him back.
|
||||
export function lose(round, cause) {
|
||||
if (round.phase !== "play" || round.you.out > 0) return false;
|
||||
round.you.lift = null;
|
||||
// A bonus room's hearts are its own: no Lucky die is rolled for one.
|
||||
if (!round.bonusRound && beginRoll(round, cause, DICE_KIT)) return true;
|
||||
return takeLife(round, cause);
|
||||
}
|
||||
|
||||
function takeLife(round, cause) {
|
||||
const you = round.you;
|
||||
if (!round.infinite) round.bonusRound ? round.bonusRound.hearts-- : round.lives--;
|
||||
round.chain = 0;
|
||||
round.chainMs = 0;
|
||||
round.roomLost = true;
|
||||
// The dark ride and the Runaway Cart play on after a hit that is not the last heart
|
||||
// (ghoul-ride.js; the cart blinks safe a moment, and a derail is re-seated by ghoul-cart.js).
|
||||
const b = round.bonusRound;
|
||||
const rolling = round.gallery || (round.cart && !round.cart.done) || (round.sled && !round.sled.done) || (round.runner && !round.runner.done);
|
||||
if (rolling && b && (round.infinite || b.hearts > 0)) {
|
||||
if (!round.gallery) you.safeMs = Math.max(you.safeMs, BONUS_SAFE_MS);
|
||||
round.events.push({ type: "lose", cause, x: you.x, y: you.y, lives: round.lives, hearts: b.hearts });
|
||||
return true;
|
||||
}
|
||||
you.out = CRASH_MS;
|
||||
you.outKind = cause;
|
||||
round.quickLoss = (you.aliveMs || 0) < QUICK_LOSS_MS;
|
||||
round.phase = "crash";
|
||||
round.phaseMs = CRASH_MS;
|
||||
round.input.jump = 0;
|
||||
round.events.push({ type: "lose", cause, x: you.x, y: you.y, lives: round.lives, hearts: round.bonusRound ? round.bonusRound.hearts : undefined });
|
||||
return true;
|
||||
}
|
||||
|
||||
// Something touched you: the Garlic shield takes it (seeing off the monster
|
||||
// that touched you), else a life.
|
||||
export function struck(round, cause, m = null) {
|
||||
const you = round.you;
|
||||
if (you.safeMs > 0) return false;
|
||||
if (you.garlic) {
|
||||
you.garlic = false;
|
||||
you.safeMs = GARLIC_SAFE_MS;
|
||||
if (m && !m.dead && MONSTERS[m.kind]) {
|
||||
kill(round, m, "garlic", () => 1);
|
||||
round.monsters = round.monsters.filter((q) => !q.dead);
|
||||
}
|
||||
round.events.push({ type: "garlic", x: you.x, y: you.y });
|
||||
return false;
|
||||
}
|
||||
return lose(round, cause);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- powers */
|
||||
|
||||
// What ghoul-powers.js needs from here, handed to its rules the way KIT is
|
||||
// handed to a stage pack.
|
||||
export const POWER_KIT = Object.freeze({ footing, leftEdge, rightEdge, seeded, landing, GRAVITY, FALL_MAX, PIT_Y, HIT_W, HIT_H });
|
||||
// And what ghoul-dice.js needs.
|
||||
export const DICE_KIT = Object.freeze({ SAFE_MS, PIT_Y, FIELD_W, footing, groundAt, leftEdge, rightEdge, takeLife, kill, give: (round, kind) => applyPowerWith(round, kind, POWER_KIT) });
|
||||
|
||||
export const applyPower = (round, kind) => applyPowerWith(round, kind, POWER_KIT);
|
||||
|
||||
// Answer "Use a Lucky Die?": true spends one and rolls, false keeps every die and lets the loss go ahead.
|
||||
export const answerDie = (round, yes) => answerAsk(round, yes, DICE_KIT);
|
||||
@@ -0,0 +1,3 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's KIT: what the stage packs are handed, the game's own helpers and numbers. One empty object here that ghoul-play.js fills as it loads, so the parts of the game that only pass the kit on need not load after the part that fills it. No imports.
|
||||
|
||||
export const KIT = {};
|
||||
@@ -0,0 +1,721 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's monsters: spawning them, how each kind walks, hops, climbs and swoops, and what they throw.
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { CHANDELIER_Y, FIELD_W } from "./ghoul-rooms.js";
|
||||
import { hurt } from "./ghoul-fight.js";
|
||||
import { footing, groundAt, landing, leftEdge, shelfThere, wallAt } from "./ghoul-planny.js";
|
||||
import { KIT } from "./ghoul-kit.js";
|
||||
import { BAT_NEAR, BAT_STEER, BAT_TURN, BONE_G, BONE_V, BONE_VX, BOUND_UP, BOUND_V, CLIMBERS, CLIMB_V, FALL_MAX, GHOST_APPEAR_MS, GHOST_CLEAR, GHOST_HIDE_MS, GHOST_SHOW_MS, GRAVITY, HEAVY, HIT_W, HOP_IN, HOP_V, HOUND_CROUCH_MS, HOUND_LUNGE_V, HOUND_LUNGE_VX, HOUND_RANGE, HOUND_REST_MS, HUNT_CROUCH_MS, HUNT_HIGH, HUNT_RANGE, HUNT_REST_MS, HUNT_UP, HUNT_VX, LURCH_RANGE, MAX_MONSTERS, MONSTERS, PIT_Y, PONDER_MS, PONDER_STEP_MS, PUDDLE_MS, RISE_MS, RUNNER_WARN, SEED_LAND_MS, SHOT_Y, SKEL_MS, SKEL_NEAR, SKEL_RANGE, SKEL_WINDUP_MS, SPIDER_DROP_V, SPIDER_NEAR, SPIT_KEEP, SPIT_MS, SPIT_RANGE, SPIT_WINDUP_MS, STACKERS, STACK_MIN, STACK_NEAR, STACK_REACH, STACK_STEP, STEP_UP, SWOOP_CLEAR, SWOOP_NEAR, UNSTACK_V, WALKERS, WALL_MAX, WALL_V, WAVE_SPEED, WRAITH_ABOVE, WRAITH_DIVE_V, WRAITH_HOVER_MS, WRAITH_KEEP, WRAITH_NEAR, WRAITH_PAST, WRAITH_WIND_MS, YOU_H, ZOMBIES, bounds, clamp, fromPacks, hopReach, listPacks } from "./ghoul-tables.js";
|
||||
|
||||
/* ------------------------------------------------------------ monsters */
|
||||
|
||||
let serial = 0;
|
||||
// The next id, for what the other parts make (a module's binding can only be changed from inside it).
|
||||
export const nextSerial = () => ++serial;
|
||||
|
||||
// A monster of `kind` at (x, y), facing you; `over` adds or replaces fields.
|
||||
export function spawnMonster(round, kind, x, y, over = {}) {
|
||||
if (round.monsters.length >= MAX_MONSTERS && !over.force) return null;
|
||||
const def = MONSTERS[kind];
|
||||
const spec = round.spec;
|
||||
const extra = ZOMBIES.has(kind) || kind === "skeleton" || kind === "hound" || kind === "spitter" || kind === "huntsman" ? spec.tough : 0;
|
||||
const m = {
|
||||
id: ++serial,
|
||||
kind,
|
||||
x,
|
||||
y,
|
||||
w: def.w,
|
||||
h: def.h,
|
||||
hp: def.hp + extra,
|
||||
max: def.hp + extra,
|
||||
vx: 0,
|
||||
vy: 0,
|
||||
dir: round.you.x < x ? -1 : 1,
|
||||
t: 0,
|
||||
rise: kind === "crawler" ? RISE_MS : 0,
|
||||
awake: kind !== "bat",
|
||||
act: ACT_START[kind] || "",
|
||||
wait: 0,
|
||||
phase: 0,
|
||||
throwIn: (kind === "spitter" ? SPIT_MS : SKEL_MS) * 0.45,
|
||||
windup: 0,
|
||||
hurt: 0,
|
||||
home: y,
|
||||
lift: 0,
|
||||
...over,
|
||||
};
|
||||
delete m.force;
|
||||
round.monsters.push(m);
|
||||
round.events.push({ type: "spawn", kind, x, y });
|
||||
return m;
|
||||
}
|
||||
|
||||
// What a hellhound, a widow and a wraith start out doing.
|
||||
const ACT_START = Object.freeze({ hound: "prowl", spider: "hang", wraith: "idle", huntsman: "prowl", ...fromPacks("act") });
|
||||
// The packs' rules by kind: whether one is solid, its moving, what its death
|
||||
// leaves, what a horde one comes in with; a boss's fight, whether it shrugs
|
||||
// off a hit, and each kind of hazard a boss leaves on the field.
|
||||
const SOLIDS = fromPacks("solid");
|
||||
const MOVERS = fromPacks("move");
|
||||
export const ON_KILL = fromPacks("kill");
|
||||
export const HORDE_WITH = fromPacks("horde");
|
||||
export const BOSS_MOVERS = fromPacks("boss");
|
||||
const GUARDS = fromPacks("guard");
|
||||
export const HAZARDS = fromPacks("hazards");
|
||||
// Kinds the Hedge Shears kill outright, a boss's weak spot (the damage
|
||||
// multiplier of a shot) and what a boss's touch is called when it costs a life.
|
||||
export const CUT = new Set(listPacks("cut"));
|
||||
export const WEAK = fromPacks("weak");
|
||||
export const CAUSES = fromPacks("cause");
|
||||
// Kinds that are stone just now (a shot glances off), a stage-wide twist run
|
||||
// each slice (the Chapel's bell, which may set `round.stunMs`), what a bolt
|
||||
// that hit a monster does besides its damage, and what else a bolt can strike.
|
||||
export const STONE = fromPacks("stone");
|
||||
export const TICKS = listPacks("tick");
|
||||
export const SHOTS = listPacks("shot");
|
||||
export const TARGETS = listPacks("target");
|
||||
// What a pack does to carry Planny itself (the Runaway Cart's ride: a hook that
|
||||
// returns true has moved him), and when he is put down in a room (a room set up,
|
||||
// a respawn).
|
||||
export const RIDES = listPacks("ride");
|
||||
export const PLACES = listPacks("place");
|
||||
export const POINTERS = listPacks("pointer");
|
||||
// Kinds that are out of sight just now (a shot goes through, a touch does
|
||||
// nothing), that hurt nothing by touch, that Planny can stand on, and what a
|
||||
// missile of a kind does where it lands (see ghoul-sanatorium.js).
|
||||
const UNSEEN = fromPacks("unseen");
|
||||
export const HARMLESS = fromPacks("harmless");
|
||||
const LANDS = fromPacks("land");
|
||||
// Whether the boss shrugs off shots and stomps just now.
|
||||
export const guarded = (b) => Boolean(GUARDS[b.kind] && GUARDS[b.kind](b));
|
||||
|
||||
// Whether a monster can be hit and can hurt: a crawler or a door's zombie
|
||||
// still coming up, a gourdling still in the air, a faded ghost and a wraith
|
||||
// not yet come cannot.
|
||||
export function solid(m) {
|
||||
if (m.unseen) return false;
|
||||
if (SOLIDS[m.kind]) return SOLIDS[m.kind](m);
|
||||
if (m.kind === "crawler" || ZOMBIES.has(m.kind)) return m.rise <= 0;
|
||||
// A gourdling flung out of the Gourd is harmless till it lands and finds its feet.
|
||||
if (m.kind === "seed") return m.vy === 0 && m.rise <= 0;
|
||||
if (m.kind === "ghost") {
|
||||
const t = (m.t + m.phase) % (GHOST_SHOW_MS + GHOST_HIDE_MS);
|
||||
return t >= GHOST_APPEAR_MS && t < GHOST_SHOW_MS;
|
||||
}
|
||||
if (m.kind === "wraith") return m.act !== "idle";
|
||||
return true;
|
||||
}
|
||||
|
||||
// Whether a monster is up and after you: solid, and not a roosting bat or a
|
||||
// widow still on the ceiling.
|
||||
export const roused = (m) => (m.kind !== "bat" || m.awake) && !(m.kind === "spider" && m.act === "hang") && solid(m);
|
||||
|
||||
// The ghost's share of full sight, 0 to 1, for the drawing.
|
||||
export function ghostSight(m) {
|
||||
const t = (m.t + m.phase) % (GHOST_SHOW_MS + GHOST_HIDE_MS);
|
||||
if (t < GHOST_APPEAR_MS) return t / GHOST_APPEAR_MS;
|
||||
if (t < GHOST_SHOW_MS) return 1;
|
||||
const fade = Math.min(1, (t - GHOST_SHOW_MS) / 250);
|
||||
return 1 - fade * 0.88;
|
||||
}
|
||||
|
||||
// Within UNDER_DX of straight under (or over) you a monster stops where it
|
||||
// is, still facing the way it went, rather than turning back and forth
|
||||
// every frame; once you move off it turns and comes on.
|
||||
export const UNDER_DX = 1;
|
||||
export const towardYou = (round, m) => (Math.abs(round.you.x - m.x) < UNDER_DX ? m.dir : Math.sign(round.you.x - m.x) || m.dir);
|
||||
|
||||
// A walker's step toward `dx` (the sign of the way it goes) at `speed`:
|
||||
// never off an edge or up a wall; it stands and sways instead, or at a pit
|
||||
// narrow enough, thinks about it and then leaps (ponder). Under you, it
|
||||
// stands (UNDER_DX).
|
||||
export function walk(round, m, dir, speed, dt) {
|
||||
// One up a pile is moved by the pile.
|
||||
if (!dir || m.lift > 0 || Math.abs(round.you.x - m.x) < UNDER_DX) return;
|
||||
if (m.dir !== dir) m.ponder = 0;
|
||||
m.dir = dir;
|
||||
const nx = m.x + dir * speed * dt;
|
||||
if (wallAt(round.spec, nx + dir * m.w * 0.4, m.y + STEP_UP)) return wall(round, m, nx + dir * m.w * 0.4, dir, dt);
|
||||
// Walkers keep to the ground, but cross a board laid level with it over a
|
||||
// pit (a bridge) while it is there; never up onto a shelf.
|
||||
const f = footing(round, nx, m.y);
|
||||
// A gourdling runs straight off a shelf's end after you.
|
||||
if (!f && m.kind === "seed" && Number.isFinite(groundAt(round.spec, nx)) && groundAt(round.spec, nx) < m.y) {
|
||||
m.hop = { vx: dir * speed, vy: 6 };
|
||||
return;
|
||||
}
|
||||
if (!f) return ponder(round, m, nx, dir, dt);
|
||||
if (f.shelf >= 0 && Math.abs(f.y - m.y) > 0.01) return;
|
||||
m.ponder = 0;
|
||||
m.x = nx;
|
||||
m.y = f.y;
|
||||
}
|
||||
|
||||
// A leap's time in the air, rising at `v`, to come down `drop` below where it
|
||||
// left (a negative drop is floor above it).
|
||||
const hopTime = (drop, v) => (v + Math.sqrt(v * v + 2 * GRAVITY * drop)) / GRAVITY;
|
||||
|
||||
// Where a leap from the edge at `nx` going `dir` lands, as { x, y, t, v }:
|
||||
// HOP_IN past the first floor no higher than a step up (BOUND_UP on four legs) that a leap reaches
|
||||
// (hopReach across on the level, more the further down); null for floor out
|
||||
// of reach, too high, or past the arena's wall.
|
||||
export function farSide(round, m, nx, dir) {
|
||||
const spec = round.spec;
|
||||
if (groundAt(spec, nx) >= m.y - STEP_UP) return null;
|
||||
const bound = bounds(m);
|
||||
const v = bound ? BOUND_V : HOP_V;
|
||||
const up = bound ? BOUND_UP : STEP_UP;
|
||||
const flat = hopTime(0, v);
|
||||
const reach = hopReach(m);
|
||||
for (let d = 0; d <= reach * 2; d += 0.5) {
|
||||
const x = nx + dir * d;
|
||||
const g = groundAt(spec, x);
|
||||
if (!Number.isFinite(g)) continue;
|
||||
if (g > m.y + up) return null;
|
||||
const t = hopTime(bound ? m.y - g : Math.max(0, m.y - g), v);
|
||||
if (d > (reach * t) / flat) return null;
|
||||
const to = x + dir * HOP_IN;
|
||||
const left = round.lockX >= 0 ? round.lockX + 2 : 2;
|
||||
return to >= left && to <= spec.length - 2 && groundAt(spec, to) === g ? { x: to, y: g, t, v } : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Whether a walker has stood thinking long enough (a "ponder" event as it
|
||||
// starts).
|
||||
function thought(round, m, dt) {
|
||||
if (!m.ponder) round.events.push({ type: "ponder", x: m.x, y: m.y + m.h });
|
||||
m.ponder = (m.ponder || 0) + dt * 1000;
|
||||
if (m.ponder < PONDER_MS + (m.id % 4) * PONDER_STEP_MS) return false;
|
||||
m.ponder = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// A walker at a pit's edge: it stands thinking, then leaps across. One too
|
||||
// heavy to leap still steps off a ledge onto the floor below.
|
||||
function ponder(round, m, nx, dir, dt) {
|
||||
const below = groundAt(round.spec, nx);
|
||||
if (HEAVY.has(m.kind) && Number.isFinite(below) && below < m.y) {
|
||||
m.ponder = 0;
|
||||
m.hop = { vx: dir * MONSTERS[m.kind].speed * round.spec.pace, vy: 0 };
|
||||
return;
|
||||
}
|
||||
const to = HEAVY.has(m.kind) ? null : farSide(round, m, nx, dir);
|
||||
if (!to) {
|
||||
m.ponder = 0;
|
||||
return;
|
||||
}
|
||||
if (!thought(round, m, dt)) return;
|
||||
m.hop = { vx: (to.x - m.x) / to.t, vy: to.v };
|
||||
round.events.push({ type: "leap", kind: m.kind, x: m.x, y: m.y });
|
||||
}
|
||||
|
||||
// A climber at a wall (its face at `wx`): it stands thinking, then climbs.
|
||||
function wall(round, m, wx, dir, dt) {
|
||||
const spec = round.spec;
|
||||
const top = groundAt(spec, wx);
|
||||
if (!CLIMBERS.has(m.kind) || !Number.isFinite(top) || top - m.y > WALL_MAX) {
|
||||
m.ponder = 0;
|
||||
return;
|
||||
}
|
||||
if (!thought(round, m, dt)) return;
|
||||
const on = wx + dir * (m.w / 2 + 0.3);
|
||||
m.scale = { top, x: groundAt(spec, on) === top ? on : wx + dir * 0.5 };
|
||||
round.events.push({ type: "scale", kind: m.kind, x: m.x, y: m.y });
|
||||
}
|
||||
|
||||
// A walker up a wall: on up its face, then onto the floor at its top.
|
||||
function scaleOn(m, dt) {
|
||||
m.y += WALL_V * dt;
|
||||
if (m.y < m.scale.top) return;
|
||||
m.y = m.scale.top;
|
||||
m.x = m.scale.x;
|
||||
m.scale = null;
|
||||
}
|
||||
|
||||
// A walker in the air: down onto the floor or shelf it crosses, or into
|
||||
// the dark below.
|
||||
function hopOn(round, m, dt) {
|
||||
const py = m.y;
|
||||
m.hop.vy = Math.max(-FALL_MAX, m.hop.vy - GRAVITY * dt);
|
||||
m.x += m.hop.vx * dt;
|
||||
m.y += m.hop.vy * dt;
|
||||
const f = m.hop.vy < 0 ? landing(round, m.x, py, m.y, -1) : null;
|
||||
if (f) {
|
||||
m.y = f.y;
|
||||
m.hop = null;
|
||||
} else if (m.y < PIT_Y) m.dead = true;
|
||||
}
|
||||
|
||||
// Gourdlings chase you up and down the shelves: with you above, one under a
|
||||
// shelf no more than SEED_REACH over it crouches SEED_CROUCH_MS and jumps up
|
||||
// onto it (toward where you are along it), SEED_JUMP_MS between jumps; with
|
||||
// you below, it runs off its shelf's end and drops (see walk).
|
||||
export const SEED_REACH = 13;
|
||||
export const SEED_CROUCH_MS = 250;
|
||||
export const SEED_JUMP_MS = 700;
|
||||
function seedJump(round, m, ms) {
|
||||
const you = round.you;
|
||||
m.jumpIn = Math.max(0, (m.jumpIn || 0) - ms);
|
||||
if (m.crouch > 0) {
|
||||
m.crouch = Math.max(0, m.crouch - ms);
|
||||
if (m.crouch > 0) return true;
|
||||
const vy = Math.sqrt(2 * GRAVITY * (m.to.top - m.y + 2));
|
||||
const t = (vy + Math.sqrt(2 * GRAVITY * 2)) / GRAVITY;
|
||||
m.hop = { vx: (m.to.x - m.x) / t, vy };
|
||||
m.dir = Math.sign(m.to.x - m.x) || m.dir;
|
||||
m.jumpIn = SEED_JUMP_MS;
|
||||
round.events.push({ type: "leap", kind: m.kind, x: m.x, y: m.y });
|
||||
return true;
|
||||
}
|
||||
if (m.jumpIn > 0 || you.y < m.y + 2.5 || Math.abs(you.x - m.x) > 40) return false;
|
||||
let to = null;
|
||||
round.spec.shelves.forEach(([x0, x1, top], i) => {
|
||||
if (!shelfThere(round, i) || top <= m.y + 2 || top > m.y + SEED_REACH || top > you.y + 1) return;
|
||||
const x = clamp(you.x, x0 + 1.2, x1 - 1.2);
|
||||
if (Math.abs(x - m.x) > 12) return;
|
||||
if (!to || Math.abs(top - you.y) < Math.abs(to.top - you.y)) to = { top, x };
|
||||
});
|
||||
if (!to) return false;
|
||||
m.to = to;
|
||||
m.crouch = SEED_CROUCH_MS;
|
||||
return true;
|
||||
}
|
||||
|
||||
// A thrown bone (or glob of acid, `kind`) from (x, y) at your chest: its
|
||||
// flight timed to come down there, across no faster than BONE_VX. `by`, the
|
||||
// thrower's kind, rides on the "throw" event so each thrower sounds its own.
|
||||
export function throwBone(round, x, y, scale = 1, kind = "bone", by = null) {
|
||||
const you = round.you;
|
||||
const dy = you.y + 2 - y;
|
||||
const disc = BONE_V * BONE_V - 2 * BONE_G * dy;
|
||||
const t = disc > 0 ? (BONE_V + Math.sqrt(disc)) / BONE_G : (2 * BONE_V) / BONE_G;
|
||||
const vx = clamp(((you.x - x) / t) * scale, -BONE_VX * scale, BONE_VX * scale);
|
||||
const b = { id: ++serial, kind, x, y, vx, vy: BONE_V, spin: 0, life: 4000 };
|
||||
round.bones.push(b);
|
||||
round.events.push({ type: "throw", kind, by, x, y });
|
||||
return b;
|
||||
}
|
||||
|
||||
// One slice of each monster's moving, by kind.
|
||||
export function moveMonsters(round, slice, random) {
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const pace = spec.pace;
|
||||
for (const m of round.monsters) {
|
||||
// A choir ghost's song (`hasteMs`) runs a monster's time `haste` times as fast.
|
||||
const ms = m.hasteMs > 0 ? slice * m.haste : slice;
|
||||
const dt = ms / 1000;
|
||||
if (UNSEEN[m.kind]) m.unseen = Boolean(UNSEEN[m.kind](round, m));
|
||||
if (m.hasteMs > 0) m.hasteMs -= slice;
|
||||
// A faded ghost never turns solid on top of you: it waits till you are clear.
|
||||
if (!(m.kind === "ghost" && !solid(m) && Math.abs(you.x - m.x) < GHOST_CLEAR && Math.abs(you.y + YOU_H / 2 - (m.y + m.h / 2)) < GHOST_CLEAR)) m.t += ms;
|
||||
m.hurt = Math.max(0, m.hurt - ms);
|
||||
// Dazed by Flash Powder or held by a Bear Trap (ghoul-arms.js): shown a while, and still deadly to touch.
|
||||
if (m.litMs > 0) m.litMs -= slice;
|
||||
if (m.stunMs > 0) {
|
||||
m.stunMs -= slice;
|
||||
continue;
|
||||
}
|
||||
if (m.hop) {
|
||||
hopOn(round, m, dt);
|
||||
continue;
|
||||
}
|
||||
if (m.scale) {
|
||||
scaleOn(m, dt);
|
||||
continue;
|
||||
}
|
||||
// A bridge gone from under a walker: it drops into the pit.
|
||||
if (WALKERS.has(m.kind) && m.rise <= 0 && !m.vy && !(m.lift > 0) && !footing(round, m.x, m.y)) {
|
||||
m.hop = { vx: 0, vy: 0 };
|
||||
hopOn(round, m, dt);
|
||||
continue;
|
||||
}
|
||||
if (MOVERS[m.kind]) {
|
||||
MOVERS[m.kind](round, m, ms, KIT);
|
||||
continue;
|
||||
}
|
||||
const dx = you.x - m.x;
|
||||
const toward = towardYou(round, m);
|
||||
if (ZOMBIES.has(m.kind)) {
|
||||
if (m.kind === "runner" && !m.warned && m.x > round.camX - RUNNER_WARN && m.x < round.camX + FIELD_W + RUNNER_WARN) {
|
||||
m.warned = true;
|
||||
round.events.push({ type: "runner", x: clamp(m.x, round.camX + 3, round.camX + FIELD_W - 3), y: m.y + m.h, side: Math.sign(m.x - you.x) || 1 });
|
||||
}
|
||||
if (m.rise > 0) {
|
||||
m.rise = Math.max(0, m.rise - ms);
|
||||
continue;
|
||||
}
|
||||
const near = Math.abs(dx) < LURCH_RANGE && Math.abs(you.y - m.y) < 6;
|
||||
walk(round, m, toward, (near ? MONSTERS[m.kind].lurch : MONSTERS[m.kind].speed) * pace, dt);
|
||||
m.lurching = near;
|
||||
} else if (m.kind === "crawler" || m.kind === "seed") {
|
||||
if (m.rise > 0) {
|
||||
m.rise = Math.max(0, m.rise - ms);
|
||||
continue;
|
||||
}
|
||||
if (m.kind === "seed" && m.vy !== 0) {
|
||||
// Flung out of the Gourd: in the air till it lands.
|
||||
m.vy -= GRAVITY * dt;
|
||||
const py = m.y;
|
||||
const nx = clamp(m.x + m.vx * dt, round.lockX >= 0 ? round.lockX + 2 : 2, spec.length - 2);
|
||||
m.x = nx;
|
||||
m.y += m.vy * dt;
|
||||
const f = m.vy < 0 ? landing(round, m.x, py, m.y, -1) : null;
|
||||
if (f) {
|
||||
m.y = f.y;
|
||||
m.vy = 0;
|
||||
m.vx = 0;
|
||||
// A moment to find its feet before it runs at you.
|
||||
m.rise = SEED_LAND_MS;
|
||||
}
|
||||
if (m.y < PIT_Y) m.dead = true;
|
||||
continue;
|
||||
}
|
||||
if (m.kind === "seed" && seedJump(round, m, ms)) continue;
|
||||
walk(round, m, toward, MONSTERS[m.kind].speed * pace, dt);
|
||||
} else if (m.kind === "bat") {
|
||||
if (!m.awake) {
|
||||
if (Math.abs(dx) < BAT_NEAR) {
|
||||
m.awake = true;
|
||||
round.events.push({ type: "bat", x: m.x, y: m.y });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Swoops: level passes at your chest, turning BAT_TURN past you and
|
||||
// climbing a little before it comes back down for the next.
|
||||
const speed = MONSTERS.bat.speed * pace;
|
||||
if (!m.pass) m.pass = toward;
|
||||
const ahead = (m.x - you.x) * m.pass;
|
||||
if (ahead > BAT_TURN) {
|
||||
m.pass = -m.pass;
|
||||
m.climb = 300;
|
||||
}
|
||||
m.climb = Math.max(0, (m.climb || 0) - ms);
|
||||
const ty = m.climb > 0 ? you.y + 12 : you.y + SHOT_Y - MONSTERS.bat.h / 2;
|
||||
// Once close it holds its height: it never drops onto your head.
|
||||
const close = Math.abs(dx) <= 9 && m.climb <= 0;
|
||||
const steer = close ? 0 : clamp((ty - m.y) * 5, -BAT_STEER, BAT_STEER);
|
||||
m.vx = clamp(m.vx + m.pass * BAT_STEER * 2 * dt, -speed, speed);
|
||||
m.vy = clamp(m.vy + (steer - m.vy) * Math.min(1, (close ? 20 : 6) * dt), -speed * 0.8, speed * 0.8);
|
||||
m.x += m.vx * dt;
|
||||
m.y = Math.max(groundAt(spec, m.x) + 0.6, Math.min(CHANDELIER_Y, m.y + (m.vy + Math.sin(m.t / 140) * 1.5) * dt));
|
||||
m.dir = Math.sign(m.vx) || m.dir;
|
||||
} else if (m.kind === "ghost") {
|
||||
const speed = MONSTERS.ghost.speed * pace;
|
||||
const ty = you.y + 1;
|
||||
const d = Math.hypot(dx, ty - m.y) || 1;
|
||||
m.x += (dx / d) * speed * dt;
|
||||
m.y += ((ty - m.y) / d) * speed * dt;
|
||||
m.dir = toward;
|
||||
} else if (m.kind === "hound") moveHound(round, m, ms, toward);
|
||||
else if (m.kind === "spider") moveSpider(round, m, ms, toward);
|
||||
else if (m.kind === "huntsman") moveHuntsman(round, m, ms, toward);
|
||||
else if (m.kind === "wraith") moveWraith(round, m, ms);
|
||||
else if (m.kind === "spitter") {
|
||||
m.dir = toward;
|
||||
if (m.windup > 0) {
|
||||
m.windup = Math.max(0, m.windup - ms);
|
||||
if (!m.windup) throwBone(round, m.x + m.dir * 1.8, m.y + m.h * 0.7, 0.9 + random() * 0.2, "acid", m.kind);
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(dx) > SPIT_KEEP) walk(round, m, toward, MONSTERS.spitter.speed * pace, dt);
|
||||
const inView = m.x > round.camX - 2 && m.x < round.camX + FIELD_W + 2;
|
||||
if (!inView || Math.abs(dx) > SPIT_RANGE || Math.abs(dx) < SKEL_NEAR) continue;
|
||||
m.throwIn -= ms * pace;
|
||||
if (m.throwIn <= 0) {
|
||||
m.throwIn = SPIT_MS * (0.85 + random() * 0.3);
|
||||
m.windup = SPIT_WINDUP_MS;
|
||||
round.events.push({ type: "spit", kind: m.kind, x: m.x, y: m.y });
|
||||
}
|
||||
} else if (m.kind === "skeleton") {
|
||||
m.dir = toward;
|
||||
const inView = m.x > round.camX - 2 && m.x < round.camX + FIELD_W + 2;
|
||||
if (m.windup > 0) {
|
||||
m.windup = Math.max(0, m.windup - ms);
|
||||
if (!m.windup) throwBone(round, m.x + m.dir * 1.2, m.y + m.h * 0.85, 0.9 + random() * 0.2, "bone", m.kind);
|
||||
continue;
|
||||
}
|
||||
if (!inView || Math.abs(dx) > SKEL_RANGE || Math.abs(dx) < SKEL_NEAR) continue;
|
||||
m.throwIn -= ms * pace;
|
||||
if (m.throwIn <= 0) {
|
||||
m.throwIn = SKEL_MS * (0.85 + random() * 0.3);
|
||||
m.windup = SKEL_WINDUP_MS;
|
||||
round.events.push({ type: "windup", x: m.x, y: m.y });
|
||||
}
|
||||
}
|
||||
}
|
||||
skimOver(round);
|
||||
}
|
||||
|
||||
// What swoops, and when: a ducked Planny is passed overhead (see SWOOP_CLEAR).
|
||||
const SWOOPS = Object.freeze({ bat: () => true, wraith: (m) => m.act === "dive", ...fromPacks("swoops") });
|
||||
|
||||
// Holds each swooper near a ducked Planny on a ramp up over his head. A ramp by
|
||||
// distance, not a rate, so no dive is too fast for it.
|
||||
function skimOver(round) {
|
||||
const you = round.you;
|
||||
if (!you.ducking) return;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !SWOOPS[m.kind]?.(m)) continue;
|
||||
const short = Math.abs(m.x - you.x) - (HIT_W + m.w * 0.8) / 2;
|
||||
if (short > SWOOP_NEAR || m.y < you.y - 1) continue;
|
||||
m.y = Math.max(m.y, you.y + SWOOP_CLEAR - Math.max(0, short));
|
||||
}
|
||||
}
|
||||
|
||||
// The piles: walkers on the same floor in a run each within STACK_NEAR of
|
||||
// the next, STACK_MIN or more of them, climb over each other toward you
|
||||
// while you are above and near; every walker not in a climbing pile comes
|
||||
// back down. Returns the piles found, oldest walker first in each, for the
|
||||
// unit suite.
|
||||
export function piles(round, ms) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const floorOf = (m) => m.y - (m.lift || 0);
|
||||
const walkers = round.monsters.filter((m) => STACKERS.has(m.kind) && !m.dead && solid(m) && !m.vy && !m.hop && !m.scale);
|
||||
walkers.sort((a, b) => a.x - b.x);
|
||||
const found = [];
|
||||
let run = [];
|
||||
const close = () => {
|
||||
if (run.length >= STACK_MIN) found.push(run.slice().sort((a, b) => a.id - b.id));
|
||||
run = [];
|
||||
};
|
||||
for (const m of walkers) {
|
||||
const last = run[run.length - 1];
|
||||
if (last && (m.x - last.x > STACK_NEAR || Math.abs(floorOf(m) - floorOf(last)) > 0.5)) close();
|
||||
run.push(m);
|
||||
}
|
||||
close();
|
||||
const target = new Map();
|
||||
const pileOf = new Map();
|
||||
for (const pile of found) {
|
||||
const base = pile[0];
|
||||
const floor = floorOf(base);
|
||||
const need = you.y - floor;
|
||||
if (need < base.h * 0.5 || Math.abs(you.x - base.x) > STACK_REACH || you.out > 0) continue;
|
||||
let lift = 0;
|
||||
pile.forEach((m, i) => {
|
||||
if (i > 0 && lift + STACK_STEP * pile[i - 1].h <= need) lift += STACK_STEP * pile[i - 1].h;
|
||||
target.set(m, lift);
|
||||
pileOf.set(m, pile);
|
||||
});
|
||||
if (!round.climbSeen && pile.some((m) => m.lift > 1)) {
|
||||
round.climbSeen = true;
|
||||
round.events.push({ type: "climb", x: base.x, y: floor + lift });
|
||||
}
|
||||
}
|
||||
for (const m of round.monsters) {
|
||||
if (!STACKERS.has(m.kind) || m.dead) continue;
|
||||
const want = target.get(m) ?? 0;
|
||||
if (!m.lift && !want) continue;
|
||||
const floor = floorOf(m);
|
||||
m.lift = want > m.lift ? Math.min(want, m.lift + CLIMB_V * dt) : Math.max(want, m.lift - UNSTACK_V * dt);
|
||||
m.y = floor + m.lift;
|
||||
if (want > 0 && m.lift > 0) {
|
||||
// Up the pile: drawn in over the one at the bottom, a little to one side.
|
||||
const pile = pileOf.get(m);
|
||||
const sway = pile.indexOf(m) % 2 ? 0.35 : -0.35;
|
||||
m.x += (pile[0].x + sway - m.x) * Math.min(1, 6 * dt);
|
||||
m.dir = towardYou(round, m);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// A hellhound: prowls toward you, crouches growling once close on your
|
||||
// level, lunges in a low arc, and rests a moment after it lands. One that
|
||||
// lunges into a pit is gone.
|
||||
function moveHound(round, m, ms, toward) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const pace = spec.pace;
|
||||
if (m.act === "leap") {
|
||||
const py = m.y;
|
||||
const nx = m.x + m.vx * dt;
|
||||
if (!wallAt(spec, nx + Math.sign(m.vx) * m.w * 0.4, m.y + 0.05)) m.x = nx;
|
||||
m.vy = Math.max(-FALL_MAX, m.vy - GRAVITY * dt);
|
||||
m.y += m.vy * dt;
|
||||
const g = groundAt(spec, m.x);
|
||||
if (m.vy < 0 && py >= g && m.y <= g) Object.assign(m, { y: g, vx: 0, vy: 0, act: "rest", wait: HOUND_REST_MS });
|
||||
if (m.y < PIT_Y) m.dead = true;
|
||||
return;
|
||||
}
|
||||
if (m.wait > 0) {
|
||||
m.wait = Math.max(0, m.wait - ms * (m.act === "crouch" ? 1 : pace));
|
||||
if (m.wait > 0) return;
|
||||
if (m.act === "crouch") {
|
||||
Object.assign(m, { act: "leap", vx: m.dir * HOUND_LUNGE_VX * pace, vy: HOUND_LUNGE_V });
|
||||
round.events.push({ type: "lunge", x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Math.abs(you.x - m.x) < HOUND_RANGE && Math.abs(you.y - m.y) < 5) {
|
||||
Object.assign(m, { dir: toward, act: "crouch", wait: HOUND_CROUCH_MS });
|
||||
round.events.push({ type: "growl", x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
m.act = "prowl";
|
||||
walk(round, m, toward, MONSTERS.hound.speed * pace, dt);
|
||||
}
|
||||
|
||||
// A Huntsman: runs at you along the floor, crouches once close, and springs
|
||||
// at you, high and fast; one that springs into a pit is gone.
|
||||
function moveHuntsman(round, m, ms, toward) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const pace = spec.pace;
|
||||
if (m.act === "leap") {
|
||||
const py = m.y;
|
||||
const nx = m.x + m.vx * dt;
|
||||
if (!wallAt(spec, nx + Math.sign(m.vx) * m.w * 0.4, m.y + 0.05)) m.x = nx;
|
||||
m.vy = Math.max(-FALL_MAX, m.vy - GRAVITY * dt);
|
||||
m.y += m.vy * dt;
|
||||
const g = groundAt(spec, m.x);
|
||||
if (m.vy < 0 && py >= g && m.y <= g) Object.assign(m, { y: g, vx: 0, vy: 0, act: "rest", wait: HUNT_REST_MS });
|
||||
if (m.y < PIT_Y) m.dead = true;
|
||||
return;
|
||||
}
|
||||
if (m.wait > 0) {
|
||||
m.wait = Math.max(0, m.wait - ms * (m.act === "crouch" ? 1 : pace));
|
||||
if (m.wait > 0) return;
|
||||
if (m.act === "crouch") return springAt(round, m);
|
||||
}
|
||||
const up = you.y - m.y;
|
||||
if (Math.abs(you.x - m.x) < HUNT_RANGE && up > -3 && up < HUNT_HIGH && you.out <= 0) {
|
||||
Object.assign(m, { dir: toward, act: "crouch", wait: HUNT_CROUCH_MS });
|
||||
round.events.push({ type: "growl", kind: m.kind, x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
m.act = "prowl";
|
||||
walk(round, m, toward, MONSTERS.huntsman.speed * pace, dt);
|
||||
}
|
||||
|
||||
// A Huntsman's spring: up to HUNT_UP over your height, coming down on where
|
||||
// you are now.
|
||||
export function springAt(round, m) {
|
||||
const you = round.you;
|
||||
const rise = Math.max(0, you.y + 1 - m.y);
|
||||
const vy = Math.sqrt(2 * GRAVITY * (rise + HUNT_UP));
|
||||
const t = (vy + Math.sqrt(2 * GRAVITY * HUNT_UP)) / GRAVITY;
|
||||
const vx = clamp((you.x - m.x) / t, -HUNT_VX, HUNT_VX);
|
||||
Object.assign(m, { act: "leap", vx, vy, dir: Math.sign(vx) || m.dir, y: m.y + 0.01 });
|
||||
round.events.push({ type: "lunge", kind: m.kind, x: m.x, y: m.y });
|
||||
}
|
||||
|
||||
// A widow: hangs from the ceiling till you come near, drops on its thread
|
||||
// onto whatever is under it, then skitters after you.
|
||||
function moveSpider(round, m, ms, toward) {
|
||||
const you = round.you;
|
||||
if (m.act === "hang") {
|
||||
if (Math.abs(you.x - m.x) < SPIDER_NEAR && you.y < m.y - 4) {
|
||||
m.act = "drop";
|
||||
round.events.push({ type: "skitter", x: m.x, y: m.y });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m.act === "drop") {
|
||||
const py = m.y;
|
||||
m.y -= SPIDER_DROP_V * round.spec.pace * (ms / 1000);
|
||||
const f = landing(round, m.x, py, m.y, -1);
|
||||
if (f) {
|
||||
m.y = f.y;
|
||||
m.act = "walk";
|
||||
} else if (m.y < PIT_Y) m.dead = true;
|
||||
return;
|
||||
}
|
||||
walk(round, m, toward, MONSTERS.spider.speed * round.spec.pace, ms / 1000);
|
||||
}
|
||||
|
||||
// A wraith: unseen till you come near, then hovers ahead of you, shrieks,
|
||||
// dives straight at where your chest was and on past, and climbs back to
|
||||
// hover again. Walls never stop it; the floor turns it.
|
||||
function moveWraith(round, m, ms) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const pace = spec.pace;
|
||||
if (m.act === "idle") {
|
||||
if (Math.abs(you.x - m.x) < WRAITH_NEAR) {
|
||||
Object.assign(m, { act: "hover", wait: WRAITH_HOVER_MS * 0.6 });
|
||||
round.events.push({ type: "wraith", x: m.x, y: m.y });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m.act === "hover" || m.act === "rise") {
|
||||
const side = Math.sign(m.x - you.x) || 1;
|
||||
const tx = you.x + side * WRAITH_KEEP;
|
||||
const ty = Math.min(m.home, you.y + WRAITH_ABOVE) + Math.sin(m.t / 400) * 1.5;
|
||||
const step = MONSTERS.wraith.speed * pace * (m.act === "rise" ? 1.8 : 1) * dt;
|
||||
m.x += clamp(tx - m.x, -step * 3, step * 3);
|
||||
m.y += clamp(ty - m.y, -step, step);
|
||||
m.dir = -side;
|
||||
if (m.act === "rise") {
|
||||
if (Math.abs(ty - m.y) < 1.5) Object.assign(m, { act: "hover", wait: WRAITH_HOVER_MS });
|
||||
return;
|
||||
}
|
||||
m.wait -= ms * pace;
|
||||
const inView = m.x > round.camX + 2 && m.x < round.camX + FIELD_W - 2;
|
||||
if (m.wait <= 0 && inView) {
|
||||
Object.assign(m, { act: "wind", wait: WRAITH_WIND_MS });
|
||||
round.events.push({ type: "shriek", x: m.x, y: m.y });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m.act === "wind") {
|
||||
m.wait -= ms;
|
||||
if (m.wait > 0) return;
|
||||
const tx = you.x - m.x;
|
||||
const ty = you.y + (YOU_H - m.h) / 2 - m.y;
|
||||
const d = Math.hypot(tx, ty) || 1;
|
||||
Object.assign(m, { act: "dive", vx: (tx / d) * WRAITH_DIVE_V * pace, vy: (ty / d) * WRAITH_DIVE_V * pace, left: d + WRAITH_PAST, dir: Math.sign(tx) || m.dir });
|
||||
round.events.push({ type: "dive", x: m.x, y: m.y });
|
||||
return;
|
||||
}
|
||||
m.x += m.vx * dt;
|
||||
m.y += m.vy * dt;
|
||||
m.left -= Math.hypot(m.vx, m.vy) * dt;
|
||||
const floor = groundAt(spec, m.x);
|
||||
if (floor > -Infinity && m.y < floor + 0.3) {
|
||||
m.y = floor + 0.3;
|
||||
m.vy = Math.max(0, m.vy);
|
||||
}
|
||||
if (m.left <= 0) m.act = "rise";
|
||||
}
|
||||
|
||||
// One slice of the thrown bones and acid, the puddles and the shockwaves.
|
||||
export function moveMissiles(round, ms) {
|
||||
const dt = ms / 1000;
|
||||
const spec = round.spec;
|
||||
let n = 0;
|
||||
for (const b of round.bones) {
|
||||
b.vy -= BONE_G * dt;
|
||||
b.x += b.vx * dt;
|
||||
b.y += b.vy * dt;
|
||||
b.spin += dt * 12 * (Math.sign(b.vx) || 1);
|
||||
b.life -= ms;
|
||||
const g = groundAt(spec, b.x);
|
||||
if (b.vy < 0 && b.y <= g) {
|
||||
if (b.kind === "acid") {
|
||||
round.puddles.push({ id: ++serial, x: b.x, y: g, life: PUDDLE_MS });
|
||||
round.events.push({ type: "splash", x: b.x, y: g });
|
||||
} else if (!(LANDS[b.kind] && LANDS[b.kind](round, b, g, KIT))) round.events.push({ type: "clatter", x: b.x, y: g });
|
||||
continue;
|
||||
}
|
||||
if (b.life > 0 && b.y > PIT_Y && b.x > round.camX - 20 && b.x < round.camX + FIELD_W + 20) round.bones[n++] = b;
|
||||
}
|
||||
round.bones.length = n;
|
||||
n = 0;
|
||||
for (const p of round.puddles) if ((p.life -= ms) > 0) round.puddles[n++] = p;
|
||||
round.puddles.length = n;
|
||||
n = 0;
|
||||
for (const w of round.waves) {
|
||||
w.x += w.dir * WAVE_SPEED * spec.pace * dt;
|
||||
w.life -= ms;
|
||||
if (w.life > 0 && groundAt(spec, w.x) === w.y && w.x > leftEdge(round) - 2 && w.x < spec.length) round.waves[n++] = w;
|
||||
}
|
||||
round.waves.length = n;
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's ground and Planny: what stands where (surfaces, shelves and landing on them), and how Planny runs, jumps and falls.
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { iceRun } from "../stages/frozen/ghoul-frozen.js";
|
||||
import { SLOW_SHARE } from "../stages/graveyard/ghoul-graveyard.js";
|
||||
import { COYOTE_MS, FROZEN, PLATFORMS, EDGE, FALL_MAX, GRAVITY, JUMP_V, RUN_SPEED, STEP_UP, WATER_JUMP, WATER_SPEED, clamp, mudJump, mudSpeed } from "./ghoul-tables.js";
|
||||
|
||||
/* ----------------------------------------------------------- surfaces */
|
||||
|
||||
// The top of the ground at `x`, or -Infinity over a pit. Pieces are
|
||||
// [x0, x1); the last one takes its end too.
|
||||
export function groundAt(spec, x) {
|
||||
const g = spec.ground;
|
||||
for (let i = 0; i < g.length; i++) {
|
||||
const [x0, x1, y] = g[i];
|
||||
if (x >= x0 && (x < x1 || (i === g.length - 1 && x <= x1))) return y;
|
||||
}
|
||||
return -Infinity;
|
||||
}
|
||||
|
||||
// Whether shelf `i` is there (a crumbled board is not, for a while).
|
||||
export const shelfThere = (round, i) => !(round.down[i] > 0);
|
||||
|
||||
// What something walking at height `y` stands on at `x`: the highest
|
||||
// surface (the ground or a shelf there) within STEP_UP of `y` either way,
|
||||
// as { y, shelf } (shelf -1 for the ground), or null. `skip` is a shelf to
|
||||
// ignore (one being dropped through).
|
||||
export function footing(round, x, y, skip = -1) {
|
||||
const spec = round.spec;
|
||||
let best = null;
|
||||
const g = groundAt(spec, x);
|
||||
if (g >= y - STEP_UP && g <= y + STEP_UP) best = { y: g, shelf: -1 };
|
||||
spec.shelves.forEach(([x0, x1, top], i) => {
|
||||
if (i === skip || !shelfThere(round, i) || x < x0 || x > x1) return;
|
||||
if (top >= y - STEP_UP && top <= y + STEP_UP && (!best || top > best.y)) best = { y: top, shelf: i };
|
||||
});
|
||||
return best;
|
||||
}
|
||||
|
||||
// The surface a fall from (x, py) to (x, y) lands on: the highest one whose
|
||||
// top it crossed going down, as { y, shelf }, or null.
|
||||
export function landing(round, x, py, y, skip) {
|
||||
const spec = round.spec;
|
||||
let best = null;
|
||||
const g = groundAt(spec, x);
|
||||
if (py >= g - 0.05 && y <= g) best = { y: g, shelf: -1 };
|
||||
spec.shelves.forEach(([x0, x1, top], i) => {
|
||||
if (i === skip || !shelfThere(round, i) || x < x0 || x > x1) return;
|
||||
if (py >= top - 0.05 && y <= top && (!best || top > best.y)) best = { y: top, shelf: i };
|
||||
});
|
||||
return best;
|
||||
}
|
||||
|
||||
// Like footing() and landing() for Planny alone: a monster the pack says is a
|
||||
// floor just now (a parked gurney) counts as one more surface, its top.
|
||||
function standing(round, x, y) {
|
||||
let best = footing(round, x, y);
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !PLATFORMS[m.kind] || !PLATFORMS[m.kind](m) || Math.abs(x - m.x) > m.w / 2) continue;
|
||||
const top = m.y + m.h;
|
||||
if (top >= y - STEP_UP && top <= y + STEP_UP && (!best || top > best.y)) best = { y: top, shelf: -1 };
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
function landOn(round, x, py, y, skip) {
|
||||
let best = landing(round, x, py, y, skip);
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !PLATFORMS[m.kind] || !PLATFORMS[m.kind](m) || Math.abs(x - m.x) > m.w / 2) continue;
|
||||
const top = m.y + m.h;
|
||||
if (py >= top - 0.05 && y <= top && (!best || top > best.y)) best = { y: top, shelf: -1 };
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
// Whether the ground at `x` stands above `y`: a wall to anything there.
|
||||
export const wallAt = (spec, x, y) => groundAt(spec, x) > y;
|
||||
|
||||
// How far left and right Planny may go: the room, or the arena once locked.
|
||||
export const leftEdge = (round) => Math.max(1.5, round.lockX >= 0 ? round.lockX + 1.5 : 1.5);
|
||||
export const rightEdge = (round) => round.spec.length - 1.5;
|
||||
|
||||
/* -------------------------------------------------------------- Planny */
|
||||
|
||||
export function makeYou(x, y) {
|
||||
return { x, y, vx: 0, vy: 0, state: "run", shelf: -1, face: 1, coyote: 0, drop: -1, cuttable: false, airMs: 0, out: 0, outKind: "", safeMs: 0, garlic: false, hat: false, aliveMs: 0, runMs: 0, fireFx: 0, flapped: false, flingMs: 0, flingVx: 0, heldMs: 0, wet: false, mud: false, mudMs: 0, belt: 0, dimMs: 0, dimBy: 0, slide: 0, glide: false, onIce: false };
|
||||
}
|
||||
|
||||
// The conveyor belts (a room's `belts`, the Funhouse's) push him along the floor: the speed of the one he stands on, or 0.
|
||||
const beltAt = (spec, you) => {
|
||||
if (!spec.belts || !spec.belts.length || you.state !== "run" || you.shelf >= 0 || you.y > groundAt(spec, you.x) + 0.01) return 0;
|
||||
const b = spec.belts.find(([x0, x1]) => you.x >= x0 && you.x <= x1);
|
||||
return b ? b[2] : 0;
|
||||
};
|
||||
|
||||
// Whether Planny stands on the floor in one of the room's water spans.
|
||||
const wetAt = (spec, you) => Boolean(spec.water && spec.water.length) && you.state === "run" && you.shelf < 0 && you.y <= groundAt(spec, you.x) + 0.01 && spec.water.some(([x0, x1]) => you.x >= x0 && you.x <= x1);
|
||||
|
||||
// Whether Planny stands on the floor in one of the room's mud spans.
|
||||
const mudAt = (spec, you) => Boolean(spec.mud && spec.mud.length) && you.state === "run" && you.shelf < 0 && you.y <= groundAt(spec, you.x) + 0.01 && spec.mud.some(([x0, x1]) => you.x >= x0 && you.x <= x1);
|
||||
|
||||
// Leaves the ground at JUMP_V, or bounces off a stomp at STOMP_V.
|
||||
export function jump(round, v = JUMP_V) {
|
||||
const you = round.you;
|
||||
if (you.out > 0) return false;
|
||||
you.vy = v === JUMP_V ? JUMP_V * (you.wet ? WATER_JUMP : 1) * (you.mud ? mudJump(you.mudMs) : 1) : v;
|
||||
you.state = "air";
|
||||
you.ducking = false;
|
||||
you.shelf = -1;
|
||||
you.coyote = 0;
|
||||
you.drop = -1;
|
||||
// Only a jump from a press is cut short by letting up go, and only once it
|
||||
// has risen CUT_AFTER_MS.
|
||||
you.cuttable = v === JUMP_V;
|
||||
you.airMs = 0;
|
||||
if (v === JUMP_V) round.events.push({ type: "jump", x: you.x, y: you.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
// One slice of your moving: running along the ground or a shelf (walking a
|
||||
// step, or off an edge into a fall), dropping through a shelf with down,
|
||||
// ducking with down on the ground (a direction held runs instead), or
|
||||
// flying, blocked by any wall in the way.
|
||||
export function moveYou(round, ms) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
// Frozen by the bell, held by an orderly or thrown: no key does anything.
|
||||
const flung = you.flingMs > 0;
|
||||
const inp = round.stunMs > 0 || you.heldMs > 0 || flung ? FROZEN : round.input;
|
||||
const spec = round.spec;
|
||||
const dir = (inp.right ? 1 : 0) - (inp.left ? 1 : 0);
|
||||
if (dir) you.face = dir;
|
||||
you.runMs = dir && you.state === "run" ? you.runMs + ms : 0;
|
||||
// A mourner's wail leaves you running at SLOW_SHARE of your speed a while.
|
||||
// Knee-deep water (a room's `water` spans): slower on the floor in it.
|
||||
you.wet = wetAt(spec, you);
|
||||
// Sinking mud: it grabs harder the longer he stands in it, and lets go on
|
||||
// dry floor or in the air. Stilt Boots wade free of it (ghoul-powers.js).
|
||||
you.mud = mudAt(spec, you) && !(round.effects.boots > 0);
|
||||
you.mudMs = you.mud ? you.mudMs + ms : Math.max(0, you.mudMs - ms);
|
||||
const speed = RUN_SPEED * (you.slowMs > 0 ? SLOW_SHARE : 1) * (you.wet ? WATER_SPEED : 1) * (you.mud ? mudSpeed(you.mudMs) : 1);
|
||||
you.belt = beltAt(spec, you);
|
||||
// Slippery ice (a room's `ice`, the Frozen Lake's): his run eases and slides (ghoul-frozen.js).
|
||||
const run = spec.ice && spec.ice.length ? iceRun(round, dir, speed, dt, you.state === "run" && you.shelf < 0 && you.y <= groundAt(spec, you.x) + 0.01) : dir * speed;
|
||||
const want = you.x + (run + you.belt) * dt;
|
||||
let nx = clamp(want, leftEdge(round), rightEdge(round));
|
||||
if (nx !== want) you.slide = 0;
|
||||
if (you.state === "run") {
|
||||
if (you.shelf >= 0 && !shelfThere(round, you.shelf)) return fall(you, 0);
|
||||
if (inp.down && you.shelf >= 0 && !dir) {
|
||||
you.drop = you.shelf;
|
||||
you.ducking = false;
|
||||
return fall(you, 0);
|
||||
}
|
||||
const duck = Boolean(inp.down) && !dir && you.shelf < 0;
|
||||
if (duck && !you.ducking) round.events.push({ type: "duck", x: you.x, y: you.y });
|
||||
you.ducking = duck;
|
||||
const way = Math.sign(nx - you.x);
|
||||
if (way && wallAt(spec, nx + way * EDGE, you.y + STEP_UP)) {
|
||||
nx = you.x;
|
||||
you.slide = 0;
|
||||
}
|
||||
const f = standing(round, nx, you.y);
|
||||
you.x = nx;
|
||||
if (f) {
|
||||
you.y = f.y;
|
||||
you.shelf = f.shelf;
|
||||
return;
|
||||
}
|
||||
return fall(you, COYOTE_MS);
|
||||
}
|
||||
// In the air: no wall passed, gravity, then a landing.
|
||||
if (flung) nx = clamp(you.x + you.flingVx * dt, leftEdge(round), rightEdge(round));
|
||||
const push = flung ? Math.sign(you.flingVx) : dir || Math.sign(nx - you.x);
|
||||
if (push && wallAt(spec, nx + push * EDGE, you.y + 0.05)) {
|
||||
nx = you.x;
|
||||
you.slide = 0;
|
||||
}
|
||||
you.coyote = Math.max(0, you.coyote - ms);
|
||||
you.vy = Math.max(-FALL_MAX, you.vy - GRAVITY * dt);
|
||||
const py = you.y;
|
||||
you.x = nx;
|
||||
you.y += you.vy * dt;
|
||||
if (you.drop >= 0 && you.y < spec.shelves[you.drop][2] - 1) you.drop = -1;
|
||||
if (you.vy > 0) return;
|
||||
const f = landOn(round, you.x, py, you.y, you.drop);
|
||||
if (!f) return;
|
||||
you.y = f.y;
|
||||
you.vy = 0;
|
||||
you.flingMs = 0;
|
||||
you.state = "run";
|
||||
you.shelf = f.shelf;
|
||||
you.drop = -1;
|
||||
you.cuttable = false;
|
||||
you.flapped = false;
|
||||
round.events.push({ type: "land", x: you.x, y: you.y });
|
||||
}
|
||||
|
||||
function fall(you, coyote) {
|
||||
you.state = "air";
|
||||
you.ducking = false;
|
||||
you.vy = 0;
|
||||
you.shelf = -1;
|
||||
you.coyote = coyote;
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's play loop: the kits it hands its packs and ghoul-run.js (KIT, RUN_KIT), the blaster and bolts, hits, stomps and timers, one slice of play, and advance().
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { armBossDamage, fillBag } from "../arms/ghoul-arms.js";
|
||||
import { bossIntroFor } from "../story/ghoul-boss-intros.js";
|
||||
import { introFor } from "../story/ghoul-intros.js";
|
||||
import { stepStory } from "../story/ghoul-story.js";
|
||||
import { BONUS_READY_MS, endBonus as endBonusWith, makeBonus } from "./ghoul-bonus.js";
|
||||
import { START_DICE, askStep, giveDiceGift, markRest, reviveSpot, rollDice } from "./ghoul-dice.js";
|
||||
import { FLAP_CLEAR, TIMED, pickPower, pickups, powerHere, retryMercy } from "./ghoul-powers.js";
|
||||
import { CHANDELIER_Y, FIELD_H, FIELD_W, ROOMS, STAGES, stageById } from "./ghoul-rooms.js";
|
||||
import { camera as cameraWith, clearRoom as clearRoomWith, horde as hordeWith, hurry as hurryWith, lockArena, newRound as newRoundWith, nextRoom as nextRoomWith, onCard, pickStage as pickStageWith, respawn as respawnWith, setupRoom as setupRoomWith, spawners as spawnersWith, stagesLeft as stagesLeftWith, steerSelect as steerSelectWith, stepIntro as stepIntroWith, takeIntro as takeIntroWith, takeSelect as takeSelectWith } from "./ghoul-run.js";
|
||||
import { pressFire as pressFireWith } from "../arms/ghoul-arms.js";
|
||||
import { KIT } from "./ghoul-kit.js";
|
||||
import { DICE_KIT, POWER_KIT, arenaMax, arenaMin, award, dropItem, hurt, hurtBoss, lose, makeBoss, moveBoss, moveHazards, struck } from "./ghoul-fight.js";
|
||||
import { CAUSES, CUT, HARMLESS, HORDE_WITH, PLACES, RIDES, SHOTS, STONE, TARGETS, TICKS, WEAK, guarded, moveMissiles, moveMonsters, piles, roused, solid, spawnMonster, throwBone, towardYou, walk } from "./ghoul-monsters.js";
|
||||
import { footing, groundAt, jump, makeYou, moveYou, shelfThere, wallAt } from "./ghoul-planny.js";
|
||||
import { AIM_DY, AIM_MAX, AIM_RANGE, ARMS_UP, BANNER_REACH, BONE_G, BONE_POINTS, BONE_R, BONUS_START, BONUS_STEP, BOSSES, BOSS_LOCK, CAM_AT, CAM_EASE, CAM_LEAD, CHANDELIER_NEAR, CHANDELIER_SHAKE_MS, CHANDELIER_W, CLEAR_MS, COOL_DELAY_MS, COOL_RATE, CRAWL_NEAR, CRUMBLE_BACK_MS, CRUMBLE_MS, CUT_AFTER_MS, CUT_V, DARK_BEHIND, DARK_CHANCE, DOOR_CLEAR, DOOR_REACH, DUCK_H, DUCK_SHOT_Y, EMERGE_MS, FALL_MAX, FLAWLESS_POINTS, GHOST_HIDE_MS, GHOST_SHOW_MS, GRAVITY, HEAD_BONK, HEAD_SHARE, HEAT_MAX, HIT_H, HIT_W, HORDE_ROOM, HURRY_MS, JUMP_V, MAX_MONSTERS, MONSTERS, OFFER_N, PICK_HOLD_MS, PIT_Y, PUDDLE_W, RAPID_MS, READY_MS, ROOM_POINTS, SAFE_MS, SHOT_R, SHOT_RANGE, SHOT_SPEED, SHOT_Y, SKULL_FROM, SLICE_MS, SPAWN_AHEAD, SPIDER_Y, SPREAD_ANGLE, START_LIVES, STOMP_DAMAGE, STOMP_V, TIME_WARN_MS, WAVE_H, WING_SAVE_ARC, WING_SAVE_MS, YOU_H, clamp, fireGap, reaching, roomFor, seeded, timeFor, variant } from "./ghoul-tables.js";
|
||||
|
||||
/* ---------------------------------------------------------------- run */
|
||||
|
||||
// The double tap, for the tests (the game calls it from key()).
|
||||
export const pressFire = (round) => pressFireWith(round, KIT);
|
||||
|
||||
// What ghoul-run.js needs from here: the room and stage tables, the timings
|
||||
// and the helpers that set a room up, handed to its rules the way KIT is
|
||||
// handed to a stage pack.
|
||||
const RUN_KIT = Object.freeze({
|
||||
ROOMS, STAGES, stageById, FIELD_W, CHANDELIER_Y, START_LIVES, START_DICE, TIMED, DARK_CHANCE, BONUS_START, HURRY_MS, OFFER_N, PICK_HOLD_MS,
|
||||
READY_MS, BONUS_READY_MS, makeBonus, endBonus: (round, won) => endBonusWith(round, won, { award, ROOM_POINTS }), SAFE_MS, CLEAR_MS, BOSS_LOCK, ROOM_POINTS, FLAWLESS_POINTS, CAM_AT, CAM_LEAD, CAM_EASE,
|
||||
SPAWN_AHEAD, DOOR_CLEAR, EMERGE_MS, CRAWL_NEAR, SPIDER_Y, GHOST_SHOW_MS, GHOST_HIDE_MS, DARK_BEHIND, MAX_MONSTERS, HORDE_ROOM, HORDE_WITH, MONSTERS,
|
||||
roomFor, seeded, powerHere, pickPower, makeYou, makeBoss, groundAt, timeFor, award, clamp, variant, spawnMonster, introFor, bossIntroFor,
|
||||
mercy: (round) => retryMercy(round, POWER_KIT),
|
||||
diceGift: (round) => giveDiceGift(round, DICE_KIT.give),
|
||||
place: (round) => PLACES.forEach((f) => f(round, KIT)),
|
||||
});
|
||||
|
||||
export const newRound = (seed = (Math.random() * 2 ** 31) >>> 0) => newRoundWith(seed, RUN_KIT);
|
||||
// Puts the round in a room by id, outside any stage's order (the suites reach a room no stage lists this way).
|
||||
export const setupRoom = (round, id) => setupRoomWith(round, id, RUN_KIT);
|
||||
export const stagesLeft = (round) => stagesLeftWith(round, RUN_KIT);
|
||||
export const pickStage = (round, i = round.pick) => pickStageWith(round, i, RUN_KIT);
|
||||
export const steerSelect = (round, dStage, dRoom) => steerSelectWith(round, dStage, dRoom, RUN_KIT);
|
||||
export const takeSelect = (round) => {
|
||||
if (!takeSelectWith(round, RUN_KIT)) return false;
|
||||
fillBag(round, round.stage);
|
||||
return true;
|
||||
};
|
||||
const nextRoom = (round, random) => nextRoomWith(round, random, RUN_KIT);
|
||||
// A stage's intro card moves on (ghoul-run.js): a move key, fire or a click.
|
||||
export const takeIntro = (round) => takeIntroWith(round, RUN_KIT);
|
||||
const camera = (round, ms) => cameraWith(round, ms, RUN_KIT);
|
||||
const respawn = (round) => respawnWith(round, RUN_KIT);
|
||||
const clearRoom = (round) => clearRoomWith(round, RUN_KIT);
|
||||
const spawners = (round, ms, random) => spawnersWith(round, ms, random, RUN_KIT);
|
||||
const horde = (round, ms, random) => hordeWith(round, ms, random, RUN_KIT);
|
||||
const hurry = (round, ms, random) => hurryWith(round, ms, random, RUN_KIT);
|
||||
|
||||
// The tilt for your next bolt: toward the nearest monster (or bone) ahead
|
||||
// whose middle is near your chest's height (a wraith anywhere the tilt
|
||||
// reaches), never more than AIM_MAX; 0 for none.
|
||||
export function aimAt(round) {
|
||||
const you = round.you;
|
||||
let best = AIM_RANGE;
|
||||
let aim = 0;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !roused(m)) continue;
|
||||
const dx = (m.x - you.x) * you.face;
|
||||
const dy = m.y + m.h / 2 - (you.y + shotY(you));
|
||||
const reach = m.kind === "wraith" ? Math.max(AIM_DY, dx * Math.tan(AIM_MAX)) : AIM_DY;
|
||||
if (dx <= 0 || dx >= best || Math.abs(dy) > reach) continue;
|
||||
best = dx;
|
||||
aim = clamp(Math.atan2(dy, dx), -AIM_MAX, AIM_MAX);
|
||||
}
|
||||
for (const b of round.bones) {
|
||||
const dx = (b.x - you.x) * you.face;
|
||||
const dy = b.y - (you.y + shotY(you));
|
||||
if (b.dead || dx <= 0 || dx >= best || Math.abs(dy) > AIM_DY) continue;
|
||||
best = dx;
|
||||
aim = clamp(Math.atan2(dy, dx), -AIM_MAX, AIM_MAX);
|
||||
}
|
||||
return aim;
|
||||
}
|
||||
|
||||
// The blaster: while fire is held, a bolt (or three) every fireGap() of its
|
||||
// heat (RAPID_MS with Rapid fire), and while it is not, it cools.
|
||||
export function fire(round, ms) {
|
||||
round.fireMs = Math.max(0, round.fireMs - ms);
|
||||
const you = round.you;
|
||||
if (!round.input.fire || you.out > 0 || round.gallery || (round.runner && round.runner.id === "lantern")) {
|
||||
round.coolMs += ms;
|
||||
const cooling = Math.min(ms, round.coolMs - COOL_DELAY_MS);
|
||||
if (cooling > 0) round.heat = Math.max(0, round.heat - (COOL_RATE * cooling) / 1000);
|
||||
return;
|
||||
}
|
||||
round.coolMs = 0;
|
||||
if (round.fireMs > 0) return;
|
||||
if (round.effects.rapid > 0) round.fireMs = RAPID_MS;
|
||||
else {
|
||||
round.heat = Math.min(HEAT_MAX, round.heat + 1);
|
||||
round.fireMs = fireGap(round.heat);
|
||||
}
|
||||
const aim = aimAt(round);
|
||||
const angles = round.effects.spread > 0 ? [0, SPREAD_ANGLE, -SPREAD_ANGLE] : [0];
|
||||
for (const a of angles) round.shots.push({ x: you.x + you.face * 1.8, y: you.y + shotY(you), vx: Math.cos(a + aim) * SHOT_SPEED * you.face, vy: Math.sin(a + aim) * SHOT_SPEED, gone: 0 });
|
||||
you.fireFx = 90;
|
||||
round.stats.shots++;
|
||||
round.events.push({ type: "fire", x: you.x, y: you.y + shotY(you), face: you.face, spread: angles.length > 1 });
|
||||
}
|
||||
|
||||
// Whether a circle at (x, y) of radius r touches a box w by h standing at (bx, by).
|
||||
const touchBox = (x, y, r, bx, by, w, h) => {
|
||||
const cx = clamp(x, bx - w / 2, bx + w / 2);
|
||||
const cy = clamp(y, by, by + h);
|
||||
return Math.hypot(x - cx, y - cy) < r;
|
||||
};
|
||||
|
||||
// One slice of the bolts: each flies until it hits a monster, a bone, the
|
||||
// boss or a wall, or has gone SHOT_RANGE.
|
||||
function moveShots(round, ms, random) {
|
||||
const dt = ms / 1000;
|
||||
const spec = round.spec;
|
||||
let n = 0;
|
||||
for (const s of round.shots) {
|
||||
const step = Math.hypot(s.vx, s.vy) * dt;
|
||||
s.x += s.vx * dt;
|
||||
s.y += s.vy * dt;
|
||||
s.gone += step;
|
||||
let used = false;
|
||||
if (wallAt(spec, s.x, s.y)) {
|
||||
round.events.push({ type: "puff", x: s.x, y: s.y });
|
||||
continue;
|
||||
}
|
||||
// A silver bolt (or the Bone Saw's) goes on through every monster it hits, once each.
|
||||
const silver = round.effects.silver > 0 || round.effects.saw > 0;
|
||||
for (const m of round.monsters) {
|
||||
const stone = !m.dead && STONE[m.kind]?.(m);
|
||||
if (m.dead || !(stone || solid(m)) || (s.hit && s.hit.includes(m.id)) || !touchBox(s.x, s.y, SHOT_R, m.x, m.y, m.w, m.h)) continue;
|
||||
// Stone: a shot glances off, Holy Water breaks it.
|
||||
if (stone) {
|
||||
if (round.effects.holy > 0) hurt(round, m, 99, "holy", random);
|
||||
else round.events.push({ type: "glance", kind: m.kind, x: s.x, y: s.y });
|
||||
used = true;
|
||||
break;
|
||||
}
|
||||
const head = MONSTERS[m.kind].head && s.y > m.y + m.h * (1 - HEAD_SHARE);
|
||||
const cut = round.effects.shears > 0 && CUT.has(m.kind);
|
||||
const mult = SHOTS.reduce((d, f) => d * f(round, m, s, KIT, random), 1) * (s.dmg || 1);
|
||||
hurt(round, m, cut ? 99 : mult, cut ? "shears" : head ? "head" : "shot", random);
|
||||
if (silver || s.pierce) {
|
||||
s.hit = [...(s.hit || []), m.id];
|
||||
continue;
|
||||
}
|
||||
used = true;
|
||||
break;
|
||||
}
|
||||
if (!used) {
|
||||
for (const b of round.bones) {
|
||||
if (b.dead || Math.hypot(b.x - s.x, b.y - s.y) > BONE_R + SHOT_R) continue;
|
||||
b.dead = true;
|
||||
award(round, BONE_POINTS);
|
||||
round.events.push({ type: "bone", kind: b.kind, x: b.x, y: b.y, points: BONE_POINTS });
|
||||
// A thrown weapon breaks what it meets and flies on.
|
||||
used = !s.arm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!used) used = TARGETS.some((f) => f(round, s, KIT));
|
||||
const boss = round.boss;
|
||||
if (!used && boss && boss.state === "fight" && touchBox(s.x, s.y, SHOT_R, boss.x, boss.y, boss.w, boss.h) && guarded(boss)) {
|
||||
round.events.push({ type: "bossBlock", kind: boss.kind, x: s.x, y: s.y });
|
||||
used = true;
|
||||
}
|
||||
if (!used && boss && boss.state === "fight" && touchBox(s.x, s.y, SHOT_R, boss.x, boss.y, boss.w, boss.h)) {
|
||||
const skull = boss.kind === "bones" && !boss.headless && s.y > boss.y + boss.h * SKULL_FROM;
|
||||
const weak = WEAK[boss.kind] ? WEAK[boss.kind](boss, s, round, KIT) : 1;
|
||||
const dmg = (skull ? 2 : 1) * weak;
|
||||
hurtBoss(round, s.arm ? armBossDamage(round, dmg * s.bossDmg, KIT) : dmg, weak > 1 ? "weak" : skull ? "head" : "shot");
|
||||
used = true;
|
||||
}
|
||||
if (!used && s.gone < (s.range || SHOT_RANGE) && (s.free || (s.x > round.camX - 4 && s.x < round.camX + FIELD_W + 4))) round.shots[n++] = s;
|
||||
}
|
||||
round.shots.length = n;
|
||||
if (round.bones.some((b) => b.dead)) round.bones = round.bones.filter((b) => !b.dead);
|
||||
if (round.monsters.some((m) => m.dead)) round.monsters = round.monsters.filter((m) => !m.dead);
|
||||
}
|
||||
|
||||
// Your feet came down on a monster's head (or the boss's): it is stomped
|
||||
// and you bounce. A ghost cannot be stomped. Returns true for a stomp.
|
||||
export function stomps(round, py, random) {
|
||||
const you = round.you;
|
||||
if (you.vy >= 0 && !(you.state === "run" && py > you.y)) return false;
|
||||
if (you.out > 0) return false;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !MONSTERS[m.kind].stomp || !solid(m)) continue;
|
||||
const top = m.y + m.h;
|
||||
if (py < top - 0.9 || you.y > top + 0.01 || Math.abs(you.x - m.x) > (reaching(m) ? HEAD_BONK : (HIT_W + m.w) / 2)) continue;
|
||||
hurt(round, m, MONSTERS[m.kind].stompDamage ?? 99, "stomp", random);
|
||||
round.events.push({ type: "stomp", x: m.x, y: top });
|
||||
jump(round, round.input.up ? JUMP_V : STOMP_V);
|
||||
round.monsters = round.monsters.filter((q) => !q.dead);
|
||||
return true;
|
||||
}
|
||||
const b = round.boss;
|
||||
if (b && b.state === "fight") {
|
||||
const top = b.y + b.h;
|
||||
if (py >= top - 1.2 && you.y <= top + 0.01 && Math.abs(you.x - b.x) <= (HIT_W + b.w) / 2) {
|
||||
if (guarded(b)) round.events.push({ type: "bossBlock", kind: b.kind, x: you.x, y: top });
|
||||
else hurtBoss(round, STOMP_DAMAGE, "stomp");
|
||||
round.events.push({ type: "stomp", x: b.x, y: top });
|
||||
jump(round, STOMP_V + 8);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// How tall you are to what hits you, and where your bolts fly from.
|
||||
const hitH = (you) => (you.ducking ? DUCK_H : HIT_H);
|
||||
const shotY = (you) => (you.ducking ? DUCK_SHOT_Y : SHOT_Y);
|
||||
|
||||
// Whether a box (the monster's, shrunk a little) overlaps your hit box.
|
||||
const boxHits = (you, x, y, w, h) => Math.abs(you.x - x) < (HIT_W + w * 0.8) / 2 && you.y < y + h * 0.9 && you.y + hitH(you) > y + h * 0.1;
|
||||
|
||||
// Whether a climbing walker's raised arms, ARMS_UP over its head either side
|
||||
// of it, reach you.
|
||||
const armsHit = (you, m) => {
|
||||
const dx = Math.abs(you.x - m.x);
|
||||
return reaching(m) && dx > HEAD_BONK && dx < (HIT_W + m.w * 0.8) / 2 && you.y < m.y + m.h + ARMS_UP && you.y + hitH(you) > m.y + m.h * 0.9;
|
||||
};
|
||||
|
||||
// The first thing touching you, unless you are safe for a moment.
|
||||
function hits(round) {
|
||||
const you = round.you;
|
||||
if (you.safeMs > 0 || you.out > 0) return;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !solid(m) || HARMLESS[m.kind]?.(m) || !(boxHits(you, m.x, m.y, m.w, m.h) || armsHit(you, m))) continue;
|
||||
struck(round, m.kind, m);
|
||||
return;
|
||||
}
|
||||
for (const b of round.bones) {
|
||||
if (!touchBox(b.x, b.y, BONE_R, you.x, you.y, HIT_W, hitH(you))) continue;
|
||||
b.dead = true;
|
||||
round.bones = round.bones.filter((q) => !q.dead);
|
||||
struck(round, b.cause || (b.kind === "acid" ? "acid" : b.kind === "stone" ? "stone" : "bone"));
|
||||
return;
|
||||
}
|
||||
for (const h of round.hazards) {
|
||||
if (!(h.live > 0) || Math.abs(you.x - h.x) >= (h.w + HIT_W) / 2 || you.y >= h.y + h.h || you.y + hitH(you) <= h.y) continue;
|
||||
struck(round, h.cause);
|
||||
return;
|
||||
}
|
||||
for (const p of round.puddles) {
|
||||
if (you.state !== "run" || you.y !== p.y || Math.abs(you.x - p.x) >= (PUDDLE_W + HIT_W) / 2 - 0.6) continue;
|
||||
struck(round, "acid");
|
||||
return;
|
||||
}
|
||||
for (const w of round.waves) {
|
||||
if (Math.abs(w.x - you.x) < 1.4 && you.y < w.y + WAVE_H) {
|
||||
struck(round, w.cause || "wave");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const b = round.boss;
|
||||
if (b && (b.state === "fight" || b.state === "intro") && boxHits(you, b.x, b.y, b.w, b.h)) struck(round, CAUSES[b.kind] ? CAUSES[b.kind](b) : b.kind);
|
||||
}
|
||||
|
||||
// The chandeliers: one shakes as you run under it, then drops and crushes
|
||||
// whatever is under it where it lands.
|
||||
function chandeliers(round, ms, random) {
|
||||
const dt = ms / 1000;
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
for (const c of round.falls) {
|
||||
if (c.state === "hang") {
|
||||
if (Math.abs(you.x - c.x) < CHANDELIER_NEAR && you.y < c.y - 6) {
|
||||
c.state = "shake";
|
||||
c.shake = CHANDELIER_SHAKE_MS;
|
||||
round.events.push({ type: "creak", x: c.x, y: c.y });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c.state === "shake") {
|
||||
c.shake -= ms;
|
||||
if (c.shake <= 0) c.state = "fall";
|
||||
continue;
|
||||
}
|
||||
if (c.state !== "fall") continue;
|
||||
c.vy -= GRAVITY * dt;
|
||||
c.y += c.vy * dt;
|
||||
const bottom = c.y - 2;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || Math.abs(m.x - c.x) > (CHANDELIER_W + m.w) / 2 || bottom > m.y + m.h || bottom < m.y) continue;
|
||||
hurt(round, m, 99, "crush", random);
|
||||
}
|
||||
round.monsters = round.monsters.filter((m) => !m.dead);
|
||||
if (Math.abs(you.x - c.x) < (CHANDELIER_W + HIT_W) / 2 - 0.4 && bottom < you.y + HIT_H && bottom > you.y) struck(round, "chandelier");
|
||||
const g = groundAt(spec, c.x);
|
||||
if (bottom <= g) {
|
||||
c.y = g + 2;
|
||||
c.state = "down";
|
||||
round.events.push({ type: "crash", x: c.x, y: g });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The crumbling boards: one you stand on shakes, then falls away, then
|
||||
// comes back.
|
||||
function crumble(round, ms) {
|
||||
const { shelves } = round.spec;
|
||||
const you = round.you;
|
||||
for (let i = 0; i < shelves.length; i++) {
|
||||
if (shelves[i][3] !== "crumble") continue;
|
||||
if (round.down[i] > 0) {
|
||||
round.down[i] = Math.max(0, round.down[i] - ms);
|
||||
if (!round.down[i]) round.events.push({ type: "back", shelf: i });
|
||||
} else if (round.shake[i] > 0) {
|
||||
round.shake[i] = Math.max(0, round.shake[i] - ms);
|
||||
if (!round.shake[i]) {
|
||||
round.down[i] = CRUMBLE_BACK_MS;
|
||||
round.events.push({ type: "drop", shelf: i });
|
||||
}
|
||||
} else if (you.state === "run" && you.shelf === i) {
|
||||
round.shake[i] = CRUMBLE_MS;
|
||||
round.events.push({ type: "crumble", shelf: i, x: you.x, y: you.y });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The clocks that run while you play: the bonus, the power-ups, being safe,
|
||||
// the chain's window.
|
||||
function timers(round, ms) {
|
||||
const you = round.you;
|
||||
round.bonusMs += ms;
|
||||
while (round.bonusMs >= 1000) {
|
||||
round.bonusMs -= 1000;
|
||||
if (round.bonus > 0) {
|
||||
round.bonus = Math.max(0, round.bonus - BONUS_STEP);
|
||||
if (!round.bonus && !round.hurry && !round.bonusRound) {
|
||||
round.hurry = true;
|
||||
round.events.push({ type: "hurry" });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (round.timeMs > 0) {
|
||||
const was = Math.ceil(round.timeMs / 1000);
|
||||
round.timeMs = Math.max(0, round.timeMs - ms);
|
||||
const now = Math.ceil(round.timeMs / 1000);
|
||||
if (now < was && round.timeMs > 0 && round.timeMs <= TIME_WARN_MS) round.events.push({ type: "tick", left: now });
|
||||
if (!round.timeMs) {
|
||||
round.events.push({ type: "timeUp", x: you.x, y: you.y });
|
||||
lose(round, "time");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const k of TIMED) {
|
||||
if (round.effects[k] > 0) {
|
||||
round.effects[k] = Math.max(0, round.effects[k] - ms);
|
||||
if (!round.effects[k]) round.events.push({ type: "expire", kind: k });
|
||||
}
|
||||
}
|
||||
round.stunMs = Math.max(0, (round.stunMs || 0) - ms);
|
||||
you.heldMs = Math.max(0, (you.heldMs || 0) - ms);
|
||||
you.flingMs = Math.max(0, (you.flingMs || 0) - ms);
|
||||
you.safeMs = Math.max(0, you.safeMs - ms);
|
||||
you.aliveMs = (you.aliveMs || 0) + ms;
|
||||
you.slowMs = Math.max(0, (you.slowMs || 0) - ms);
|
||||
you.dimMs = Math.max(0, (you.dimMs || 0) - ms);
|
||||
you.fireFx = Math.max(0, you.fireFx - ms);
|
||||
if (round.chainMs > 0) {
|
||||
round.chainMs = Math.max(0, round.chainMs - ms);
|
||||
if (!round.chainMs) round.chain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// The top of the highest surface under you (the ground, or a shelf there),
|
||||
// or -Infinity over a pit.
|
||||
function surfaceBelow(round) {
|
||||
const you = round.you;
|
||||
let top = groundAt(round.spec, you.x);
|
||||
if (top > you.y) top = -Infinity;
|
||||
round.spec.shelves.forEach(([x0, x1, y], i) => {
|
||||
if (shelfThere(round, i) && i !== you.drop && you.x >= x0 && you.x <= x1 && y <= you.y && y > top) top = y;
|
||||
});
|
||||
return top;
|
||||
}
|
||||
|
||||
// A jump press, first in its slice: from the ground or a shelf, from the
|
||||
// air a moment after running off an edge, or saved a moment for the landing.
|
||||
function takeOff(round, ms) {
|
||||
const you = round.you;
|
||||
const inp = round.input;
|
||||
if (inp.jump <= 0) return false;
|
||||
if (you.state === "run" || you.coyote > 0) {
|
||||
inp.jump = 0;
|
||||
return jump(round);
|
||||
}
|
||||
// With Bat wings, a press in the air flaps once for another jump, unless
|
||||
// you are coming down within FLAP_CLEAR of a surface: then it is a press
|
||||
// saved for the landing, as without them.
|
||||
if (round.effects.wings > 0 && !you.flapped && you.out <= 0 && !(you.vy < 0 && you.y - surfaceBelow(round) < FLAP_CLEAR)) {
|
||||
inp.jump = 0;
|
||||
you.flapped = true;
|
||||
jump(round);
|
||||
round.events.push({ type: "flap", x: you.x, y: you.y });
|
||||
return true;
|
||||
}
|
||||
inp.jump = Math.max(0, inp.jump - ms);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Whether you are at the open door, standing.
|
||||
function atDoor(round) {
|
||||
const you = round.you;
|
||||
return round.hasKey && you.state === "run" && Math.abs(you.x - round.spec.door) < DOOR_REACH && you.y === groundAt(round.spec, round.spec.door);
|
||||
}
|
||||
|
||||
// Your keys for one slice of walking: a jump press, a short hop (up let go
|
||||
// while a jump still rises), then moveYou.
|
||||
function walkYou(round, ms, frozen) {
|
||||
const you = round.you;
|
||||
if (frozen || you.heldMs > 0 || you.flingMs > 0) round.input.jump = 0;
|
||||
else takeOff(round, ms);
|
||||
if (you.state === "air") you.airMs = (you.airMs || 0) + ms;
|
||||
if (you.cuttable && !round.input.up && you.vy > CUT_V && you.airMs >= CUT_AFTER_MS) {
|
||||
you.vy = CUT_V;
|
||||
you.cuttable = false;
|
||||
}
|
||||
moveYou(round, ms);
|
||||
}
|
||||
|
||||
function play(round, ms, random) {
|
||||
for (const f of TICKS) f(round, ms, KIT);
|
||||
timers(round, ms);
|
||||
if (round.phase !== "play") return;
|
||||
// The bell has frozen you (see moveYou) and everything else on the field,
|
||||
// but for the bolts in flight: no key does anything till it passes.
|
||||
const frozen = round.stunMs > 0;
|
||||
const you = round.you;
|
||||
const py = you.y;
|
||||
if (you.lift) stepLift(round, ms);
|
||||
else if (frozen || !RIDES.some((f) => f(round, ms, KIT))) walkYou(round, ms, frozen);
|
||||
markRest(you);
|
||||
if (atDoor(round)) return clearRoom(round);
|
||||
const spec = round.spec;
|
||||
if (round.boss && round.lockX < 0 && you.x > spec.arena + BOSS_LOCK) lockArena(round);
|
||||
if (!frozen) fire(round, ms);
|
||||
// While the Church bell rings, the dead stand still and no more come.
|
||||
if (!(round.effects.bell > 0 || frozen)) {
|
||||
spawners(round, ms, random);
|
||||
horde(round, ms, random);
|
||||
hurry(round, ms, random);
|
||||
moveMonsters(round, ms, random);
|
||||
piles(round, ms);
|
||||
}
|
||||
if (!frozen) {
|
||||
moveBoss(round, ms, random);
|
||||
moveHazards(round, ms);
|
||||
moveMissiles(round, ms);
|
||||
}
|
||||
moveShots(round, ms, random);
|
||||
stomps(round, py, random);
|
||||
chandeliers(round, ms, random);
|
||||
if (round.phase !== "play") return;
|
||||
hits(round);
|
||||
if (round.phase !== "play") return;
|
||||
pickups(round, ms, POWER_KIT);
|
||||
crumble(round, ms);
|
||||
if (you.y < PIT_Y && !you.lift && !wingSave(round)) {
|
||||
struckFall(round);
|
||||
return;
|
||||
}
|
||||
// Monsters far behind the camera are let go.
|
||||
if (round.monsters.some((m) => m.x < round.camX - 30 || m.y < PIT_Y)) round.monsters = round.monsters.filter((m) => m.x >= round.camX - 30 && m.y >= PIT_Y);
|
||||
camera(round, ms);
|
||||
}
|
||||
|
||||
// What a stage pack's rules may use of this file's.
|
||||
Object.assign(KIT, { BOSSES, shotY, aimAt, dropItem, guarded, weakOf: (b, s, round) => (WEAK[b.kind] ? WEAK[b.kind](b, s, round, KIT) : 1), stone: (m) => Boolean(STONE[m.kind]?.(m)), strike: (round, s) => TARGETS.some((f) => f(round, s, KIT)), harmlessNow: (m) => Boolean(HARMLESS[m.kind]?.(m)), walk, towardYou, throwBone, spawnMonster, groundAt, footing, struck, hurt, hurtBoss, fling, arenaMin, arenaMax, solid, FIELD_W, CHANDELIER_Y, SHOT_Y, YOU_H, HIT_W, HIT_H, GRAVITY, FALL_MAX, PIT_Y, BONE_G, DUCK_H, lose });
|
||||
Object.freeze(KIT);
|
||||
|
||||
// Throws Planny: up at `v` and `dx` units across (signed) by the time he is
|
||||
// back at the height he left, no key doing anything till he lands. What he
|
||||
// lands on (a pit, a monster) is what it costs, never the throw.
|
||||
function fling(round, dx, v) {
|
||||
const you = round.you;
|
||||
const t = (2 * v) / GRAVITY;
|
||||
Object.assign(you, { vy: v, state: "air", shelf: -1, coyote: 0, drop: -1, cuttable: false, airMs: 0, flapped: false, flingVx: dx / t, flingMs: Math.round(t * 1000) + 200 });
|
||||
return true;
|
||||
}
|
||||
|
||||
// Bat wings catch a fall down a pit, before a life or a Lucky die is at stake:
|
||||
// no key works while they carry him back. A ride has no ground to go back to.
|
||||
function wingSave(round) {
|
||||
if (!(round.effects.wings > 0) || round.spec.ride) return false;
|
||||
const you = round.you;
|
||||
const at = reviveSpot(round, DICE_KIT);
|
||||
round.effects.wings = 0;
|
||||
round.input.jump = 0;
|
||||
Object.assign(you, { lift: { x0: you.x, y0: you.y, x: at.x, y: at.y, shelf: at.shelf, t: 0 }, vy: 0, state: "air", shelf: -1, coyote: 0, drop: -1, cuttable: false, flapped: false, flingMs: 0, ducking: false, safeMs: Math.max(you.safeMs, WING_SAVE_MS + SAFE_MS) });
|
||||
if (at.x !== you.x) you.face = Math.sign(at.x - you.x);
|
||||
round.events.push({ type: "wingSave", x: you.x, y: 1 });
|
||||
return true;
|
||||
}
|
||||
|
||||
// One slice of the flight back, and setting him down at the end of it.
|
||||
function stepLift(round, ms) {
|
||||
const you = round.you;
|
||||
const l = you.lift;
|
||||
l.t += ms;
|
||||
const k = Math.min(1, l.t / WING_SAVE_MS);
|
||||
const ease = k * (2 - k);
|
||||
you.x = l.x0 + (l.x - l.x0) * ease;
|
||||
you.y = l.y0 + (l.y - l.y0) * ease + Math.sin(Math.PI * k) * WING_SAVE_ARC;
|
||||
if (k < 1) return;
|
||||
Object.assign(you, { lift: null, x: l.x, y: l.y, shelf: l.shelf, state: "run", vy: 0 });
|
||||
round.events.push({ type: "land", x: you.x, y: you.y });
|
||||
}
|
||||
|
||||
// A fall down a pit: always a life, garlic or not.
|
||||
function struckFall(round) {
|
||||
round.you.garlic = false;
|
||||
lose(round, "pit");
|
||||
}
|
||||
|
||||
export function advance(round, ms, random = Math.random) {
|
||||
let left = ms;
|
||||
while (left > 0 && !round.over) {
|
||||
const slice = Math.min(left, SLICE_MS);
|
||||
left -= slice;
|
||||
if (round.phase === "ready") {
|
||||
// The dark ride's title screen holds for a key or a press, its clock running on for the art.
|
||||
if (round.gallery?.waiting) {
|
||||
round.phaseMs += slice;
|
||||
continue;
|
||||
}
|
||||
round.phaseMs -= slice;
|
||||
if (round.phaseMs <= 0) {
|
||||
round.phase = "play";
|
||||
round.input.jump = 0;
|
||||
round.events.push({ type: "go" });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (round.phase === "clear") {
|
||||
round.phaseMs -= slice;
|
||||
if (round.phaseMs <= 0) nextRoom(round, random);
|
||||
continue;
|
||||
}
|
||||
// Waiting on a choice of stage: nothing moves.
|
||||
if (round.phase === "pick") {
|
||||
round.phaseMs = Math.max(0, round.phaseMs - slice - left);
|
||||
return "pick";
|
||||
}
|
||||
if (round.phase === "select") return "select";
|
||||
if (onCard(round)) {
|
||||
stepIntroWith(round, slice);
|
||||
continue;
|
||||
}
|
||||
// The intro story, before the first room: only its pages move.
|
||||
if (round.phase === "story") {
|
||||
stepStory(round, slice);
|
||||
continue;
|
||||
}
|
||||
round.clock += slice;
|
||||
// Asking whether to use a Lucky die for a life: nothing else moves.
|
||||
if (round.phase === "ask") {
|
||||
askStep(round, slice);
|
||||
continue;
|
||||
}
|
||||
// Rolling the Lucky dice for a life: nothing else moves.
|
||||
if (round.phase === "roll") {
|
||||
rollDice(round, slice, random, DICE_KIT);
|
||||
continue;
|
||||
}
|
||||
if (round.phase === "crash") {
|
||||
round.phaseMs -= slice;
|
||||
round.you.out = Math.max(1, round.phaseMs);
|
||||
moveMonsters(round, slice, random);
|
||||
moveMissiles(round, slice);
|
||||
if (round.phaseMs <= 0) respawn(round);
|
||||
continue;
|
||||
}
|
||||
play(round, slice, random);
|
||||
}
|
||||
return round.over ? "over" : round.phase;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- banners */
|
||||
|
||||
// Whether anything that matters to you is in a banner's strip, its middle
|
||||
// `y` units down from the field's top: you, a monster on screen that can
|
||||
// hurt you (not a roosting bat, a widow still on the ceiling, a faded ghost
|
||||
// or one still coming up), the boss, a bone, a glob of acid, a puddle or a
|
||||
// shockwave.
|
||||
export function underBanner(round, y) {
|
||||
const lo = round.camX - 2;
|
||||
const hi = round.camX + FIELD_W + 2;
|
||||
const inStrip = (x, bottom, h) => x > lo && x < hi && FIELD_H - (bottom + h) < y + BANNER_REACH && FIELD_H - bottom > y - BANNER_REACH;
|
||||
const you = round.you;
|
||||
if (inStrip(you.x, you.y, YOU_H)) return true;
|
||||
// A roosting bat, or anything not yet able to hurt you, does not count.
|
||||
if (round.monsters.some((m) => roused(m) && inStrip(m.x, m.y, m.h))) return true;
|
||||
if (round.bones.some((b) => inStrip(b.x, b.y - BONE_R, BONE_R * 2))) return true;
|
||||
if (round.puddles.some((p) => inStrip(p.x, p.y, 1))) return true;
|
||||
if (round.waves.some((w) => inStrip(w.x, w.y, WAVE_H))) return true;
|
||||
// A room drawn whole by its own art (the Drowned Lantern) lists what matters there as [x, y up].
|
||||
if (round.runner && round.runner.marks && round.runner.marks.some(([x, y]) => inStrip(x, y - YOU_H / 2, YOU_H))) return true;
|
||||
const b = round.boss;
|
||||
return Boolean(b && b.state !== "sleep" && b.state !== "down" && inStrip(b.x, b.y, b.h));
|
||||
}
|
||||
|
||||
// Where a banner goes: high on the field while you are low on it, low
|
||||
// while you are high.
|
||||
export const bannerY = (round) => (round.you.y > FIELD_H * 0.42 ? FIELD_H * 0.72 : FIELD_H * 0.3);
|
||||
+7
-9
@@ -1,7 +1,7 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's power-ups and pickups: what each power-up does (POWERS), which can turn up where, picking one, and taking candy, power-ups, crystals and the key.
|
||||
//
|
||||
// No imports: ghoul.js hands the rules here a kit of its own helpers and
|
||||
// numbers (landing, MAX_LIVES, GRAVITY and the rest), the way it hands a
|
||||
// numbers (landing, GRAVITY and the rest), the way it hands a
|
||||
// stage pack its KIT, so this file never reaches back into it. ghoul.js
|
||||
// re-exports what it always exported from here (POWERS, TIMED, powerHere,
|
||||
// applyPower and the numbers), so its importers need not know.
|
||||
@@ -22,16 +22,16 @@
|
||||
// found only in The Deep Seam Mine) is worn till a rock bounces off it or an imp
|
||||
// knocks it off;
|
||||
// the secondary weapons (`arm: true`, see below) are not timed either; the Garlic shield shrugs off one hit (and sees off whatever
|
||||
// touched you), a 1UP is a life (POWER_POINTS more past MAX_LIVES), and the
|
||||
// touched you), a 1UP is a life (no limit), and the
|
||||
// Hourglass puts HOURGLASS_MS on the room's clock (POWER_POINTS more where
|
||||
// there is none). A Lucky die is kept for the run (ghoul-dice.js rolls it
|
||||
// when a life would be lost), up to MAX_DICE (POWER_POINTS more past it), and
|
||||
// when a life would be lost), with no limit on how many, and
|
||||
// turns up only as a drop (`drop: true`), as often as a 1UP. A kill (in
|
||||
// ghoul.js) drops candy DROP_CANDY of the time and a power-up DROP_POWER, by
|
||||
// `weight`.
|
||||
export const POWERS = Object.freeze({
|
||||
spread: Object.freeze({ name: "Spread shot", blurb: "Three bolts at once", color: "#ff8a1f", ms: 8000, weight: 3 }),
|
||||
rapid: Object.freeze({ name: "Rapid fire", blurb: "Twice the bolts", color: "#e04dd0", ms: 8000, weight: 3 }),
|
||||
rapid: Object.freeze({ name: "Rapid fire", blurb: "65% more bolts", color: "#e04dd0", ms: 8000, weight: 3 }),
|
||||
garlic: Object.freeze({ name: "Garlic shield", blurb: "Shrugs off one hit", color: "#e6e0b8", weight: 2 }),
|
||||
life: Object.freeze({ name: "1UP", blurb: "An extra life", color: "#ff4fa3", weight: 1.5 }),
|
||||
lantern: Object.freeze({ name: "Lantern", blurb: "The dark pulls back", color: "#ffc857", ms: 15000, weight: 3, dark: true }),
|
||||
@@ -144,7 +144,7 @@ export function pickPower(random, round, skip = "", dropping = false) {
|
||||
}
|
||||
|
||||
// A power-up taken: a timed one starts, or adds its time to what is left of
|
||||
// the same one already running; the rest act at once. `kit` is ghoul.js's kit (for MAX_LIVES).
|
||||
// the same one already running; the rest act at once. `kit` is ghoul.js's kit.
|
||||
export function applyPower(round, kind, kit) {
|
||||
const you = round.you;
|
||||
if (TIMED.includes(kind)) round.effects[kind] = (round.effects[kind] || 0) + POWERS[kind].ms;
|
||||
@@ -155,11 +155,9 @@ export function applyPower(round, kind, kit) {
|
||||
else award(round, POWER_POINTS);
|
||||
}
|
||||
else if (kind === "life") {
|
||||
if (round.lives < kit.MAX_LIVES) round.lives++;
|
||||
else award(round, POWER_POINTS * 10);
|
||||
round.lives++;
|
||||
} else if (kind === "die") {
|
||||
if (round.dice < kit.MAX_DICE) round.dice++;
|
||||
else award(round, POWER_POINTS * 10);
|
||||
round.dice++;
|
||||
} else if (POWERS[kind].arm && !addArm(round, kind)) award(round, POWER_POINTS);
|
||||
}
|
||||
|
||||
+43
-42
@@ -143,7 +143,7 @@
|
||||
// Lucky Dice for a finish and costs the run nothing (ghoul-bonus.js).
|
||||
// - `dark`: true for a room always dark, false for one always lit; left out,
|
||||
// each time it is entered it is dark DARK_CHANCE of the time (ghoul.js).
|
||||
import { COURSE } from "./ghoul-pew-course.js";
|
||||
import { COURSE } from "../rides/pew/ghoul-pew-course.js";
|
||||
|
||||
|
||||
export const FIELD_W = 96;
|
||||
@@ -1479,57 +1479,58 @@ export const ROOMS = freeze([
|
||||
key: [300, 24],
|
||||
door: 550,
|
||||
candy: [[18, 8.5, 4], [57, 18, 3], [101, 18, 3], [161, 18, 3], [197, 18, 3], [266, 25, 3], [293, 27, 3], [359, 18, 3], [401, 18, 3], [440, 8.5, 4], [463, 18, 3], [501, 20, 3]],
|
||||
items: [["wings", 60, 6], ["rapid", 168, 15], ["dyn", 204, 15], ["boots", 350, 6], ["harpoon", 380, 6], ["garlic", 404, 15], ["rocket", 508, 17]],
|
||||
items: [["wings", 60, 6], ["rapid", 168, 15], ["spread", 204, 15], ["boots", 350, 6], ["harpoon", 380, 6], ["garlic", 404, 15], ["rocket", 508, 17]],
|
||||
sky: [["crystal", 296, 44], ["crystal", 302, 46], ["crystal", 308, 44]],
|
||||
spawns: [["lurker", 70], ["wisp", 140, 16], ["leech", 190], ["bogbody", 240], ["lurker", 390], ["door", 412, 3, 1400, "bogbody"], ["wisp", 460, 16], ["bogbody", 480], ["leech", 500]],
|
||||
horde: ["bogbody", "leech"],
|
||||
hordeMs: 2000,
|
||||
}),
|
||||
// The Bog Runner, Gallows Bog's BONUS ROUND: a fan-boat skim over black
|
||||
// water with a leech swarm in its wake. A ride, not a walk; the course is
|
||||
// from a one-off hash generator (no random draws), the rules are in
|
||||
// ghoul-bogboat.js.
|
||||
room("bogboat", "The Bog Runner", "Something swims in your wake", {
|
||||
length: 2400,
|
||||
ground: [[0, 2400, 9]],
|
||||
// The Drowned Lantern, Gallows Bog's BONUS ROUND (see ghoul-lantern.js and ghoul-bonus.js): not a ride.
|
||||
// A top-down game on one fixed screen: carry a lantern over a black island of mossy hummocks and plank
|
||||
// walks, light the five wisp shrines (each guarded by a circling wisp), then run back to the boat while
|
||||
// Old Mother Bog rises out of her pool in the middle. The Bog Lurker hears steps on the planks, the
|
||||
// leeches keep out of the light, the bog bodies lie beside the planks. The whole field is the art's
|
||||
// (ghoul-lantern-draw.js), so this room's ground is only the floor the door stands on; the island is
|
||||
// `ride`. Positions are field units, y counted down from the field's top; `planks` join two hummocks.
|
||||
room("lantern", "The Drowned Lantern", "Keep the flame lit, and keep quiet", {
|
||||
length: 96,
|
||||
ground: [[0, 96, 12]],
|
||||
start: 8,
|
||||
key: null,
|
||||
door: 2390,
|
||||
door: 95,
|
||||
bonus: true,
|
||||
dark: false,
|
||||
candy: [
|
||||
[14, 11.5, 4], [140, 11.6, 3], [144, 11.6, 3], [180, 17.5, 3], [210, 11.6, 3], [216, 10.4, 3], [216, 17.6, 3], [240, 17.6, 3],
|
||||
[252, 17.5, 3], [280, 11.6, 3], [344, 10.4, 3], [344, 23.5, 3], [350, 11.6, 3], [380, 10.4, 3], [380, 17.6, 3], [416, 10.4, 3],
|
||||
[416, 17.6, 3], [420, 11.6, 3], [450, 17.6, 3], [452, 17.5, 3], [452, 17.6, 3], [490, 11.6, 3], [544, 17.5, 3], [544, 17.6, 3],
|
||||
[560, 11.6, 3], [580, 17.5, 3], [580, 17.6, 3], [616, 11.6, 3], [616, 17.6, 3], [630, 11.6, 3], [652, 17.5, 3], [652, 17.6, 3],
|
||||
[660, 17.6, 3], [700, 11.6, 3], [744, 17.5, 3], [744, 17.6, 3], [770, 11.6, 3], [780, 11.6, 3], [780, 16.4, 3], [816, 10.4, 3],
|
||||
[816, 17.6, 3], [840, 11.6, 3], [852, 10.4, 3], [852, 17.6, 3], [870, 17.6, 3], [910, 11.6, 3], [944, 10.4, 3], [944, 16.4, 3],
|
||||
[980, 11.6, 3], [980, 23.5, 3], [980, 11.6, 3], [1016, 10.4, 3], [1016, 16.4, 3], [1050, 11.6, 3], [1052, 17.5, 3], [1052, 17.6, 3],
|
||||
[1080, 17.6, 3], [1120, 11.6, 3], [1144, 11.6, 3], [1144, 17.6, 3], [1180, 11.6, 3], [1180, 17.6, 3], [1190, 11.6, 3], [1216, 17.6, 3],
|
||||
[1252, 17.5, 3], [1252, 17.6, 3], [1260, 11.6, 3], [1290, 17.6, 3], [1330, 11.6, 3], [1344, 11.6, 3], [1344, 23.5, 3], [1380, 23.5, 3],
|
||||
[1400, 11.6, 3], [1416, 17.5, 3], [1416, 23.5, 3], [1452, 10.4, 3], [1452, 16.4, 3], [1470, 11.6, 3], [1500, 17.6, 3], [1540, 11.6, 3],
|
||||
[1544, 17.5, 3], [1544, 17.6, 3], [1580, 17.5, 3], [1610, 11.6, 3], [1616, 10.4, 3], [1616, 17.6, 3], [1652, 17.5, 3], [1680, 11.6, 3],
|
||||
[1710, 17.6, 3], [1744, 11.6, 3], [1744, 17.6, 3], [1750, 11.6, 3], [1780, 11.6, 3], [1816, 17.5, 3], [1816, 17.6, 3], [1820, 11.6, 3],
|
||||
[1852, 10.4, 3], [1852, 17.6, 3], [1890, 11.6, 3], [1920, 17.6, 3], [1944, 17.5, 3], [1944, 17.6, 3], [1960, 11.6, 3], [1980, 17.5, 3],
|
||||
[1980, 23.5, 3], [2016, 17.5, 3], [2030, 11.6, 3], [2052, 10.4, 3], [2052, 23.5, 3], [2100, 11.6, 3], [2130, 17.6, 3], [2144, 10.4, 3],
|
||||
[2144, 23.5, 3], [2170, 11.6, 3], [2180, 11.6, 3], [2180, 16.4, 3], [2216, 11.6, 3], [2216, 17.6, 3], [2240, 11.6, 3], [2252, 10.4, 3],
|
||||
[2252, 23.5, 3], [2330, 11.5, 4],
|
||||
],
|
||||
candy: [],
|
||||
items: [],
|
||||
spawns: [],
|
||||
horde: [],
|
||||
ride: {
|
||||
runner: "bogboat",
|
||||
how: "LEFT or RIGHT at a bank: switch lane. UP jump, DOWN duck, SPACE shoot",
|
||||
time: 100000,
|
||||
finish: 2320,
|
||||
checks: [480, 960, 1440, 1920],
|
||||
banks: [[90, 106], [290, 306], [490, 506], [690, 706], [890, 906], [1090, 1106], [1290, 1306], [1490, 1506], [1690, 1706], [1890, 1906], [2090, 2106]],
|
||||
snags: [[180, 0], [452, 0], [580, 0], [744, 0], [980, 1], [1052, 0], [1252, 0], [1344, 1], [1416, 0], [1416, 1], [1580, 0], [1652, 0], [1980, 0], [2052, 1], [2144, 1], [2252, 1]],
|
||||
knees: [[252, 0], [344, 1], [544, 0], [652, 0], [1380, 1], [1544, 0], [1816, 0], [1944, 0], [1980, 1], [2016, 0]],
|
||||
veils: [[340, 348, 0], [776, 784, 1], [848, 856, 0], [940, 948, 0], [940, 948, 1], [1448, 1456, 0], [1448, 1456, 1], [1848, 1856, 0], [2048, 2056, 0], [2140, 2148, 0], [2176, 2184, 1], [2248, 2256, 0]],
|
||||
limbs: [[213, 219, 0], [377, 383, 0], [413, 419, 0], [813, 819, 0], [1013, 1019, 0], [1013, 1019, 1], [1613, 1619, 0]],
|
||||
props: [[144, 0, 0], [544, 1, 0], [580, 1, 1], [616, 0, 1], [616, 1, 0], [780, 0, 1], [816, 1, 0], [1052, 1, 0], [1144, 0, 1], [1144, 1, 0], [1180, 0, 1], [1180, 1, 1], [1344, 0, 0], [1744, 0, 1], [1780, 0, 0], [1944, 1, 1]],
|
||||
gas: [[216, 1], [380, 1], [416, 1], [452, 1], [652, 1], [744, 1], [852, 1], [980, 0], [1216, 1], [1252, 1], [1544, 1], [1616, 1], [1744, 1], [1816, 1], [1852, 1], [2180, 0], [2216, 0], [2216, 1]],
|
||||
runner: "lantern",
|
||||
time: 90000,
|
||||
how: "ARROWS walk, SPACE flares. Light 5 shrines, then run to the boat",
|
||||
start: [10, 45],
|
||||
boat: [3.5, 45],
|
||||
pool: [48.5, 30],
|
||||
hummocks: [[10, 45, 5.5], [28, 44, 4.5], [13, 23, 5], [32, 30, 4.5], [40, 15, 5], [62, 15, 4.5], [83, 16, 5.5], [84, 36, 5], [64, 46, 5], [47, 44, 4], [65, 30, 4]],
|
||||
planks: [[0, 1], [0, 2], [1, 3], [1, 9], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 10], [6, 7], [7, 8], [8, 9], [10, 7], [10, 8], [3, 10]],
|
||||
shrines: [2, 4, 6, 7, 8],
|
||||
bodies: [[14.4, 34.4], [51, 17.9], [48.5, 32.9], [37.5, 41.1], [75.3, 43.6]],
|
||||
lurker: { home: [74, 24], route: [[74, 24], [56, 38], [38, 37], [22, 33], [22, 14], [52, 22]] },
|
||||
leeches: [
|
||||
{ home: [22, 14], route: [[22, 14], [30, 22], [18, 30]] },
|
||||
{ home: [56, 22], route: [[56, 22], [56, 38], [42, 24]] },
|
||||
{ home: [78, 50], route: [[78, 50], [90, 46], [72, 52]] },
|
||||
],
|
||||
wisps: [
|
||||
{ shrine: 0, phase: 0, home: [18.5, 23] },
|
||||
{ shrine: 1, phase: 1.3, home: [41.5, 20.3] },
|
||||
{ shrine: 2, phase: 2.6, home: [78.3, 18.8] },
|
||||
{ shrine: 3, phase: 3.9, home: [80, 32.3] },
|
||||
{ shrine: 4, phase: 5.2, home: [66.6, 41.1] },
|
||||
{ shrine: -1, wake: 3, home: [48.5, 30], route: [[48.5, 30], [30, 38], [20, 30], [40, 22]] },
|
||||
{ shrine: -1, wake: 4, home: [48.5, 30], route: [[48.5, 30], [70, 40], [86, 26], [60, 22]] },
|
||||
{ shrine: -1, wake: 5, home: [48.5, 30], route: [[48.5, 30], [30, 40], [12, 40], [28, 46]] },
|
||||
],
|
||||
},
|
||||
}),
|
||||
// The Drowning Pool, Gallows Bog's boss room: planks over open black
|
||||
@@ -1542,7 +1543,7 @@ export const ROOMS = freeze([
|
||||
key: null,
|
||||
door: 194,
|
||||
candy: [[18, 8.5, 5], [70, 8.5, 5]],
|
||||
items: [["garlic", 24, 6]],
|
||||
items: [["garlic", 24, 6], ["harpoon", 48, 6]],
|
||||
spawns: [["zombie", 44], ["crawl", 96]],
|
||||
boss: "motherbog",
|
||||
}),
|
||||
@@ -1571,6 +1572,6 @@ export const STAGES = freeze([
|
||||
stage("mine", "The Deep Seam Mine", "They are still knocking", ["shaft", "tunnels", "collapse", "cart", "seam"]),
|
||||
stage("carnival", "The Midnight Carnival", "Every game is rigged in its favor", ["midway", "mirrors", "funhouse", "darkride", "bigtop"]),
|
||||
stage("frozen", "The Frozen Lake", "The ice remembers who fell through", ["huts", "lodge", "blackice", "sled", "widow"]),
|
||||
stage("bog", "Gallows Bog", "The mud does not like to let go", ["boardwalk", "hollow", "stilts", "bogboat", "drowning"]),
|
||||
stage("bog", "Gallows Bog", "The mud does not like to let go", ["boardwalk", "hollow", "stilts", "lantern", "drowning"]),
|
||||
]);
|
||||
export const stageById = (id) => STAGES.find((s) => s.id === id) || null;
|
||||
+1
@@ -114,6 +114,7 @@ export function newRound(seed, kit) {
|
||||
// Lucky dice kept for the run, and the roll in hand while a life is at stake.
|
||||
dice: START_DICE,
|
||||
roll: null,
|
||||
ask: null,
|
||||
// The bonus room's own hearts and result, null elsewhere (ghoul-bonus.js).
|
||||
bonusRound: null,
|
||||
// The secondary weapons in the bag, the latest picked up first, and whether one has been used yet (ghoul-arms.js).
|
||||
@@ -0,0 +1,557 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's numbers and tables: every timing and size the rules share, the monsters and bosses with each stage pack's joined in (PACKS), the seeded dice, and a room's numbers at a depth (roomFor).
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { ARMS, releaseFire } from "../arms/ghoul-arms.js";
|
||||
import { BANISTER } from "../rides/banister/ghoul-banister.js";
|
||||
import { CART } from "../rides/cart/ghoul-cart.js";
|
||||
import { RIDE } from "../rides/dark-ride/ghoul-ride.js";
|
||||
import { GURNEY } from "../rides/gurney/ghoul-gurney.js";
|
||||
import { HEARSE } from "../rides/hearse/ghoul-hearse.js";
|
||||
import { LANTERN } from "../rides/lantern/ghoul-lantern.js";
|
||||
import { MOWER } from "../rides/mower/ghoul-mower.js";
|
||||
import { PEW } from "../rides/pew/ghoul-pew.js";
|
||||
import { SLED } from "../rides/sled/ghoul-sled.js";
|
||||
import { TRAY } from "../rides/tray/ghoul-tray.js";
|
||||
import { WAGON } from "../rides/wagon/ghoul-wagon.js";
|
||||
import { BOG } from "../stages/bog/ghoul-bog.js";
|
||||
import { CARNIVAL } from "../stages/carnival/ghoul-carnival.js";
|
||||
import { CHAPEL } from "../stages/chapel/ghoul-chapel.js";
|
||||
import { FROZEN as FROZEN_LAKE } from "../stages/frozen/ghoul-frozen.js";
|
||||
import { GRAVEYARD } from "../stages/graveyard/ghoul-graveyard.js";
|
||||
import { GROUNDS } from "../stages/grounds/ghoul-grounds.js";
|
||||
import { MINE } from "../stages/mine/ghoul-mine.js";
|
||||
import { SANATORIUM } from "../stages/sanatorium/ghoul-sanatorium.js";
|
||||
import { VILLAGE } from "../stages/village/ghoul-village.js";
|
||||
import { BONES } from "../stages/wing/ghoul-bones.js";
|
||||
import { FLAP_CLEAR, POWERS, TIMED, powerHere } from "./ghoul-powers.js";
|
||||
import { CEILING_Y, FIELD_H, FIELD_W, FLOOR_Y, ROOMS, STAGES, roomById, stageById } from "./ghoul-rooms.js";
|
||||
import { steerPick } from "./ghoul-run.js";
|
||||
|
||||
export { FIELD_H, FIELD_W, FLOOR_Y, ROOMS, STAGES, roomById, stageById };
|
||||
export { FLAP_CLEAR, POWERS, TIMED, powerHere };
|
||||
export { INTRO_MIN_MS } from "./ghoul-run.js";
|
||||
export { releaseFire };
|
||||
// The stage pick, which moved to ghoul-run.js.
|
||||
export { steerPick };
|
||||
export { CANDY_POINTS, CRYSTAL_POINTS, HOURGLASS_MS, POWER_POINTS } from "./ghoul-powers.js";
|
||||
// The Lucky die's numbers, which the tests read from here.
|
||||
export { ASK_GUARD_MS, DICE_FACES, LEAD_MS, MAX_DICE, START_DICE, ROLL_MS, SAVED_TIME_MS, TUMBLE_MS } from "./ghoul-dice.js";
|
||||
// The bonus rounds' numbers (the Runaway Cart is the first), which the tests read from here.
|
||||
export { BONUS_FLOOR, BONUS_HEARTS, BONUS_SAFE_MS, CARD_LOST_MS, CARD_MS, diceFor } from "./ghoul-bonus.js";
|
||||
// Old Rattlebones' numbers, which the tests read from here.
|
||||
export { BONES_KEEP, BONES_MS, BONES_RAGE_MS, BONES_WINDUP_MS, VOLLEY } from "../stages/wing/ghoul-bones.js";
|
||||
|
||||
// The board: the strip of pills along the top, then the field. The strip is
|
||||
// one row of pills tall (ghoul-draw.js's hudLayout shrinks the pills to keep
|
||||
// them in one row), so the field gets the room. The field runs to the
|
||||
// canvas's edges with no frame (PAD 0), so full screen shows all play. The
|
||||
// canvas scales a unit in quarter-pixel steps.
|
||||
export const HUD_H = 4.5;
|
||||
export const PAD = 0;
|
||||
export const W = PAD * 2 + FIELD_W;
|
||||
export const H = HUD_H + FIELD_H + PAD;
|
||||
|
||||
// Below this many pixels a unit, Planny and the monsters are too small to
|
||||
// read; the window shows its bigger-window note.
|
||||
export const MIN_CELL = 3;
|
||||
|
||||
// Planny, in units: YOU_W across and YOU_H tall as drawn, his feet at his y.
|
||||
// Monsters hit a smaller box, HIT_W by HIT_H, so a graze never counts.
|
||||
export const YOU_W = 3.6;
|
||||
export const YOU_H = 5;
|
||||
export const HIT_W = 2.4;
|
||||
export const HIT_H = 4.4;
|
||||
// Ducking (down, on the ground, not running): HIT_H falls to DUCK_H, and his
|
||||
// bolts fly from DUCK_SHOT_Y. A swooper (a pack's `swoops`) ramps up over a
|
||||
// ducked Planny, its underside SWOOP_CLEAR above his feet by the time it can
|
||||
// touch him, starting SWOOP_NEAR short of that: so duck before it arrives and it
|
||||
// passes overhead, whatever the angle of its dive. Standing, it still hits him.
|
||||
export const DUCK_H = 2.4;
|
||||
export const DUCK_SHOT_Y = 1.4;
|
||||
export const SWOOP_CLEAR = 2.6;
|
||||
export const SWOOP_NEAR = 3;
|
||||
// Half his width, where his front edge meets a wall.
|
||||
export const EDGE = 1.2;
|
||||
|
||||
// Moving, in units and seconds. Running is RUN_SPEED at once, on the ground
|
||||
// and in the air alike (no slide, no drift: an arcade's grip). A jump leaves
|
||||
// at JUMP_V against GRAVITY (12 units high and about 0.61 s in the air, a
|
||||
// snappy arc); letting up go while still rising cuts the jump to CUT_V.
|
||||
// Landing on a monster bounces you up at STOMP_V. Nothing falls faster than
|
||||
// FALL_MAX.
|
||||
export const RUN_SPEED = 36;
|
||||
export const GRAVITY = 260;
|
||||
export const JUMP_V = 79;
|
||||
export const CUT_V = 28;
|
||||
// A jump always rises CUT_AFTER_MS before letting go of up can cut it, so a
|
||||
// press saved for a landing and let go before it never comes out as a twitch.
|
||||
export const CUT_AFTER_MS = 50;
|
||||
export const STOMP_V = 58;
|
||||
export const FALL_MAX = 120;
|
||||
// Knee-deep water (a room's `water` spans of floor, the Mine's tunnels): on the
|
||||
// floor in one Planny runs at WATER_SPEED of his speed and a jump leaves at
|
||||
// WATER_JUMP of its speed; `you.wet` says so (ghoul-mine.js reads it).
|
||||
export const WATER_SPEED = 0.65;
|
||||
export const WATER_JUMP = 0.93;
|
||||
// Sinking mud (a room's `mud` spans, Gallows Bog): on the floor in one,
|
||||
// `you.mudMs` climbs toward MUD_MS and the run sags from WATER_SPEED down to
|
||||
// MUD_SPEED_MIN, a jump from WATER_JUMP down to MUD_JUMP_MIN; dry floor or
|
||||
// the air lets it go again (`you.mud`, `you.mudMs`).
|
||||
export const MUD_MS = 2400;
|
||||
export const MUD_SPEED_MIN = 0.25;
|
||||
export const MUD_JUMP_MIN = 0.7;
|
||||
export const mudSpeed = (ms) => WATER_SPEED + (MUD_SPEED_MIN - WATER_SPEED) * Math.min(1, ms / MUD_MS);
|
||||
export const mudJump = (ms) => WATER_JUMP + (MUD_JUMP_MIN - WATER_JUMP) * Math.min(1, ms / MUD_MS);
|
||||
// A step of STEP_UP or less between two surfaces is walked, not jumped.
|
||||
export const STEP_UP = 3;
|
||||
// Forgiving edges: a jump pressed up to COYOTE_MS after running off an edge
|
||||
// still leaves it, and a press up to JUMP_BUFFER_MS before landing jumps as
|
||||
// you land.
|
||||
export const COYOTE_MS = 100;
|
||||
export const JUMP_BUFFER_MS = 120;
|
||||
// Under this height a fall has gone down a pit.
|
||||
export const PIT_Y = -8;
|
||||
// Bat wings save a fall down a pit: Planny flies back over WING_SAVE_MS to the
|
||||
// last solid ground he stood on, swooping WING_SAVE_ARC over the straight line,
|
||||
// safe till a moment after he lands, and the wings are spent (see wingSave).
|
||||
export const WING_SAVE_MS = 700;
|
||||
export const WING_SAVE_ARC = 7;
|
||||
|
||||
// Nothing moves more than FALL_MAX * SLICE_MS / 1000 units (0.48) in a
|
||||
// slice, and a landing is found by crossing a surface's line, so no fall
|
||||
// goes through one.
|
||||
export const SLICE_MS = 4;
|
||||
|
||||
// The flashlight blaster: a bolt every FIRE_MS while fire is held (RAPID_MS
|
||||
// with Rapid fire), flying SHOT_SPEED level with Planny's chest (SHOT_Y over
|
||||
// his feet) until it hits something, a wall, or has gone SHOT_RANGE. Spread
|
||||
// shot adds two more, SPREAD_ANGLE up and down.
|
||||
export const FIRE_MS = 100;
|
||||
export const RAPID_MS = 60;
|
||||
export const SHOT_SPEED = 130;
|
||||
export const SHOT_RANGE = 80;
|
||||
export const SHOT_Y = 2.4;
|
||||
export const SHOT_R = 0.5;
|
||||
|
||||
// The blaster heats up, so holding or hammering fire is not the whole game.
|
||||
// Each bolt adds a shot of heat: the first HEAT_FREE go at the full rate,
|
||||
// then each waits longer, until from HEAT_MAX on it fires one bolt every
|
||||
// SLOW_FIRE_MS. Let go of fire and, once COOL_DELAY_MS has passed without
|
||||
// firing (so tapping it does not cool it), it sheds COOL_RATE shots of heat a
|
||||
// second. So about three seconds of fire go at the full rate, a held blaster
|
||||
// is down to one bolt a second some fifteen seconds in, and the hottest one
|
||||
// is cool again a couple of seconds after it is let go. Rapid fire's bolts
|
||||
// add no heat and ignore it.
|
||||
export const HEAT_FREE = 30;
|
||||
export const HEAT_MAX = 50;
|
||||
export const SLOW_FIRE_MS = 1000;
|
||||
export const COOL_DELAY_MS = 200;
|
||||
export const COOL_RATE = 25;
|
||||
// The blaster fizzes from half of HEAT_FREE on.
|
||||
export const HEAT_SHOWN = HEAT_FREE / 2;
|
||||
|
||||
// The wait after a bolt fired at `heat`: FIRE_MS while cool, rising in a
|
||||
// line to SLOW_FIRE_MS at HEAT_MAX.
|
||||
export function fireGap(heat) {
|
||||
const t = clamp((heat - HEAT_FREE) / (HEAT_MAX - HEAT_FREE), 0, 1);
|
||||
return Math.round(FIRE_MS + (SLOW_FIRE_MS - FIRE_MS) * t);
|
||||
}
|
||||
|
||||
export const SPREAD_ANGLE = 0.13;
|
||||
// A little help aiming: a bolt tilts toward the nearest monster ahead within
|
||||
// AIM_RANGE whose middle is within AIM_DY of your chest, by up to AIM_MAX.
|
||||
export const AIM_RANGE = 50;
|
||||
export const AIM_DY = 9;
|
||||
export const AIM_MAX = 0.5;
|
||||
|
||||
// The monsters: a box `w` across and `h` tall standing on (or flying with
|
||||
// its bottom at) its y, the shots it takes, its speed, the points a kill is
|
||||
// worth, whether a stomp from above kills it and whether its head (the top
|
||||
// HEAD_SHARE of it) doubles a kill. A zombie (a runner, a glutton) sprints at
|
||||
// `lurch` once you are within LURCH_RANGE on its level. `stompDamage`, where
|
||||
// set, is all a stomp takes off (a glutton is too soft to burst at once).
|
||||
// `color` is what spills when it dies.
|
||||
// The stage packs: each stage past the house's own two brings its monsters,
|
||||
// its boss and their rules (see ghoul-graveyard.js for what a pack holds).
|
||||
// Their tables join this file's own, and their rules run where its own do.
|
||||
const PACKS = Object.freeze([BONES, GRAVEYARD, GROUNDS, CHAPEL, SANATORIUM, VILLAGE, MINE, ARMS, CART, SLED, GURNEY, PEW, MOWER, WAGON, HEARSE, TRAY, CARNIVAL, FROZEN_LAKE, BOG, LANTERN, RIDE, BANISTER]);
|
||||
export const fromPacks = (key) => Object.assign({}, ...PACKS.map((pk) => pk[key] || {}));
|
||||
export const listPacks = (key) => PACKS.flatMap((pk) => pk[key] || []);
|
||||
|
||||
export const MONSTERS = Object.freeze({
|
||||
...fromPacks("monsters"),
|
||||
zombie: Object.freeze({ name: "Zombie", w: 3, h: 5, hp: 3, speed: 9, lurch: 20, points: 100, stomp: true, head: true, color: "#7a1010" }),
|
||||
runner: Object.freeze({ name: "Runner", w: 2.4, h: 5.2, hp: 1, speed: 24, lurch: 34, points: 120, stomp: true, head: true, color: "#7a1010" }),
|
||||
glutton: Object.freeze({ name: "Glutton", w: 4.8, h: 5.4, hp: 15, speed: 5, lurch: 7, points: 250, stomp: true, stompDamage: 3, head: true, color: "#6a1a10" }),
|
||||
crawler: Object.freeze({ name: "Crawler", w: 3, h: 2.4, hp: 2, speed: 16, points: 75, stomp: true, head: false, color: "#7a1010" }),
|
||||
bat: Object.freeze({ name: "Bat", w: 2.6, h: 1.6, hp: 1, speed: 26, points: 50, stomp: true, head: false, color: "#5a0c14" }),
|
||||
ghost: Object.freeze({ name: "Ghost", w: 3.2, h: 4, hp: 3, speed: 10, points: 150, stomp: false, head: false, color: "#b8e6d0" }),
|
||||
skeleton: Object.freeze({ name: "Skeleton", w: 3, h: 5.2, hp: 4, speed: 0, points: 200, stomp: true, head: true, color: "#cfc4a6" }),
|
||||
seed: Object.freeze({ name: "Gourdling", w: 2.2, h: 2, hp: 1, speed: 14, points: 40, stomp: true, head: false, color: "#8a4a12" }),
|
||||
hound: Object.freeze({ name: "Hellhound", w: 3.8, h: 2.6, hp: 2, speed: 13, points: 150, stomp: true, head: false, color: "#8a0e0e" }),
|
||||
spider: Object.freeze({ name: "Widow", w: 3.2, h: 2, hp: 2, speed: 18, points: 120, stomp: true, head: false, color: "#3d5a1a" }),
|
||||
huntsman: Object.freeze({ name: "Huntsman", w: 4.8, h: 2.8, hp: 4, speed: 20, points: 300, stomp: true, head: false, color: "#3a2a12" }),
|
||||
wraith: Object.freeze({ name: "Wraith", w: 3, h: 4.2, hp: 2, speed: 12, points: 200, stomp: false, head: false, color: "#9fb2c4" }),
|
||||
spitter: Object.freeze({ name: "Bloater", w: 4.2, h: 4.8, hp: 5, speed: 3, points: 250, stomp: false, head: true, color: "#8fa82a" }),
|
||||
});
|
||||
export const HEAD_SHARE = 0.3;
|
||||
// The zombies and their kin, which shamble, lurch and come out of doors alike.
|
||||
export const ZOMBIES = new Set(["zombie", "runner", "glutton", ...listPacks("zombies")]);
|
||||
// Now and then a zombie that comes is a Runner (RUNNER_CHANCE: fast, and
|
||||
// down in one bolt) or a Glutton (GLUTTON_CHANCE: slow, 15 bolts to kill, and
|
||||
// it never leaps or climbs), and a widow or a hellhound is a Huntsman
|
||||
// (HUNTSMAN_CHANCE): a big spider on the floor that springs at you.
|
||||
export const RUNNER_CHANCE = 0.14;
|
||||
// A runner shrieks once as it comes within RUNNER_WARN of the view, a
|
||||
// "runner" event with the x on screen nearest it, so one coming up from
|
||||
// behind is heard before it is on you.
|
||||
export const RUNNER_WARN = 14;
|
||||
export const GLUTTON_CHANCE = 0.07;
|
||||
export const HUNTSMAN_CHANCE = 0.12;
|
||||
export function variant(kind, random) {
|
||||
if (kind === "zombie") {
|
||||
const r = random();
|
||||
return r < GLUTTON_CHANCE ? "glutton" : r < GLUTTON_CHANCE + RUNNER_CHANCE ? "runner" : "zombie";
|
||||
}
|
||||
if (kind === "spider" || kind === "hound") return random() < HUNTSMAN_CHANCE ? "huntsman" : kind;
|
||||
return kind;
|
||||
}
|
||||
// A Huntsman runs at you, and within HUNT_RANGE across (and no higher than
|
||||
// HUNT_HIGH over it) crouches HUNT_CROUCH_MS, then springs to come down on
|
||||
// where you are from HUNT_UP above, as high as you are, no faster across
|
||||
// than HUNT_VX, and rests HUNT_REST_MS where it lands.
|
||||
export const HUNT_RANGE = 26;
|
||||
export const HUNT_HIGH = 26;
|
||||
export const HUNT_CROUCH_MS = 380;
|
||||
export const HUNT_UP = 3;
|
||||
export const HUNT_VX = 60;
|
||||
export const HUNT_REST_MS = 700;
|
||||
export const LURCH_RANGE = 20;
|
||||
// A crawler takes RISE_MS to come up through the boards (harmless till up),
|
||||
// woken once you are within CRAWL_NEAR. A bat wakes within BAT_NEAR and
|
||||
// steers toward your chest at BAT_STEER a second. A ghost is solid (it can
|
||||
// hurt and be hit) from GHOST_APPEAR_MS to GHOST_SHOW_MS of its cycle and
|
||||
// faded the rest, GHOST_HIDE_MS; a faded one within GHOST_CLEAR of you stays
|
||||
// faded till you are clear. A skeleton throws a bone every SKEL_MS,
|
||||
// raising its arm for SKEL_WINDUP_MS first, when you are within SKEL_RANGE.
|
||||
export const RISE_MS = 450;
|
||||
export const CRAWL_NEAR = 26;
|
||||
export const BAT_NEAR = 44;
|
||||
export const BAT_STEER = 60;
|
||||
export const BAT_TURN = 18;
|
||||
export const GHOST_APPEAR_MS = 300;
|
||||
export const GHOST_SHOW_MS = 2200;
|
||||
export const GHOST_HIDE_MS = 900;
|
||||
export const GHOST_CLEAR = 4;
|
||||
export const SKEL_MS = 1500;
|
||||
export const SKEL_WINDUP_MS = 350;
|
||||
export const SKEL_RANGE = 60;
|
||||
// Closer than SKEL_NEAR a skeleton holds its bone (it would only go straight up).
|
||||
export const SKEL_NEAR = 6;
|
||||
// A thrown bone (or a glob of acid): up at BONE_V against BONE_G, never
|
||||
// across faster than BONE_VX; shot down for BONE_POINTS.
|
||||
export const BONE_V = 40;
|
||||
export const BONE_G = 110;
|
||||
export const BONE_VX = 42;
|
||||
export const BONE_R = 0.8;
|
||||
export const BONE_POINTS = 25;
|
||||
// A hellhound prowls at its speed; within HOUND_RANGE on your level it
|
||||
// crouches for HOUND_CROUCH_MS (growling), then lunges at HOUND_LUNGE_VX,
|
||||
// up at HOUND_LUNGE_V, and needs HOUND_REST_MS after it lands.
|
||||
export const HOUND_RANGE = 16;
|
||||
export const HOUND_CROUCH_MS = 320;
|
||||
export const HOUND_LUNGE_VX = 40;
|
||||
export const HOUND_LUNGE_V = 40;
|
||||
export const HOUND_REST_MS = 600;
|
||||
// A widow hangs from the ceiling at SPIDER_Y until you come within
|
||||
// SPIDER_NEAR across, then drops on its thread at SPIDER_DROP_V and skitters
|
||||
// after you.
|
||||
export const SPIDER_Y = CEILING_Y - 4;
|
||||
export const SPIDER_NEAR = 22;
|
||||
export const SPIDER_DROP_V = 70;
|
||||
// A wraith waits unseen until you are within WRAITH_NEAR, then hovers
|
||||
// WRAITH_KEEP ahead of you at its height (never more than WRAITH_ABOVE over
|
||||
// you, where a tilted bolt still finds it) for WRAITH_HOVER_MS, shrieks for
|
||||
// WRAITH_WIND_MS, and dives at where your chest was at WRAITH_DIVE_V, on
|
||||
// WRAITH_PAST beyond it before it climbs back.
|
||||
export const WRAITH_NEAR = 60;
|
||||
export const WRAITH_KEEP = 26;
|
||||
export const WRAITH_ABOVE = 12;
|
||||
export const WRAITH_HOVER_MS = 1400;
|
||||
export const WRAITH_WIND_MS = 450;
|
||||
export const WRAITH_DIVE_V = 48;
|
||||
export const WRAITH_PAST = 18;
|
||||
// A bloater wades toward you till SPIT_KEEP away and lobs a glob of acid
|
||||
// every SPIT_MS within SPIT_RANGE, swelling for SPIT_WINDUP_MS first. Acid
|
||||
// that lands leaves a puddle PUDDLE_W wide for PUDDLE_MS that burns whoever
|
||||
// stands in it, and a bloater bursts into globs when it dies.
|
||||
export const SPIT_KEEP = 22;
|
||||
export const SPIT_MS = 2000;
|
||||
export const SPIT_WINDUP_MS = 450;
|
||||
export const SPIT_RANGE = 54;
|
||||
export const PUDDLE_W = 4;
|
||||
export const PUDDLE_MS = 1800;
|
||||
// A wall door holds its zombies while you are within DOOR_CLEAR of it, and
|
||||
// each one steps out over EMERGE_MS, harmless till it is through.
|
||||
export const DOOR_CLEAR = 14;
|
||||
export const EMERGE_MS = 350;
|
||||
// Monsters wake a little off screen; no more than MAX_MONSTERS at once (the
|
||||
// horde stops HORDE_ROOM short of that, leaving room for the rest).
|
||||
export const SPAWN_AHEAD = 4;
|
||||
export const MAX_MONSTERS = 18;
|
||||
export const HORDE_ROOM = 4;
|
||||
|
||||
// The bosses, in a room's last FIELD_W. The arena locks once you are
|
||||
// BOSS_LOCK into it, and the boss wakes after BOSS_INTRO_MS. Its hp grows
|
||||
// BOSS_DEPTH_HP for each stage already cleared that run (up to
|
||||
// BOSS_DEPTH_MAX of them); a stomp deals STOMP_DAMAGE, a shot one (two to
|
||||
// Rattlebones' skull).
|
||||
export const BOSSES = Object.freeze({
|
||||
gourd: Object.freeze({ name: "The Rotting Gourd", sub: "Watch its shadow, then run", w: 14, h: 12, hp: 65, points: 2000, color: "#d0631c" }),
|
||||
...fromPacks("bosses"),
|
||||
});
|
||||
export const BOSS_LOCK = 10;
|
||||
export const BOSS_INTRO_MS = 1000;
|
||||
export const BOSS_DEPTH_HP = 0.12;
|
||||
export const BOSS_DEPTH_MAX = 12;
|
||||
// Each stage cleared makes the monsters a little quicker and lets them out a
|
||||
// little sooner (see roomFor).
|
||||
export const DEPTH_PACE = 0.03;
|
||||
export const DEPTH_EVERY = 0.95;
|
||||
export const STOMP_DAMAGE = 3;
|
||||
// Old Rattlebones' skull starts SKULL_FROM of the way up it: a level bolt
|
||||
// from the Crypt's shelf reaches it.
|
||||
export const SKULL_FROM = 0.72;
|
||||
// The Rotting Gourd waits GOURD_WAIT_MS (shaking the last part of it), then
|
||||
// picks its next move at random, never one three times running: a hop at
|
||||
// GOURD_HOP_V (every third hop GOURD_BIG_V) to land where you stood,
|
||||
// shaking the floor and letting gourdlings loose; a spit, winding up
|
||||
// GOURD_SPIT_MS, then lobbing a glob of acid at each GOURD_SPIT scale of the
|
||||
// throw that lands on you; or a quake, a leap straight up at GOURD_QUAKE_V
|
||||
// that sends a shockwave along the floor both ways as it lands.
|
||||
export const GOURD_WAIT_MS = 850;
|
||||
export const GOURD_HOP_V = 95;
|
||||
export const GOURD_BIG_V = 110;
|
||||
export const GOURD_ACTS = Object.freeze(["hop", "spit", "quake"]);
|
||||
export const GOURD_SPIT_MS = 500;
|
||||
export const GOURD_SPIT = Object.freeze([1, 1.35]);
|
||||
export const GOURD_QUAKE_V = 100;
|
||||
// A gourdling lands and finds its feet for SEED_LAND_MS before it can hurt.
|
||||
export const SEED_LAND_MS = 300;
|
||||
// No more than MAX_SEEDS gourdlings run about at once: one a hop, two a big one.
|
||||
export const MAX_SEEDS = 4;
|
||||
// Old Rattlebones' fight (his volleys, slams, skull, bone rain and skeletons)
|
||||
// lives in ghoul-bones.js; a shockwave runs along the floor at WAVE_SPEED,
|
||||
// WAVE_H high.
|
||||
export const WAVE_SPEED = 40;
|
||||
export const WAVE_H = 2.2;
|
||||
|
||||
// A chandelier shakes CHANDELIER_SHAKE_MS once you run within CHANDELIER_NEAR
|
||||
// under it, then drops; whatever it lands on is crushed.
|
||||
export const CHANDELIER_NEAR = 6;
|
||||
export const CHANDELIER_SHAKE_MS = 350;
|
||||
export const CHANDELIER_W = 7;
|
||||
// A crumbling board shakes CRUMBLE_MS once stood on, then is gone for
|
||||
// CRUMBLE_BACK_MS.
|
||||
export const CRUMBLE_MS = 500;
|
||||
export const CRUMBLE_BACK_MS = 3500;
|
||||
|
||||
// The power-ups (POWERS, TIMED, FLAP_CLEAR, HOURGLASS_MS), which can turn up
|
||||
// where, and picking up candy, power-ups, crystals and the key live in
|
||||
// ghoul-powers.js.
|
||||
|
||||
// A room is dark DARK_CHANCE of the times it is entered (unless its spec
|
||||
// says which); a lit one never has a Lantern, its placed ones swapped for
|
||||
// another power-up (never a 1UP).
|
||||
export const DARK_CHANCE = 0.6;
|
||||
// In a dark room only DARK_BEHIND of what comes in from the edge behind
|
||||
// you (the horde, the stragglers once the bonus is gone) gets in.
|
||||
export const DARK_BEHIND = 0.5;
|
||||
export const DROP_CANDY = 0.3;
|
||||
export const DROP_POWER = 0.07;
|
||||
// Stragglers: the horde (and the dead that come once the bonus is gone)
|
||||
// never ends, so each of its kills in a room is worth STRAY_FADE of the last
|
||||
// (never under STRAY_MIN of its points) and leaves nothing behind. Holding a
|
||||
// doorway to farm them pays next to nothing.
|
||||
export const STRAY_FADE = 0.8;
|
||||
export const STRAY_MIN = 0.1;
|
||||
export const DROP_MS = 9000;
|
||||
export const GARLIC_SAFE_MS = 1200;
|
||||
|
||||
// Points: a kill is its points times the chain (kills each within CHAIN_MS
|
||||
// of the last, the multiplier capped at MAX_MULT), doubled for a headshot or
|
||||
// a stomp. Candy is CANDY_POINTS, a power-up POWER_POINTS. Through a door,
|
||||
// ROOM_POINTS times the room plus the time bonus left (BONUS_START, dropping
|
||||
// BONUS_STEP a second) and FLAWLESS_POINTS with no life lost; a boss is its
|
||||
// points, more the deeper into the run (see roomFor), and a life.
|
||||
export const CHAIN_MS = 1200;
|
||||
export const MAX_MULT = 10;
|
||||
// CANDY_POINTS, POWER_POINTS and CRYSTAL_POINTS are in ghoul-powers.js.
|
||||
export const ROOM_POINTS = 300;
|
||||
export const BONUS_START = 1500;
|
||||
export const BONUS_STEP = 50;
|
||||
export const FLAWLESS_POINTS = 500;
|
||||
// With the bonus run out, a zombie shambles in from the edge every HURRY_MS.
|
||||
export const HURRY_MS = 1500;
|
||||
|
||||
// The clock: every room but a boss's gives TIME_BASE_S plus TIME_PER_UNIT_S
|
||||
// a unit of its length, to the nearest 5 seconds (70 to 80), to get out. At
|
||||
// none a life goes, and the room starts over with a full clock. The last
|
||||
// TIME_WARN_MS tick away out loud.
|
||||
export const TIME_BASE_S = 30;
|
||||
export const TIME_PER_UNIT_S = 0.09;
|
||||
export const TIME_WARN_MS = 10000;
|
||||
export const timeFor = (spec) => (spec.boss ? 0 : spec.ride ? spec.ride.time : Math.round((TIME_BASE_S + spec.length * TIME_PER_UNIT_S) / 5) * 5000);
|
||||
|
||||
// Piling up: STACK_MIN or more walkers (zombies, crawlers, gourdlings) each
|
||||
// within STACK_NEAR of the next on the same floor are a pile, and once you
|
||||
// are above them and within STACK_REACH across they climb over each other to
|
||||
// reach you: the oldest stays at the bottom and each one more stands
|
||||
// STACK_STEP of its height over the one below, rising at CLIMB_V, only as
|
||||
// high as it takes to reach your feet. A pile that breaks up, or that you
|
||||
// leave, drops back at UNSTACK_V. So waiting on a shelf over a crowd for a
|
||||
// run of stomps is never safe.
|
||||
export const STACK_MIN = 2;
|
||||
export const STACK_NEAR = 2.2;
|
||||
export const STACK_REACH = 12;
|
||||
export const STACK_STEP = 0.8;
|
||||
export const CLIMB_V = 14;
|
||||
export const UNSTACK_V = 30;
|
||||
export const STACKERS = new Set(["zombie", "runner", "crawler", "seed", ...listPacks("stackers")]);
|
||||
// A walker climbing (a pile or a wall) reaches up with both arms, ARMS_UP
|
||||
// over its head: landing on them hurts you. Only a landing within HEAD_BONK
|
||||
// of its middle comes down on its head between them, for a stomp.
|
||||
export const ARMS_UP = 1.4;
|
||||
export const HEAD_BONK = 0.9;
|
||||
export const reaching = (m) => m.lift > 0.5 || Boolean(m.scale);
|
||||
|
||||
// Hopping a pit: a walker that comes to the edge of a pit, or of a drop to
|
||||
// a lower floor, stops and thinks about it for PONDER_MS (PONDER_STEP_MS
|
||||
// more for some, so a crowd does not leap as one), then leaps, rising at
|
||||
// HOP_V and landing HOP_IN past the far edge. Across to floor about its own
|
||||
// height it clears HOP_GAP; down to a lower one it is longer in the air and
|
||||
// so clears more, as far as the same leap carries. Floor higher than a step
|
||||
// up, or a pit too wide, stops it for good. Anything on four legs (a hound, a
|
||||
// topiary beast, a wolf-man) leaps BOUND_REACH times as far and twice as high
|
||||
// (rising at BOUND_V), so it also lands on floor up to BOUND_UP above it across
|
||||
// a gap. A wall with no gap before it still stops one: it never climbs.
|
||||
export const HOP_GAP = 10.5;
|
||||
export const BOUND_REACH = 2;
|
||||
export const HOP_V = 50;
|
||||
export const BOUND_V = HOP_V * Math.SQRT2;
|
||||
export const BOUND_UP = 9;
|
||||
export const HOP_IN = 1.5;
|
||||
export const PONDER_MS = 900;
|
||||
export const PONDER_STEP_MS = 150;
|
||||
// Climbing a wall: a zombie, a runner or a crawler stopped by floor more than
|
||||
// a step up (no more than WALL_MAX) thinks about it the same way, then
|
||||
// climbs its face at WALL_V and steps on at the top. A glutton is too heavy
|
||||
// to leap a pit or climb, but steps off a ledge onto the floor below.
|
||||
export const WALL_MAX = 8;
|
||||
export const WALL_V = 7;
|
||||
export const CLIMBERS = new Set(["zombie", "runner", "crawler", ...listPacks("climbers")]);
|
||||
export const HEAVY = new Set(["glutton"]);
|
||||
const FOUR_LEGGED = new Set(["hound", ...listPacks("fourLegged")]);
|
||||
// A turned villager is a villager until the moon says otherwise, so it goes by
|
||||
// `m.turned`, not kind.
|
||||
export const bounds = (m) => FOUR_LEGGED.has(m.kind) || Boolean(m.turned);
|
||||
// How far across a monster's leap clears, on the level.
|
||||
export const hopReach = (m) => HOP_GAP * (bounds(m) ? BOUND_REACH : 1);
|
||||
// Everything that walks the floor with walk(), and so can stand on a bridge.
|
||||
export const WALKERS = new Set(["zombie", "runner", "glutton", "crawler", "seed", "spitter", "hound", "huntsman", ...listPacks("walkers"), ...listPacks("zombies")]);
|
||||
|
||||
// A life lost holds CRASH_MS, then puts you back at the room's start (in a
|
||||
// boss room, the arena's) for READY_MS, safe for SAFE_MS. A door gone through
|
||||
// holds CLEAR_MS.
|
||||
export const START_LIVES = 7;
|
||||
export const CRASH_MS = 900;
|
||||
export const READY_MS = 500;
|
||||
export const SAFE_MS = 1200;
|
||||
// A life lost within QUICK_LOSS_MS (12 s) of coming in (into a room, or back after
|
||||
// the last life lost) brings Planny back holding the Garlic shield.
|
||||
export const QUICK_LOSS_MS = 12000;
|
||||
export const CLEAR_MS = 1200;
|
||||
// Stages offered at each choice, and how long the offer settles before a
|
||||
// press takes one.
|
||||
export const OFFER_N = 2;
|
||||
export const PICK_HOLD_MS = 700;
|
||||
export const BANNER_STRETCH = 2;
|
||||
export const DOOR_REACH = 2.5;
|
||||
|
||||
// A banner fades to BANNER_SEE_THROUGH over BANNER_FADE_MS while something
|
||||
// that matters to you is in its strip, BANNER_REACH either side of its middle.
|
||||
export const BANNER_SEE_THROUGH = 0.12;
|
||||
export const BANNER_FADE_MS = 140;
|
||||
export const BANNER_REACH = 8;
|
||||
|
||||
// The camera eases toward a spot CAM_LEAD ahead of the way you face.
|
||||
export const CAM_EASE = 9;
|
||||
export const CAM_AT = 0.32;
|
||||
export const CAM_LEAD = 12;
|
||||
|
||||
export const chainMult = (chain) => Math.max(1, Math.min(MAX_MULT, chain));
|
||||
|
||||
export const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
|
||||
// A small seeded random (mulberry32), handed to advance() so a seed always
|
||||
// plays the same drops, throws and hops (the rooms themselves are fixed).
|
||||
export function seeded(seed) {
|
||||
let a = seed >>> 0;
|
||||
return () => {
|
||||
a = (a + 0x6d2b79f5) >>> 0;
|
||||
let t = a;
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1);
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
}
|
||||
|
||||
// How high a jump is, `dx` across from where it left, at RUN_SPEED: the
|
||||
// unit suite's measure of which gaps and ledges a jump can clear.
|
||||
export function jumpHeightAt(dx) {
|
||||
const t = Math.abs(dx) / RUN_SPEED;
|
||||
return JUMP_V * t - (GRAVITY * t * t) / 2;
|
||||
}
|
||||
export const JUMP_TOP = (JUMP_V * JUMP_V) / (2 * GRAVITY);
|
||||
|
||||
/* -------------------------------------------------------------- rooms */
|
||||
|
||||
// A room's numbers, built once each for the room `id` (as ghoul-rooms.js
|
||||
// lays it out) played `depth` stages into a run: the deeper, the quicker and
|
||||
// tougher its monsters, the sooner they are let out, and the more hp (and
|
||||
// points) its boss has, each capped.
|
||||
const BUILT = new Map();
|
||||
|
||||
export function roomFor(id, depth = 0) {
|
||||
const base = roomById(id) || ROOMS[0];
|
||||
const d = Math.max(0, Math.floor(depth) || 0);
|
||||
const k = `${base.id}:${d}`;
|
||||
if (BUILT.has(k)) return BUILT.get(k);
|
||||
const candy = [];
|
||||
for (const [x0, y, count] of base.candy) for (let i = 0; i < count; i++) candy.push(Object.freeze({ x: x0 + i * 3, y }));
|
||||
const spec = Object.freeze({
|
||||
...base,
|
||||
depth: d,
|
||||
base,
|
||||
name: base.title,
|
||||
pace: Math.min(1.4, 1 + DEPTH_PACE * d),
|
||||
every: Math.max(0.55, DEPTH_EVERY ** d),
|
||||
tough: Math.min(2, Math.floor(d / 3)),
|
||||
// Doors in the wall let this many more out.
|
||||
extra: Math.min(2, Math.floor(d / 2)),
|
||||
bossHp: base.boss ? Math.round(BOSSES[base.boss].hp * (1 + BOSS_DEPTH_HP * Math.min(d, BOSS_DEPTH_MAX))) : 0,
|
||||
bossPoints: base.boss ? Math.round(BOSSES[base.boss].points * (1 + d / 4)) : 0,
|
||||
candyAt: Object.freeze(candy),
|
||||
arena: base.boss ? base.length - FIELD_W : -1,
|
||||
});
|
||||
BUILT.set(k, spec);
|
||||
return spec;
|
||||
}
|
||||
|
||||
// "Library (room 3)": room `n` of a run.
|
||||
export const roomName = (spec, n) => `${spec.name} (room ${n})`;
|
||||
|
||||
export const PLATFORMS = fromPacks("platform");
|
||||
// Your keys while the bell has frozen you: none.
|
||||
export const FROZEN = Object.freeze({});
|
||||
@@ -0,0 +1,653 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's window: the game's contract with the Activities page (create), its keys and pointer, what fx and sounds its events set off, each room's music (ROOM_MUSIC), and the view handed to the drawing.
|
||||
//
|
||||
// One of the parts of ghoul.js (see its header and the list of parts there).
|
||||
|
||||
import { armOnTop, pressFire as pressFireWith, releaseFire, resetTap } from "../arms/ghoul-arms.js";
|
||||
import { GOLD, bonusTick, drawScene, lookOf, react, readColors } from "../draw/ghoul-draw.js";
|
||||
import { isWaiting, startRide } from "../rides/dark-ride/ghoul-ride.js";
|
||||
import { lanternHums } from "../rides/lantern/ghoul-lantern.js";
|
||||
import { BONES_WINDUP_MS } from "../stages/wing/ghoul-bones.js";
|
||||
import { beginStory, pressStory, releaseStory, takeStory } from "../story/ghoul-story.js";
|
||||
import { heartsText } from "./ghoul-bonus.js";
|
||||
import { answerAsk, steerAsk } from "./ghoul-dice.js";
|
||||
import { ARM_POP_MS, PILL_WORDS, POWERS, TIMED } from "./ghoul-powers.js";
|
||||
import { CEILING_Y, FIELD_H, FIELD_W, STAGES, roomById, stageById } from "./ghoul-rooms.js";
|
||||
import { onCard, openSelect, steerPick } from "./ghoul-run.js";
|
||||
import { DICE_KIT } from "./ghoul-fight.js";
|
||||
import { POINTERS, ghostSight, solid } from "./ghoul-monsters.js";
|
||||
import { groundAt, shelfThere } from "./ghoul-planny.js";
|
||||
import { KIT } from "./ghoul-kit.js";
|
||||
import { advance, bannerY, fire, newRound, pickStage, steerSelect, stomps, takeIntro, takeSelect, underBanner } from "./ghoul-play.js";
|
||||
import { BANNER_FADE_MS, BANNER_SEE_THROUGH, BANNER_STRETCH, BOSSES, BOSS_INTRO_MS, CHAIN_MS, CHANDELIER_SHAKE_MS, CHANDELIER_W, CLEAR_MS, CRASH_MS, CRUMBLE_BACK_MS, DUCK_SHOT_Y, EMERGE_MS, GOURD_WAIT_MS, H, HEAT_FREE, HEAT_MAX, HEAT_SHOWN, HOUND_CROUCH_MS, HUD_H, JUMP_BUFFER_MS, MIN_CELL, MONSTERS, OFFER_N, PAD, PUDDLE_MS, PUDDLE_W, READY_MS, RISE_MS, SHOT_Y, SKEL_WINDUP_MS, SPIT_WINDUP_MS, TIME_WARN_MS, W, WAVE_H, WRAITH_WIND_MS, YOU_H, YOU_W, ZOMBIES, chainMult, roomFor, roomName } from "./ghoul-tables.js";
|
||||
|
||||
/* ------------------------------------------------------------- contract */
|
||||
|
||||
const MAX_PARTS = 320;
|
||||
// Flares of light and floor stains kept at once, and how long a stain lasts.
|
||||
const MAX_GLOWS = 24;
|
||||
const MAX_SPLATS = 40;
|
||||
const SPLAT_MS = 14000;
|
||||
// Lightning: the first a few seconds in, then every BOLT_EVERY_MS or so,
|
||||
// each BOLT_MS long.
|
||||
const BOLT_FIRST_MS = 4000;
|
||||
const BOLT_EVERY_MS = 11000;
|
||||
const BOLT_MS = 650;
|
||||
|
||||
// How far a flash of lightning `left` ms from its end lifts the dark, 0 to
|
||||
// 1: a bright flash, a flicker off, a second flash, then a fade.
|
||||
export function lightning(left) {
|
||||
if (!(left > 0)) return 0;
|
||||
const p = 1 - left / BOLT_MS;
|
||||
if (p < 0.1) return 1;
|
||||
if (p < 0.2) return 0.15;
|
||||
if (p < 0.3) return 0.85;
|
||||
return Math.max(0, (1 - p) / 0.7) * 0.4;
|
||||
}
|
||||
|
||||
// The end screen's nudge to play again, by the most stages ever cleared.
|
||||
function teaser(most) {
|
||||
if (most < STAGES.length) return `Best: ${most} of ${STAGES.length} stages. Clear them all to escape.`;
|
||||
return "You have escaped the house before. Can you do it again?";
|
||||
}
|
||||
|
||||
// The held sounds under play (no drone under the house: every room has its
|
||||
// own music). The nearest monster within NEAR_SOUND (its hum by kind,
|
||||
// louder the closer); a footstep every STEP_MS while you run; the heart
|
||||
// pounding on the last life, quicker with a monster within HEART_NEAR.
|
||||
const NEAR_HUMS = Object.freeze({ zombie: "ghoulMoan", runner: "ghoulMoan", glutton: "ghoulMoan", huntsman: "ghoulSnarl", crawler: "ghoulMoan", spitter: "ghoulMoan", bat: "ghoulFlutter", ghost: "ghoulSpecter", wraith: "ghoulSpecter", hound: "ghoulSnarl", spider: "ghoulSnarl" });
|
||||
const NEAR_PITCH = Object.freeze({ runner: 1.35, glutton: 0.6, huntsman: 0.75, crawler: 1.25, spitter: 0.7, wraith: 0.8, spider: 1.4 });
|
||||
const NEAR_SOUND = 36;
|
||||
const STEP_MS = 270;
|
||||
const HEART_MS = 1000;
|
||||
const HEART_FAST_MS = 600;
|
||||
const HEART_NEAR = 16;
|
||||
// Each room's music, from ghoul-sfx.js, at one steady level whatever the
|
||||
// monsters are doing: DREAD_ROOM brings in everything but a track's top
|
||||
// layers (its melody and drums included), the clock's last seconds add
|
||||
// DREAD_CLOCK, and a boss fight plays all of it. The level eases toward its
|
||||
// target over about DREAD_EASE_MS, so a change never lands as a jolt.
|
||||
export const ROOM_MUSIC = Object.freeze({ banister: "ghoulBanister", hall: "ghoulHall", darkride: "ghoulRideTheme", lychgate: "ghoulLychgate", graves: "ghoulGraves", mausoleums: "ghoulMausoleums", angel: "ghoulAngel", maze: "ghoulMaze", topiary: "ghoulTopiary", gazebo: "ghoulGazebo", yard: "ghoulYard", nave: "ghoulNave", tower: "ghoulTower", loft: "ghoulLoft", choir: "ghoulChoir", shaft: "ghoulShaft", tunnels: "ghoulTunnels", collapse: "ghoulCollapse", seam: "ghoulSeam", cart: "ghoulCart", midway: "ghoulMidway", mirrors: "ghoulMirrors", funhouse: "ghoulFunhouse", bigtop: "ghoulBigTop", admissions: "ghoulAdmissions", baths: "ghoulBaths", theater: "ghoulTheater", ward: "ghoulWard", street: "ghoulStreet", inn: "ghoulInn", square: "ghoulSquare", green: "ghoulGreen", foyer: "ghoulFoyer", gallery: "ghoulGallery", library: "ghoulLibrary", ballroom: "ghoulBallroom", kitchen: "ghoulKitchen", conservatory: "ghoulConservatory", attic: "ghoulAttic", crypt: "ghoulCrypt", huts: "ghoulHuts", lodge: "ghoulLodge", blackice: "ghoulBlackIce", sled: "ghoulSledRide", codeblue: "ghoulBlueRide", pew: "ghoulPewDirge", mower: "ghoulMowerRide", wagon: "ghoulWagonRide", hearse: "ghoulHearseRide", tray: "ghoulTrayRide", widow: "ghoulWidow", boardwalk: "ghoulBoardwalk", hollow: "ghoulHollow", stilts: "ghoulStilts", lantern: "ghoulLanternTheme", drowning: "ghoulDrowning" });
|
||||
const DREAD_ROOM = 0.7;
|
||||
const DREAD_CLOCK = 0.2;
|
||||
const DREAD_EASE_MS = 900;
|
||||
|
||||
// How full the music is right now, 0 to 1: the target the music eases toward.
|
||||
export function dread(round) {
|
||||
const b = round.boss;
|
||||
if (b && round.lockX >= 0 && (b.state === "fight" || b.state === "intro")) return 0.9 + 0.1 * (1 - b.hp / Math.max(1, b.max));
|
||||
if (round.gallery && round.gallery.track) return 0.9;
|
||||
let level = DREAD_ROOM;
|
||||
if (round.timeMs > 0 && round.timeMs <= TIME_WARN_MS) level += DREAD_CLOCK;
|
||||
return Math.min(1, level);
|
||||
}
|
||||
|
||||
// A sound's pitch a little either side of 1, so it never repeats exactly.
|
||||
const vary = (n = 0.1) => 1 - n / 2 + Math.random() * n;
|
||||
|
||||
function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onScore = () => {}, best = () => 0, memo = null }) {
|
||||
const ctx = canvas.getContext("2d");
|
||||
let colors = null;
|
||||
let round = newRound();
|
||||
let state = "ready";
|
||||
let u = MIN_CELL;
|
||||
let bestAtStart = 0;
|
||||
let beaten = false;
|
||||
// A jump press waits for the first tick after a start or a play-on, so the
|
||||
// key that plays on never also jumps; and up must be let go between jumps.
|
||||
let armed = false;
|
||||
let upHeld = false;
|
||||
// The most stages ever cleared in one run, and whether this run beat it.
|
||||
// Without a memo (the unit suite) it lasts as long as the game.
|
||||
let most = 0;
|
||||
let further = false;
|
||||
try {
|
||||
most = Math.max(0, memo ? Number(memo.get()) | 0 : 0);
|
||||
} catch {}
|
||||
// Particles, floating words, rings, banners, the chain's big number, the
|
||||
// shake and the flash, the flares of light and the stains on the floor,
|
||||
// and the lightning, in room units (y up) and ms.
|
||||
let fx = null;
|
||||
const resetFx = () => (fx = { parts: [], floats: [], banners: [], rings: [], glows: [], splats: [], shake: 0, shakeMag: 0, flash: null, clock: 0, cheer: 0, combo: null, candyRun: 0, candyMs: 0, step: 0, bolt: 0, nextBolt: BOLT_FIRST_MS, stepMs: 0, foot: 0, beatMs: 0, hot: false, dread: 0 });
|
||||
resetFx();
|
||||
|
||||
const burst = (x, y, color, n, speed = 14, life = 500) => {
|
||||
for (let i = 0; i < n && fx.parts.length < MAX_PARTS; i++) {
|
||||
const a = Math.random() * Math.PI * 2;
|
||||
const v = speed * (0.35 + Math.random() * 0.65);
|
||||
fx.parts.push({ x, y, vx: Math.cos(a) * v, vy: Math.sin(a) * v, life: life * (0.6 + Math.random() * 0.4), max: life, color, size: 0.45 + Math.random() * 0.55 });
|
||||
}
|
||||
};
|
||||
const float = (x, y, text, color, size = 2.4) => fx.floats.push({ x, y, rise: 0, text, color, size, life: 900, max: 900 });
|
||||
const ring = (x, y, color, r0, grow, ms = 420) => fx.rings.push({ x, y, color, r0, grow, life: ms, max: ms });
|
||||
// A flare of light that lifts the dark around (x, y) and fades over `ms`.
|
||||
const glow = (x, y, r, s, ms) => fx.glows.length < MAX_GLOWS && fx.glows.push({ x, y, r, s, life: ms, max: ms });
|
||||
// A stain on the floor at (x, y), the oldest gone once there are too many.
|
||||
const splat = (x, y, r, color) => {
|
||||
if (fx.splats.length >= MAX_SPLATS) fx.splats.shift();
|
||||
fx.splats.push({ x, y, r, color, life: SPLAT_MS });
|
||||
};
|
||||
const floorAt = (x) => groundAt(round.spec, x);
|
||||
// A banner waits its turn behind the one showing, three at most. One
|
||||
// tied to a phase (`phase`: "Ready?" to the hold before play) is dropped
|
||||
// once that phase has passed; a full queue makes room for a more
|
||||
// important one (`rank`: "New best!") by dropping the least important one
|
||||
// waiting, and otherwise drops the newcomer.
|
||||
// Every banner is up BANNER_STRETCH times as long as its caller asks, so the words can be read.
|
||||
const banner = (title, sub, color, ms = 1800, { phase = "", rank = 0 } = {}) => {
|
||||
ms *= BANNER_STRETCH;
|
||||
if (fx.banners.some((b) => b.title === title)) return null;
|
||||
if (fx.banners.length >= 3) {
|
||||
let low = -1;
|
||||
for (let i = 1; i < fx.banners.length; i++) if (fx.banners[i].rank < rank && (low < 0 || fx.banners[i].rank < fx.banners[low].rank)) low = i;
|
||||
if (low < 0) return null;
|
||||
fx.banners.splice(low, 1);
|
||||
}
|
||||
const b = { title, sub, color, life: ms, max: ms, tag: "", y: null, see: 1, phase, rank };
|
||||
fx.banners.push(b);
|
||||
return b;
|
||||
};
|
||||
// A shake still running keeps the stronger of the two; a new one starts
|
||||
// from its own strength, so one big hit never loudens every later shake.
|
||||
const shake = (ms, mag) => {
|
||||
fx.shakeMag = Math.max(fx.shake > 0 ? fx.shakeMag : 0, mag);
|
||||
fx.shake = Math.max(fx.shake, ms);
|
||||
};
|
||||
const flash = (color, ms = 220) => (fx.flash = { color, life: ms, max: ms });
|
||||
|
||||
// A stage cleared: a new record (most stages in a run) is saved, and
|
||||
// named on the banner `b`.
|
||||
const markFurthest = (n, b) => {
|
||||
if (n <= most || round.practice) return;
|
||||
most = n;
|
||||
further = true;
|
||||
try {
|
||||
if (memo) memo.set(most);
|
||||
} catch {}
|
||||
if (b) b.tag = `NEW RECORD: ${n} OF ${STAGES.length} STAGES`;
|
||||
};
|
||||
|
||||
// A room's banner, named for its stage and how far into it.
|
||||
const roomBanner = (n) => {
|
||||
const spec = round.spec;
|
||||
const b = banner(`Room ${n}: ${spec.name}`, spec.sub, lookOf(spec.id).color, 2000);
|
||||
const st = round.stage && stageById(round.stage);
|
||||
if (b && st) b.tag = `${st.title.toUpperCase()}, ${round.stageAt + 1} OF ${st.rooms.length}`;
|
||||
return b;
|
||||
};
|
||||
|
||||
const kit = { tone, burst, float, ring, banner, shake, flash, glow, splat, floorAt, get fx() { return fx; }, roomBanner, markFurthest, monsters: MONSTERS, powers: POWERS, bosses: BOSSES, g: Object.freeze({ READY_MS, BOSS_INTRO_MS, CLEAR_MS }) };
|
||||
const handle = (e) => react(e, kit);
|
||||
|
||||
// A score past the best this round began with: once a round, a fanfare.
|
||||
const checkBest = () => {
|
||||
if (beaten || round.practice || !(bestAtStart > 0) || round.score <= bestAtStart) return;
|
||||
beaten = true;
|
||||
tone("best");
|
||||
tone("fanfare", 0.45);
|
||||
banner("New best!", "Every point from here is a record", GOLD, 1700, { rank: 2 });
|
||||
};
|
||||
|
||||
const drain = () => {
|
||||
colors ||= readColors(canvas);
|
||||
for (const e of round.events.splice(0)) handle(e);
|
||||
checkBest();
|
||||
};
|
||||
|
||||
// Banners tied to a phase that has passed ("Ready?" once play is on) go,
|
||||
// wherever they wait in the queue.
|
||||
const dropPassed = () => {
|
||||
if (fx.banners.some((b) => b.phase && b.phase !== round.phase)) fx.banners = fx.banners.filter((b) => !b.phase || b.phase === round.phase);
|
||||
};
|
||||
|
||||
const runFx = (ms) => {
|
||||
fx.clock += ms;
|
||||
const s = ms / 1000;
|
||||
fx.parts = fx.parts.filter((p) => {
|
||||
p.life -= ms;
|
||||
p.x += p.vx * s;
|
||||
p.y += p.vy * s;
|
||||
const drag = 0.9 ** (ms / 16);
|
||||
p.vx *= drag;
|
||||
p.vy = p.vy * drag - 12 * s;
|
||||
return p.life > 0;
|
||||
});
|
||||
fx.floats = fx.floats.filter((f) => {
|
||||
f.life -= ms;
|
||||
f.rise += 5 * s;
|
||||
return f.life > 0;
|
||||
});
|
||||
fx.rings = fx.rings.filter((r) => (r.life -= ms) > 0);
|
||||
fx.glows = fx.glows.filter((gl) => (gl.life -= ms) > 0);
|
||||
fx.splats = fx.splats.filter((sp) => (sp.life -= ms) > 0);
|
||||
// Lightning now and then, the thunder with it.
|
||||
fx.bolt = Math.max(0, fx.bolt - ms);
|
||||
fx.nextBolt -= ms;
|
||||
if (fx.nextBolt <= 0) {
|
||||
fx.bolt = BOLT_MS;
|
||||
fx.nextBolt = BOLT_EVERY_MS * (0.6 + Math.random() * 0.8);
|
||||
const deep = 0.8 + Math.random() * 0.4;
|
||||
tone("ghoulThunder", 0.5, deep);
|
||||
tone("ghoulCrack", 0.3, deep);
|
||||
tone("rumbleLong", 0.5, deep);
|
||||
}
|
||||
if (fx.combo && (fx.combo.life -= ms) <= 0) fx.combo = null;
|
||||
if (fx.lucky && (fx.lucky.life -= ms) <= 0) fx.lucky = null;
|
||||
fx.cheer = Math.max(0, fx.cheer - ms);
|
||||
fx.candyMs = Math.max(0, fx.candyMs - ms);
|
||||
dropPassed();
|
||||
if (fx.banners.length) {
|
||||
const b = fx.banners[0];
|
||||
if (b.y == null) b.y = bannerY(round);
|
||||
const target = underBanner(round, b.y) ? BANNER_SEE_THROUGH : 1;
|
||||
b.see += (target - b.see) * Math.min(1, ms / BANNER_FADE_MS);
|
||||
b.life -= ms;
|
||||
if (b.life <= 0) fx.banners.shift();
|
||||
dropPassed();
|
||||
}
|
||||
fx.shake = Math.max(0, fx.shake - ms);
|
||||
if (fx.flash && (fx.flash.life -= ms) <= 0) fx.flash = null;
|
||||
};
|
||||
|
||||
// The pills' numbers: the stage and how many are cleared, lives, the bonus, the chain while it runs,
|
||||
// the key once held, and the power-ups held (a timed one emptying as it runs).
|
||||
const effects = [];
|
||||
const gauge = { fill: 0, free: HEAT_FREE / HEAT_MAX, rapid: null };
|
||||
const hud = { room: "", stage: "", time: 0, timeLow: false, bonus: 0, chain: 0, chainFill: 1, key: "", effects, gauge, arm: null };
|
||||
const hudOf = () => {
|
||||
const you = round.you;
|
||||
effects.length = 0;
|
||||
for (const k of TIMED) if (round.effects[k] > 0) effects.push({ text: PILL_WORDS[k], color: POWERS[k].color, fill: Math.min(1, round.effects[k] / POWERS[k].ms) });
|
||||
if (you.garlic) effects.push({ text: "GARLIC", color: POWERS.garlic.color, fill: 1 });
|
||||
if (you.hat) effects.push({ text: PILL_WORDS.hat, color: POWERS.hat.color, fill: 1 });
|
||||
if (round.dice > 0) effects.push({ text: `DICE x${round.dice}`, color: POWERS.die.color, fill: 1 });
|
||||
// The blaster's heat for the gauge, the notch where its bolts slow.
|
||||
gauge.fill = round.heat / HEAT_MAX;
|
||||
gauge.rapid = round.effects.rapid > 0 ? POWERS.rapid.color : null;
|
||||
// The stage (or the hall) by name, and how many stages are cleared of
|
||||
// all there are.
|
||||
const st = round.stage && stageById(round.stage);
|
||||
hud.room = (st ? st.title : round.spec.name).toUpperCase();
|
||||
hud.stage = `STAGE ${round.cleared.length} OF ${STAGES.length}`;
|
||||
hud.bonus = round.bonus;
|
||||
hud.hearts = round.bonusRound ? heartsText(round.bonusRound) : "";
|
||||
hud.time = round.timeMs > 0 ? Math.ceil(round.timeMs / 1000) : 0;
|
||||
hud.timeLow = round.timeMs > 0 && round.timeMs <= TIME_WARN_MS;
|
||||
hud.chain = round.chain > 1 ? chainMult(round.chain) : 0;
|
||||
hud.chainFill = round.chainMs / CHAIN_MS;
|
||||
// "have" once found, "need" until then; a room with no key (a boss, a bonus ride) shows nothing.
|
||||
hud.key = round.spec.key && !round.spec.boss && !round.spec.bonus ? (round.hasKey ? "have" : "need") : "";
|
||||
// The Drowned Lantern has no blaster (SPACE flares the lantern, its oil drawn by the room's own art): no gauge.
|
||||
hud.gauge = round.runner && round.runner.id === "lantern" ? null : gauge;
|
||||
// The weapon that comes out next, its count, and how many other kinds wait under it.
|
||||
const top = armOnTop(round);
|
||||
hud.arm = top ? { kind: top.kind, n: top.n, more: round.arms.length - 1, text: `x${top.n}${round.arms.length > 1 ? ` +${round.arms.length - 1}` : ""}${round.armUsed ? "" : " TAP TAP"}`, color: POWERS[top.kind].color, fresh: !round.armUsed, pop: (round.armPopMs || 0) / ARM_POP_MS } : null;
|
||||
return hud;
|
||||
};
|
||||
|
||||
// The view ghoul-draw.js draws from: one object, refilled each frame.
|
||||
const view = { g: Object.freeze({ W, H, HUD_H, PAD, FIELD_W, FIELD_H, YOU_W, YOU_H, CRASH_MS, CRUMBLE_BACK_MS, RISE_MS, SKEL_WINDUP_MS, BONES_WINDUP_MS, WAVE_H, CHANDELIER_W, CHANDELIER_SHAKE_MS, SHOT_Y, DUCK_SHOT_Y, GOURD_WAIT_MS, EMERGE_MS, PUDDLE_W, PUDDLE_MS, HOUND_CROUCH_MS, WRAITH_WIND_MS, SPIT_WINDUP_MS, CEILING_Y, ZOMBIES }), powers: POWERS, monsters: MONSTERS, bosses: BOSSES, groundAt, shelfThere, solid, ghostSight, roomFor, roomById, stages: STAGES, stageById, OFFER_N };
|
||||
const shakeAt = { x: 0, y: 0 };
|
||||
|
||||
const paint = () => {
|
||||
if (!ctx) return;
|
||||
colors ||= readColors(canvas);
|
||||
// A banner takes its place on its first frame: a frame painted before the
|
||||
// next tick (the start's, held through the 3, 2, 1) would draw it at the top.
|
||||
dropPassed();
|
||||
const head = fx.banners[0] || null;
|
||||
if (head && head.y == null) head.y = bannerY(round);
|
||||
view.u = u;
|
||||
view.clock = fx.clock;
|
||||
view.state = state;
|
||||
view.colors = colors;
|
||||
view.round = round;
|
||||
view.spec = round.spec;
|
||||
view.fx = fx;
|
||||
view.pillH = Math.max(12 / u, 2.4);
|
||||
view.hud = hudOf();
|
||||
view.cheer = fx.cheer > 0 || round.phase === "clear";
|
||||
view.combo = fx.combo;
|
||||
view.flash = fx.flash;
|
||||
view.banner = head;
|
||||
view.lightning = lightning(fx.bolt);
|
||||
view.furthest = most;
|
||||
view.won = round.won;
|
||||
// A dot per stage along the start and end screens: those cleared this
|
||||
// run in their colors (or, before one, as many as the record, in gold).
|
||||
view.dots = STAGES.map((_, i) => (state === "ready" ? (i < most ? GOLD : null) : round.cleared[i] || null));
|
||||
view.lost = state === "over";
|
||||
view.overMs = fx.clock - (fx.overAt || 0);
|
||||
view.shake = null;
|
||||
if (fx.shake > 0 && state === "running") {
|
||||
shakeAt.x = (Math.random() - 0.5) * 2 * fx.shakeMag;
|
||||
shakeAt.y = (Math.random() - 0.5) * 2 * fx.shakeMag;
|
||||
view.shake = shakeAt;
|
||||
}
|
||||
view.tally = null;
|
||||
view.big = null;
|
||||
const record = most >= STAGES.length ? "You have escaped before" : `Best: ${most} of ${STAGES.length} stages`;
|
||||
if (state === "ready") view.tally = ["Run. Shoot. Clear every stage and escape before the house gets you", `Arrows run, up jumps, hold space to fire, tap it twice to throw what you find. ${record}`];
|
||||
else if (state === "over") {
|
||||
const st = round.stats;
|
||||
view.big = String(round.score);
|
||||
const how = `${st.kills} ghouls (${st.headshots} headshots, ${st.stomps} stomps), best chain x${chainMult(st.bestChain)}, ${st.candy} souls.`;
|
||||
if (round.won) view.tally = [`You escaped! Every stage cleared${beaten ? ". A new best!" : ""}`, how];
|
||||
else view.tally = [`Cleared ${round.cleared.length} of ${STAGES.length} stages, out in ${roomName(round.spec, round.room)}${further ? ". A new record!" : ""}${beaten ? " A new best!" : ""}`, `${how} ${round.practice ? "A practice run: nothing kept." : teaser(most)}`];
|
||||
}
|
||||
drawScene(ctx, view);
|
||||
};
|
||||
|
||||
// Nothing held carries over a pause or a new round: a release may never
|
||||
// arrive, and a jump pressed early is dropped.
|
||||
const letGo = () => {
|
||||
const inp = round.input;
|
||||
inp.up = inp.down = inp.left = inp.right = inp.fire = false;
|
||||
resetTap(round);
|
||||
inp.jump = 0;
|
||||
upHeld = false;
|
||||
releaseStory(round);
|
||||
};
|
||||
|
||||
// A new round. A real run opens on the intro story (ghoul-story.js) and the hall is announced when it ends; the stage select skips it.
|
||||
const begin = (story) => {
|
||||
colors = readColors(canvas);
|
||||
round = newRound();
|
||||
if (story) beginStory(round);
|
||||
state = "running";
|
||||
further = false;
|
||||
armed = false;
|
||||
upHeld = false;
|
||||
resetFx();
|
||||
try {
|
||||
bestAtStart = Number(best()) || 0;
|
||||
} catch {
|
||||
bestAtStart = 0;
|
||||
}
|
||||
beaten = false;
|
||||
if (!story) roomBanner(1);
|
||||
paint();
|
||||
};
|
||||
const start = () => begin(true);
|
||||
|
||||
// The held sounds and the ones kept to a beat, each tick of a round still
|
||||
// running: a hum not asked for again fades by itself, so a pause or the
|
||||
// end goes quiet. Sounds only: nothing here touches the round.
|
||||
const sounds = (ms) => {
|
||||
const you = round.you;
|
||||
const spec = round.spec;
|
||||
const playing = round.phase === "play";
|
||||
// The story has its own drone under its own sounds, and the hall's music waits for the hall.
|
||||
if (round.phase === "story") {
|
||||
hum("ghoul:story", "ghoulStoryDrone", 0.6, 1);
|
||||
return;
|
||||
}
|
||||
const b = round.boss;
|
||||
const fight = Boolean(b && round.lockX >= 0 && (b.state === "fight" || b.state === "intro"));
|
||||
// The room's music, its dread eased toward where play is now.
|
||||
fx.dread += (dread(round) - fx.dread) * Math.min(1, ms / DREAD_EASE_MS);
|
||||
// A pack may switch the room's track mid-room with round.gallery.track (the dark ride's finale).
|
||||
const track = (round.gallery && round.gallery.track) || ROOM_MUSIC[spec.id];
|
||||
if (track) music(track, fx.dread);
|
||||
// The nearest monster that can be heard.
|
||||
let near = null;
|
||||
let nearD = Infinity;
|
||||
for (const m of round.monsters) {
|
||||
if (m.dead || !NEAR_HUMS[m.kind] || (m.kind === "bat" && !m.awake)) continue;
|
||||
const d = Math.hypot(m.x - you.x, m.y - you.y);
|
||||
if (d < nearD) {
|
||||
near = m;
|
||||
nearD = d;
|
||||
}
|
||||
}
|
||||
if (near && nearD < NEAR_SOUND) {
|
||||
const close = (1 - nearD / NEAR_SOUND) ** 1.5;
|
||||
hum("ghoul:near", NEAR_HUMS[near.kind], close * (solid(near) ? 1 : 0.5), (NEAR_PITCH[near.kind] ?? 1) * (1 + (near.id % 5) * 0.04));
|
||||
}
|
||||
// The boss heaving, its breath quickening as its hp runs down.
|
||||
if (fight) hum("ghoul:boss", "ghoulBoss", b.state === "intro" ? 0.6 : 0.9, 1 + 0.5 * (1 - b.hp / Math.max(1, b.max)));
|
||||
// A chandelier shaking loose rattles its chains.
|
||||
if (round.falls.some((c) => c.state === "shake")) hum("ghoul:chains", "ghoulChains", 0.8, 1);
|
||||
// The blaster's heat fizzing, a hiss once it starts to slow.
|
||||
if (round.heat >= HEAT_SHOWN && round.effects.rapid <= 0) {
|
||||
hum("ghoul:heat", "ghoulHeat", round.heat / HEAT_MAX, 0.7 + round.heat / HEAT_MAX);
|
||||
if (!fx.hot && round.heat > HEAT_FREE) {
|
||||
fx.hot = true;
|
||||
tone("hiss", 0.25, 1.2);
|
||||
}
|
||||
}
|
||||
if (round.heat < HEAT_FREE * 0.8) fx.hot = false;
|
||||
if (you.garlic) hum("ghoul:garlic", "ghoulGarlic", 0.8, 1);
|
||||
// The Drowned Lantern's own: the Lurker near, Mother awake.
|
||||
for (const [id, name, level, pitch] of lanternHums(round)) hum(id, name, level, pitch);
|
||||
// Footsteps on the boards, left and right, higher on a shelf, now and
|
||||
// then a board creaking under you.
|
||||
if (playing && you.state === "run" && you.runMs > 0) {
|
||||
fx.stepMs -= ms;
|
||||
if (fx.stepMs <= 0) {
|
||||
fx.stepMs = STEP_MS;
|
||||
fx.foot ^= 1;
|
||||
tone("ghoulStep", 0.3, (you.shelf >= 0 ? 1.25 : 1) * (fx.foot ? 1.05 : 0.95) * vary(0.06));
|
||||
if (Math.random() < 0.08) tone("creakBoard", 0.12, vary(0.5));
|
||||
}
|
||||
} else fx.stepMs = 0;
|
||||
// The last life: a heartbeat, quicker with something close.
|
||||
if (playing && round.lives === 1) {
|
||||
fx.beatMs -= ms;
|
||||
if (fx.beatMs <= 0) {
|
||||
const close = nearD < HEART_NEAR || fight;
|
||||
fx.beatMs = close ? HEART_FAST_MS : HEART_MS;
|
||||
tone("heartbeat", close ? 0.55 : 0.4);
|
||||
}
|
||||
} else fx.beatMs = 0;
|
||||
};
|
||||
|
||||
const end = () => {
|
||||
if (round.won) {
|
||||
tone("victory", 0.8);
|
||||
tone("fanfare", 0.6);
|
||||
flash(GOLD, 500);
|
||||
} else {
|
||||
tone("gameOver", 0.7);
|
||||
tone("ghoulToll", 0.45, 0.7);
|
||||
tone("ghoulLaughTrack", 0.55);
|
||||
fx.overAt = fx.clock;
|
||||
fx.laugh = 1;
|
||||
}
|
||||
state = "over";
|
||||
letGo();
|
||||
if (!round.practice) onScore(round.score);
|
||||
};
|
||||
|
||||
const MOVES = Object.freeze({ left: true, right: true, up: true, down: true });
|
||||
|
||||
return {
|
||||
get score() {
|
||||
return round.score;
|
||||
},
|
||||
get state() {
|
||||
return state;
|
||||
},
|
||||
// The lost end screen animates, so the window keeps ticking it.
|
||||
get animating() {
|
||||
return state === "over" && !round.won;
|
||||
},
|
||||
// For the tests only: the window never reads it.
|
||||
get round() {
|
||||
return round;
|
||||
},
|
||||
// Endless lives for this round (the Activities window's code), or not.
|
||||
cheat(on) {
|
||||
round.infinite = Boolean(on);
|
||||
},
|
||||
// The stage select (the window's stage code, for testing): a new round
|
||||
// that opens on every stage and room to choose from, kept as practice
|
||||
// (no best score, no record). Endless lives already on carry over.
|
||||
stageSelect() {
|
||||
const endless = Boolean(round.infinite);
|
||||
begin(false);
|
||||
round.infinite = endless;
|
||||
fx.banners.length = 0;
|
||||
openSelect(round);
|
||||
paint();
|
||||
},
|
||||
// And the pills' numbers, the blaster's gauge among them.
|
||||
get hud() {
|
||||
return hudOf();
|
||||
},
|
||||
start,
|
||||
pause() {
|
||||
if (state === "running") state = "paused";
|
||||
letGo();
|
||||
paint();
|
||||
},
|
||||
resume() {
|
||||
if (state !== "paused") return;
|
||||
state = "running";
|
||||
armed = false;
|
||||
},
|
||||
// The mouse (the window hands a press, a move and a let-go in CSS pixels): it
|
||||
// starts a round, and in the dark ride it aims and fires (ghoul-ride.js).
|
||||
// Any other key the window does not use: whether it started a ride waiting on one.
|
||||
anyKey() {
|
||||
return state === "running" && startRide(round);
|
||||
},
|
||||
pointer(type, x, y) {
|
||||
if (state === "ready" || state === "over") {
|
||||
if (type !== "down") return false;
|
||||
start();
|
||||
return true;
|
||||
}
|
||||
if (state !== "running") return false;
|
||||
const fx = x / u - PAD;
|
||||
const fy = y / u - HUD_H - PAD;
|
||||
if (onCard(round)) return type === "down" ? takeIntro(round) || true : true;
|
||||
if (round.phase === "story") return type === "down" ? takeStory(round) || true : true;
|
||||
// Use a Lucky die? A click lights its half (Yes on the left, No on the right); a click on the lit half answers.
|
||||
if (round.phase === "ask") {
|
||||
if (type === "down") {
|
||||
const yes = fx < FIELD_W / 2;
|
||||
if (round.ask.yes === yes) answerAsk(round, yes, DICE_KIT);
|
||||
else steerAsk(round, yes);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return POINTERS.some((f) => f(round, type, fx, fy));
|
||||
},
|
||||
// Held arrows run until let go (their key repeats, held through the
|
||||
// countdown, keep them held). Up jumps once a press: never on a repeat,
|
||||
// never again until it is let go, never with the press that plays on.
|
||||
// Space starts a round (with fire off) or fires while held; while
|
||||
// paused it does nothing, since only the window plays on, through
|
||||
// resume().
|
||||
key(name, repeat = false) {
|
||||
if (state === "running" && isWaiting(round)) {
|
||||
if (!repeat) startRide(round);
|
||||
return true;
|
||||
}
|
||||
if (name === "action") {
|
||||
if (state === "ready" || state === "over") start();
|
||||
else if (state === "running" && round.phase === "select") {
|
||||
if (!repeat) takeSelect(round);
|
||||
} else if (state === "running" && round.phase === "ask") {
|
||||
if (!repeat) answerAsk(round, round.ask.yes, DICE_KIT);
|
||||
} else if (state === "running" && round.phase === "pick") {
|
||||
if (!repeat) pickStage(round);
|
||||
} else if (state === "running" && onCard(round)) {
|
||||
if (!repeat) takeIntro(round);
|
||||
} else if (state === "running" && round.phase === "story") {
|
||||
pressStory(round, repeat);
|
||||
} else if (state === "running") {
|
||||
round.input.fire = true;
|
||||
// The dark ride's trigger: a tap shorter than a step still fires; no weapon.
|
||||
if (round.gallery) round.gallery.trigger = true;
|
||||
else if (!repeat) pressFireWith(round, KIT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!MOVES[name]) return false;
|
||||
if (state !== "running") return true;
|
||||
// On the stage select: up and down pick a stage out, left and right
|
||||
// one of its rooms.
|
||||
if (round.phase === "select") {
|
||||
if (name === "up" || name === "down") steerSelect(round, name === "up" ? -1 : 1, 0);
|
||||
else steerSelect(round, 0, name === "left" ? -1 : 1);
|
||||
return true;
|
||||
}
|
||||
// Use a Lucky die? Left and up light Yes, right and down No; the action key answers.
|
||||
if (round.phase === "ask") {
|
||||
steerAsk(round, name === "left" || name === "up");
|
||||
return true;
|
||||
}
|
||||
// Choosing a stage: left and right pick one out, up takes it.
|
||||
if (round.phase === "pick") {
|
||||
if (name === "left" || name === "right") steerPick(round, name === "left" ? -1 : 1);
|
||||
else if (name === "up" && !repeat) pickStage(round);
|
||||
return true;
|
||||
}
|
||||
// The intro story: any fresh move key turns the page.
|
||||
if (round.phase === "story") {
|
||||
if (!repeat) takeStory(round);
|
||||
return true;
|
||||
}
|
||||
// A stage's intro card: any fresh move key walks in (a repeat never does).
|
||||
if (onCard(round)) {
|
||||
if (!repeat) takeIntro(round);
|
||||
return true;
|
||||
}
|
||||
round.input[name] = true;
|
||||
if (name === "up") {
|
||||
if (!repeat && armed && !upHeld && round.phase === "play") round.input.jump = JUMP_BUFFER_MS;
|
||||
upHeld = true;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// A key let go: stop running that way, cut a rising jump short, or stop
|
||||
// firing.
|
||||
release(name) {
|
||||
if (name === "action") {
|
||||
round.input.fire = false;
|
||||
releaseFire(round);
|
||||
releaseStory(round);
|
||||
}
|
||||
else if (MOVES[name]) round.input[name] = false;
|
||||
if (name === "up") upHeld = false;
|
||||
},
|
||||
tick(ms) {
|
||||
// The lost end screen animates its "G A M E - O V E R"; the rest hold still.
|
||||
if (state === "over" && !round.won) {
|
||||
fx.clock += ms;
|
||||
// The rest of the laugh track, a second a part.
|
||||
if (fx.laugh && fx.laugh < 3 && fx.clock - fx.overAt >= fx.laugh * 1000) tone(`ghoulLaughTrack${++fx.laugh}`, 0.55);
|
||||
paint();
|
||||
return;
|
||||
}
|
||||
if (state !== "running") return;
|
||||
runFx(ms);
|
||||
advance(round, ms);
|
||||
drain();
|
||||
bonusTick(round, kit);
|
||||
if (round.over) end();
|
||||
else sounds(ms);
|
||||
paint();
|
||||
armed = true;
|
||||
},
|
||||
resize(w, h) {
|
||||
const next = Math.floor(Math.min(w / W, h / H) * 4) / 4;
|
||||
if (!(next >= MIN_CELL)) return false;
|
||||
u = next;
|
||||
colors = null;
|
||||
const ratio = typeof devicePixelRatio === "number" && devicePixelRatio > 0 ? devicePixelRatio : 1;
|
||||
canvas.width = Math.round(W * u * ratio);
|
||||
canvas.height = Math.round(H * u * ratio);
|
||||
if (canvas.style) {
|
||||
canvas.style.width = `${Math.round(W * u)}px`;
|
||||
canvas.style.height = `${Math.round(H * u)}px`;
|
||||
}
|
||||
if (ctx && typeof ctx.setTransform === "function") ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
||||
paint();
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default Object.freeze({ id: "ghoul", title: "Ghoul Rush", create });
|
||||
+62
-40
@@ -29,37 +29,37 @@
|
||||
// The strip the pills sit on, Planny's box and his star (in your highlight)
|
||||
// follow the page.
|
||||
|
||||
import { drawPill, LIVES, livesText, PILL, pillInk } from "./pills.js";
|
||||
import { LOSE_SOUNDS as BONES_LOSE_SOUNDS, LOSE_WORDS as BONES_LOSE_WORDS, boneArt } from "./ghoul-bones-draw.js";
|
||||
import { LOOKS as GRAVEYARD_LOOKS, graveyardArt } from "./ghoul-graveyard-draw.js";
|
||||
import { LOOKS as GROUNDS_LOOKS, LOSE_SOUNDS as GROUNDS_LOSE_SOUNDS, LOSE_WORDS as GROUNDS_LOSE_WORDS, VOICES as GROUNDS_VOICES, groundsArt } from "./ghoul-grounds-draw.js";
|
||||
import { LOOKS as CHAPEL_LOOKS, LOSE_SOUNDS as CHAPEL_LOSE_SOUNDS, LOSE_WORDS as CHAPEL_LOSE_WORDS, VOICES as CHAPEL_VOICES, chapelArt } from "./ghoul-chapel-draw.js";
|
||||
import { LOOKS as SANATORIUM_LOOKS, LOSE_SOUNDS as SANATORIUM_LOSE_SOUNDS, LOSE_WORDS as SANATORIUM_LOSE_WORDS, VOICES as SANATORIUM_VOICES, sanatoriumArt } from "./ghoul-sanatorium-draw.js";
|
||||
import { LOOKS as VILLAGE_LOOKS, LOSE_SOUNDS as VILLAGE_LOSE_SOUNDS, LOSE_WORDS as VILLAGE_LOSE_WORDS, VOICES as VILLAGE_VOICES, villageArt } from "./ghoul-village-draw.js";
|
||||
import { LOOKS as MINE_LOOKS, LOSE_SOUNDS as MINE_LOSE_SOUNDS, LOSE_WORDS as MINE_LOSE_WORDS, VOICES as MINE_VOICES, mineArt } from "./ghoul-mine-draw.js";
|
||||
import { LOOKS as CART_LOOKS, LOSE_SOUNDS as CART_LOSE_SOUNDS, LOSE_WORDS as CART_LOSE_WORDS, VOICES as CART_VOICES, cartArt } from "./ghoul-cart-draw.js";
|
||||
import { LOOKS as WAGON_LOOKS, LOSE_SOUNDS as WAGON_LOSE_SOUNDS, LOSE_WORDS as WAGON_LOSE_WORDS, VOICES as WAGON_VOICES, wagonArt } from "./ghoul-wagon-draw.js";
|
||||
import { LOOKS as SLED_LOOKS, LOSE_SOUNDS as SLED_LOSE_SOUNDS, LOSE_WORDS as SLED_LOSE_WORDS, VOICES as SLED_VOICES, sledArt } from "./ghoul-sled-draw.js";
|
||||
import { LOOKS as BANISTER_LOOKS, LOSE_SOUNDS as BANISTER_LOSE_SOUNDS, LOSE_WORDS as BANISTER_LOSE_WORDS, VOICES as BANISTER_VOICES, banisterArt } from "./ghoul-banister-draw.js";
|
||||
import { LOOKS as HEARSE_LOOKS, LOSE_SOUNDS as HEARSE_LOSE_SOUNDS, LOSE_WORDS as HEARSE_LOSE_WORDS, VOICES as HEARSE_VOICES, hearseArt } from "./ghoul-hearse-draw.js";
|
||||
import { LOOKS as GURNEY_LOOKS, LOSE_SOUNDS as GURNEY_LOSE_SOUNDS, LOSE_WORDS as GURNEY_LOSE_WORDS, VOICES as GURNEY_VOICES, gurneyArt } from "./ghoul-gurney-draw.js";
|
||||
import { LOOKS as PEW_LOOKS, LOSE_SOUNDS as PEW_LOSE_SOUNDS, LOSE_WORDS as PEW_LOSE_WORDS, VOICES as PEW_VOICES, pewArt } from "./ghoul-pew-draw.js";
|
||||
import { LOOKS as MOWER_LOOKS, LOSE_SOUNDS as MOWER_LOSE_SOUNDS, LOSE_WORDS as MOWER_LOSE_WORDS, VOICES as MOWER_VOICES, mowerArt } from "./ghoul-mower-draw.js";
|
||||
import { LOOKS as TRAY_LOOKS, LOSE_SOUNDS as TRAY_LOSE_SOUNDS, LOSE_WORDS as TRAY_LOSE_WORDS, VOICES as TRAY_VOICES, trayArt } from "./ghoul-tray-draw.js";
|
||||
import { LOOKS as CARNIVAL_LOOKS, LOSE_SOUNDS as CARNIVAL_LOSE_SOUNDS, LOSE_WORDS as CARNIVAL_LOSE_WORDS, VOICES as CARNIVAL_VOICES, carnivalArt } from "./ghoul-carnival-draw.js";
|
||||
import { LOOKS as FROZEN_LOOKS, LOSE_SOUNDS as FROZEN_LOSE_SOUNDS, LOSE_WORDS as FROZEN_LOSE_WORDS, VOICES as FROZEN_VOICES, frozenArt } from "./ghoul-frozen-draw.js";
|
||||
import { LOOKS as BOG_LOOKS, LOSE_SOUNDS as BOG_LOSE_SOUNDS, LOSE_WORDS as BOG_LOSE_WORDS, VOICES as BOG_VOICES, bogArt } from "./ghoul-bog-draw.js";
|
||||
import { LOOKS as BOGBOAT_LOOKS, LOSE_SOUNDS as BOGBOAT_LOSE_SOUNDS, LOSE_WORDS as BOGBOAT_LOSE_WORDS, VOICES as BOGBOAT_VOICES, bogboatArt } from "./ghoul-bogboat-draw.js";
|
||||
import { diceArt } from "./ghoul-dice-draw.js";
|
||||
import { gameOverBanner } from "./ghoul-gameover-draw.js";
|
||||
import { introArt } from "./ghoul-intro-draw.js";
|
||||
import { storyArt } from "./ghoul-story-draw.js";
|
||||
import { bonusArt } from "./ghoul-bonus-draw.js";
|
||||
import { LOOKS as RIDE_LOOKS, LOSE_SOUNDS as RIDE_LOSE_SOUNDS, LOSE_WORDS as RIDE_LOSE_WORDS, VOICES as RIDE_VOICES, react as rideReact } from "./ghoul-ride-voices.js";
|
||||
import { rideArt } from "./ghoul-ride-draw.js";
|
||||
import { armsArt } from "./ghoul-arms-draw.js";
|
||||
import { drawPill, LIVES, livesText, PILL, pillInk } from "../../pills.js";
|
||||
import { LOSE_SOUNDS as BONES_LOSE_SOUNDS, LOSE_WORDS as BONES_LOSE_WORDS, boneArt } from "../stages/wing/ghoul-bones-draw.js";
|
||||
import { LOOKS as GRAVEYARD_LOOKS, graveyardArt } from "../stages/graveyard/ghoul-graveyard-draw.js";
|
||||
import { LOOKS as GROUNDS_LOOKS, LOSE_SOUNDS as GROUNDS_LOSE_SOUNDS, LOSE_WORDS as GROUNDS_LOSE_WORDS, VOICES as GROUNDS_VOICES, groundsArt } from "../stages/grounds/ghoul-grounds-draw.js";
|
||||
import { LOOKS as CHAPEL_LOOKS, LOSE_SOUNDS as CHAPEL_LOSE_SOUNDS, LOSE_WORDS as CHAPEL_LOSE_WORDS, VOICES as CHAPEL_VOICES, chapelArt } from "../stages/chapel/ghoul-chapel-draw.js";
|
||||
import { LOOKS as SANATORIUM_LOOKS, LOSE_SOUNDS as SANATORIUM_LOSE_SOUNDS, LOSE_WORDS as SANATORIUM_LOSE_WORDS, VOICES as SANATORIUM_VOICES, sanatoriumArt } from "../stages/sanatorium/ghoul-sanatorium-draw.js";
|
||||
import { LOOKS as VILLAGE_LOOKS, LOSE_SOUNDS as VILLAGE_LOSE_SOUNDS, LOSE_WORDS as VILLAGE_LOSE_WORDS, VOICES as VILLAGE_VOICES, villageArt } from "../stages/village/ghoul-village-draw.js";
|
||||
import { LOOKS as MINE_LOOKS, LOSE_SOUNDS as MINE_LOSE_SOUNDS, LOSE_WORDS as MINE_LOSE_WORDS, VOICES as MINE_VOICES, mineArt } from "../stages/mine/ghoul-mine-draw.js";
|
||||
import { LOOKS as CART_LOOKS, LOSE_SOUNDS as CART_LOSE_SOUNDS, LOSE_WORDS as CART_LOSE_WORDS, VOICES as CART_VOICES, cartArt } from "../rides/cart/ghoul-cart-draw.js";
|
||||
import { LOOKS as WAGON_LOOKS, LOSE_SOUNDS as WAGON_LOSE_SOUNDS, LOSE_WORDS as WAGON_LOSE_WORDS, VOICES as WAGON_VOICES, wagonArt } from "../rides/wagon/ghoul-wagon-draw.js";
|
||||
import { LOOKS as SLED_LOOKS, LOSE_SOUNDS as SLED_LOSE_SOUNDS, LOSE_WORDS as SLED_LOSE_WORDS, VOICES as SLED_VOICES, sledArt } from "../rides/sled/ghoul-sled-draw.js";
|
||||
import { LOOKS as BANISTER_LOOKS, LOSE_SOUNDS as BANISTER_LOSE_SOUNDS, LOSE_WORDS as BANISTER_LOSE_WORDS, VOICES as BANISTER_VOICES, banisterArt } from "../rides/banister/ghoul-banister-draw.js";
|
||||
import { LOOKS as HEARSE_LOOKS, LOSE_SOUNDS as HEARSE_LOSE_SOUNDS, LOSE_WORDS as HEARSE_LOSE_WORDS, VOICES as HEARSE_VOICES, hearseArt } from "../rides/hearse/ghoul-hearse-draw.js";
|
||||
import { LOOKS as GURNEY_LOOKS, LOSE_SOUNDS as GURNEY_LOSE_SOUNDS, LOSE_WORDS as GURNEY_LOSE_WORDS, VOICES as GURNEY_VOICES, gurneyArt } from "../rides/gurney/ghoul-gurney-draw.js";
|
||||
import { LOOKS as PEW_LOOKS, LOSE_SOUNDS as PEW_LOSE_SOUNDS, LOSE_WORDS as PEW_LOSE_WORDS, VOICES as PEW_VOICES, pewArt } from "../rides/pew/ghoul-pew-draw.js";
|
||||
import { LOOKS as MOWER_LOOKS, LOSE_SOUNDS as MOWER_LOSE_SOUNDS, LOSE_WORDS as MOWER_LOSE_WORDS, VOICES as MOWER_VOICES, mowerArt } from "../rides/mower/ghoul-mower-draw.js";
|
||||
import { LOOKS as TRAY_LOOKS, LOSE_SOUNDS as TRAY_LOSE_SOUNDS, LOSE_WORDS as TRAY_LOSE_WORDS, VOICES as TRAY_VOICES, trayArt } from "../rides/tray/ghoul-tray-draw.js";
|
||||
import { LOOKS as CARNIVAL_LOOKS, LOSE_SOUNDS as CARNIVAL_LOSE_SOUNDS, LOSE_WORDS as CARNIVAL_LOSE_WORDS, VOICES as CARNIVAL_VOICES, carnivalArt } from "../stages/carnival/ghoul-carnival-draw.js";
|
||||
import { LOOKS as FROZEN_LOOKS, LOSE_SOUNDS as FROZEN_LOSE_SOUNDS, LOSE_WORDS as FROZEN_LOSE_WORDS, VOICES as FROZEN_VOICES, frozenArt } from "../stages/frozen/ghoul-frozen-draw.js";
|
||||
import { LOOKS as BOG_LOOKS, LOSE_SOUNDS as BOG_LOSE_SOUNDS, LOSE_WORDS as BOG_LOSE_WORDS, VOICES as BOG_VOICES, bogArt } from "../stages/bog/ghoul-bog-draw.js";
|
||||
import { LOOKS as LANTERN_LOOKS, LOSE_SOUNDS as LANTERN_LOSE_SOUNDS, LOSE_WORDS as LANTERN_LOSE_WORDS, VOICES as LANTERN_VOICES, lanternArt } from "../rides/lantern/ghoul-lantern-draw.js";
|
||||
import { diceArt } from "../core/ghoul-dice-draw.js";
|
||||
import { gameOverBanner } from "../story/ghoul-gameover-draw.js";
|
||||
import { introArt } from "../story/ghoul-intro-draw.js";
|
||||
import { storyArt } from "../story/ghoul-story-draw.js";
|
||||
import { bonusArt } from "../core/ghoul-bonus-draw.js";
|
||||
import { LOOKS as RIDE_LOOKS, LOSE_SOUNDS as RIDE_LOSE_SOUNDS, LOSE_WORDS as RIDE_LOSE_WORDS, VOICES as RIDE_VOICES, react as rideReact } from "../rides/dark-ride/ghoul-ride-voices.js";
|
||||
import { rideArt } from "../rides/dark-ride/ghoul-ride-draw.js";
|
||||
import { armsArt } from "../arms/ghoul-arms-draw.js";
|
||||
import { pickerArt } from "./ghoul-picker-draw.js";
|
||||
import { bossIntroArt } from "./ghoul-bossintro-draw.js";
|
||||
import { bossIntroArt } from "../story/ghoul-bossintro-draw.js";
|
||||
import { monsterArt } from "./ghoul-monsters-draw.js";
|
||||
|
||||
const FALLBACK_COLORS = Object.freeze({ board: "#ffffff", line: "#e4ddd1", you: "#206cc3", ink: "#1d1a17" });
|
||||
@@ -139,7 +139,7 @@ export const LOOKS = Object.freeze({
|
||||
...FROZEN_LOOKS,
|
||||
...RIDE_LOOKS,
|
||||
...BOG_LOOKS,
|
||||
...BOGBOAT_LOOKS,
|
||||
...LANTERN_LOOKS,
|
||||
crypt: Object.freeze({ wallTop: "#0a0b0e", wallLow: "#1b1e25", paper: "#262a33", wainscot: "#14161b", floorTop: "#43474f", floor: "#22252b", floorEdge: "#0a0b0d", shelf: "#30343c", shelfTop: "#4a4f58", pit: "#010102", window: "#b4bfd1", decor: "tombs", color: "#b4bfd1", dark: 0.9 }),
|
||||
});
|
||||
export const lookOf = (id) => LOOKS[id] || LOOKS.foyer;
|
||||
@@ -263,9 +263,9 @@ const { drawZombie, drawZombieKin, drawHuntsman, drawCrawler, drawBat, drawGhost
|
||||
// backdrops (a look's `pack` names whose, the Graveyard's by default), graves,
|
||||
// monsters, bosses, missiles, hazards, waves, power-up badges and lights by
|
||||
// kind, and what their events look and sound like.
|
||||
const HELP = { hudLayout, drawPower, ellipse, circle, roundRect, line, rotate, eye, hash, say, gate, label, drawBoneShape, BONE, DANGER, GOLD, FLASH, EYE_RED, EYE_PALE, EYE_AMBER };
|
||||
const HELP = { paintDark, hudLayout, drawPower, ellipse, circle, roundRect, line, rotate, eye, hash, say, gate, label, drawBoneShape, BONE, DANGER, GOLD, FLASH, EYE_RED, EYE_PALE, EYE_AMBER };
|
||||
const ARMS_ART = armsArt(HELP);
|
||||
const PACK_ART = { arms: ARMS_ART, bones: boneArt(HELP), graveyard: graveyardArt(HELP), grounds: groundsArt(HELP), chapel: chapelArt(HELP), sanatorium: sanatoriumArt(HELP), village: villageArt(HELP), mine: mineArt(HELP), cart: cartArt(HELP), sled: sledArt(HELP), banister: banisterArt(HELP), hearse: hearseArt(HELP), codeblue: gurneyArt(HELP), pew: pewArt(HELP), mower: mowerArt(HELP), tray: trayArt(HELP), wagon: wagonArt(HELP), carnival: carnivalArt(HELP), frozen: frozenArt(HELP), bog: bogArt(HELP), bogboat: bogboatArt(HELP), ride: { backdrop() {}, lights() {}, react: rideReact } };
|
||||
const PACK_ART = { arms: ARMS_ART, bones: boneArt(HELP), graveyard: graveyardArt(HELP), grounds: groundsArt(HELP), chapel: chapelArt(HELP), sanatorium: sanatoriumArt(HELP), village: villageArt(HELP), mine: mineArt(HELP), cart: cartArt(HELP), sled: sledArt(HELP), banister: banisterArt(HELP), hearse: hearseArt(HELP), codeblue: gurneyArt(HELP), pew: pewArt(HELP), lantern: lanternArt(HELP), mower: mowerArt(HELP), tray: trayArt(HELP), wagon: wagonArt(HELP), carnival: carnivalArt(HELP), frozen: frozenArt(HELP), bog: bogArt(HELP), ride: { backdrop() {}, lights() {}, react: rideReact } };
|
||||
const packs = Object.values(PACK_ART);
|
||||
const DICE = diceArt(HELP);
|
||||
const OVER_BANNER = gameOverBanner(HELP);
|
||||
@@ -1676,6 +1676,27 @@ function hole(c, x, y, r, s) {
|
||||
c.fill();
|
||||
}
|
||||
|
||||
// A night over the whole field with a hole for each of `lights` ([x, y, r, strength], field units, y down): a room that
|
||||
// is drawn whole by its own art (the Drowned Lantern) uses it, since it has no scrolling and no still layers to dim.
|
||||
// False where the page cannot make the layer (the caller dims plainly instead).
|
||||
function paintDark(ctx, v, alpha, lit) {
|
||||
const { g } = v;
|
||||
const d = darkCanvas(ctx, g);
|
||||
if (!d) return false;
|
||||
const { c, a } = d;
|
||||
c.setTransform(1, 0, 0, 1, 0, 0);
|
||||
c.globalCompositeOperation = "source-over";
|
||||
c.clearRect(0, 0, d.w, d.h);
|
||||
c.fillStyle = `rgba(2, 5, 7, ${alpha.toFixed(3)})`;
|
||||
c.fillRect(0, 0, d.w, d.h);
|
||||
c.setTransform(a, 0, 0, a, DARK_MARGIN * a, DARK_MARGIN * a);
|
||||
c.globalCompositeOperation = "destination-out";
|
||||
for (const [x, y, r, s] of lit) hole(c, x, y, r, s);
|
||||
c.globalCompositeOperation = "source-over";
|
||||
ctx.drawImage(d.canvas, -DARK_MARGIN, -DARK_MARGIN, g.FIELD_W + DARK_MARGIN * 2, g.FIELD_H + DARK_MARGIN * 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The flashlight's cone, out from the blaster the way Planny faces.
|
||||
const CONE_LEN = 46;
|
||||
const CONE_HALF = 0.36;
|
||||
@@ -1746,7 +1767,7 @@ function drawGlowing(ctx, v) {
|
||||
/* ------------------------------------------------------------ feedback */
|
||||
|
||||
const KILL_WORDS = Object.freeze({ head: "Headshot!", stomp: "Crunch!", crush: "Flattened!", garlic: "Garlic!" });
|
||||
const LOSE_WORDS = Object.freeze({ time: "Out of time", pit: "Into the dark", bone: "Skull cracked", chandelier: "Crushed", acid: "Burned alive", wave: "Thrown down", ...BONES_LOSE_WORDS, ...BANISTER_LOSE_WORDS, ...GROUNDS_LOSE_WORDS, ...CHAPEL_LOSE_WORDS, ...SANATORIUM_LOSE_WORDS, ...VILLAGE_LOSE_WORDS, ...MINE_LOSE_WORDS, ...CART_LOSE_WORDS, ...SLED_LOSE_WORDS, ...HEARSE_LOSE_WORDS, ...GURNEY_LOSE_WORDS, ...PEW_LOSE_WORDS, ...MOWER_LOSE_WORDS, ...TRAY_LOSE_WORDS, ...WAGON_LOSE_WORDS, ...CARNIVAL_LOSE_WORDS, ...FROZEN_LOSE_WORDS,...RIDE_LOSE_WORDS, ...BOG_LOSE_WORDS, ...BOGBOAT_LOSE_WORDS, hound: "Mauled", spider: "Bitten", wraith: "Taken", hands: "Dragged under", mourner: "Mourned", robber: "Buried alive", crow: "Pecked", legs: "Kicked down", stone: "Struck by a headstone", fist: "Crushed by stone", angel: "Turned to stone" });
|
||||
const LOSE_WORDS = Object.freeze({ time: "Out of time", pit: "Into the dark", bone: "Skull cracked", chandelier: "Crushed", acid: "Burned alive", wave: "Thrown down", ...BONES_LOSE_WORDS, ...BANISTER_LOSE_WORDS, ...GROUNDS_LOSE_WORDS, ...CHAPEL_LOSE_WORDS, ...SANATORIUM_LOSE_WORDS, ...VILLAGE_LOSE_WORDS, ...MINE_LOSE_WORDS, ...CART_LOSE_WORDS, ...SLED_LOSE_WORDS, ...HEARSE_LOSE_WORDS, ...GURNEY_LOSE_WORDS, ...PEW_LOSE_WORDS, ...MOWER_LOSE_WORDS, ...TRAY_LOSE_WORDS, ...WAGON_LOSE_WORDS, ...CARNIVAL_LOSE_WORDS, ...FROZEN_LOSE_WORDS,...RIDE_LOSE_WORDS, ...BOG_LOSE_WORDS, ...LANTERN_LOSE_WORDS, hound: "Mauled", spider: "Bitten", wraith: "Taken", hands: "Dragged under", mourner: "Mourned", robber: "Buried alive", crow: "Pecked", legs: "Kicked down", stone: "Struck by a headstone", fist: "Crushed by stone", angel: "Turned to stone" });
|
||||
// What spills from each kind when it dies, and whether it leaves a stain.
|
||||
const STAINS = Object.freeze({ ghost: false, wraith: false, skeleton: false, bat: true });
|
||||
|
||||
@@ -2108,7 +2129,7 @@ export const VOICES = Object.freeze({
|
||||
...RIDE_VOICES,
|
||||
angel: Object.freeze({ wake: "ghoulAngelWake", weep: "ghoulAngelWeep", watch: "ghoulAngelWatch", see: "ghoulAngelSee", slam: "ghoulAngelSlam", wings: "ghoulAngelWings", hurt: "ghoulAngelHurt", die: "ghoulAngelDie" }),
|
||||
...BOG_VOICES,
|
||||
...BOGBOAT_VOICES,
|
||||
...LANTERN_VOICES,
|
||||
});
|
||||
// Plays a kind's voice for an act, if it has one, its pitch a touch varied.
|
||||
function say(tone, kind, act, level) {
|
||||
@@ -2155,7 +2176,7 @@ const LOSE_SOUNDS = Object.freeze({
|
||||
...WAGON_LOSE_SOUNDS,
|
||||
...RIDE_LOSE_SOUNDS,
|
||||
...BOG_LOSE_SOUNDS,
|
||||
...BOGBOAT_LOSE_SOUNDS,
|
||||
...LANTERN_LOSE_SOUNDS,
|
||||
});
|
||||
// The door's boom in each of the eight rooms, the Crypt deepest.
|
||||
const ROOM_PITCH = Object.freeze([1, 1.1, 0.95, 1.2, 1.05, 1.15, 0.9, 0.75]);
|
||||
@@ -2475,8 +2496,8 @@ export function drawScene(ctx, v) {
|
||||
}
|
||||
// Holy Roller is an endless-runner drawn whole by its own art (ghoul-pew-draw.js): the nave in pseudo-3D from behind the
|
||||
// pew. The hearts, the flash, the banner, the cards and the HUD pills go over it as they do over the dark ride.
|
||||
if (round.runner && round.runner.id === "pew") {
|
||||
PACK_ART.pew.field(ctx, v);
|
||||
if (round.runner && (round.runner.id === "pew" || round.runner.id === "lantern")) {
|
||||
PACK_ART[round.runner.id].field(ctx, v);
|
||||
for (const f of v.fx.floats) {
|
||||
ctx.globalAlpha = Math.min(1, (f.life / f.max) * 1.6);
|
||||
const at = labelSpot(f.text, f.x, Y(f.y) - f.rise, f.size, g.FIELD_W, g.FIELD_H);
|
||||
@@ -2491,7 +2512,7 @@ export function drawScene(ctx, v) {
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
if (v.state === "running" && round.phase === "clear") BONUS.card(ctx, v);
|
||||
if (v.state === "running" && v.banner && round.phase !== "pick" && round.phase !== "select" && round.phase !== "roll") drawBanner(ctx, v, v.banner);
|
||||
if (v.state === "running" && v.banner && round.phase !== "pick" && round.phase !== "select" && round.phase !== "roll" && round.phase !== "ask") drawBanner(ctx, v, v.banner);
|
||||
if (v.state === "running" && v.fx.lucky) DICE.lucky(ctx, v);
|
||||
ctx.restore();
|
||||
ctx.translate(-g.PAD, -g.HUD_H);
|
||||
@@ -2592,8 +2613,9 @@ export function drawScene(ctx, v) {
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
if (v.state === "running" && round.phase === "roll") DICE.roll(ctx, v);
|
||||
if (v.state === "running" && round.phase === "ask") DICE.ask(ctx, v);
|
||||
if (v.state === "running" && round.phase === "clear") BONUS.card(ctx, v);
|
||||
if (v.state === "running" && v.banner && round.phase !== "pick" && round.phase !== "select" && round.phase !== "roll") drawBanner(ctx, v, v.banner);
|
||||
if (v.state === "running" && v.banner && round.phase !== "pick" && round.phase !== "select" && round.phase !== "roll" && round.phase !== "ask") drawBanner(ctx, v, v.banner);
|
||||
if (v.state === "running" && v.fx.lucky) DICE.lucky(ctx, v);
|
||||
if ((v.state === "running" || v.state === "paused") && round.phase === "pick" && round.offer) drawPicker(ctx, v);
|
||||
if ((v.state === "running" || v.state === "paused") && round.phase === "select" && round.select) drawSelect(ctx, v);
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,50 @@
|
||||
// Plan2Code Web Console - Ghoul Rush, the twelfth activity: a dark haunted house seen side on, Planny running, jumping and blasting his flashlight through it room by room, the zombies, crawlers, bats, ghosts, skeletons, hellhounds, widows, wraiths, bloaters and bosses, and the game contract.
|
||||
//
|
||||
// The Activities window (screens/activities.js) drives everything: it ticks
|
||||
// the game, hands it keys (and their releases) and pauses it. A game never
|
||||
// runs a timer or listens for a key of its own, so a paused game cannot move.
|
||||
// The rules are plain functions over a round object (newRound, roomFor,
|
||||
// stagesLeft, steerPick, pickStage, steerSelect, takeSelect, groundAt,
|
||||
// footing, jumpHeightAt, jump, moveYou, spawnMonster, hurt, kill, lose,
|
||||
// applyPower, advance, underBanner), exported so the unit suite can
|
||||
// drive them without a canvas; the rooms live in ghoul-rooms.js, the
|
||||
// power-ups and pickups in ghoul-powers.js, the run flow (rounds, the stage
|
||||
// pick, the camera, respawns and spawners) in ghoul-run.js and the drawing (and what each
|
||||
// event looks and sounds like) in ghoul-draw.js, and
|
||||
// the default export is the contract every listed game answers.
|
||||
//
|
||||
// Planny sprints left to right through a haunted mansion, the camera
|
||||
// scrolling with him: held arrows run, up jumps (let go early for a short
|
||||
// hop), space fires his flashlight blaster the way he faces (hold it to keep
|
||||
// firing), and down ducks on the ground or drops through a shelf. Each room's door opens once he grabs its key. A run starts in a
|
||||
// long hall, then goes stage by stage (three rooms, then a boss whose fall
|
||||
// opens the door), each next stage picked from two not yet played that run;
|
||||
// clearing every stage wins. Every other room keeps a horde pouring in from
|
||||
// the edges of the view, so standing still is never safe. Kills in quick succession build a chain that multiplies their points
|
||||
// and runs out fast; a shot to the head or a stomp from above doubles a
|
||||
// kill. Souls (the `candy` in the rules), power-ups (spread shot, rapid
|
||||
// fire, a garlic shield, an extra life, a lantern, bat wings, a church bell
|
||||
// and an hourglass) and a time bonus per room add up. Every room but a boss's has
|
||||
// a clock, and a crowd of the dead piles up to reach him on a shelf above. A
|
||||
// hit, a fall or the clock running out costs one of seven lives and puts him
|
||||
// back at the room's start, safe for a moment. Each stage cleared makes the
|
||||
// next quicker and tougher, and the memo keeps the most stages ever cleared
|
||||
// in one run.
|
||||
//
|
||||
// This file is only the game's public face, so the page and the tests have one
|
||||
// place to import from. The game itself is in its parts:
|
||||
//
|
||||
// core/ghoul-tables.js: numbers and tables: every timing and size the rules share, the monsters and bosses with each stage pack's joined in (PACKS), the seeded dice, and a room's numbers at a depth (roomFor).
|
||||
// core/ghoul-planny.js: ground and Planny: what stands where (surfaces, shelves and landing on them), and how Planny runs, jumps and falls.
|
||||
// core/ghoul-monsters.js: monsters: spawning them, how each kind walks, hops, climbs and swoops, and what they throw.
|
||||
// core/ghoul-fight.js: bosses and damage: a boss's fight and fall, hurting and killing a monster, and losing a life.
|
||||
// core/ghoul-play.js: play loop: the kits it hands its packs and ghoul-run.js (KIT, RUN_KIT), the blaster and bolts, hits, stomps and timers, one slice of play, and advance().
|
||||
// core/ghoul-window.js: window: the game's contract with the Activities page (create), its keys and pointer, what fx and sounds its events set off, each room's music (ROOM_MUSIC), and the view handed to the drawing.
|
||||
|
||||
export * from "./core/ghoul-tables.js";
|
||||
export * from "./core/ghoul-planny.js";
|
||||
export * from "./core/ghoul-monsters.js";
|
||||
export * from "./core/ghoul-fight.js";
|
||||
export * from "./core/ghoul-play.js";
|
||||
export * from "./core/ghoul-window.js";
|
||||
export { default } from "./core/ghoul-window.js";
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
// - YOU: `you.state`, `you.vy`, `you.ducking`, `you.x`, `you.y` (the portraits' eyes follow).
|
||||
// - events leave short-lived bits in the view's `fx` (`banBits`, `banLand`).
|
||||
|
||||
import { linesOf, trackY } from "./ghoul-cart.js";
|
||||
import { linesOf, trackY } from "../cart/ghoul-cart.js";
|
||||
import { BUTLER_H, CANDLE_H, SWING_BOB_W, WEB_HI, WEB_LO, lowerLine, swingAt } from "./ghoul-banister.js";
|
||||
import { ANSWER_COLORS, TELEGRAPH_ALPHA, TELEGRAPH_FULL, TELEGRAPH_SEE, TELEGRAPH_WORDS } from "./ghoul-sled-draw.js";
|
||||
import { ANSWER_COLORS, TELEGRAPH_ALPHA, TELEGRAPH_FULL, TELEGRAPH_SEE, TELEGRAPH_WORDS } from "../sled/ghoul-sled-draw.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const TAU = Math.PI * 2;
|
||||
+1
-1
@@ -68,7 +68,7 @@
|
||||
// butlers: [{ state "wait"|"warn"|"lunge"|"broken"|"spent", t, x }], webs: ["up"|"torn"|"shot"] },
|
||||
// `round.you` (`state`, `vy`, `ducking`), the events in EVENTS.
|
||||
|
||||
import { linesAt, linesOf, slopeOf, trackY } from "./ghoul-cart.js";
|
||||
import { linesAt, linesOf, slopeOf, trackY } from "../cart/ghoul-cart.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -26,7 +26,7 @@
|
||||
// - Planny: `you.state`, `you.vy` (tilts the gurney in the air), `you.ducking`, `you.x`, `you.y`.
|
||||
// - events leave short-lived bits in the view's `fx` (`blueBits`, `blueLand`).
|
||||
|
||||
import { ANSWER_COLORS } from "./ghoul-sled-draw.js";
|
||||
import { ANSWER_COLORS } from "../sled/ghoul-sled-draw.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const TAU = Math.PI * 2;
|
||||
+1
-1
@@ -66,7 +66,7 @@
|
||||
// "spent", t }], chairs: [{ x, rolling }], lamps: [broken] }, `round.bonusRound.hearts`,
|
||||
// `round.you` (`state`, `vy`, `ducking`), the events in EVENTS.
|
||||
|
||||
import { linesAt, linesOf, slopeOf, trackY } from "./ghoul-cart.js";
|
||||
import { linesAt, linesOf, slopeOf, trackY } from "../cart/ghoul-cart.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,809 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Drowned Lantern, its rules: Gallows Bog's bonus round, a top-down game on one fixed screen and not a ride. YOU carry a lantern over a black bog island of mossy hummocks joined by plank walks, light the five wisp shrines, then run back to the boat while Old Mother Bog rises out of her pool. Four kinds of hunter each play by one rule you can see and use: the Bog Lurker hears footsteps on wood, the wisps guard the shrines and burst in a flare, the leeches never enter your light, and the bog bodies grab whatever stops beside them. A stage pack that ghoul.js plugs in.
|
||||
//
|
||||
// Like Holy Roller (ghoul-pew.js) it is handed a kit `k` of ghoul.js's own helpers and never imports
|
||||
// ghoul.js. Pack fields used: `ride` (a hook that moves Planny himself, so no key walks him) and `place`
|
||||
// (Planny put down in the room). It adds no monster, boss or hazard kind, and it draws NO random number:
|
||||
// every hunter follows a table in the room's `ride` and a fixed rule, stepped on the slice. Its state lives
|
||||
// in the shared ride slot `round.runner` (`id` "lantern"; null in any other room). Every event it puts on
|
||||
// the field starts with `lantern`.
|
||||
//
|
||||
// THE FIELD IS THE ART'S ALONE (like the pew's): ghoul-draw.js hands the whole field to lanternArt's `field`.
|
||||
// Positions here are field units with y counted DOWN from the field's top (the way the art draws). `you.x`
|
||||
// mirrors Planny's x and `you.y` stays on the room's floor, so the engine's own checks never see a fall;
|
||||
// what the banners must keep clear of is listed in `runner.marks` ([x, y up] pairs, read by ghoul.js's
|
||||
// underBanner).
|
||||
//
|
||||
// THE KEYS (the game has the four arrows and SPACE only): the ARROWS walk (two at once walk a diagonal; a
|
||||
// walk that runs into the water slides along the shore or the plank, so one arrow follows a crooked plank).
|
||||
// SPACE flares the lantern: a ring of light FLARE_R wide that bursts every wisp in it and scatters the
|
||||
// leeches, at the price of FLARE_OIL of the oil and a bang the Lurker hears from anywhere.
|
||||
//
|
||||
// THE OBJECTIVE: stand on a shrine's stone for SHRINE_MS (the time is kept if you step off) to light it;
|
||||
// the fifth lit wakes Old Mother Bog for good, and the boat (`boat`) at the landing you started on is the
|
||||
// way out. The oil burns down over OIL_MS and the lantern's light shrinks with it (`lightR`); a lit shrine
|
||||
// fills it again.
|
||||
//
|
||||
// THE HUNTERS, one rule each:
|
||||
// - The BOG LURKER hunts SOUND: a step on the planks (heard within STEP_HEAR; the moss is silent), a flare
|
||||
// (heard anywhere) and a shrine catching (SHRINE_HEAR). It swims to the last place it heard you; within
|
||||
// AIM_FROM of it, it stops, lines up a lane through that spot (AIM_MS, the lane drawn red) and dashes down
|
||||
// it (DASH_V, DASH_PAST beyond the spot). It strikes where it HEARD you, never where you are: off the lane,
|
||||
// or on the moss, you are safe. After a dash it rests, deaf, for REST_MS. Once Mother rises it cowers (state
|
||||
// "cower"), deaf, under the far water: the run to the boat is hers.
|
||||
// - The WISPS guard the shrines: each unlit shrine has one circling it that rushes a lantern within
|
||||
// GUARD_SENSE (on a leash of LEASH round its shrine) and has you at WISP_CATCH. A flare bursts it; it comes
|
||||
// back after WISP_REFORM_MS unless its shrine is lit by then. From the third shrine on, Old Mother Bog sends
|
||||
// roaming wisps out of her pool (`wake`), which drift after a lantern within ROAM_SENSE.
|
||||
// - The LEECHES never enter your light. They follow you at its edge, and once the oil is out (the flame
|
||||
// gutters) they swarm in and bite (LEECH_BITE). A flare scatters them for SCATTER_MS.
|
||||
// - The BOG BODIES lie beside the planks, bubbling: stand still within BODY_NOTICE of one for BODY_STILL_MS and
|
||||
// the water boils (BODY_RISE_MS), then a hand comes up for BODY_UP_MS and takes anything within BODY_REACH.
|
||||
// Walking past is always safe; stopping is not (which the Lurker, who hears you walk, makes hard).
|
||||
// - OLD MOTHER BOG stirs in her pool as the shrines are lit (her eyes open a fifth each). From the third
|
||||
// shrine (or MOTHER_LATE_S into the round) her hand's shadow finds you every so often: it follows you
|
||||
// (HAND_TRACK_MS), stops and reddens (HAND_LOCK_MS), then slams (HAND_R). Keep moving and it misses. Once the
|
||||
// fifth shrine is lit she RISES and the slams come one after another until you reach the boat.
|
||||
//
|
||||
// A catch costs one of the round's five hearts (ghoul-bonus.js), never a life, and never moves Planny: he
|
||||
// blinks safe for BONUS_SAFE_MS and the hunter that took him backs off. The last heart gone ends the round
|
||||
// with nothing. The room's clock (`round.timeMs`, TIME_S) at nought is the end too, unless the endless-lives
|
||||
// code is on (the clock then starts again).
|
||||
//
|
||||
// THE GRADE (ghoul-bonus.js's `perf`): `total` is the five kinds that can take you (HUNTERS), `hits` the kinds
|
||||
// that did, `acts` the wisps burst and the close calls (a dash or a slam that missed by less than CLOSE_R;
|
||||
// the goal is ACTS_GOAL), and `steady` falls if the flame ever gutters.
|
||||
//
|
||||
// WHAT THE ART READS: `spec.ride`, `round.runner` (see `place`), `round.you.safeMs`, `round.timeMs`, the
|
||||
// events in EVENTS, and the exported numbers and helpers.
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
const dist = (ax, ay, bx, by) => Math.hypot(ax - bx, ay - by);
|
||||
|
||||
export const MONSTERS = freeze({});
|
||||
|
||||
// Every event this pack puts on the field, for the art and the sounds to answer.
|
||||
export const EVENTS = freeze([
|
||||
"lanternStep", "lanternFlare", "lanternSputter", "lanternPop", "lanternShrine", "lanternGutter", "lanternCatch", "lanternFinish", "lanternMeet",
|
||||
"lanternLurkerCue", "lanternAim", "lanternDash", "lanternClose", "lanternWispCue", "lanternLeechCue", "lanternBodyCue",
|
||||
"lanternWake", "lanternRise", "lanternHand", "lanternSlam",
|
||||
]);
|
||||
|
||||
// What costs a heart, by hunter (and the round's grade counts these five kinds).
|
||||
export const CAUSES = freeze({ lurker: "lanternLurker", leech: "lanternLeech", wisp: "lanternWisp", body: "lanternBody", mother: "lanternMother" });
|
||||
export const HUNTERS = freeze(["lurker", "leech", "wisp", "body", "mother"]);
|
||||
|
||||
// The field's map, in field units (y down): where Planny and the hunters can be (the band above y0 is the HUD's).
|
||||
export const MAP = freeze({ x0: 3, x1: 93, y0: 11, y1: 52 });
|
||||
// Planny. Speeds are units a second.
|
||||
export const WALK_V = 9.5;
|
||||
export const PLANK_HALF = 2.4;
|
||||
// The room's clock.
|
||||
export const TIME_S = 90;
|
||||
// The shrines: stand on one SHRINE_MS (kept if you step off) to light it.
|
||||
export const SHRINES = 5;
|
||||
export const SHRINE_MS = 1800;
|
||||
export const SHRINE_R = 2.8;
|
||||
export const SHRINE_POINTS = 200;
|
||||
// The light a lit shrine casts, which the art draws.
|
||||
export const SHRINE_LIGHT = 9;
|
||||
// The way out: within BOAT_R of the boat, once all five are lit.
|
||||
export const BOAT_R = 4;
|
||||
export const ESCAPE_POINTS = 500;
|
||||
// The oil: full burns down in OIL_MS; the light's radius follows it.
|
||||
export const OIL_MS = 26000;
|
||||
export const LIGHT_MIN = 1.6;
|
||||
export const LIGHT_MAX = 15;
|
||||
export const OIL_LOW = 0.3;
|
||||
export const lightR = (oil) => (oil > 0 ? LIGHT_MIN + 2.4 + (LIGHT_MAX - LIGHT_MIN - 2.4) * clamp(oil, 0, 1) : LIGHT_MIN);
|
||||
// The flare.
|
||||
export const FLARE_OIL = 0.22;
|
||||
export const FLARE_CD_MS = 700;
|
||||
export const FLARE_R = 12;
|
||||
export const FLARE_MS = 900;
|
||||
export const POP_POINTS = 80;
|
||||
// The Bog Lurker.
|
||||
export const STEP_MS = 330;
|
||||
export const STEP_HEAR = 28;
|
||||
export const SHRINE_HEAR = 45;
|
||||
export const LURKER_V = 9;
|
||||
export const LURKER_DRIFT_V = 4;
|
||||
export const AIM_FROM = 14;
|
||||
export const AIM_MS = 800;
|
||||
export const DASH_V = 46;
|
||||
export const DASH_PAST = 8;
|
||||
export const DASH_HIT = 2.7;
|
||||
export const REST_MS = 2200;
|
||||
// A dash or a slam that missed Planny by less than this was a close call (an act).
|
||||
export const CLOSE_R = 6.5;
|
||||
export const CLOSE_POINTS = 50;
|
||||
// The wisps.
|
||||
export const ORBIT_R = 5.5;
|
||||
export const ORBIT_W = 1.1;
|
||||
export const GUARD_SENSE = 12;
|
||||
export const LEASH = 19;
|
||||
export const WISP_V = 7;
|
||||
export const WISP_RETURN_V = 5;
|
||||
export const ROAM_V = 3.5;
|
||||
export const ROAM_SENSE = 20;
|
||||
export const ROAM_CHASE_V = 6;
|
||||
export const WISP_CATCH = 2;
|
||||
export const WISP_REFORM_MS = 6000;
|
||||
// The leeches.
|
||||
export const LEECH_V = 7;
|
||||
export const LEECH_DRIFT_V = 3;
|
||||
export const LEECH_SENSE = 30;
|
||||
export const LEECH_EDGE = 0.8;
|
||||
export const LEECH_BITE = 2.4;
|
||||
export const SCATTER_MS = 3000;
|
||||
export const SCATTER_V = 10;
|
||||
// What the leeches' bite leaves in the lantern (Planny shakes them off and fans the flame).
|
||||
export const OIL_AFTER_BITE = 0.4;
|
||||
// The bog bodies: they feel Planny stand still within BODY_NOTICE for BODY_STILL_MS.
|
||||
export const BODY_NOTICE = 6;
|
||||
export const BODY_STILL_MS = 250;
|
||||
export const BODY_REACH = 3.4;
|
||||
export const BODY_RISE_MS = 700;
|
||||
export const BODY_UP_MS = 900;
|
||||
export const BODY_REST_MS = 2600;
|
||||
// Old Mother Bog: her hand's cycle, the gap between hands by shrines lit (risen: MOTHER_RISEN_GAP), and the late wake.
|
||||
export const HAND_TRACK_MS = 1000;
|
||||
export const HAND_TRACK_RISEN_MS = 750;
|
||||
export const HAND_LOCK_MS = 420;
|
||||
export const HAND_REST_MS = 450;
|
||||
export const HAND_V = 8;
|
||||
export const HAND_RISEN_V = 9.5;
|
||||
export const HAND_R = 4;
|
||||
export const MOTHER_GAP = freeze([0, 0, 0, 5500, 4000]);
|
||||
export const MOTHER_LATE_S = 55;
|
||||
export const MOTHER_RISEN_GAP = 250;
|
||||
export const RISE_MS = 1300;
|
||||
// A hunter's tag the first time it comes this near (the art shows its rule once).
|
||||
export const MEET_R = 22;
|
||||
// Cues heard before a thing is close: how near, and how often.
|
||||
export const CUE_R = freeze({ leech: 24, wisp: 22 });
|
||||
export const CUE_MS = freeze({ leech: 2600, wisp: 1800 });
|
||||
// The things done on purpose that are worth a die.
|
||||
export const ACTS_GOAL = 6;
|
||||
|
||||
const mine = (round) => (round.runner && round.runner.id === "lantern" ? round.runner : null);
|
||||
// How far into the round it is (ms), from the room's clock.
|
||||
export const elapsedOf = (round) => Math.max(0, (round.spec.ride ? round.spec.ride.time : TIME_S * 1000) - round.timeMs);
|
||||
// The lantern's light radius now.
|
||||
export const lightOf = (c) => lightR(c.oil);
|
||||
|
||||
/* ------------------------------------------------------------- the island */
|
||||
|
||||
// The island's walkable shapes, built once per ride: hummock disks and plank capsules.
|
||||
const GEOM = new WeakMap();
|
||||
export function geomOf(R) {
|
||||
let g = GEOM.get(R);
|
||||
if (!g) {
|
||||
const disks = R.hummocks.map(([x, y, r]) => freeze({ x, y, r }));
|
||||
const planks = R.planks.map(([a, b]) => freeze({ x1: R.hummocks[a][0], y1: R.hummocks[a][1], x2: R.hummocks[b][0], y2: R.hummocks[b][1], a, b }));
|
||||
g = freeze({ disks: freeze(disks), planks: freeze(planks) });
|
||||
GEOM.set(R, g);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
// The point of plank `p` nearest (x, y), and how far it is.
|
||||
function onPlankAxis(p, x, y) {
|
||||
const dx = p.x2 - p.x1;
|
||||
const dy = p.y2 - p.y1;
|
||||
const t = clamp(((x - p.x1) * dx + (y - p.y1) * dy) / (dx * dx + dy * dy), 0, 1);
|
||||
const sx = p.x1 + dx * t;
|
||||
const sy = p.y1 + dy * t;
|
||||
return [sx, sy, dist(x, y, sx, sy)];
|
||||
}
|
||||
|
||||
// The nearest point of the island to (x, y) (the point itself when it is on it).
|
||||
export function project(R, x, y) {
|
||||
const g = geomOf(R);
|
||||
let best = null;
|
||||
let bd = Infinity;
|
||||
const take = (px, py) => {
|
||||
const d = dist(x, y, px, py);
|
||||
if (d < bd) {
|
||||
bd = d;
|
||||
best = [px, py];
|
||||
}
|
||||
};
|
||||
for (const s of g.disks) {
|
||||
const d = dist(x, y, s.x, s.y);
|
||||
if (d <= s.r) return [x, y];
|
||||
take(s.x + ((x - s.x) / d) * s.r, s.y + ((y - s.y) / d) * s.r);
|
||||
}
|
||||
for (const p of g.planks) {
|
||||
const [sx, sy, d] = onPlankAxis(p, x, y);
|
||||
if (d <= PLANK_HALF) return [x, y];
|
||||
take(sx + ((x - sx) / d) * PLANK_HALF, sy + ((y - sy) / d) * PLANK_HALF);
|
||||
}
|
||||
return best || [x, y];
|
||||
}
|
||||
|
||||
export const onIsland = (R, x, y) => {
|
||||
const p = project(R, x, y);
|
||||
return dist(p[0], p[1], x, y) < 1e-6;
|
||||
};
|
||||
// Whether (x, y) is on the moss of a hummock (silent) rather than on a plank (heard).
|
||||
export const onMoss = (R, x, y) => geomOf(R).disks.some((s) => dist(x, y, s.x, s.y) <= s.r);
|
||||
|
||||
// The shrine i's stone.
|
||||
export const shrineAt = (R, i) => R.hummocks[R.shrines[i]];
|
||||
|
||||
/* -------------------------------------------------------------- placing */
|
||||
|
||||
const wispOf = (w, i) => ({ i, x: w.home[0], y: w.home[1], wp: 0, state: w.wake > 0 ? "asleep" : w.shrine >= 0 ? "guard" : "roam", t: 0, cue: 0 });
|
||||
|
||||
// Planny put down in the room: on the landing at the start, or (the same room, after a respawn) with the shrines already lit kept as they were.
|
||||
function place(round, k) {
|
||||
const R = round.spec.ride;
|
||||
if (!R || R.runner !== "lantern") {
|
||||
// (Another ride's state in the shared slot is not ours to touch.)
|
||||
if (mine(round)) round.runner = null;
|
||||
return;
|
||||
}
|
||||
const again = mine(round) && round.runner.room === round.room ? round.runner : null;
|
||||
const [sx, sy] = R.start;
|
||||
const you = round.you;
|
||||
Object.assign(you, { x: sx, y: k.groundAt(round.spec, sx), vy: 0, state: "run", shelf: -1, face: 1, ducking: false, coyote: 0, drop: -1 });
|
||||
const shrines = R.shrines.map((s, i) => (again ? again.shrines[i] : 0));
|
||||
round.runner = {
|
||||
id: "lantern", room: round.room, x: sx, y: sy, fx: 1, fy: 0, moving: false, plank: false, stepMs: 0, clock: 0, hf: false,
|
||||
shrines, lit: shrines.filter((v) => v >= SHRINE_MS).length, oil: 1, gutter: false, flareCd: 0, flare: null, done: false,
|
||||
lurker: { x: R.lurker.home[0], y: R.lurker.home[1], wp: 0, state: "drift", t: 0, tx: 0, ty: 0, ax: 0, ay: 0, bx: 0, by: 0, near: Infinity },
|
||||
wisps: R.wisps.map(wispOf),
|
||||
leeches: R.leeches.map((h, i) => ({ i, x: h.home[0], y: h.home[1], wp: 0, state: "drift", t: 0, cue: 0 })),
|
||||
bodies: R.bodies.map(([x, y]) => ({ x, y, state: "sunk", t: 0 })),
|
||||
mother: { stir: 0, risen: false, riseT: 0, gap: 0, hand: null },
|
||||
met: {}, caught: { lurker: 0, leech: 0, wisp: 0, body: 0, mother: 0 }, marks: [],
|
||||
};
|
||||
const b = round.bonusRound;
|
||||
if (b) {
|
||||
b.perf.total = HUNTERS.length;
|
||||
b.perf.goal = ACTS_GOAL;
|
||||
if (!again) b.perf.steady = true;
|
||||
}
|
||||
round.camLead = 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ the round */
|
||||
|
||||
// Planny and the whole island for one slice. Returns true once it has moved Planny (every slice of the
|
||||
// round); false once he is in the boat and has been put at the door.
|
||||
function ride(round, ms, k) {
|
||||
const R = round.spec.ride;
|
||||
const c = mine(round);
|
||||
if (!R || R.runner !== "lantern" || !c || c.done) return false;
|
||||
const you = round.you;
|
||||
const inp = round.input;
|
||||
const ev = (type, extra = {}) => round.events.push({ type, x: c.x, y: c.y, ...extra });
|
||||
inp.jump = 0;
|
||||
// The door is past the map's edge, so no walk reaches it; a Planny put at it (the suites, a bot) has the room done, as a ride's finish line does.
|
||||
if (you.x >= round.spec.door) return finish(round, c, R, k, ev);
|
||||
c.clock += ms;
|
||||
const noises = [];
|
||||
// SPACE: a flare, once a press.
|
||||
const fire = Boolean(inp.fire);
|
||||
if (fire && !c.hf) flare(round, c, noises, ev);
|
||||
c.hf = fire;
|
||||
walk(round, c, R, ms, noises, ev);
|
||||
you.x = c.x;
|
||||
Object.assign(you, { y: k.groundAt(round.spec, c.x), vy: 0, state: "run", ducking: false, face: c.fx < 0 ? -1 : 1 });
|
||||
oil(round, c, ms, ev);
|
||||
shrines(round, c, R, ms, noises, ev);
|
||||
if (c.flare && (c.flare.t -= ms) <= 0) c.flare = null;
|
||||
c.flareCd = Math.max(0, c.flareCd - ms);
|
||||
// All five lit and Planny at the boat: away.
|
||||
if (c.lit >= SHRINES && dist(c.x, c.y, R.boat[0], R.boat[1]) <= BOAT_R) return finish(round, c, R, k, ev);
|
||||
if (hunters(round, c, R, ms, noises, k, ev) || round.phase !== "play") return true;
|
||||
marks(c, round);
|
||||
// The clock ran out: the bog keeps the light.
|
||||
if (round.timeMs <= 0) return drowned(round, k);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The walk: the arrows, sliding along the shore when the straight way is water; a step on the planks is heard.
|
||||
function walk(round, c, R, ms, noises, ev) {
|
||||
const inp = round.input;
|
||||
let dx = (inp.right ? 1 : 0) - (inp.left ? 1 : 0);
|
||||
let dy = (inp.down ? 1 : 0) - (inp.up ? 1 : 0);
|
||||
c.moving = false;
|
||||
if (dx || dy) {
|
||||
const m = Math.hypot(dx, dy);
|
||||
dx /= m;
|
||||
dy /= m;
|
||||
c.fx = dx;
|
||||
c.fy = dy;
|
||||
const want = WALK_V * (ms / 1000);
|
||||
const at = slide(R, c.x, c.y, dx, dy, want);
|
||||
if (dist(at[0], at[1], c.x, c.y) > want * 0.05) {
|
||||
c.x = clamp(at[0], MAP.x0, MAP.x1);
|
||||
c.y = clamp(at[1], MAP.y0, MAP.y1);
|
||||
c.moving = true;
|
||||
}
|
||||
}
|
||||
c.plank = !onMoss(R, c.x, c.y);
|
||||
if (c.moving && c.plank) {
|
||||
c.stepMs -= ms;
|
||||
if (c.stepMs <= 0) {
|
||||
c.stepMs += STEP_MS;
|
||||
noises.push({ x: c.x, y: c.y, r: STEP_HEAR, kind: "step" });
|
||||
ev("lanternStep");
|
||||
}
|
||||
} else c.stepMs = 0;
|
||||
}
|
||||
|
||||
// Where a step of `len` the way (dx, dy) lands: straight on if it can, else turned up to 85 degrees toward
|
||||
// whichever way the shore or the plank runs, the first that keeps at least half the step going forward.
|
||||
const TURNS = [0, 0.5, -0.5, 1, -1, 1.48, -1.48];
|
||||
export function slide(R, x, y, dx, dy, len) {
|
||||
let best = null;
|
||||
let bestGo = -Infinity;
|
||||
for (const a of TURNS) {
|
||||
const ca = Math.cos(a);
|
||||
const sa = Math.sin(a);
|
||||
const ux = dx * ca - dy * sa;
|
||||
const uy = dx * sa + dy * ca;
|
||||
const [px, py] = project(R, x + ux * len, y + uy * len);
|
||||
const go = (px - x) * dx + (py - y) * dy;
|
||||
if (a === 0 && go >= len * 0.6) return [px, py];
|
||||
if (go >= len * 0.5 * Math.cos(a) && go > bestGo + 1e-9) {
|
||||
best = [px, py];
|
||||
bestGo = go;
|
||||
if (a !== 0) break;
|
||||
}
|
||||
}
|
||||
return best || project(R, x, y);
|
||||
}
|
||||
|
||||
// The oil burns down; out, the flame gutters (the leeches' moment); a shrine fills it again.
|
||||
function oil(round, c, ms, ev) {
|
||||
const was = c.oil;
|
||||
c.oil = Math.max(0, c.oil - ms / OIL_MS);
|
||||
if (was > 0 && c.oil <= 0) {
|
||||
c.gutter = true;
|
||||
ev("lanternGutter");
|
||||
if (round.bonusRound) round.bonusRound.perf.steady = false;
|
||||
}
|
||||
if (c.oil > 0) c.gutter = false;
|
||||
}
|
||||
|
||||
// SPACE: a ring of light FLARE_R round Planny, if there is oil for it.
|
||||
function flare(round, c, noises, ev) {
|
||||
if (c.flareCd > 0) return;
|
||||
if (c.oil < FLARE_OIL) {
|
||||
c.flareCd = FLARE_CD_MS;
|
||||
ev("lanternSputter");
|
||||
return;
|
||||
}
|
||||
c.oil -= FLARE_OIL;
|
||||
c.flareCd = FLARE_CD_MS;
|
||||
c.flare = { x: c.x, y: c.y, t: FLARE_MS };
|
||||
noises.push({ x: c.x, y: c.y, r: Infinity, kind: "flare" });
|
||||
ev("lanternFlare");
|
||||
let popped = 0;
|
||||
for (const w of c.wisps) {
|
||||
if (!live(w) || dist(w.x, w.y, c.x, c.y) > FLARE_R) continue;
|
||||
pop(round, c, w, ev, true);
|
||||
popped++;
|
||||
}
|
||||
if (popped >= 2) ev("lanternPop", { combo: popped, x: c.x, y: c.y, points: POP_POINTS * popped });
|
||||
if (popped >= 2) round.score += POP_POINTS * popped;
|
||||
for (const S of c.leeches) if (dist(S.x, S.y, c.x, c.y) <= FLARE_R * 2) Object.assign(S, { state: "scatter", t: SCATTER_MS });
|
||||
}
|
||||
|
||||
const live = (w) => w.state !== "popped" && w.state !== "gone" && w.state !== "asleep";
|
||||
|
||||
function act(round, points) {
|
||||
round.score += points;
|
||||
if (round.bonusRound) round.bonusRound.perf.acts++;
|
||||
}
|
||||
|
||||
// A wisp bursts (an act when it was a flare's doing); it comes back unless its shrine is lit by then.
|
||||
function pop(round, c, w, ev, byFlare) {
|
||||
const R = round.spec.ride;
|
||||
const spec = R.wisps[w.i];
|
||||
Object.assign(w, { state: spec.shrine >= 0 && c.shrines[spec.shrine] >= SHRINE_MS ? "gone" : "popped", t: WISP_REFORM_MS });
|
||||
if (byFlare) act(round, POP_POINTS);
|
||||
ev("lanternPop", { x: w.x, y: w.y, points: byFlare ? POP_POINTS : 0 });
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- shrines */
|
||||
|
||||
function shrines(round, c, R, ms, noises, ev) {
|
||||
R.shrines.forEach((h, i) => {
|
||||
if (c.shrines[i] >= SHRINE_MS) return;
|
||||
const [hx, hy] = R.hummocks[h];
|
||||
if (dist(c.x, c.y, hx, hy) > SHRINE_R) return;
|
||||
c.shrines[i] += ms;
|
||||
if (c.shrines[i] < SHRINE_MS) return;
|
||||
c.shrines[i] = SHRINE_MS;
|
||||
c.lit++;
|
||||
c.oil = 1;
|
||||
c.gutter = false;
|
||||
round.score += SHRINE_POINTS;
|
||||
noises.push({ x: hx, y: hy, r: SHRINE_HEAR, kind: "shrine" });
|
||||
ev("lanternShrine", { n: c.lit, x: hx, y: hy, points: SHRINE_POINTS });
|
||||
// Its guardian is laid to rest.
|
||||
c.wisps.forEach((w) => {
|
||||
if (R.wisps[w.i].shrine !== i) return;
|
||||
if (live(w)) ev("lanternPop", { x: w.x, y: w.y, points: 0 });
|
||||
w.state = "gone";
|
||||
});
|
||||
// Mother stirs; from the third shrine her hand comes now and then, and the fifth raises her.
|
||||
const M = c.mother;
|
||||
M.stir = c.lit;
|
||||
if (c.lit === 3) ev("lanternWake", { x: R.pool[0], y: R.pool[1] });
|
||||
if (c.lit >= SHRINES) {
|
||||
Object.assign(M, { risen: true, riseT: RISE_MS, hand: null, gap: RISE_MS });
|
||||
Object.assign(c.lurker, { state: "cower", t: 0 });
|
||||
ev("lanternRise", { x: R.pool[0], y: R.pool[1] });
|
||||
} else if (c.lit >= 3 && !M.hand) M.gap = Math.min(M.gap || Infinity, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
// In the boat: Planny is put at the door, which the next slice walks through.
|
||||
function finish(round, c, R, k, ev) {
|
||||
const you = round.you;
|
||||
if (!c.done && c.lit >= SHRINES) {
|
||||
round.score += ESCAPE_POINTS;
|
||||
ev("lanternFinish", { lit: c.lit, x: R.boat[0], y: R.boat[1], points: ESCAPE_POINTS });
|
||||
}
|
||||
c.done = true;
|
||||
round.hasKey = true;
|
||||
Object.assign(you, { x: round.spec.door, y: k.groundAt(round.spec, round.spec.door), vy: 0, state: "run", ducking: false });
|
||||
return false;
|
||||
}
|
||||
|
||||
// The clock is at nought: the last heart goes, and the round with it (the endless-lives code starts the clock again).
|
||||
function drowned(round, k) {
|
||||
const b = round.bonusRound;
|
||||
if (round.infinite || !b) {
|
||||
round.timeMs = round.spec.ride.time;
|
||||
return true;
|
||||
}
|
||||
b.hearts = Math.min(b.hearts, 1);
|
||||
k.lose(round, "time");
|
||||
return true;
|
||||
}
|
||||
|
||||
// What a banner over the field must keep clear of: Planny and anything that can hurt him, as [x, y up].
|
||||
function marks(c, round) {
|
||||
const up = (y) => 54 - y;
|
||||
const out = [[c.x, up(c.y)]];
|
||||
const L = c.lurker;
|
||||
if (L.state === "aim" || L.state === "dash" || L.state === "hunt") out.push([L.x, up(L.y)]);
|
||||
for (const w of c.wisps) if (live(w) && dist(w.x, w.y, c.x, c.y) < 20) out.push([w.x, up(w.y)]);
|
||||
if (c.mother.hand) out.push([c.mother.hand.x, up(c.mother.hand.y)]);
|
||||
c.marks = out;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- hunters */
|
||||
|
||||
// A heart lost to `kind`: Planny blinks safe (the engine's) where he stands. False when the blink (or the Garlic) took it.
|
||||
function grab(round, c, kind, k, ev) {
|
||||
if (!k.struck(round, CAUSES[kind])) return false;
|
||||
c.caught[kind]++;
|
||||
const b = round.bonusRound;
|
||||
if (b && !b.perf.hits.includes(kind)) b.perf.hits.push(kind);
|
||||
// The engine's "hearts left" float goes over Planny where he really is (the floor is all `you.y` knows).
|
||||
const lose = round.events.findLast((e) => e.type === "lose");
|
||||
if (lose) lose.y = 54 - c.y - 2.5;
|
||||
ev("lanternCatch", { kind });
|
||||
return true;
|
||||
}
|
||||
|
||||
// Moves `e` toward (tx, ty) by `v` a second; returns what is left of the way.
|
||||
function stepTo(e, tx, ty, v, dt) {
|
||||
const d = dist(e.x, e.y, tx, ty);
|
||||
if (d < 1e-6) return 0;
|
||||
const m = Math.min(d, v * dt);
|
||||
e.x += ((tx - e.x) / d) * m;
|
||||
e.y += ((ty - e.y) / d) * m;
|
||||
return d - m;
|
||||
}
|
||||
|
||||
// Along a route: head for the next waypoint, and take the one after on arrival.
|
||||
function patrol(e, route, v, dt) {
|
||||
const [tx, ty] = route[e.wp % route.length];
|
||||
if (stepTo(e, tx, ty, v, dt) < 0.8) e.wp = (e.wp + 1) % route.length;
|
||||
}
|
||||
|
||||
const keep = (e) => {
|
||||
e.x = clamp(e.x, MAP.x0 - 2, MAP.x1 + 2);
|
||||
e.y = clamp(e.y, MAP.y0 - 2, MAP.y1 + 2);
|
||||
};
|
||||
|
||||
// The first time a hunter comes near, it is named (the art shows its rule once).
|
||||
function meet(c, kind, x, y, ev) {
|
||||
if (c.met[kind]) return;
|
||||
c.met[kind] = true;
|
||||
ev("lanternMeet", { kind, x, y });
|
||||
}
|
||||
|
||||
// A cue the ear gets before the eye: at most one a CUE_MS, while `e` is within CUE_R.
|
||||
function cue(c, e, kind, ms, ev) {
|
||||
e.cue = Math.max(0, (e.cue || 0) - ms);
|
||||
if (e.cue > 0 || dist(e.x, e.y, c.x, c.y) > CUE_R[kind]) return;
|
||||
e.cue = CUE_MS[kind];
|
||||
ev(kind === "leech" ? "lanternLeechCue" : "lanternWispCue", { x: e.x, y: e.y });
|
||||
}
|
||||
|
||||
// Every hunter for one slice. Returns true when the round is no longer in play (a last heart).
|
||||
function hunters(round, c, R, ms, noises, k, ev) {
|
||||
const steps = [lurker, wisps, leeches, bodies, mother];
|
||||
for (const f of steps) if (f(round, c, R, ms, noises, k, ev)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The distance from (px, py) to the segment (ax, ay)-(bx, by).
|
||||
function toSegment(px, py, ax, ay, bx, by) {
|
||||
const dx = bx - ax;
|
||||
const dy = by - ay;
|
||||
const l2 = dx * dx + dy * dy;
|
||||
const t = l2 > 0 ? clamp(((px - ax) * dx + (py - ay) * dy) / l2, 0, 1) : 0;
|
||||
return dist(px, py, ax + dx * t, ay + dy * t);
|
||||
}
|
||||
|
||||
// THE LURKER: drift on its route; hunt the last noise it heard; within AIM_FROM, line up and dash through it; rest.
|
||||
function lurker(round, c, R, ms, noises, k, ev) {
|
||||
const L = c.lurker;
|
||||
const dt = ms / 1000;
|
||||
const heard = L.state === "drift" || L.state === "hunt" ? noises.filter((n) => dist(L.x, L.y, n.x, n.y) <= n.r).pop() : null;
|
||||
if (heard) {
|
||||
if (L.state === "drift") ev("lanternLurkerCue", { x: L.x, y: L.y });
|
||||
Object.assign(L, { state: "hunt", tx: heard.x, ty: heard.y });
|
||||
if (dist(L.x, L.y, c.x, c.y) <= MEET_R + 10) meet(c, "lurker", L.x, L.y, ev);
|
||||
}
|
||||
if (L.state === "drift") {
|
||||
patrol(L, R.lurker.route, LURKER_DRIFT_V, dt);
|
||||
} else if (L.state === "hunt") {
|
||||
const left = stepTo(L, L.tx, L.ty, LURKER_V, dt);
|
||||
if (left <= AIM_FROM) {
|
||||
// The lane: from where it stops, through the spot it heard, DASH_PAST beyond.
|
||||
const d = Math.max(0.5, dist(L.x, L.y, L.tx, L.ty));
|
||||
const ux = (L.tx - L.x) / d;
|
||||
const uy = (L.ty - L.y) / d;
|
||||
Object.assign(L, { state: "aim", t: AIM_MS, ax: L.x, ay: L.y, bx: clamp(L.tx + ux * DASH_PAST, MAP.x0 - 2, MAP.x1 + 2), by: clamp(L.ty + uy * DASH_PAST, MAP.y0 - 2, MAP.y1 + 2), near: Infinity });
|
||||
ev("lanternAim", { x: L.x, y: L.y, bx: L.bx, by: L.by });
|
||||
}
|
||||
} else if (L.state === "aim") {
|
||||
L.t -= ms;
|
||||
if (L.t <= 0) {
|
||||
L.state = "dash";
|
||||
ev("lanternDash", { x: L.x, y: L.y });
|
||||
}
|
||||
} else if (L.state === "dash") {
|
||||
const x0 = L.x;
|
||||
const y0 = L.y;
|
||||
const left = stepTo(L, L.bx, L.by, DASH_V, dt);
|
||||
const d = toSegment(c.x, c.y, x0, y0, L.x, L.y);
|
||||
L.near = Math.min(L.near, d);
|
||||
if (d <= DASH_HIT && grab(round, c, "lurker", k, ev)) {
|
||||
Object.assign(L, { state: "rest", t: REST_MS });
|
||||
return round.phase !== "play";
|
||||
}
|
||||
if (left <= 0.01) {
|
||||
if (L.near > DASH_HIT && L.near <= CLOSE_R && round.you.safeMs <= 0) {
|
||||
act(round, CLOSE_POINTS);
|
||||
ev("lanternClose", { x: c.x, y: c.y, points: CLOSE_POINTS, by: "lurker" });
|
||||
}
|
||||
Object.assign(L, { state: "rest", t: REST_MS });
|
||||
}
|
||||
} else if (L.state === "cower") {
|
||||
// Away from her pool, as far as its route goes.
|
||||
let far = R.lurker.route[0];
|
||||
for (const p of R.lurker.route) if (dist(p[0], p[1], R.pool[0], R.pool[1]) > dist(far[0], far[1], R.pool[0], R.pool[1])) far = p;
|
||||
stepTo(L, far[0], far[1], LURKER_V, dt);
|
||||
} else if (L.state === "rest") {
|
||||
L.t -= ms;
|
||||
if (L.t <= 0) {
|
||||
L.state = "drift";
|
||||
// Back to the nearest point of its route.
|
||||
let bi = 0;
|
||||
R.lurker.route.forEach(([x, y], i) => {
|
||||
if (dist(L.x, L.y, x, y) < dist(L.x, L.y, ...R.lurker.route[bi])) bi = i;
|
||||
});
|
||||
L.wp = bi;
|
||||
}
|
||||
}
|
||||
keep(L);
|
||||
if (dist(L.x, L.y, c.x, c.y) <= MEET_R && L.state !== "rest" && L.state !== "cower") meet(c, "lurker", L.x, L.y, ev);
|
||||
return false;
|
||||
}
|
||||
|
||||
// THE WISPS: guardians circle their shrine and rush a lantern near it; roamers from Mother's pool drift after one. A flare bursts them.
|
||||
function wisps(round, c, R, ms, noises, k, ev) {
|
||||
const dt = ms / 1000;
|
||||
for (const w of c.wisps) {
|
||||
const spec = R.wisps[w.i];
|
||||
if (w.state === "gone") continue;
|
||||
if (w.state === "asleep") {
|
||||
if (c.lit >= spec.wake) {
|
||||
Object.assign(w, { state: "roam", x: R.pool[0], y: R.pool[1] });
|
||||
ev("lanternWispCue", { x: w.x, y: w.y });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (w.state === "popped") {
|
||||
w.t -= ms;
|
||||
if (w.t <= 0) {
|
||||
if (spec.shrine >= 0 && c.shrines[spec.shrine] >= SHRINE_MS) w.state = "gone";
|
||||
else Object.assign(w, { state: spec.shrine >= 0 ? "guard" : "roam", x: spec.home[0], y: spec.home[1], wp: 0 });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const d = dist(w.x, w.y, c.x, c.y);
|
||||
if (spec.shrine >= 0) {
|
||||
const [sx, sy] = shrineAt(R, spec.shrine);
|
||||
const yours = dist(c.x, c.y, sx, sy) <= LEASH;
|
||||
if (yours && (w.state === "chase" || d <= GUARD_SENSE)) {
|
||||
w.state = "chase";
|
||||
stepTo(w, c.x, c.y, WISP_V, dt);
|
||||
} else {
|
||||
// Back to its circle, then round it.
|
||||
const a = spec.phase + (c.clock / 1000) * ORBIT_W;
|
||||
const ox = sx + Math.cos(a) * ORBIT_R;
|
||||
const oy = sy + Math.sin(a) * ORBIT_R;
|
||||
if (w.state === "chase" || w.state === "back") w.state = stepTo(w, ox, oy, WISP_RETURN_V, dt) < 0.5 ? "guard" : "back";
|
||||
else {
|
||||
w.x = ox;
|
||||
w.y = oy;
|
||||
}
|
||||
}
|
||||
} else if (d <= ROAM_SENSE) {
|
||||
w.state = "chase";
|
||||
stepTo(w, c.x, c.y, ROAM_CHASE_V, dt);
|
||||
} else {
|
||||
w.state = "roam";
|
||||
patrol(w, spec.route, ROAM_V, dt);
|
||||
}
|
||||
keep(w);
|
||||
cue(c, w, "wisp", ms, ev);
|
||||
if (w.state === "chase") meet(c, "wisp", w.x, w.y, ev);
|
||||
if (dist(w.x, w.y, c.x, c.y) <= WISP_CATCH && grab(round, c, "wisp", k, ev)) {
|
||||
pop(round, c, w, ev, false);
|
||||
return round.phase !== "play";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// THE LEECHES: they follow you at the edge of your light and never come into it; the flame out, they bite. A flare scatters them.
|
||||
function leeches(round, c, R, ms, noises, k, ev) {
|
||||
const dt = ms / 1000;
|
||||
const r = lightOf(c);
|
||||
for (const S of c.leeches) {
|
||||
const d = dist(S.x, S.y, c.x, c.y);
|
||||
if (S.state === "scatter") {
|
||||
S.t -= ms;
|
||||
if (d > 0.01) stepTo(S, S.x + (S.x - c.x) * 4, S.y + (S.y - c.y) * 4, SCATTER_V, dt);
|
||||
if (S.t <= 0) S.state = "drift";
|
||||
} else if (d <= LEECH_SENSE || c.gutter) {
|
||||
S.state = c.gutter ? "swarm" : "stalk";
|
||||
if (c.gutter) stepTo(S, c.x, c.y, LEECH_V * 1.4, dt);
|
||||
else {
|
||||
// To the light's edge, a little round from where it is (each swarm its own way), never inside.
|
||||
const a = Math.atan2(S.y - c.y, S.x - c.x) + (S.i % 2 ? 0.35 : -0.35) * dt;
|
||||
const edge = r + LEECH_EDGE;
|
||||
if (d < edge) stepTo(S, c.x + Math.cos(a) * edge, c.y + Math.sin(a) * edge, LEECH_V * 1.3, dt);
|
||||
else stepTo(S, c.x + Math.cos(a) * edge, c.y + Math.sin(a) * edge, LEECH_V, dt);
|
||||
}
|
||||
if (d <= r + 3) meet(c, "leech", S.x, S.y, ev);
|
||||
} else {
|
||||
S.state = "drift";
|
||||
patrol(S, R.leeches[S.i].route, LEECH_DRIFT_V, dt);
|
||||
}
|
||||
keep(S);
|
||||
cue(c, S, "leech", ms, ev);
|
||||
if (c.gutter && dist(S.x, S.y, c.x, c.y) <= LEECH_BITE && grab(round, c, "leech", k, ev)) {
|
||||
c.oil = OIL_AFTER_BITE;
|
||||
c.gutter = false;
|
||||
for (const T of c.leeches) Object.assign(T, { state: "scatter", t: SCATTER_MS });
|
||||
return round.phase !== "play";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// THE BOG BODIES: stand still near one and the water boils, then a hand comes up and takes what is within reach.
|
||||
function bodies(round, c, R, ms, noises, k, ev) {
|
||||
for (const B of c.bodies) {
|
||||
const d = dist(B.x, B.y, c.x, c.y);
|
||||
if (d <= BODY_NOTICE + 2) meet(c, "body", B.x, B.y, ev);
|
||||
if (B.state === "sunk") {
|
||||
B.t = d <= BODY_NOTICE && !c.moving ? B.t + ms : 0;
|
||||
if (B.t >= BODY_STILL_MS) {
|
||||
Object.assign(B, { state: "rise", t: BODY_RISE_MS });
|
||||
ev("lanternBodyCue", { x: B.x, y: B.y });
|
||||
}
|
||||
} else if (B.state === "rise") {
|
||||
B.t -= ms;
|
||||
if (B.t <= 0) Object.assign(B, { state: "up", t: BODY_UP_MS });
|
||||
} else if (B.state === "up") {
|
||||
B.t -= ms;
|
||||
if (d <= BODY_REACH && grab(round, c, "body", k, ev)) {
|
||||
Object.assign(B, { state: "rest", t: BODY_REST_MS });
|
||||
return round.phase !== "play";
|
||||
}
|
||||
if (B.t <= 0) Object.assign(B, { state: "rest", t: BODY_REST_MS });
|
||||
} else if (B.state === "rest") {
|
||||
B.t -= ms;
|
||||
if (B.t <= 0) Object.assign(B, { state: "sunk", t: 0 });
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// OLD MOTHER BOG: her hand's shadow finds you, stops, and slams; from the third shrine now and then, once risen one after another.
|
||||
function mother(round, c, R, ms, noises, k, ev) {
|
||||
const M = c.mother;
|
||||
const dt = ms / 1000;
|
||||
if (M.riseT > 0) M.riseT -= ms;
|
||||
const late = elapsedOf(round) >= MOTHER_LATE_S * 1000;
|
||||
const awake = M.risen || c.lit >= 3 || late;
|
||||
if (!awake) return false;
|
||||
const H = M.hand;
|
||||
if (!H) {
|
||||
M.gap = (M.gap || (M.risen ? MOTHER_RISEN_GAP : MOTHER_GAP[Math.min(4, Math.max(3, c.lit))])) - ms;
|
||||
if (M.gap > 0) return false;
|
||||
M.gap = 0;
|
||||
// The shadow falls a little behind where Planny is heading, so a walk carries him out of it.
|
||||
M.hand = { x: c.x - c.fx * 2, y: c.y - c.fy * 2, state: "track", t: M.risen ? HAND_TRACK_RISEN_MS : HAND_TRACK_MS };
|
||||
ev("lanternHand", { x: M.hand.x, y: M.hand.y });
|
||||
meet(c, "mother", c.x, c.y, ev);
|
||||
return false;
|
||||
}
|
||||
H.t -= ms;
|
||||
if (H.state === "track") {
|
||||
stepTo(H, c.x, c.y, M.risen ? HAND_RISEN_V : HAND_V, dt);
|
||||
if (H.t <= 0) Object.assign(H, { state: "lock", t: HAND_LOCK_MS });
|
||||
} else if (H.state === "lock") {
|
||||
if (H.t <= 0) {
|
||||
const d = dist(H.x, H.y, c.x, c.y);
|
||||
ev("lanternSlam", { x: H.x, y: H.y });
|
||||
Object.assign(H, { state: "rest", t: HAND_REST_MS });
|
||||
if (d <= HAND_R) {
|
||||
if (grab(round, c, "mother", k, ev)) {
|
||||
H.t = HAND_REST_MS * 3;
|
||||
return round.phase !== "play";
|
||||
}
|
||||
} else if (d <= CLOSE_R && round.you.safeMs <= 0) {
|
||||
act(round, CLOSE_POINTS);
|
||||
ev("lanternClose", { x: c.x, y: c.y, points: CLOSE_POINTS, by: "mother" });
|
||||
}
|
||||
}
|
||||
} else if (H.t <= 0) {
|
||||
M.hand = null;
|
||||
M.gap = M.risen ? MOTHER_RISEN_GAP : MOTHER_GAP[Math.min(4, Math.max(3, c.lit))];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// The held sounds this room wants now, as [id, hum name, level, pitch] (ghoul.js plays them; sounds never touch the round).
|
||||
export function lanternHums(round) {
|
||||
const c = mine(round);
|
||||
if (!c || c.done || round.phase !== "play") return [];
|
||||
const out = [];
|
||||
const L = c.lurker;
|
||||
const d = dist(L.x, L.y, c.x, c.y);
|
||||
if (L.state !== "rest" && L.state !== "cower" && d < 34) out.push(["ghoul:lurker", "ghoulLanternLurk", (1 - d / 34) ** 1.4 * (L.state === "drift" ? 0.5 : 1), L.state === "aim" ? 1.4 : L.state === "hunt" ? 1.15 : 1]);
|
||||
if (c.mother.risen) out.push(["ghoul:mother", "ghoulLanternMother", 0.9, 1]);
|
||||
else if (c.mother.stir >= 3) out.push(["ghoul:mother", "ghoulLanternMother", 0.35, 0.85]);
|
||||
return out;
|
||||
}
|
||||
|
||||
export const LANTERN = freeze({
|
||||
id: "lantern",
|
||||
monsters: MONSTERS,
|
||||
walkers: freeze([]),
|
||||
zombies: freeze([]),
|
||||
stackers: freeze([]),
|
||||
climbers: freeze([]),
|
||||
act: freeze({}),
|
||||
horde: freeze({}),
|
||||
ride: freeze([ride]),
|
||||
place: freeze([place]),
|
||||
});
|
||||
@@ -0,0 +1,262 @@
|
||||
// Plan2Code Web Console - ghoul: The Drowned Lantern's own sound effects, merged into ghoul-sfx.js; defines only.
|
||||
//
|
||||
// Same shape and rules as ghoul-sfx-hearse.js: `tones` (a `ghoulLantern<Act>` sound for each thing the
|
||||
// round does, built from the house tone layers, none over 1.2 s with its delay), `hums` (the held sounds the
|
||||
// room asks for through lanternHums in ghoul-lantern.js: the Lurker near, Mother awake) and `music` (the
|
||||
// room's theme, `ghoulLanternTheme`, named in ROOM_MUSIC in ghoul.js, the user's pick, Tiptoe plucks).
|
||||
// Every hunter is heard before it reaches you: the Lurker's groan when it hears you and the rising
|
||||
// hiss as it lines up its dash, the leeches' dry skitter, the wisps' thin chime, the bog bodies' wet boil, and
|
||||
// Mother's low thrum as her hand's shadow falls. First drafts, to be picked by ear later. A name may be
|
||||
// defined only once across tones.js and every game's file. No imports.
|
||||
|
||||
export const LANTERN_SFX = {
|
||||
tones: {
|
||||
// Step: a board creaking underfoot, the sound the Lurker listens for.
|
||||
ghoulLanternStep: {
|
||||
layers: [
|
||||
{ type: "triangle", from: 190, to: 150, seconds: 0.09, attack: 0.01, gain: 0.35, vibrato: { rate: 30, depth: 0.08 } },
|
||||
{ type: "brown", seconds: 0.08, attack: 0, gain: 0.3, filter: { type: "lowpass", from: 900, to: 300, q: 2 } },
|
||||
],
|
||||
},
|
||||
// Flare: the lantern blazes up, a whoomp and a bright hiss.
|
||||
ghoulLanternFlare: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.12, attack: 0, gain: 0.6, filter: { type: "highpass", from: 2200, to: 900 } },
|
||||
{ type: "sine", from: 160, to: 70, seconds: 0.26, attack: 0, gain: 0.7 },
|
||||
{ type: "noise", seconds: 0.7, attack: 0.04, gain: 0.3, filter: { type: "bandpass", from: 3400, to: 1800, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Sputter: no oil for a flare, a weak cough of flame.
|
||||
ghoulLanternSputter: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.08, attack: 0, gain: 0.35, filter: { type: "bandpass", from: 1200, to: 600, q: 2 } },
|
||||
{ type: "noise", seconds: 0.08, delay: 0.12, attack: 0, gain: 0.25, filter: { type: "bandpass", from: 1000, to: 500, q: 2 } },
|
||||
],
|
||||
},
|
||||
// Pop: a wisp bursts, a small bright pop and a falling whistle.
|
||||
ghoulLanternPop: {
|
||||
layers: [
|
||||
{ type: "sine", from: 1500, to: 400, seconds: 0.16, attack: 0, gain: 0.4 },
|
||||
{ type: "noise", seconds: 0.07, attack: 0, gain: 0.45, filter: { type: "highpass", from: 3000, to: 2000 } },
|
||||
],
|
||||
},
|
||||
// Shrine: a wisp shrine takes the flame, a rising three-note chime.
|
||||
ghoulLanternShrine: {
|
||||
layers: [
|
||||
{ type: "triangle", from: 660, to: 660, seconds: 0.2, attack: 0, gain: 0.4 },
|
||||
{ type: "triangle", from: 880, to: 880, seconds: 0.2, delay: 0.12, attack: 0, gain: 0.4 },
|
||||
{ type: "triangle", from: 1320, to: 1320, seconds: 0.5, delay: 0.24, attack: 0, gain: 0.42 },
|
||||
],
|
||||
},
|
||||
// Gutter: the oil is out, the flame shrinks with a choke and a sigh.
|
||||
ghoulLanternGutter: {
|
||||
layers: [
|
||||
{ type: "sawtooth", from: 220, to: 70, seconds: 0.6, attack: 0.02, gain: 0.3, filter: { type: "lowpass", from: 1200, to: 200, q: 2 } },
|
||||
{ type: "noise", seconds: 0.5, attack: 0.05, gain: 0.3, filter: { type: "lowpass", from: 1400, to: 300, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Catch: a hunter has you, a thump, a splash and a drop in the flame.
|
||||
ghoulLanternCatch: {
|
||||
layers: [
|
||||
{ type: "sine", from: 150, to: 45, seconds: 0.3, attack: 0, gain: 0.8 },
|
||||
{ type: "noise", seconds: 0.4, attack: 0.02, gain: 0.5, filter: { type: "bandpass", from: 1600, to: 400, q: 1.2 } },
|
||||
{ type: "brown", seconds: 0.5, attack: 0.04, gain: 0.5, filter: { type: "lowpass", from: 500, to: 120, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Finish: into the boat and away, a bright run of notes.
|
||||
ghoulLanternFinish: {
|
||||
layers: [
|
||||
{ type: "triangle", from: 523, to: 523, seconds: 0.18, attack: 0, gain: 0.4 },
|
||||
{ type: "triangle", from: 659, to: 659, seconds: 0.18, delay: 0.14, attack: 0, gain: 0.4 },
|
||||
{ type: "triangle", from: 784, to: 784, seconds: 0.18, delay: 0.28, attack: 0, gain: 0.4 },
|
||||
{ type: "triangle", from: 1047, to: 1047, seconds: 0.6, delay: 0.42, attack: 0, gain: 0.45 },
|
||||
],
|
||||
},
|
||||
// Meet: a hunter's rule shown for the first time, a soft low sting.
|
||||
ghoulLanternMeet: {
|
||||
layers: [
|
||||
{ type: "sine", from: 311, to: 311, seconds: 0.5, attack: 0.02, gain: 0.3 },
|
||||
{ type: "sine", from: 440, to: 440, seconds: 0.5, attack: 0.02, gain: 0.22 },
|
||||
],
|
||||
},
|
||||
// Close: a dash or a slam that just missed, a quick rushing whoosh.
|
||||
ghoulLanternClose: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.3, attack: 0.05, gain: 0.45, filter: { type: "bandpass", from: 600, to: 2400, q: 1.5 } },
|
||||
{ type: "sine", from: 700, to: 1100, seconds: 0.2, delay: 0.1, attack: 0.02, gain: 0.2 },
|
||||
],
|
||||
},
|
||||
// The Bog Lurker hears you: a low bubbling groan under the water.
|
||||
ghoulLanternLurker: {
|
||||
layers: [
|
||||
{ type: "sawtooth", from: 46, to: 62, seconds: 0.9, attack: 0.2, gain: 0.6, vibrato: { rate: 7, depth: 0.14 }, filter: { type: "lowpass", from: 220, to: 480, q: 4 } },
|
||||
{ type: "brown", seconds: 0.8, attack: 0.1, gain: 0.5, filter: { type: "lowpass", from: 600, to: 160, q: 1 } },
|
||||
],
|
||||
},
|
||||
// It lines up its dash: a rising hiss and a growl, the cue to get off the lane.
|
||||
ghoulLanternAim: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.75, attack: 0.5, gain: 0.45, filter: { type: "bandpass", from: 800, to: 3200, q: 2 } },
|
||||
{ type: "sawtooth", from: 70, to: 110, seconds: 0.75, attack: 0.2, gain: 0.4, filter: { type: "lowpass", from: 300, to: 700, q: 3 } },
|
||||
],
|
||||
},
|
||||
// The dash: a surge of water and a snap of jaws.
|
||||
ghoulLanternDash: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.35, attack: 0, gain: 0.6, filter: { type: "lowpass", from: 2400, to: 500, q: 1 } },
|
||||
{ type: "square", from: 140, to: 60, seconds: 0.08, delay: 0.18, attack: 0, gain: 0.45, filter: { type: "lowpass", from: 1600, to: 600, q: 1 } },
|
||||
],
|
||||
},
|
||||
// The leeches: a dry rapid skitter, like many small things on wet wood.
|
||||
ghoulLanternLeech: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.5, attack: 0.02, gain: 0.5, filter: { type: "bandpass", from: 5200, to: 3600, q: 4 } },
|
||||
{ type: "noise", seconds: 0.4, delay: 0.12, attack: 0.02, gain: 0.35, filter: { type: "bandpass", from: 3000, to: 4400, q: 3 } },
|
||||
],
|
||||
},
|
||||
// The wisps: a thin whistling chime that wavers.
|
||||
ghoulLanternWisp: {
|
||||
layers: [
|
||||
{ type: "sine", from: 1760, to: 1480, seconds: 0.8, attack: 0.1, gain: 0.22, vibrato: { rate: 9, depth: 0.06 } },
|
||||
{ type: "sine", from: 2640, to: 2220, seconds: 0.7, delay: 0.1, attack: 0.1, gain: 0.12, vibrato: { rate: 11, depth: 0.05 } },
|
||||
],
|
||||
},
|
||||
// A bog body stirs: a wet boil, a slow slurp and a gasp of marsh gas.
|
||||
ghoulLanternBody: {
|
||||
layers: [
|
||||
{ type: "brown", seconds: 0.7, attack: 0.1, gain: 0.7, filter: { type: "lowpass", from: 300, to: 900, q: 2 } },
|
||||
{ type: "sine", from: 120, to: 240, seconds: 0.5, attack: 0.05, gain: 0.4 },
|
||||
{ type: "noise", seconds: 0.25, delay: 0.5, attack: 0.04, gain: 0.25, filter: { type: "bandpass", from: 700, to: 1500, q: 1.5 } },
|
||||
],
|
||||
},
|
||||
// Mother stirs (the third shrine): a held low chord that swells.
|
||||
ghoulLanternWake: {
|
||||
layers: [
|
||||
{ type: "sawtooth", from: 55, to: 58, seconds: 1.1, attack: 0.5, gain: 0.5, filter: { type: "lowpass", from: 260, to: 520, q: 3 } },
|
||||
{ type: "sawtooth", from: 58, to: 62, seconds: 1.1, attack: 0.5, gain: 0.4, filter: { type: "lowpass", from: 260, to: 520, q: 3 } },
|
||||
{ type: "sine", from: 800, to: 760, seconds: 0.9, delay: 0.2, attack: 0.3, gain: 0.12 },
|
||||
],
|
||||
},
|
||||
// She rises (the fifth): water pouring off her, a long gurgling roar.
|
||||
ghoulLanternRise: {
|
||||
layers: [
|
||||
{ type: "brown", seconds: 1.1, attack: 0.1, gain: 0.8, filter: { type: "lowpass", from: 300, to: 1400, q: 1.5 } },
|
||||
{ type: "sawtooth", from: 40, to: 72, seconds: 1.1, attack: 0.15, gain: 0.5, vibrato: { rate: 5, depth: 0.12 }, filter: { type: "lowpass", from: 300, to: 700, q: 3 } },
|
||||
{ type: "noise", seconds: 0.8, delay: 0.3, attack: 0.1, gain: 0.3, filter: { type: "bandpass", from: 500, to: 1800, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Her hand's shadow falls: a low thrum from under the water.
|
||||
ghoulLanternHand: {
|
||||
layers: [
|
||||
{ type: "sine", from: 58, to: 52, seconds: 0.7, attack: 0.15, gain: 0.6 },
|
||||
{ type: "triangle", from: 116, to: 104, seconds: 0.6, attack: 0.15, gain: 0.25 },
|
||||
],
|
||||
},
|
||||
// The slam: a huge wet slap on the water.
|
||||
ghoulLanternSlam: {
|
||||
layers: [
|
||||
{ type: "sine", from: 110, to: 35, seconds: 0.35, attack: 0, gain: 0.85 },
|
||||
{ type: "noise", seconds: 0.5, attack: 0, gain: 0.6, filter: { type: "lowpass", from: 2600, to: 400, q: 1 } },
|
||||
{ type: "brown", seconds: 0.7, delay: 0.08, attack: 0.05, gain: 0.45, filter: { type: "lowpass", from: 700, to: 150, q: 1 } },
|
||||
],
|
||||
},
|
||||
},
|
||||
hums: {
|
||||
// The Lurker close: a low bubbling growl under the water, louder and higher as it closes and hunts.
|
||||
ghoulLanternLurk: { parts: [{ type: "sawtooth", freq: 48 }, { type: "square", freq: 24, gain: 0.4 }], noise: { color: "brown", gain: 0.5 }, filter: { type: "lowpass", freq: 300, q: 4, follow: 0.8 }, pulse: { rate: 3, depth: 0.5 }, peak: 0.035 },
|
||||
// Mother awake: a deep slow breath from the pool, a held dread under everything once she has risen.
|
||||
ghoulLanternMother: { parts: [{ type: "sawtooth", freq: 36 }, { type: "sine", freq: 54, gain: 0.5 }], noise: { color: "brown", gain: 0.3 }, filter: { type: "lowpass", freq: 220, q: 2, follow: 0.5 }, pulse: { rate: 0.5, depth: 0.6 }, peak: 0.04 },
|
||||
},
|
||||
music: {
|
||||
// The Drowned Lantern: tiptoe plucks. A sparse stealth tiptoe: dry
|
||||
// marimba plucks that stop and start, a soft footfall kick, a creeping
|
||||
// triangle bass and a few pluck plinks in the gaps. The footfalls double
|
||||
// in the sour third part; a high plink and a snap join only near full
|
||||
// dread.
|
||||
ghoulLanternTheme: {
|
||||
bpm: 88,
|
||||
rush: 20,
|
||||
voices: {
|
||||
marimba: { wave: "triangle", gain: 0.3, decay: 0.03, sustain: 0.05 },
|
||||
pluck: { wave: "pulse", duty: 0.25, gain: 0.08, decay: 0.03, sustain: 0.15, from: 0.4 },
|
||||
bass: { wave: "triangle", gain: 0.4, decay: 0.06, sustain: 0.5 },
|
||||
foot: { kit: true, gain: 0.14, from: 0.3 },
|
||||
tick: { kit: true, gain: 0.06, from: 0.5 },
|
||||
plink: { wave: "sine", gain: 0.05, decay: 0.05, sustain: 0.1, from: 0.85 },
|
||||
snap: { kit: true, gain: 0.12, from: 0.85 },
|
||||
},
|
||||
patterns: {
|
||||
A: {
|
||||
marimba:
|
||||
"A3 - . . . . E4 - . . C5 - . . . . | F3 - . . . . C4 - . . A4 - . . . . | " +
|
||||
"D3 - . . . . A3 - . . F4 - . . . . | E3 - . . . . G#4 - . . B4 - . . E5 .",
|
||||
pluck:
|
||||
". . . . C5 . . . . . . . . E5 . . | . . . . . . . C5 . . . . . C5 . . | " +
|
||||
". . . . D5 . . . . . . . . A4 . . | . . . . . . . G#5 . . . . . B4 . .",
|
||||
bass:
|
||||
"A2 - . . . . E3 . A2 - . . . . A2 . | F2 - . . . . C3 . F2 - . . . . F2 . | " +
|
||||
"D2 - . . . . A2 . D2 - . . . . D2 . | E2 - . . . . B2 . E2 - . . . . G#2 .",
|
||||
foot:
|
||||
"k . . . . . . . k . . . . . . . | k . . . . . . . k . . . . . . . | " +
|
||||
"k . . . . . . . k . . . . . . . | k . . . . . . . k . . . . . . .",
|
||||
tick:
|
||||
". . . . h . . . . . . . h . . . | . . . . h . . . . . . . h . . . | " +
|
||||
". . . . h . . . . . . . h . . . | . . . . h . . . . . . . h . . .",
|
||||
plink:
|
||||
". . . E7 . . . . . . . . . . . . | . . . . . . . . . C7 . . . . . . | " +
|
||||
". . . A6 . . . . . . . . . . . . | . . . . . . . . . B6 . . . . . .",
|
||||
snap:
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . .",
|
||||
},
|
||||
B: {
|
||||
marimba:
|
||||
"D3 - . . . . A3 - . . F4 - . A4 . . | A3 - . . . . E4 - . . C5 - . E5 . . | " +
|
||||
"F3 - . . . . C4 - . . A4 - . C5 . . | E3 - . . . . G#4 - . . B4 - . . E5 .",
|
||||
pluck:
|
||||
". . . . F4 . . . . . . . . A4 . . | . . . . . . . E5 . . . . . E5 . . | " +
|
||||
". . . . F5 . . . . . . . . C5 . . | . . . . . . . G#5 . . . . . B4 . .",
|
||||
bass:
|
||||
"D2 - . . . . A2 . D2 - . . . . D2 . | A2 - . . . . E3 . A2 - . . . . A2 . | " +
|
||||
"F2 - . . . . C3 . F2 - . . . . F2 . | E2 - . . . . B2 . E2 - . . . . G#2 .",
|
||||
foot:
|
||||
"k . . . . . . . k . . . . . . . | k . . . . . . . k . . . . . . . | " +
|
||||
"k . . . . . . . k . . . . . . . | k . . . . . . . k . . . . . . .",
|
||||
tick:
|
||||
". . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h . | " +
|
||||
". . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h .",
|
||||
plink:
|
||||
". . . A6 . . . . . . . . . . . . | . . . . . . . . . E7 . . . . . . | " +
|
||||
". . . C7 . . . . . . . . . . . . | . . . . . . . . . B6 . . . . . .",
|
||||
snap:
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . .",
|
||||
},
|
||||
C: {
|
||||
marimba:
|
||||
"A3 - . . . . E4 - . . C5 - . . . . | A#3 - . . . . F4 - . . D5 - . . . . | " +
|
||||
"A3 - . . . . E4 - . . C5 - . . . . | E3 - . . . . G#4 - . . B4 - . . E5 .",
|
||||
pluck:
|
||||
". . . . C5 . . . . . . . . E5 . . | . . . . . . . F5 . . . . . F5 . . | " +
|
||||
". . . . A5 . . . . . . . . E5 . . | . . . . . . . G#5 . . . . . B4 . .",
|
||||
bass:
|
||||
"A2 - . . . . E3 . A2 - . . . . A2 . | A#2 - . . . . F3 . A#2 - . . . . A#2 . | " +
|
||||
"A2 - . . . . E3 . A2 - . . . . A2 . | E2 - . . . . B2 . E2 - . . . . G#2 .",
|
||||
foot:
|
||||
"k . . k . . . . k . . k . . . . | k . . k . . . . k . . k . . . . | " +
|
||||
"k . . k . . . . k . . k . . . . | k . . k . . . . k . . k . . . .",
|
||||
tick:
|
||||
". . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h . | " +
|
||||
". . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h .",
|
||||
plink:
|
||||
". . . E7 . . . . . . . . . . . . | . . . . . . . . . F7 . . . . . . | " +
|
||||
". . . E7 . . . . . . . . . . . . | . . . . . . . . . B6 . . . . . .",
|
||||
snap:
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | . . . . s . . . . . . . s . . .",
|
||||
},
|
||||
},
|
||||
order: ["A", "B", "A", "C", "B"],
|
||||
},
|
||||
},
|
||||
};
|
||||
File renamed without changes.
+1
-1
@@ -59,7 +59,7 @@
|
||||
// "idle"|"warn"|"snap"|"sink"|"spent"|"broken", t }] }, `round.you` (`state`, `vy`, `ducking`),
|
||||
// the events in EVENTS.
|
||||
|
||||
import { linesAt, linesOf, trackY } from "./ghoul-cart.js";
|
||||
import { linesAt, linesOf, trackY } from "../cart/ghoul-cart.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 160 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user