← Back to the gamebug or idea?Terrapin Trail//Code BibleIIhow the game works, archive to van
Reel 06 · 6 min read

The crew system

Archetype ids as a join key: name tokens, gated events, and perks wired at hook sites.

The crew system is the richest subsystem, and it is a case study in using one stable key to wire four different mechanics. That key is the archetype id (deb, randy, doses, rita, hitch, bird).

One id, four mechanisms

Everything hangs off crewHas, a two-line predicate:

●assets/game/game.js : 1219–1219trace ↗
1219  function crewHas(s, id) { var c = crewByArch(s, id); return !!(c && c.ok); }
crewHas: is this archetype aboard AND alive? Every crew-dependent behavior funnels through this one check.

With that in hand, the archetype id drives:

  1. Name tokens. Flavor text embeds {deb}, {randy}, … and resolveCrew(s, str) swaps in the current (possibly renamed) name — falling back to another living crew member if that archetype isn't aboard, so a raw token or "undefined" never renders. Applied to event title/text, choice labels, outcome lines, and driving captions.
  2. Gated storylines. Events carry needs: "<archetype>"; driveOn's pool filter keeps them out unless crewHas passes. A benched or lost van-mate's storyline never fires.
  3. Passive perks. crewHas is checked at each hook site, so perks apply only while the member rides with you:
archetype perk hook
deb −$1 Shakedown prices lotPrice()
doses −1 grub per leg legNeeds()
rita +6 tape quality finishMini()
hitch −1 van wear, +1 road luck driveOn()
bird +2 show Vibes show boost
randy scavenges on arrival maybeRandyFind()
  1. Arrival perks. maybePoolCrew (morale-gated resource sharing above 65 Vibes) and maybeRandyFind fire in resumeLeg.

Selection, renaming, and variants

S.crewPick (a roster with on/name) is edited on the crew screen; rebuildCrew(s) projects it into live S.crew ({id, name, trait, ok}), preserving each survivor's ok. Each archetype ships two name variants (a female and a male take), and rollRoster() picks one per trip — so a run fields Cosmic Deb or Cosmic Dean. Perks and traits are archetype-level, so either name reads right.

Loss

loseCrewById(s, id) sets ok = false. Lose the last one and checkDeath ends the run ("alone"). Low morale can make a member quit (maybeCrewQuits), which is why a Vibes crash is a compounding threat — it removes hands and their perks, not just a number.

Adding a van-mate

A roster entry in VANMATES, a crewHas check at the relevant hook site, and (optionally) a needs-gated event. That's the whole recipe — the four mechanisms above already understand a new archetype id.

Key takeaways
  • The archetype id is a join key wiring names, gated events, perks, and arrival bonuses.
  • Everything crew-dependent funnels through crewHas (aboard AND alive), so perks vanish with the member.
  • A new van-mate is a roster entry plus one crewHas hook; losing the last one ends the run.