The people in your van
How a character's name, story, and special ability all hang off one small label the code checks for.
Up to four van-mates ride with you, each with a personality and a special ability. Here's the neat trick: a character's name, their personal storyline, and their ability are all connected to one small hidden label. Learn how that works and you've learned a pattern used all over software.
Concept: an "id" (identifier). An id is a short, unique label the program uses to refer to something — like a username, or a product's SKU. Each van-mate archetype has one:
deb,randy,doses, and so on. The player sees a friendly name; the code works with the id.
One question the game keeps asking
Almost everything about a crew member runs through a single tiny check: is this character currently in the van and still with you?
1219 function crewHas(s, id) { var c = crewByArch(s, id); return !!(c && c.ok); }
Because everything asks that question, a member's perks simply stop working the moment they leave — no special "remove their bonus" code needed. That's elegant: the ability is only ever applied while the answer is "yes."
Four things hang off that one label
Using just the id and that check, the game wires up:
- Their name in the story. Event text contains little placeholders like
{deb}. The game swaps in the real (possibly player-renamed) name when it shows the text — so you never see a raw{deb}or a blank. - Their personal storyline. Some road events are marked "needs
doses." Those events only ever appear when that character is aboard. Bench or lose them, and their stories never show up. - Their special ability. Deb gets you cheaper prices; Doses stretches the food; Rita improves your recordings. Each is applied only while that member is with you (thanks to the check above).
- Bonus surprises. When morale is high, a crew member might chip in supplies as you roll into town.
Concept: "reuse." Notice we solved four different features with one idea (an id plus a yes/no check). Good code finds a small idea that many features can share. That's reuse, and it's a hallmark of a clean design.
Two names per character
Each archetype comes in two versions — for example Cosmic Deb and Cosmic Dean — and the game randomly picks one at the start of each trip. The personality and ability are the same either way; only the name differs. And you can rename any of them yourself.
- An id is a short unique label; each van-mate archetype has one the code works with.
- One yes/no check ("aboard and okay?") powers a member's name, story, ability, and bonuses — so losing them cleanly removes all of it.
- Solving many features with one small shared idea is reuse, a sign of clean code.