# game.bridge
The Undercroft's link to arpgKit (dungeons, heroes, monsters, co-op revive) and classKit (the three pilgrims). The director calls only this module for them: `setup()`, `relicKits()`, `on(event, fn)` for arpgKit's kill, won, heroDowned, heroRevived and partyDown events, `buildFloor(floor, isBoss)` (an exact seeded floor from runLoopKit's floor record, the Hollow Abbot on the boss floor), `toCamp(pos)`, `toDungeon()`, `showHud(on)`, `applyClass(id)`, `classTags(id)`, `openClassPicker(ids, current, done)`, `pickerOpen()`, `startRun(classId, loadout)` (starting stats, potions and rerolls from the Star Vault), `partySize()`, `partyIndex()` and `isMine(who)`. Keeping the kit calls here means a kit's next version changes one file.
# relic_pickup
This sound clip signifies an ancient relic pickup, featuring a mystical shimmer chime with a low resonant hum. It is intended as a sound effect for collecting a valuable or magical item.
# player_down
This sound clip features a dying gasp and a body falling onto stone with an armor clank. It is a short and dramatic sound effect, intended to signify a player character being defeated or knocked down.
# ui_confirm
This sound clip is a low wooden knock with a small bell chime, used for a UI confirm action. It serves as a user interface sound effect to confirm a selection or action.
# boss_roar
This sound clip is a huge undead abbot roar, echoing in a cathedral crypt. It is designed as a monstrous and deep sound effect, likely for a boss character's vocalization.
# game.unlocks
The Undercroft's Star Vault catalogue: every unlock the camp's constellation board (runLoopKit `unlockScreen = "constellation"`) sells for Tallow, in three constellations: the Bell (might: health, damage, Powder Keg, Ram Horn, Titan Core, Phoenix Feather), the Key (cunning: rerolls, an extra relic choice, Soul Jar, Storm Coil, Hunter's Rush, a starting Whetstone) and the Lantern (spirit: a spare flask, the Lamplighter class, Wisp Lantern, Bond Charm, healing, Aegis Seal). Each entry carries a `pos` for its star.
Called by the game's director: `CATALOGUE` goes to `Run.setup({ unlocks = ... })`, `lockedRelics()` to relicsKit's `setLocked` so a relic only shows up in offers once its star is bought, `classesFor(loadout)` to the class picker, `CLASSES` names the three classKit classes.
# seal_break
This sound clip depicts a stone seal cracking and breaking open, with a rumble and a magical release. It is intended as a sound effect for breaking a magical barrier or unlocking a sealed area.
# bell_toll
This sound clip is a single deep church bronze bell toll with a long reverb tail, set in stone ruins. It is intended as a sound effect for significant in-game events or atmospheric touches.
# game.hud
The Undercroft's own HUD pieces, drawn beside arpgKit's classic HUD and runLoopKit's floor strip, from installed kits only:
- **Party portraits** (portraitPartyKit on portraitKit): every pilgrim in the room as a live 3D portrait in the `horror` look, lit by flickering firelight inside an arched frame on a glow, with a blood health bar read from SecondWind (through barsKit). A hit flashes the face and leaves a ghost on the bar; a hero at no health or downed (arpgKit `heroDowned`) shows KO with a hurt face until `heroRevived`. Desktop: a column on the left, below arpgKit's stats button and room tracker. Phone: a column on the right, under Bag/pause and above the minimap. Kept cheap: 144 px renders (128 on a phone), 5 idle renders a second, at most 2 portrait renders a frame, a 45 fps target for the kit's governor.
- **Minimap** (navUiKit): the gothic look, a `fog` minimap that uncovers the floor as you walk it, baked from the floor's colliders after arpgKit's `levelBuilt` (and again 0.6 s later, once the walls stand), bounded to the floor's rooms, a door icon on the stair room and a skull on the last room (gold on a floor, red on the boss floor). Bottom right on desktop and phone (right of arpgKit's globes and of its phone skill cluster). M or a tap opens the full fog map. No compass, objectives, toasts or waypoint parts, so runLoopKit's top-centre strip and the boss bar stay clear.
Each player gets an `hp` function of its own: portraitPartyKit 1.0.6 otherwise reads back the share it last wrote with `Portrait.health` before asking barsKit, so a `members = "players"` bar froze at its first reading.
## Calls (the director makes them)
- `Hud.setup()` once per peer at init: listens to arpgKit; shows nothing.
- `Hud.onFloor(floor, isBoss)` when a floor starts: portraits and the minimap on (re-run safe; the minimap re-bakes on every `levelBuilt`).
- `Hud.toCamp()` at camp and `Hud.hideAll()` on title, game over, victory and summary screens: both off.
- `Hud.state()` for tests: `{ mode, party, minimap, members, boss }`.
## Cost (desktop editor, measured in play with the rest of the game running)
NavHud (fog minimap) about 1.7 ms median per frame (a plain round minimap is 0.6 ms; the fog is what was asked for), PartyFrames about 1.3 ms, plus one small portrait camera pass per pilgrim at 5 renders a second while idle.
# revive
This sound clip is a holy revive sound, characterized by a soft rising choir chord and a warm chime. It serves as a sound effect for a player character being resurrected or revived.
# game_over
This sound clip is a funeral bell toll with a low choir sigh, functioning as a final and somber stinger. It is intended as a sound effect for a 'game over' state or a significant, melancholic event.
# game.campLayout
Where the camp's stations stand: the class lectern, the Star Vault altar, the bell rope in the tower and the crypt gate, each as an offset from the camp's origin (the campfire), with how close a pilgrim must stand and its prompt text, plus where pilgrims arrive. Matches the `camp.AbbeyCamp` scene module at its default size and the camp's placement in the main scene. Used by `game.CampStations` (prompts) and `game.director` (sending pilgrims to camp).
# game.boss
The Hollow Abbot, the Undercroft's final boss in the Ossuary Nave (the boss floor's last arpgKit room), built on bossFightKit (`Boss.defineBoss`, id `hollowAbbot`) with dungeonKit (Trapwright) arena hazards. A towering skeletal abbot in black and crimson robes with a gold stole, a bronze bell for a mitre, embers in his ribs and a burning censer on a chain. He rises out of the ossuary floor when the first pilgrim enters the room; phase 1 is a censer brawl (Censer Swing, Censer Smash, Funeral Dirge) with Ember Volleys; at half health the bell cracks (armour break: gold shards and embers), he tolls for his monks (arpgKit grunts, swarmlings and a caster join) and phase 2 is faster (Censer Flail, Rain of Embers, Cracked Toll, Procession of Ash, Grave Fall) while the nave wakes: a shockwave ring with four pillars for cover, falling debris and burning floor panels, at their harshest below 25%. Every attack has a ground telegraph that fills before it lands. Horror boss bar; health scales with party size (+70% for a second pilgrim) and floor difficulty.
Host-authoritative: the host spawns and runs the Abbot and the hazards' state; every peer draws them. arpgKit heroes hit him like any monster (SecondWind team `boss`), and his attacks hurt heroes through SecondWind (downed heroes take no damage).
## API (`local Boss = require("game.boss")`)
- `Boss.setup()`: once per peer at game start (registers the boss, listens to bossFightKit).
- `Boss.startFight(floor)`: on EVERY peer when the boss floor starts (after the host's `Bridge.buildFloor`). Waits for the level, places the arena hazards on every peer, and on the host raises the Abbot when a pilgrim walks into the last room.
- `Boss.on(name, fn) -> { disconnect }`: `spawned`, `phase` `{ phase = 2 }`, `frenzy`, `defeated` `{ floor }` (every peer, once per fight: the floor is won).
- `Boss.stop()`: on every peer when leaving the floor (the host removes the Abbot and his monks, every peer the hazards).
- `Boss.status()`: the fight on this peer, for tests and debugging.
# game.music
The Undercroft's adaptive score as soundstage music sets, so one music system plays (arpgKit's feel drives the state and intensity during a floor). Three sets, each with a calm and an intense take that crossfade with the fight:
- `undercroft` (floors 1-3): explore = crypt drone, swelling to a tense cello-and-bell take near danger; action = the combat loop, swelling to drums, organ and choir in a big fight.
- `undercroftBoss` (the Ossuary Nave): the boss loop, and the furious second-phase organ-and-choir take once the Abbot's bell cracks (`setBossPhase(2)`).
- `undercroftCamp` (title and camp): the cloister night theme, the title theme on menus.
`Music.play(id)` with `title`, `camp`, `explore`, `boss` or nil (silence) is what the director calls.
# game.hazards
The Undercroft's traps and secrets, built on Trapwright (`dungeonKit`). Every floor but the boss floor gets 2 to 4 traps (floor 1: 2, floor 2: 3, floor 3: 4, now and then one more; deeper pools add arrow walls, frost runes, gargoyle turrets, lightning pylons, crushing walls and collapsing floors; damage +15% per floor). Every trap is aimed at `all`, so heroes can lure monsters into it, and keeps Trapwright's wind-up tell (sound, red glow, shake). Traps sit inside the generated rooms, never within 5 cells of the start pad or 3 of the exit, never on a cell of the start-to-exit path, and never touching another piece.
Each floor also hides one secret: a 6 m niche walled into a room edge with no doorway behind it, closed by a cracked wall (strike it three times), an illusory wall (walk through), a torch-sconce lever or a sliding bookshelf/statue, with a hidden chest (gold and a health potion) in the rubble inside. If no wall fits, the chest alone is buried in a room. Choices come only from the floor seed and the built level, so every peer places the same pieces with the same ids (`uc.f<floor>.<seed>.trapN`, `.secret`, `.chest`); Trapwright's host owns their state.
## API
- `Hazards.setup()` once per peer (listens to Trapwright's `found`/`looted` and arpgKit's `levelBuilt`).
- `Hazards.onFloor(floor, isBoss)` on every peer when a floor starts (runLoopKit's floor record); the pieces go in as soon as that floor's level is built here. The boss floor gets none.
- `Hazards.clear()` when leaving to camp.
- `Hazards.on(name, fn)`: `secret` { id, kind, floor, by, mine, first, tallow } on every peer when the floor's secret opens (`mine` on the finder's machine; `tallow` is the suggested reward), `loot` { id, floor, by, mine, gold, potions } when its chest is looted (the looter already has the loot), `placed` { floor, seed, traps, secret }.
- `Hazards.current()` what stands on this floor.
# tallow_pickup
This sound clip is a small tinkle sound, representing the pickup of wax coins and candle stubs. It serves as a sound effect for collecting small, mundane items.
# victory
This sound clip is a triumphant bell peal with a choir and brass stinger, set in a cathedral. It serves as a sound effect for a victory state or a major accomplishment.
# unlock_star
This sound clip represents a star igniting in a night sky vault, with a crystalline chime swelling with a soft choir. It is intended as a sound effect for unlocking a significant achievement or a celestial-themed event.