hazards.module
README.md
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'sfound/lootedand arpgKit'slevelBuilt).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 (mineon the finder's machine;tallowis 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.