Case study: Retur
Context
Retur began as a compact alternative to another progression-heavy fantasy game: a dead-letter office where impossible correspondence still has to be processed according to policy. The player gets five shifts at Avdelningen för obestÀllbara försÀndelser, reading each envelope and routing it to delivery, its sender, Archive 9, or quarantine.
The premise works because the supernatural material is treated as an administrative detail. A letter from a dead sender is not evidence of an afterlife; it is a conflict between §4.3 and the later §4.7. A corridor with a negative number is invalid unless the envelope is internal mail from Avdelning Noll. The horror lives inside the institutionâs calm certainty that there is already a form for this.
Problem
Build a small, complete deduction game that:
- Teaches its rules through play rather than a long opening explanation
- Makes each letter readable as both a story and a logic problem
- Escalates across five short sessions without adding mechanical clutter
- Reuses Djupetâs established visual character while giving Retur its own physical setting
- Remains a static, easily deployed web project
Approach
The rulebook is the puzzle
Each letter exposes six kinds of evidence: sender, recipient, address, postmark, body text, and administrative marks. The current regulations map that evidence to one of four routes:
- Vidarebefordra â a valid contemporary destination
- Ă tersĂ€nd â an invalid destination with somewhere to send the letter back
- Arkiv 9 â historical correspondence and other archival cases
- KarantĂ€n â material that should not be opened, trusted, or allowed to circulate
New regulations arrive each morning. Later and more specific rules take precedence, so play gradually shifts from simple matching to resolving exceptions. A negative street number normally means return, but Avdelning Nollâs internal mail must always go forward. Three black stamps indicate Archive 9, except when the text changes between readings, which requires quarantine. The final shift adds future mail, then immediately adds an exception for mail describing the current working day.
That hierarchy is the main mechanic. The player is not guessing what seems safest; they are working out what the institution currently considers correct.
Authored correspondence, not generated filler
The game contains thirty hand-written letters across five shifts. Early cases establish the grammar with ordinary post, an invalid address, a 1912 postmark, and an explicit warning not to open an envelope. Later letters build small continuities: a deceased recipient answers a municipal reminder, Avdelning Noll addresses the employee directly, and a future reply revisits the apparently harmless cardigan from the first shift.
Every letter has a fixed correct route and a bespoke explanation shown after stamping. Those explanations do two jobs: they make the relevant regulation explicit, and keep the dry administrative voice intact. This makes a wrong answer useful feedback rather than an opaque penalty.
Consequences stay legible
Wrong routing has two linked mechanical consequences: it can remove lugn and add misstanke. Each recorded decision also carries a written aftermath, shown immediately and retained in a short incident log. The engine provides route-specific fallback outcomes and lets individual letters override both the prose and penalty, so mishandling a particular envelope can have a consequence that belongs to that correspondence rather than a generic error message.
Completing a day restores one lugn, but suspicion persists between shifts. Reaching zero composure or five suspicion ends the run and reassigns the employee; surviving all five days results in permanent employment, which the game carefully avoids presenting as an uncomplicated reward.
Accuracy, total decisions, and suspicion are retained in the final personnel record. The consequence model is deliberately small: the pressure comes from making policy decisions under accumulating risk, not from managing an inventory or skill tree.
Djupetâs language, moved indoors
Retur deliberately inherits Djupetâs JetBrains Mono typography, near-black blue surfaces, restrained magenta and red accents, compact labels, and screen-edge pressure effect. Instead of Djupetâs map, locations, and idle-resource panels, the interface is arranged as a municipal desk: regulations and employee status on the left, a paper letter in the centre, and physical-looking sorting controls and a stamp button on the right.
Suspicion drives the danger vignette around the viewport. At narrower widths the desk collapses first into a two-column layout and then a single-column flow; route controls remain available as buttons and through keys 1â4, with Enter used to stamp and continue. The core interaction stays the same on desktop and mobile.
A small state machine is enough
The game uses vanilla TypeScript and Vite with no framework, backend, or runtime dependencies. Content is represented as typed letter and regulation arrays. The engine is a small immutable state transition layer with five phases: intro, playing, day end, won, and lost. Routing a letter records the decision, recalculates accuracy, applies consequences, and chooses the next phase.
State is serialized to localStorage, so a shift survives a refresh. The production build is static and served through nginx in the provided Docker setup. Engine tests cover starting state, correct and incorrect routing, and day progression with composure recovery.
What Iâd do differently
The thirty-letter run is fixed. That gives the writing and rule order control, but limits replay once the answers are known. Selected subsets, alternate regulations, or a second authored week could add repeat runs without giving up the hand-written voice.
Consequences currently explain what happened after a decision, but do not change later letters or regulations. Carrying selected outcomes into later shifts could make the office feel more reactive; any such branch would need to remain visible enough that it does not turn a deduction game into hidden-rule punishment.
Stack
Client: Vanilla TypeScript, Vite, plain DOM rendering, responsive CSS, localStorage persistence.
Content and engine: Typed in-repository letter and regulation data; immutable game-state transitions; Vitest coverage for the core routing and progression rules.
Infrastructure: Static Vite build served by nginx. Gitea Actions builds and publishes latest and short-SHA images to the private registry on every push to main; the production host pulls the published image through Docker Compose. Live at retur.games.goonk.se.
Related
Diariet is directly descended from this engine (routeLetter/nextDay â routeReport/nextShift) â a records office one desk further from the cult than Retur is. Both sit alongside Djupet in the same Malmö; see /malmo for all three.