← Back to the gamebug or idea?Terrapin Trail//Code BibleIIhow the game works, archive to van
Appendix A

Function map

The load-bearing functions, grouped by subsystem. Every name links straight into the source.

Boot & the shared surface

HAS_DOMassets/game/game.js:11The browser-vs-headless seam the whole file branches on.
globalThis.TerrapinTrailassets/game/game.js:3898The test/data surface handed out at the end of the IIFE.
newGameassets/game/game.js:1143Seed a fresh run from a role; roll the crew; clear any save.

The game loop (a leg)

legNeedsassets/game/game.js:1478Gas/grub the next leg will cost.
driveOnassets/game/game.js:1506Spend resources, queue events, start the drive.
resumeLegassets/game/game.js:1604Resolve the leg on arrival, in strict order.
checkDeathassets/game/game.js:1633End the run if Vibes hit 0 or the crew is gone.

Crew

resolveCrewassets/game/game.js:1276Swap {archetype} tokens for the current crew name.
crewHasassets/game/game.js:1219Is this archetype aboard and alive? (gates perks & events).
maybePoolCrewassets/game/game.js:1382High-morale resource pooling on arrival.
maybeRandyFindassets/game/game.js:1409Randy's scavenge chance on arrival.

Taping

startTapingassets/game/game.js:1761Build the mini-game stages for the chosen spot.
lockMiniassets/game/game.js:1811Grade one needle lock; track the combo.
finishMiniassets/game/game.js:1838Turn average accuracy into tape quality.
applyTapeOutcomeassets/game/game.js:1867Legendary/bust resolution and the show boost.

Economy, buffs & the Peak

recomputeBuffsassets/game/game.js:1123Rebuild s.buff and the shared CAP from installed parts.
statCapassets/game/game.js:1111The ceiling for a given stat.
showPeakassets/game/game.js:1640The once-per-run scripted stat surge.

Scoring & endgame

computeScoreassets/game/game.js:2035The final score formula.
endGameassets/game/game.js:2061Persist the run, evaluate badges, show win/gameover.
evaluateAchievementsassets/game/game.js:2192Check every badge against a run snapshot.

Render & input

viewHtmlassets/game/game.js:2328Pure view -> HTML string map (the switch).
renderassets/game/game.js:2363Paint and fire per-view side effects.
handleassets/game/game.js:3440The delegated action dispatcher.

Persistence

serializeSaveassets/game/game.js:2214Snapshot the run minus transient keys.
applySaveassets/game/game.js:2244Restore a save and re-derive CAP.

Leaderboards in the game

loadHallassets/game/game.js:2108The game's own Hall of the Fallen: this browser's saved runs.
saveRunassets/game/game.js:2119Keep a finished run in the local Hall.
endGameassets/game/game.js:2061Fires tt:runend so the play page can offer the shared board.

The server (Python)

create_apprunner.py:172Every route: pages, archive browser API, boards, guide mount.
api_scorerunner.py:645Post a run to its tour-and-rules leaderboard.
pick_dailyrunner.py:497Tour of the Day: a band, the show nearest today, its tour.
build_tourarchive.py:339One year's shows -> a playable tour with legendary and finale.
list_bandsarchive.py:411Every band collection on the Live Music Archive.
show_tracksarchive.py:554A recording's playable songs and taper credits.
resolvegeocode.py:166City text -> map position (state centre for small towns).

Tags, rules and fair play

base_tagstags.py:34#TTGD77Apr: a readable hashtag per tour.
registertags.py:66Claim a tag in the shared store so links resolve.
encodedna.py:72Slider positions -> the short rules code on the tag.
decodedna.py:89A rules code -> exact slider positions.
check_runtrust.py:79Run ticket, speed and number checks on a score.
clean_nametrust.py:43The public-board name filter.
make_storestore.py:231Redis on Vercel, JSON files in the workspace.