diff --git a/CLIENT_TODO.md b/CLIENT_TODO.md index a2922d3..87b9f74 100644 --- a/CLIENT_TODO.md +++ b/CLIENT_TODO.md @@ -12,7 +12,7 @@ The production client must tolerate TTS being unavailable. The safe default TTS - Done: native ES module loader with dependency graph, module states, progress overlay, cache-busted development loading, and ordered async initialization. - Done: responsive book layout that scales page, font sizes, and word positions relative to page size. -- Done: story parser for chapters, text blocks, Markdown emphasis, image blocks, sound effect cues, and music cues. +- Done: story parser/protocol bridge for Ink-style `#` tags, chapters, text blocks, Markdown emphasis, image blocks, sound effect cues, and music cues. - Done: SmartyPants punctuation, language-aware Hyphenopoly integration, and Knuth-Plass paragraph line breaking. - Done: paragraph rules for normal paragraphs, chapter-first paragraphs, textblock-first paragraphs, drop caps, and first-line indentation. - Done: sentence queue and playback coordinator for preparing text and TTS before synchronized playback. @@ -124,6 +124,13 @@ Known inherited implementation note: the old `linked-list.js` analysis identifie ## Story Markup Specification +Canonical structural and media tags use Ink-style `#` syntax: + +- Ink engines write native Ink tags such as `# chapter[Title]`, `# image[file.png](landscape)`, or `# music[track.ogg](crossfade loop)`. +- inkjs exposes those tags without the leading `#`; the server parses them into `StoryTag` objects. +- YAML and Zork narrative output use the same leading `#...` syntax, parsed by the server into `StoryTag` objects before the client sees them. +- The browser protocol is structured `TurnResult` objects with structured tags and render blocks, not raw story markup. + Markdown emphasis: ```text @@ -135,7 +142,7 @@ Markdown emphasis: Chapter: ```text -::chapter[The Mysterious Mansion] +#chapter[The Mysterious Mansion] The first paragraph has a drop cap and no first-line indent. ``` @@ -145,35 +152,36 @@ The heading is centered, italic, and uses the body font size. Following ordinary Section or text block: ```text -::section +#section The first paragraph is vertically separated from previous content and has no first-line indent. ``` -`::textblock` is an alias. Following ordinary paragraphs return to normal indentation. +`#textblock` is an alias. Following ordinary paragraphs return to normal indentation. Images: ```text -::image[widescreen](file-name.jpg) -::image[portrait](file-name.jpg) +#image[file-name.jpg](landscape) +#image[file-name.jpg](portrait pause=2) +#image[file-name.jpg](square delay=1.5) ``` -File names resolve relative to `public/images/`. `widescreen` means full page width and half page height. `portrait` means full page width and full page height. Parsing is implemented; visual rendering is pending. +File names resolve relative to `public/images/`. `widescreen` is still accepted as an alias for `landscape`. Landscape and square images are centered and rendered near full page width with heights snapped to whole text lines. Portrait images float at half page width and following prose is narrowed for the number of lines the image covers. Image pauses accept the same timing style as music (`pause=2`, `delay=2`, `lead=2`, or `2s`); pauses are skippable with click/space and do not prevent the next TTS item from being prepared in the background. Sound effects: ```text -The old door opens {{sfx:squeaky-door.ogg}} into the dark. +#sfx[squeaky-door.ogg] +The old door opens into the dark. ``` -File names resolve relative to `public/sounds/`. The marker is not displayed and is not sent to TTS. Playback starts when animation reaches the marker position. +File names resolve relative to `public/sounds/`. The server parses the tag into a `StoryTag`; the tag is not displayed and is not sent to TTS. Music: ```text -::music[crossfade, loop, lead=4](track.ogg) -{{music:cut:track.ogg}} +#music[track.ogg](crossfade, loop, lead=4) ``` File names resolve relative to `public/music/`. Modes: @@ -185,6 +193,8 @@ File names resolve relative to `public/music/`. Modes: - `once`: do not repeat the track. - `lead=`: for block music, let music play alone before the following text/TTS paragraph starts. +For chapter openings, authors can place `#music[file](..., lead=N)` after `#chapter[...]` and before the first prose paragraph. The heading is rendered/spoken first, then music starts and plays alone for the lead duration, then the dropcapped paragraph continues. Music and image pauses are playback gates only; they must not stop the queue from preparing upcoming TTS in the background. + ## TTS And Playback Specification The playback system must keep text animation and audio synchronized. @@ -354,7 +364,7 @@ Longer-term goal: ### Pending -- [ ] Implement image rendering for `::image[widescreen]` and `::image[portrait]`. +- [x] Implement image rendering for `#image[file](landscape)`, `#image[file](portrait)`, and `#image[file](square)`. - [ ] Replace placeholder save implementation with durable save files or server-side save storage. - [ ] Replace command mirroring with the full LLM/world-model command loop when typography/audio testing no longer needs mirroring. - [ ] Add optical margin alignment or punctuation protrusion support for line endings. diff --git a/README.md b/README.md index ae06ab4..d5ce624 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Major modules: - `module-registry.js`, `base-module.js`, `loader.js`: module lifecycle, dependency graph, progress overlay, state reporting. - `text-processor-module.js`, `paragraph-layout-module.js`, `layout-renderer-module.js`: SmartyPants, language-aware hyphenation, Knuth-Plass line breaking, DOM rendering. -- `markup-parser-module.js`: story markup for chapters, sections, Markdown emphasis, images, SFX, and music. +- `markup-parser-module.js`: story markup fallback for chapters, sections, Markdown emphasis, images, SFX, and music. - `sentence-queue-module.js`, `playback-coordinator-module.js`, `animation-queue-module.js`: sentence preparation, synchronized playback, timing, fast-forward. - `tts-factory-module.js` plus provider modules: TTS provider selection, voice settings, speed mapping, caching, and playback. - `audio-manager-module.js`: master, speech, music, and sound effect volume, music playback, sound effects, and music ducking. @@ -82,10 +82,12 @@ Inline Markdown emphasis: ***bold italic*** or ___bold italic___ ``` +Canonical block/media tags use Ink-style `#` syntax. In Ink these are real Ink tags. In YAML and Zork narrative output, leading `#...` lines are parsed by the server into the same structured `StoryTag` objects before reaching the client. The browser only consumes structured `TurnResult` objects. + Chapter: ```text -::chapter[The Mysterious Mansion] +#chapter[The Mysterious Mansion] The first paragraph uses a drop cap and no first-line indent. @@ -97,51 +99,46 @@ The heading is centered, italic, and uses the same text face as the body. The fi Section or text block: ```text -::section +#section The first paragraph starts a separated block without horizontal indent. The following paragraph returns to the normal indent. ``` -`::textblock` is treated the same way. The first paragraph after the marker is separated from previous content by one line of vertical space. +`#textblock` is treated the same way. The first paragraph after the marker is separated from previous content by one line of vertical space. Images are parsed for future rendering: ```text -::image[widescreen](mansion-rain.jpg) -::image[portrait](portrait-letter.jpg) +#image[mansion-rain.jpg](landscape) +#image[portrait-letter.jpg](portrait pause=2) ``` -Image file names are relative to `public/images/`. `widescreen` means 100% page width and 50% page height. `portrait` means 100% page width and 100% page height. +Image file names are relative to `public/images/`. `widescreen` is accepted as an alias for `landscape`. -Sound effects can be placed inline: +Sound effects are story tags: ```text -The door opens {{sfx:squeaky-door.ogg}} and the hall exhales. +#sfx[squeaky-door.ogg] +The door opens and the hall exhales. ``` -The marker is removed from display text and TTS text. It becomes a timed media cue that fires when the text animation reaches that point. Sound effect paths are relative to `public/sounds/`. +The tag is parsed by the server into a `StoryTag` object. Sound effect paths are relative to `public/sounds/`. Music can be placed as a block: ```text -::music[crossfade, loop, lead=4](rain-theme.ogg) +#music[rain-theme.ogg](crossfade, loop, lead=4) ``` -Music can also be placed inline: - -```text -The candles gutter. {{music:cut:danger.ogg}} Something moves upstairs. -``` - -Music paths are relative to `public/music/`. Supported modes are `queue`, `crossfade`, and `cut`. Use `loop` or `once` to control repetition. `lead=` delays the following text/TTS paragraph so the music can play alone before narration continues. +Music paths are relative to `public/music/`. Supported modes are `queue`, `crossfade`, and `cut`. Use `loop` or `once` to control repetition. `lead=` delays the following text/TTS paragraph so the music can play alone before narration continues. To place that pause between a chapter heading and the dropcapped first paragraph, put the music tag after the chapter tag and before the first prose paragraph; TTS generation for the next spoken paragraph continues during the lead pause. ## Assets -- `public/sounds/`: sound effects referenced by `{{sfx:file}}`. -- `public/music/`: background music referenced by `::music[...]` or `{{music:mode:file}}`. -- `public/images/`: story images referenced by `::image[...]`. +- `public/sounds/`: sound effects referenced by `#sfx[file]` tags. +- `public/music/`: background music referenced by `#music[file](...)` tags. +- `public/images/`: story images referenced by `#image[file](...)`. - `public/fonts/`: font assets used by the book UI. Keep third-party assets licensed for local redistribution, and document source and license in the folder README or alongside the file. diff --git a/config/engines/ink.json b/config/engines/ink.json new file mode 100644 index 0000000..e26400a --- /dev/null +++ b/config/engines/ink.json @@ -0,0 +1,19 @@ +{ + "engine": "ink", + "locale": "en_US", + "paths": { + "mainGameFile": "data/ink/kaiserpunk.ink.json", + "inkSource": "data/ink-src/kaiserpunk.ink", + "inkCompiled": "data/ink/kaiserpunk.ink.json", + "music": "public/music", + "sfx": "public/sounds", + "images": "public/images" + }, + "metadata": { + "title": "Eibenreith", + "author": "Georg Tomitsch", + "subtitle": "A Kaiserpunk Adventure", + "version": "0.0.1", + "copyright": "2026 by Bad Tools Studio" + } +} diff --git a/config/engines/yaml.json b/config/engines/yaml.json new file mode 100644 index 0000000..e9923a6 --- /dev/null +++ b/config/engines/yaml.json @@ -0,0 +1,17 @@ +{ + "engine": "yaml", + "locale": "en_US", + "paths": { + "mainGameFile": "data/worlds/example_world.yml", + "music": "public/music", + "sfx": "public/sounds", + "images": "public/images" + }, + "metadata": { + "title": "The Mysterious Mansion", + "author": "AI Interactive Fiction", + "subtitle": "An open-world text adventure", + "version": "1.0.0", + "copyright": "Prototype content for local development." + } +} diff --git a/config/engines/zork.json b/config/engines/zork.json new file mode 100644 index 0000000..3f7b3b4 --- /dev/null +++ b/config/engines/zork.json @@ -0,0 +1,18 @@ +{ + "engine": "zork", + "locale": "en_US", + "paths": { + "mainGameFile": "data/z-code/zork1.bin", + "promptDir": "data/zork-prompts", + "music": "public/music", + "sfx": "public/sounds", + "images": "public/images" + }, + "metadata": { + "title": "Zork I", + "author": "Infocom", + "subtitle": "A narrated Z-code adventure", + "version": "1.0.0", + "copyright": "Use only with a legally supplied Z-code story file." + } +} diff --git a/data/ink-src/kaiserpunk.ink b/data/ink-src/kaiserpunk.ink new file mode 100644 index 0000000..2948477 --- /dev/null +++ b/data/ink-src/kaiserpunk.ink @@ -0,0 +1,795 @@ +// Kaiserpunk Horror Intro +// Ink source file draft +// Covers: opening train journey, class selection, name builder, supernatural stance, +// spiritual-sense selection, first Viktor relationship choices, and arrival at Eibenreith. + +VAR birth_class = "unset" +VAR title_part = "" +VAR given_names = "" +VAR common_name = "" +VAR surname = "" +VAR full_name = "" + +VAR supernatural_belief = "unset" // believer, sceptic, performer, undecided +VAR supernatural_senses = "unset" // genuine, faked, repressed, ambiguous +VAR viktor_relation = "unset" // trust, tension, utility, dependence, provocation + +VAR lover = 0 +VAR sapphic = 0 +VAR detective = 0 +VAR careless = 0 +VAR eccentric = 0 +VAR class_confidence = 0 +VAR medium_reputation = 0 +VAR court_loyalty = 0 +VAR viktor_trust = 0 +VAR viktor_suspicion = 0 +VAR supernatural_exposure = 0 + +-> intro_train + +=== intro_train === + +The train has left Vienna behind, though Vienna has not yet left you. #chapter[Eibenreith] #music[Kaiserpunk Waltz.mp3](crossfade, loop, lead=8) + +It clings to the black gloss of your travelling boots, to the cut of your coat, to the stiff little prison of your gloves. It lives in the seal upon the letter folded inside your reticule, in the thin scent of coal smoke that has insinuated itself even into first-class upholstery, in the fact that Herr Viktor Nowak sits opposite you as if the carriage were a field office and not a compartment lined in velvet, polished wood, and brass. + +Outside the window, the last outskirts of the capital have broken apart into winter-browned fields and villages with church towers too small to compete with the engine's whistle. The rails take the land without asking permission. Embankments cut through orchards. Telegraph poles pass at regular intervals, each one vanishing behind you like a thought dismissed too quickly. #sfx[steam-whistle.ogg] + +You had expected the train to feel like a triumph of the age. + +Instead it feels like an argument. #image[suedbahn.png](landscape) + +The machine throws itself southward with a violence that polite society would never admit to admiring. The lamps tremble in their fittings. Your cup rattles against its saucer. Beyond the glass, the country begins to rise, first gently, then with a firmer will, until the line itself seems to negotiate with the mountains through stone arches, black tunnels, and viaducts thrown across ravines with all the confidence of imperial engineering. + +Viktor has not looked impressed once. + +His civilian clothes are correct enough to pass without comment: dark frock coat, sober waistcoat, gloves, collar immaculate, the posture of a man who has never truly sat at ease in his life. But no tailor can disguise discipline. It remains in his shoulders, in the economy of his movements, in the way his eyes measure doors, windows, luggage rack, corridor, your face, then the door again. + +On the paperwork he is your secretary and travelling companion. + +In truth, he is an officer lent to a delicate matter by channels that prefer not to be named. Rittmeister Viktor Alois Nowak, though no one at Jagdhaus Hohenreith is expected to call him that. Your hosts have asked for a medium. The Cabinet has sent them you. The military has sent him to make certain that you do not become a scandal before you become useful. + +He folds the newspaper, though you are quite certain he had not been reading it. + +"You have been very quiet, gnädiges Fräulein." + +The form of address is technically correct if you are noble, excessive if you are not, and perfectly chosen because he does not yet know which part of you is useful, which part is costume, and which part is threat. + +"For a lady on her first official journey," he adds, "you show remarkable restraint." + +You look around the compartment before you answer. The answer comes from somewhere older than the letter in your reticule. It comes from the place you began. + +* [The compartment seems built for people who never wonder whether they belong in it.] #class:noble + ~ birth_class = "noble" + ~ class_confidence += 2 + ~ court_loyalty += 1 + It is not luxury that unsettles you. Luxury is only wood, cloth, brass, service, silence. What matters is whether the servants glance twice, whether the guard lowers his voice, whether another passenger weighs your gloves and decides not to ask your business. + + You were born among people who understood such things before they understood kindness. + + -> class_noble_background + +* [You count the cost of each detail before you can stop yourself.] #class:middle + ~ birth_class = "middle" + ~ class_confidence += 1 + The upholstery, the lamps, the polished veneer, the quiet attendance at stations: none of it is magical. It is paid for. Accounted for. Itemised somewhere by someone with ink on his cuffs and a wife who knows how long candles may be burned before the household budget complains. + + You were not born to this compartment, but you were born close enough to study its rules. + + -> class_middle_background + +* [You notice first how clean everything is, and how carefully one must sit so as not to betray noticing.] #class:working + ~ birth_class = "working" + ~ class_confidence -= 1 + The velvet looks soft enough to swallow fingerprints. The brass fittings have been polished by hands that will never sit here. The little curtain strap is worn where other travellers, all of them more certain than you, have touched it without gratitude. + + You were not born on this side of service. + + -> class_working_background + +=== class_noble_background === + +"Restraint is not a virtue, Herr Nowak," you say. "It is often only good breeding with its mouth shut." + +His brows move almost imperceptibly. + +You learned young that every room contains a court, even when no emperor is present. A girl of your rank is trained to enter, to bow, to be introduced, to be placed, to speak only enough, to understand more than she admits, and to know that a family name can be both a key and a chain. + +Your own family possesses no grand seat, no army of retainers, no ancient right to command provinces. But your name opened drawing-room doors in Vienna, and once inside those rooms you learned to make people repeat stories they had meant only to hint at. You learned how widows speak when priests are absent, how officers lie when flattered, how old men confess when they believe themselves admired, and how a young woman may be underestimated so consistently that underestimation becomes a profession. + +Your reputation as a medium did not descend from heaven. It was assembled from half-lights, correct guesses, careful silences, and the willingness of better-born fools to mistake performance for revelation. + +Before the court could use you, society had first to invent you. + +Now choose the name by which Vienna invented you. + +-> choose_name_noble + +=== class_middle_background === + +"Restraint," you say, "is easier when one has learned that every mistake is remembered by someone better placed." + +Viktor watches you more closely. + +You were born in that broad, anxious territory between deference and ambition. Your family had books, invoices, respectability, perhaps a piano no one played well enough, perhaps a father with an office, a mother with callers, brothers who were expected to advance, and daughters who were expected not to make advancement look hungry. + +You learned accounts before etiquette, etiquette before French, and French before you learned how easily a woman with a calm voice could make men explain themselves. You rose because you listened. You rose because you understood that fraud, faith, medicine, gossip, politics, and grief all use the same doors into the human mind. + +The court does not like to admit that it needs middle-class competence. It prefers to borrow it, dress it properly, and call it discretion. + +Your reputation as a medium gave them a word that sounded less dangerous than investigator. + +Now choose the name under which you entered the salons that first laughed at you, then invited you back. + +-> choose_name_middle + +=== class_working_background === + +"Restraint," you say, "is what people praise when they prefer not to see the effort." + +The newspaper in Viktor's hand creases once. + +You were born among people who owned little but obligations. Work had a sound before it had a meaning: water, broom, bootsteps, breath, the clatter of dishes, the cough of men coming in from cold yards, women counting coins under their breath. You learned early that the high-born are not more observant than others. They are merely less often required to observe. + +That was your first advantage. + +A servant knows which door matters because she uses the others. A seamstress learns bodies because she measures them. A maid learns secrets because fine people leave their souls lying about like gloves, certain that no one beneath them has hands. + +You rose by talent, patronage, imitation, nerve, and the terrible convenience of being believed harmless. By the time Vienna began whispering that you saw more than respectable people saw, you had already spent years seeing what respectable people missed. + +The court has placed you in first class because it needs what birth did not give you. + +Now choose the name you carried upward, altered perhaps in pronunciation, never quite cleansed of where it began. + +-> choose_name_working + +=== choose_name_noble === + +// Noble title is fixed for the canonical lower-noble route. +// Full names are formal; common_name is used for narration and dialogue. + +* [Valerie Eleonore Josepha] + ~ given_names = "Valerie Eleonore Josepha" + ~ common_name = "Valerie" + -> choose_surname_noble +* [Helene Cäcilie Franziska] + ~ given_names = "Helene Cäcilie Franziska" + ~ common_name = "Helene" + -> choose_surname_noble +* [Clara Theresia Leopoldine] + ~ given_names = "Clara Theresia Leopoldine" + ~ common_name = "Clara" + -> choose_surname_noble +* [Sophie Eleonore Auguste] + ~ given_names = "Sophie Eleonore Auguste" + ~ common_name = "Sophie" + -> choose_surname_noble +* [Mathilde Josepha Henriette] + ~ given_names = "Mathilde Josepha Henriette" + ~ common_name = "Mathilde" + -> choose_surname_noble +* [Therese Valerie Franziska] + ~ given_names = "Therese Valerie Franziska" + ~ common_name = "Therese" + -> choose_surname_noble +* [Ilona Theresia Eleonore] + ~ given_names = "Ilona Theresia Eleonore" + ~ common_name = "Ilona" + -> choose_surname_noble +* [Zdenka Eleonore Josepha] + ~ given_names = "Zdenka Eleonore Josepha" + ~ common_name = "Zdenka" + -> choose_surname_noble + +=== choose_surname_noble === + +Your title is fixed by birth and by the careful modesty of your family: not countess, not princess, not one of the brilliant names that gather ambassadors and creditors like dust. + +A Freiin. Baronial. Usable. Admitted, but not enthroned. + +* [Freiin von Rauhenfels] + ~ title_part = "Freiin von" + ~ surname = "Rauhenfels" + -> assemble_full_name +* [Freiin von Traunegg] + ~ title_part = "Freiin von" + ~ surname = "Traunegg" + -> assemble_full_name +* [Freiin von Ebenwald] + ~ title_part = "Freiin von" + ~ surname = "Ebenwald" + -> assemble_full_name +* [Freiin von Arnsberg] + ~ title_part = "Freiin von" + ~ surname = "Arnsberg" + -> assemble_full_name +* [Freiin von Reichenau] + ~ title_part = "Freiin von" + ~ surname = "Reichenau" + -> assemble_full_name +* [Freiin von Waldstätten] + ~ title_part = "Freiin von" + ~ surname = "Waldstätten" + -> assemble_full_name + +=== choose_name_middle === + +* [Clara Eleonore] + ~ given_names = "Clara Eleonore" + ~ common_name = "Clara" + -> choose_surname_middle +* [Anna Katharina] + ~ given_names = "Anna Katharina" + ~ common_name = "Anna" + -> choose_surname_middle +* [Helene Theresia] + ~ given_names = "Helene Theresia" + ~ common_name = "Helene" + -> choose_surname_middle +* [Rosa Franziska] + ~ given_names = "Rosa Franziska" + ~ common_name = "Rosa" + -> choose_surname_middle +* [Johanna Elise] + ~ given_names = "Johanna Elise" + ~ common_name = "Johanna" + -> choose_surname_middle +* [Katharina Sophie] + ~ given_names = "Katharina Sophie" + ~ common_name = "Katharina" + -> choose_surname_middle +* [Therese Leopoldine] + ~ given_names = "Therese Leopoldine" + ~ common_name = "Therese" + -> choose_surname_middle +* [Magdalena Cäcilie] + ~ given_names = "Magdalena Cäcilie" + ~ common_name = "Magdalena" + -> choose_surname_middle + +=== choose_surname_middle === + +Your family name contains no particle to soften the ascent. It must stand upright by itself. + +* [Leitner] + ~ title_part = "Fräulein" + ~ surname = "Leitner" + -> assemble_full_name +* [Wagner] + ~ title_part = "Fräulein" + ~ surname = "Wagner" + -> assemble_full_name +* [Kellner] + ~ title_part = "Fräulein" + ~ surname = "Kellner" + -> assemble_full_name +* [Baumgartner] + ~ title_part = "Fräulein" + ~ surname = "Baumgartner" + -> assemble_full_name +* [Fischer] + ~ title_part = "Fräulein" + ~ surname = "Fischer" + -> assemble_full_name +* [Schmid] + ~ title_part = "Fräulein" + ~ surname = "Schmid" + -> assemble_full_name +* [Pichler] + ~ title_part = "Fräulein" + ~ surname = "Pichler" + -> assemble_full_name +* [Rosenfeld] + ~ title_part = "Fräulein" + ~ surname = "Rosenfeld" + -> assemble_full_name + +=== choose_name_working === + +* [Anna] + ~ given_names = "Anna" + ~ common_name = "Anna" + -> choose_surname_working +* [Klara] + ~ given_names = "Klara" + ~ common_name = "Klara" + -> choose_surname_working +* [Agnes] + ~ given_names = "Agnes" + ~ common_name = "Agnes" + -> choose_surname_working +* [Leni] + ~ given_names = "Leni" + ~ common_name = "Leni" + -> choose_surname_working +* [Rosa] + ~ given_names = "Rosa" + ~ common_name = "Rosa" + -> choose_surname_working +* [Gertrud] + ~ given_names = "Gertrud" + ~ common_name = "Gertrud" + -> choose_surname_working +* [Elisabeth] + ~ given_names = "Elisabeth" + ~ common_name = "Elisabeth" + -> choose_surname_working +* [Franziska] + ~ given_names = "Franziska" + ~ common_name = "Franziska" + -> choose_surname_working + +=== choose_surname_working === + +A simple name can be a burden in Vienna. It tells people how little they must pretend to respect you before you have spoken. + +* [Pichler] + ~ title_part = "Fräulein" + ~ surname = "Pichler" + -> assemble_full_name +* [Huber] + ~ title_part = "Fräulein" + ~ surname = "Huber" + -> assemble_full_name +* [Maier] + ~ title_part = "Fräulein" + ~ surname = "Maier" + -> assemble_full_name +* [Gruber] + ~ title_part = "Fräulein" + ~ surname = "Gruber" + -> assemble_full_name +* [Schuster] + ~ title_part = "Fräulein" + ~ surname = "Schuster" + -> assemble_full_name +* [Krenn] + ~ title_part = "Fräulein" + ~ surname = "Krenn" + -> assemble_full_name +* [Wolf] + ~ title_part = "Fräulein" + ~ surname = "Wolf" + -> assemble_full_name +* [Moser] + ~ title_part = "Fräulein" + ~ surname = "Moser" + -> assemble_full_name + +=== assemble_full_name === + +{birth_class == "noble": + ~ full_name = given_names + " " + title_part + " " + surname +- else: + ~ full_name = title_part + " " + given_names + " " + surname +} + +{birth_class == "noble": + On visiting cards, in letters, in the cautious mouths of servants, you are {full_name}. +- else: + On railway documents, hotel ledgers, and the tongues of people who have not yet decided how much respect you deserve, you are {full_name}. +} + +But in the private chamber where a name is first answered before it is performed, you are {common_name}. + +Viktor has waited through your silence with a soldier's patience and a jailer's courtesy. The train enters another tunnel. For several seconds the compartment window gives you back only your own reflection: your hat, your pale face above the dark collar, your eyes too steady or not steady enough. + +When the mountains return, they seem closer. + +-> supernatural_stance + +=== supernatural_stance === + +The letter of commission in your reticule does not call you an investigator. + +It calls you, in prose dry enough to pass through any number of offices, a woman whose unusual spiritual reputation has recommended her to a delicate household matter. The phrasing is exquisite. It neither affirms nor denies. It permits everyone involved to believe afterward that they had believed nothing improper. + +The comital family at Jagdhaus Hohenreith has asked for discretion. Vienna has answered with a sealed letter, a woman reputed to speak with what is hidden, and a man opposite her who has orders of his own. + +Before this journey, before this train, before the mountains began taking the sky piece by piece, what did you believe? + +* [The dead are not silent. The living are merely poor listeners.] #supernatural:believer + ~ supernatural_belief = "believer" + ~ medium_reputation += 1 + ~ supernatural_exposure += 1 + You have always thought disbelief a provincial arrogance of the educated. There are pressures in rooms where grief has been. There are words people speak before they know they have spoken. There are dreams that arrive with mud on their hems. + + Perhaps the world is not haunted. Perhaps it is simply crowded. + + -> spiritual_senses + +* [The supernatural is usually pain, fraud, fever, inheritance, or bad ventilation.] #supernatural:sceptic #route:detective + ~ supernatural_belief = "sceptic" + ~ detective += 1 + The word spirit covers too much and explains too little. You have watched respectable people call an echo a message, a coincidence a sign, a trembling hand an angelic visitation. Men of science can be fools, but fools with candles and planchettes are no improvement. + + If Hohenreith has ghosts, you expect them to keep accounts, write letters, leave footprints, and benefit someone. + + -> spiritual_senses + +* [Belief is a costume. You wear it because men insist on dressing you in it.] #supernatural:performer + ~ supernatural_belief = "performer" + ~ medium_reputation += 2 + You discovered early that men who distrust a woman's mind will sometimes worship her nerves. A conclusion from evidence irritates them. A vision, sighed through lowered lashes, makes them lean closer. + + Very well. Let them lean. + + -> spiritual_senses + +* [You have learned not to decide too early.] #supernatural:undecided + ~ supernatural_belief = "undecided" + There are things you can explain, things you cannot yet explain, and things that explanation damages before it helps. You have made a profession of standing at thresholds with a face composed enough for both sides to continue speaking. + + Hohenreith will have to show you what kind of case it is. + + -> spiritual_senses + +=== spiritual_senses === + +Belief is one matter. Experience is another. + +People call a woman sensitive when they want her perceptions to sound like an illness. They call her hysterical when those perceptions inconvenience them. They call her inspired when they need her, and unstable when they do not. + +What, beneath reputation and performance, has truly happened to you? + +* [There have been moments you cannot explain away.] #powers:genuine + ~ supernatural_senses = "genuine" + ~ supernatural_exposure += 2 + Once, as a child, you knew before the telegram came. Once, in a crowded room, a stranger's grief entered you with such force that your own knees failed. Once, in a mirror, you saw a door behind you that was not in the room when you turned. + + You learned caution after that. It is unwise for a woman to know things before a man has asked her opinion. + + -> viktor_first_exchange + +* [Everything you do can be explained by observation, timing, and nerve.] #powers:faked #route:detective + ~ supernatural_senses = "faked" + ~ detective += 1 + You notice rings removed too recently, mourning gloves worn too carefully, letters folded and refolded until the crease gives away the reader's obsession. You hear servants misname guests, mothers pause before daughters' rooms, officers lie by becoming too exact. + + The dead have never told you anything. The living cannot stop telling you everything. + + -> viktor_first_exchange + +* [Something happens, but never when summoned.] #powers:ambiguous + ~ supernatural_senses = "ambiguous" + ~ supernatural_exposure += 1 + Your reputation depends upon command. The truth, if truth it is, has no respect for appointments. + + Sometimes a room changes pressure around you. Sometimes a face acquires an old expression no living person taught it. Sometimes names arrive before introductions. But the harder you reach, the more ordinary the world becomes. + + -> viktor_first_exchange + +* [You buried the first signs so thoroughly that even you do not know what remains.] #powers:repressed #route:eccentric + ~ supernatural_senses = "repressed" + ~ eccentric += 1 + There are childhood memories sealed behind politeness: a nursery mirror turned to the wall, a nurse dismissed without reference, your mother's hand tightening around your wrist until the bones complained. + + You became strange afterward in ways society found easier to admire than understand. + + -> viktor_first_exchange + +=== viktor_first_exchange === + +The train emerges from the tunnel into a pale afternoon cut by dark firs and white rock. Far below, water shows itself only in flashes. The valley is no longer a view from a salon painting. It has depth enough to hide things. + +Viktor opens a leather folder and removes a memorandum. He does not hand it to you at once. + +"When we leave the railway," he says, "we will be met by a coach from Hohenreith. From that moment, appearances matter. Your hosts have been told that I assist with correspondence, travel, and practical arrangements. They need not be troubled with military definitions." + +"And the villagers?" you ask. + +"The villagers need not be troubled with anything." + +There it is: the empire in miniature. A man, a folder, a locked sentence. + +"You will be addressed according to the station you present," he continues. "The Graf's household will observe rank. Servants will observe what the household observes. Villagers may observe less and remember more. I advise restraint." + +The advice is sound. That makes it no less irritating. + +How do you answer him? + +* ["If gentlemen were less easily led, Herr Nowak, ladies would require fewer methods."] #route:lover + ~ lover += 1 + ~ viktor_relation = "provocation" + ~ viktor_trust -= 1 + ~ viktor_suspicion += 1 + For the first time, amusement almost reaches his mouth. + + "A dangerous doctrine." + + "A practical one." + + "You intend to practice it at Hohenreith?" + + "Only where patriotism requires sacrifice." + + He looks down at the memorandum, but not quickly enough to conceal that he is reassessing you. + + -> viktor_explains_orders + +* ["If you wish me to pass as harmless, you must stop warning me like a gaoler."] #route:sapphic + ~ sapphic += 1 + ~ viktor_relation = "tension" + ~ viktor_suspicion += 1 + His gaze sharpens. + + "I am not your gaoler." + + "No. A gaoler is at least honest about the key." + + The words surprise you by leaving a mark. Not on him, perhaps. On yourself. The closer the train carries you to Amalia's world, though you do not yet know her face, the more intolerable it seems that every female life there might be guarded by men who call the guarding concern. + + Viktor folds the memorandum once, precisely. + + -> viktor_explains_orders + +* ["Then let us be exact. What do they know, what do they suspect, and what am I permitted to verify?"] #route:detective + ~ detective += 1 + ~ viktor_relation = "professional" + ~ viktor_trust += 1 + He gives the smallest nod, as if you have chosen the only answer fit for adults. + + "They know that you come recommended. They suspect that you may be able to settle disturbances without police, priest, or press. You are permitted to verify fraud, coercion, threat to public order, or credible phenomena not presently classifiable." + + "Credible phenomena not presently classifiable." + + "That is the phrase." + + "A bureaucratic ghost." + + "The safest kind." + + -> viktor_explains_orders + +* ["I shall do my best not to faint unless it is useful."] #route:careless + ~ careless += 1 + ~ viktor_relation = "dependence" + ~ viktor_trust -= 1 + Something in his expression tightens; not contempt exactly, but readiness. + + "I would prefer you did not faint at all." + + "How ungallant." + + "How practical." + + "Then you must be practical for both of us. I have never trusted the floor in strange houses." + + His answer is delayed by half a breath. + + "That, gnädiges Fräulein, is precisely what concerns me." + + -> viktor_explains_orders + +* ["Restraint is what timid people call obedience after they have forgotten who trained them."] #route:eccentric + ~ eccentric += 1 + ~ viktor_relation = "challenge" + ~ viktor_suspicion += 2 + Viktor studies you as he might study an unfamiliar weapon found in luggage. + + "You enjoy making enemies." + + "No. I dislike the laziness of letting fools remain undecided." + + "At Hohenreith, that dislike may become expensive." + + "Then the Graf should have invited someone cheaper." + + The wheels strike a curve. The compartment leans. For a moment the two of you are held in the same narrow imbalance. + + -> viktor_explains_orders + +=== viktor_explains_orders === + +Viktor gives you the memorandum at last. + +The document is not long. That is part of its menace. Long documents invite argument; short ones carry authority. + +A comital household. A hunting residence in Upper Styria, not the family's principal seat. Reports of disturbances among servants and villagers. No police action requested. No public ecclesiastical inquiry desired. No press. No correspondence beyond approved channels. Your presence to be explained as a discreet consultation requested by the family. Herr Nowak to assist in practical matters. + +No one has written the word ghost. + +No one has written the word fraud. + +No one has written the word daughter. + +Yet the omissions arrange themselves around the page like furniture around a corpse. + +"There is another instruction," you say. + +Viktor does not ask how you know. + +"There is always another instruction," he says. + +"For you." + +"Yes." + +"Concerning me?" + +"Partly." + +The train begins to slow. The rhythm changes first in the floor, then in the window, then in the body. Houses gather beside the line. A station roof appears between drifting smoke and the dark combs of forested slopes. #sfx[steam-whistle.ogg] + +"Then I shall try to be worth the ink," you say. + +"I sincerely hope so." + +You cannot decide whether it is an insult, a prayer, or his first honest sentence. + +-> railway_station + +=== railway_station === + +The station is small enough that the train seems briefly embarrassed to stop there. #chapter[The Station] #image[muerzzuschlag.png](portrait) + +A porter in a cap too large for him hurries along the platform. A woman with a basket steps back from the steam as if from an animal. Somewhere beyond the station building, a cart horse stamps at frozen mud. The signboard gives the place a name you have seen in the timetable but will not remember with affection. + +Your luggage descends in stages: trunk, hatbox, smaller travelling case, dispatch case, folded rug, a narrow black case whose contents would embarrass both a priest and a conjurer if either searched it without imagination. Viktor oversees the transfer with clipped civility. He does not carry like a servant. He directs like a man pretending not to command. + +The coach from Hohenreith waits beyond the station yard: dark green paint, black wheels, the comital crest discreetly worn on the door, and two horses already restless beneath harness. The driver removes his hat when he sees you. Not too deeply. Deep enough for rank, not deep enough for reverence. #sfx[horse-neigh.ogg] + +"Gnädiges Fräulein? Herr Sekretär?" + +{birth_class == "noble": + He has been told enough to place you. That is a courtesy. It is also a warning. +- else: + He hesitates over you by the smallest measure. The hesitation is not rudeness. It is calculation. First-class carriage, court letter, no title beyond Fräulein, and a man beside you who looks like he has arrested people for less than staring. +} + +Viktor answers before you can. + +"From Jagdhaus Hohenreith?" + +"Jawohl, Herr Sekretär. The road is passable. If the mist holds, we should reach Eibenreith before dark." + +The word enters the air without ceremony. + +Eibenreith. + +Not Hohenreith, the name printed on the invitation in a clean hand. Eibenreith: the village below it. A smaller name. Older in the mouth. A name with roots rather than stationery. + +-> coach_journey + +=== coach_journey === + +The coach leaves the station behind and with it the last easy evidence of empire. #chapter[The Graben] #music[Kaiserpunk Jodler.mp3](crossfade, loop, lead=4) + +At first the road follows a valley where telegraph wire still keeps company with it and the river moves in a pale, stony bed. Sawmills, fenced meadows, and farmhouses appear and vanish behind stands of spruce. The mountains do not rise all at once. They advance by jurisdiction. A wooded slope claims the left-hand sky, then a grey wall of limestone closes the north, then another ridge gathers to the east until even the clouds seem to have entered service. + +The driver names places when Viktor asks, but the names are local and practical, meant for men who know which bridge floods and which farm breeds stubborn horses. Somewhere beyond the visible ridges, he says, lies the great white back of the Hochschwab. Eastward, beyond forest and pass, the Hohe Veitsch keeps its own weather. He says this not as a guide would say it, but as a man explaining neighbours who may or may not be in a temper. + +The main valley narrows. + +The road turns from it into a side Graben, and the change is immediate. Sound alters. The wheels no longer ring against open distance but grind between banks, roots, and wet stone. The air smells of leaf mould, resin, and cold water. Yews appear among the firs in dark, improbable patience, their needles too black for the afternoon. + +"Eibenreither Graben," the driver says, and crosses himself so quickly that the gesture might have been meant for a rut in the road. + +Viktor notices. Of course he notices. + +"Bad road?" he asks. + +"Old road," the driver says. + +No one speaks for a while. + +You watch the trees. + +There are forests that invite stories because they are pretty, and forests that reject stories because whatever happened there did not require witnesses. This one belongs to the second kind. Its trunks stand close, not wildly, but with the air of a crowd making room for something carried through it long ago. The snow that remains in hollows is not clean. It has gathered needles, bark, and a yellowish stain where water has risen underneath. + +On a slope above the road, half swallowed by undergrowth, you glimpse stone. + +A shrine, perhaps. A boundary marker. A figure. The coach has passed before your eyes can persuade themselves of its shape. For one instant you are left with the impression of a woman's head inclined not in prayer, but in listening. #image[statue.png](square) + +{supernatural_senses == "genuine" or supernatural_senses == "ambiguous" or supernatural_senses == "repressed": + The back of your neck tightens. + + Not fear. Recognition would be worse. + + ~ supernatural_exposure += 1 +- else: + You tell yourself that old stone, seen through moving branches, will become whatever the mind is cowardly enough to supply. +} + +Viktor has turned slightly toward the same slope. + +"Did you see something?" he asks. + +* ["A woman in the wood, perhaps. Or a stone that wanted to be one."] #route:eccentric #statue_hint + ~ eccentric += 1 + ~ viktor_suspicion += 1 + He studies the passing trees. + + "A local shrine?" + + "If it is a shrine, it has not been loved recently." + + "You speak as if stones notice neglect." + + "Do soldiers not?" + + He does not answer. + + -> coach_nears_village + +* ["A marker. I would like to know where that path leads."] #route:detective #statue_hint + ~ detective += 1 + ~ viktor_trust += 1 + "You saw a path?" + + "Not clearly. Enough to ask later." + + Viktor looks back through the small rear window. The bend has already erased the slope. + + "Ask carefully. Places people fail to mention are often more informative than those they recommend." + + -> coach_nears_village + +* ["Only trees. The sort that make one grateful for gentlemen with revolvers."] #route:careless + ~ careless += 1 + ~ viktor_relation = "dependence" + His expression darkens by one official degree. + + "A revolver is a poor instrument against trees." + + "Then I shall rely on your conversation to intimidate them." + + The driver pretends not to hear. His shoulders, however, hear everything. + + -> coach_nears_village + +* ["Would you believe me if I said I had?"] #route:lover + ~ lover += 1 + ~ viktor_suspicion += 1 + "That would depend on what advantage you expected from the answer." + + "Herr Nowak. You wound me." + + "Not yet." + + It is the first thing he has said all day that almost sounds like flirtation, though perhaps only because danger has a talent for borrowing warmer clothes. + + -> coach_nears_village + +* ["No." ] #route:sapphic + ~ sapphic += 1 + The denial is too quick, and you both hear it. + + You are not thinking of the stone now. You are thinking of the young woman waiting somewhere ahead: the Graf's daughter, the reason carefully not written into the memorandum, the stranger whose household has summoned you under a title both absurd and useful. + + If this place keeps women in stone, you think, what does it do to them in houses? + + -> coach_nears_village + +=== coach_nears_village === + +The Graben opens reluctantly. + +First comes the smell of smoke. Then a roof, low and dark with weather. Then another. Then a church tower, not high, not graceful, but thick-shouldered and pale against the slope behind it. Its walls look older than the village around them and less certain of victory. The windows are small. The churchyard wall holds the road at a distance, as if the dead require fortification from the living, or the living from something else. #chapter[Eibenreith Village] #sfx[church-bells.ogg](max=8, fade) #image[eibenreith.png](landscape) + +Eibenreith appears not as a village in a picture appears, all at once and composed for admiration, but by fragments. + +A woman in a dark kerchief pauses with a pail in her hand. A boy stops driving geese and lets them complain around his boots. Two men outside a shed end their conversation at the same moment without looking at each other. Curtains stir in windows where no one admits to standing. A blacksmith's sign moves slightly in air you cannot feel. Water runs somewhere under boards, under stone, under the road itself, quick and cold and hidden. + +The houses are not poor, not exactly. Many are solid, whitewashed, shingled, kept with the stubborn decency of people who repair what they cannot replace. Yet something in their arrangement troubles the eye. They turn toward the church but not fully. They keep the road but lean from it. They leave, between yard and fence and woodpile, narrow passages where shadow gathers too early. + +The coach slows. + +No one runs to greet it. + +No one needs to. News has already entered the village by means faster than railway, telegraph, or imperial seal. + +You sit very straight as Eibenreith takes its first look at you. + +Beside you, Viktor lowers his voice. + +"Remember: at Hohenreith, every courtesy will mean something. Here, every silence will." + +The horses draw the coach past the churchyard wall. Above it, on the old plaster beside the gate, a faded painted woman looks down from beneath a flaking blue mantle. Her hands are folded in prayer. Her eyes, damaged by weather, no longer point in the same direction. + +For one breath, as the wheels pass over a buried runnel of water, the painted face seems less like the Holy Mother than like a mask put on something that had been waiting longer. + +Then the coach enters the village proper, and the road bends toward the unseen height where Jagdhaus Hohenreith stands above Eibenreith under its newer name. + +-> END diff --git a/data/ink-src/story.ink b/data/ink-src/story.ink new file mode 100644 index 0000000..6d18457 --- /dev/null +++ b/data/ink-src/story.ink @@ -0,0 +1,1686 @@ +// Character variables. We track just two, using a +/- scale +VAR forceful = 0 +VAR evasive = 0 + + +// Inventory Items +VAR teacup = false +VAR gotcomponent = false + + +// Story states: these can be done using read counts of knots; or functions that collect up more complex logic; or variables +VAR drugged = false +VAR hooper_mentioned = false + +VAR losttemper = false +VAR admitblackmail = false + +// what kind of clue did we pass to Hooper? +CONST NONE = 0 +CONST STRAIGHT = 1 +CONST CHESS = 2 +CONST CROSSWORD = 3 +VAR hooperClueType = NONE + +VAR hooperConfessed = false + +CONST SHOE = 1 +CONST BUCKET = 2 +VAR smashingWindowItem = NONE + +VAR notraitor = false +VAR revealedhooperasculprit = false +VAR smashedglass = false +VAR muddyshoes = false + +VAR framedhooper = false + +// What did you do with the component? +VAR putcomponentintent = false +VAR throwncomponentaway = false +VAR piecereturned = false +VAR longgrasshooperframe = false + + +// DEBUG mode adds a few shortcuts - remember to set to false in release! +VAR DEBUG = false +{DEBUG: + IN DEBUG MODE! + * [Beginning...] -> start + * [Framing Hooper...] -> claim_hooper_took_component + * [In with Hooper...] -> inside_hoopers_hut +- else: + // First diversion: where do we begin? + -> start +} + + /*-------------------------------------------------------------------------------- + Wrap up character movement using functions, in case we want to develop this logic in future +--------------------------------------------------------------------------------*/ + + + === function lower(ref x) + ~ x = x - 1 + + === function raise(ref x) + ~ x = x + 1 + +/*-------------------------------------------------------------------------------- + + Start the story! + +--------------------------------------------------------------------------------*/ + +=== start === + +// Intro + - They are keeping me waiting. + * Hut 14[]. The door was locked after I sat down. + I don't even have a pen to do any work. There's a copy of the morning's intercept in my pocket, but staring at the jumbled letters will only drive me mad. + I am not a machine, whatever they say about me. + + - (opts) + {|I rattle my fingers on the field table.|} + * (think) [Think] + They suspect me to be a traitor. They think I stole the component from the calculating machine. They will be searching my bunk and cases. + When they don't find it, {plan:then} they'll come back and demand I talk. + -> opts + * (plan) [Plan] + {not think:What I am is|I am} a problem—solver. Good with figures, quick with crosswords, excellent at chess. + But in this scenario — in this trap — what is the winning play? + * * (cooperate) [Co—operate] + I must co—operate. My credibility is my main asset. To contradict myself, or another source, would be fatal. + I must simply hope they do not ask the questions I do not want to answer. + ~ lower(forceful) + * * [Dissemble] + Misinformation, then. Just as the war in Europe is one of plans and interceptions, not planes and bombs. + My best hope is a story they prefer to the truth. + ~ raise(forceful) + * * (delay) [Divert] + Avoidance and delay. The military machine never fights on a single front. If I move slowly enough, things will resolve themselves some other way, my reputation intact. + ~ raise(evasive) + * [Wait] + - -> waited + += waited + - Half an hour goes by before Commander Harris returns. He closes the door behind him quickly, as though afraid a loose word might slip inside. + "Well, then," he begins, awkwardly. This is an unseemly situation. + * "Commander." + He nods. <> + * (tellme) {not start.delay} "Tell me what this is about." + He shakes his head. + "Now, don't let's pretend." + * [Wait] + I say nothing. + - He has brought two cups of tea in metal mugs: he sets them down on the tabletop between us. + * {tellme} [Deny] "I'm not pretending anything." + {cooperate:I'm lying already, despite my good intentions.} + Harris looks disapproving. -> pushes_cup + * (took) [Take one] + ~ teacup = true + I take a mug and warm my hands. It's <> + * (what2) {not tellme} "What's going on?" + "You know already." + -> pushes_cup + * [Wait] + I wait for him to speak. + - - (pushes_cup) He pushes one mug halfway towards me: <> + - a small gesture of friendship. + Enough to give me hope? + * (lift_up_cup) {not teacup} [Take it] + I {took:lift the mug|take the mug,} and blow away the steam. It is too hot to drink. + Harris picks his own up and just holds it. + ~ teacup = true + ~ lower(forceful) + * {not teacup} [Don't take it] + Just a cup of insipid canteen tea. I leave it where it is. + ~ raise(forceful) + + * {teacup} [Drink] + I raise the cup to my mouth but it's too hot to drink. + + * {teacup} [Wait] + I say nothing as -> lift_up_cup + +- "Quite a difficult situation," {lift_up_cup:he|Harris} begins{forceful <= 0:, sternly}. I've seen him adopt this stiff tone of voice before, but only when talking to the brass. "I'm sure you agree." + * [Agree] + "Awkward," I reply + * (disagree) [Disagree] + "I don't see why," I reply + ~ raise(forceful) + ~ raise(evasive) + * [Lie] -> disagree + * [Evade] + "I'm sure you've handled worse," I reply casually + ~ raise(evasive) + - { teacup: + ~ drugged = true + <>, sipping at my tea as though we were old friends + } + <>. + + - + * [Watch him] + His face is telling me nothing. I've seen Harris broad and full of laughter. Today he is tight, as much part of the military machine as the device in Hut 5. + + * [Wait] + I wait to see how he'll respond. + + * {not disagree} [Smile] + I try a weak smile. It is not returned. + ~ lower(forceful) + +// Why you're here + - + "We need that component," he says. + + - //"There's no alternative, of course," he continues. + {not missing_reel: + -> missing_reel -> harris_demands_component + } + - + * [Yes] + "Of course I do," I answer. + * (no) [No] + "No I don't. And I've got work to do..." + "Work that will be rather difficult for you to do, don't you think?" Harris interrupts. + + * [Evade] + -> here_at_bletchley_diversion + * [Lie] + -> no + - -> missing_reel -> harris_demands_component + +=== missing_reel === + * [The stolen component...] + * [Shrug] + I shrug. + ->-> + - The reel went missing from the Bombe this afternoon. The four of us were in the Hut, working on the latest German intercept. The results were garbage. It was Russell who found the gap in the plugboard. + - Any of us could have taken it; and no one else would have known its worth. + + * {forceful <= 0 }[Panic] They will pin it on me. They need a scapegoat so that the work can continue. I'm a likely target. Weaker than the rest. + ~ lower(forceful) + * [Calculate] My odds, then, are one in four. Not bad; although the stakes themselves are higher than I would like. + ~ raise(evasive) + * {evasive >= 0} [Deny] But this is still a mere formality. The work will not stop. A replacement component will be made and we will all be put back to work. We are too valuable to shoot. + ~ raise(forceful) + - ->-> + + +=== here_at_bletchley_diversion + "Here at Bletchley? Of course." + ~ raise(evasive) + ~ lower(forceful) + "Here, now," Harris corrects. "We are not talking to everyone. I can imagine you might feel pretty sore about that. I can imagine you feeling picked on. { forceful < 0:You're a sensitive soul.}" + + * (fine) "I'm fine[."]," I reply. "This is all some misunderstanding and the quicker we have it cleared up the better." + ~ lower(forceful) + "I couldn't agree more." And then he comes right out with it, with an accusation. + + * {forceful < 0} "What do you mean by that?" + + * (sore) { forceful >= 0 } "Damn right[."] I'm sore. Was it one of the others who put you up to this? Was it Hooper? He's always been jealous of me. He's..." + ~ raise(forceful) + ~ hooper_mentioned = true + The Commander moustache bristles as he purses his lips. "Has he now? Of your achievements, do you think?" + It's difficult not to shake the sense that he's { evasive > 1 :mocking|simply humouring} me. + "Or of your brain? Or something else?" + * * "Of my genius.["] Hooper simply can't stand that I'm cleverer than he is. We work so closely together, cooped up in that Hut all day. It drives him to distraction. To worse." + "You're suggesting Hooper would sabotage this country's future simply to spite you?" Harris chooses his words like the military man he is, each lining up to create a ring around me. + * * * [Yes] + "{ forceful > 0:He's petty enough, certainly|I wouldn't put it past him}. He's a creep." { teacup : I set the teacup down.|I wipe a hand across my forehead.} + ~ raise(forceful) + ~ teacup = false + * * * [No] + "No, { forceful >0:of course not|I suppose not}." { teacup :I put the teacup back down on the table|I push the teacup around on its base}. + ~ lower(forceful) + ~ teacup = false + * * * [Evade] + "I don't know what I'm suggesting. I don't understand what's going on." + ~ raise(evasive) + "But of course you do." Harris narrows his eyes. + -> done + + - - - (suggest_its_a_lie) "All I can say is, ever since I arrived here, he's been looking to ways to bring me down a peg. I wouldn't be surprised if he set this whole affair up just to have me court—martialled." + "We don't court—martial civilians," Harris replies. "Traitors are simply hung at her Majesty's pleasure." + * * * "Quite right[."]," I answer smartly. + * * * (iamnotraitor) "I'm no traitor[."]," I answer{forceful > 0 :smartly|, voice quivering. "For God's sake!"} + * * * [Lie] -> iamnotraitor + - - - He stares back at me. + + * * "Of my standing.["] My reputation." { forceful > 0:I'm aware of how arrogant I must sound but I plough on all the same.|I don't like to talk of myself like this, but I carry on all the same.} "Hooper simply can't bear knowing that, once all this is over, I'll be the one receiving the knighthood and he..." + "No—one will be getting a knighthood if the Germans make landfall," Harris answers sharply. He casts a quick eye to the door of the Hut to check the latch is still down, then continues in more of a murmur: "Not you and not Hooper. Now answer me." + For the first time since the door closed, I wonder what the threat might be if I do not. + + * * [Evade] + ~ teacup = false + ~ raise(forceful) + "How should I know?" I reply, defensively. { teacup :I set the teacup back on the table.} -> suggest_its_a_lie + + + * [Be honest] -> sore + * [Lie] -> fine + +- (done) -> harris_demands_component + + +=== harris_demands_component === + "{here_at_bletchley_diversion:Please|So}. Do you have it?" Harris is {forceful > 3:sweating slightly|wasting no time}: Bletchley is his watch. "Do you know where it is?" + * [Yes] + "I do." + -> admitted_to_something + * (nope) [No] "I have no idea." + -> silence + * [Lie] -> nope + * [Evade] + "The component?" + ~ raise(evasive) + ~ lower(forceful) + "Don't play stupid," he replies. "{ not missing_reel:The component that went missing this afternoon. }Where is it?" + + - { not missing_reel: + -> missing_reel -> + } + * [Co-operate] "I know where it is." + -> admitted_to_something + * (nothing) [Delay] "I know nothing about it." My voice shakes{ forceful > 0: with anger|; I'm unaccustomed to facing off against men with holstered guns}. + + * [Lie] -> nothing + * [Evade] + + "I don't know what gives you the right to pick on me. { forceful > 0:I demand a lawyer.|I want a lawyer.}" + + "This is time of war," Harris answers. "And by God, if I have to shoot you to recover the component, I will. Understand?" He points at the mug,-> drinkit + + - (silence) There's an icy silence. { forceful > 2:I've cracked him a little.|{ evasive > 2:He's tiring of my evasiveness.}} + + // Drink tea and talk + - (drinkit) "Now drink your tea and talk." + * { teacup } [Drink] -> drinkfromcup + * { teacup } [Put the cup down] + I set the cup carefully down on the table once more. + ~ teacup = false + ~ raise(forceful) + -> whatsinit + + * { not teacup } [Take the cup] + - - (drinkfromcup) I lift the cup { teacup :to my lips }and sip. He waits for me to swallow before speaking again. + ~ drugged = true + ~ teacup = true + * { not teacup } [Don't take it] + I leave the cup where it is. + ~ raise(forceful) + - - (whatsinit) "Why?" I ask coldly. "What's in it?" + + - "Lapsang Souchong," he {drinkfromcup:remarks|replies}, placing his own cup back on the table untouched. "Such a curious flavour. It might almost not be tea at all. You might say it hides a multitude of sins. As do you. Isn't that right?" + + * (suppose_i_have) [Agree] + // Regrets + "I suppose so," I reply. "I've done things I shouldn't have done." + ~ lower(forceful) + -> harris_presses_for_details + + * (nothing_ashamed_of) { not drugged } [Disagree] + "I've done nothing that I'm ashamed of." + -> harris_asks_for_theory + + * (cant_talk_right) { drugged } [Disagree] + I open my mouth to disagree, but the words I want won't come. It is like Harris has taken a screwdriver to the sides of my jaw. + -> admitted_to_something.ive_done_things + + * {drugged} [Lie] -> cant_talk_right + * {not drugged} [Lie] -> nothing_ashamed_of + * { drugged } [Evade] -> cant_talk_right + + * { not drugged } [Evade] + "None of us are blameless, Harris. { forceful > 1:But you're not my priest and I'm not yours|But I've done nothing to deserve this treatment}. Now, please. Let me go. I'll help you find this damn component, of course I will." + // Who do you blame? + He appears to consider the offer. + -> harris_asks_for_theory + + + +=== harris_presses_for_details +// Open to Blackmail + "You mean you've left yourself open," Harris answers. "To pressure. Is that what you're saying?" + * [Yes] -> admit_open_to_pressure + * { not drugged } [No] + "I'm not saying anything of the sort," I snap back. "What is this, Harris? You're accusing me of treachery but I don't see a shred of evidence for it! Why don't you put your cards on the table?" + ~ raise(forceful) + + + * {drugged} [No] + I shake my head violently, to say no, that's not it, but whatever is wrong with tongue is wrong with neck too. I look across at the table at Harris' face and realise with a start how sympathetic he is. Such a kind, generous man. How can I hold anything back from him? + ~ lower(forceful) + I take another mouthful of the bitter, strange—tasting tea before answering. + -> admit_open_to_pressure + + + * { not drugged } [Evade] + "You're the one applying pressure here," I answer { forceful > 1:smartly|somewhat miserably}. "I'm just waiting until you tell me what is really going on." + ~ raise(evasive) + * { drugged } [Evade] + "We're all under pressure here." + He looks at me with pity. -> harris_has_seen_it_before + + - "It's simple enough," Harris says. -> harris_has_seen_it_before + += admit_open_to_pressure + "That's it," I reply. "There are some things... which a man shouldn't do." + ~ admitblackmail = true + Harris doesn't stiffen. Doesn't lean away, as though my condition might be infectious. I had thought they trained them in the army to shoot my kind on sight. + He offers no sympathy either. He nods, once. His understanding of me is a mere turning cog in his calculations, with no meaning to it. + -> harris_has_seen_it_before + + +=== admitted_to_something + // Admitting Something + { not drugged : + Harris stares back at me. { evasive == 0:He cannot have expected it to be so easy to break me.} + - else: + Harris smiles with satisfaction, as if your willingness to talk was somehow his doing. + } + "I see." + There's a long pause, like the delay between feeding a line of cypher into the Bombe and waiting for its valves to warm up enough to begin processing. + "You want to explain that?" + * [Explain] + I pause a moment, trying to choose my words. To just come out and say it, after a lifetime of hiding... that is a circle I cannot square. + * * [Explain] -> ive_done_things + * * {drugged} [Say nothing] -> say_nothing + * * {not drugged} [Lie] -> claim_hooper_took_component + + * { not drugged } [Don't explain] + "There's nothing to explain," I reply stiffly. -> i_know_where + + * { not drugged } [Lie] -> claim_hooper_took_component + * { not drugged } [Evade] + "Explain what you should be doing, do you mean, rather than bullying me? Certainly." I fold my arms. -> i_know_where + + * (say_nothing) { drugged } [Say nothing] + I fold my arms, intended firmly to say nothing. But somehow, watching Harris' face, I cannot bring myself to do it. I want to confess. I want to tell him everything I can, to explain myself to him, to earn his forgiveness. The sensation is so strong my will is powerless in the face of it. + Something is wrong with me, I am sure of it. There is a strange, bitter flavour on my tongue. I taste it as words start to form. + -> ive_done_things + += i_know_where + "I know where your component is because it's obvious where your component is. That doesn't mean I took it, just because I can figure out a simple problem, any more than it means I'm a German spy because I can crack their codes." + -> harris_asks_for_theory + + += ive_done_things + "I've done things," I begin{harris_demands_component.cant_talk_right: helplessly}. "Things I didn't want to do. I tried not to. But in the end, it felt like cutting off my own arm to resist." + -> harris_presses_for_details + + + + +=== harris_asks_for_theory +"Tell me, then," he asks. "What's your theory? You're a smart fellow — as smart as they come around here, and that's saying something. What's your opinion on the missing component? Accident, perhaps? Or do you blame one of the other men? { hooper_mentioned :Hooper?}" + * [Blame no—one] + -> an_accident + * [Blame someone] -> claim_hooper_took_component + += an_accident + "An accident, naturally." I risk a smile. "That damned machine is made from spare parts and string. Even these Huts leak when it rains. It wouldn't take more than one fellow to trip over a cable to shake out a component. Have you tried looking under the thing?" + "Do you believe we haven't?" + In a sudden moment I understand that his reply is a threat. + "Now," he continues. "Are you sure there isn't anything you want to tell me?" + + * [Co-operate] + "All right." With a sigh, your defiance collapses. "If you're searched my things then I suppose you've found { evasive > 1: what you need|my letters. Haven't you? In fact, if you haven't, don't tell me}. + ~ admitblackmail = true + Harris nods once. + <> -> harris_has_seen_it_before + + * {evasive > 0} [Evade] "Only that you're being unreasonable, and behaving like a swine." + // Loses temper + "You imbecile," Harris replies, with sudden force. He is half out of his chair. "You know the situation as well as I do. Why the fencing? The Hun are poised like rats, ready to run all over this country. They'll destroy everything. You understand that, don't you? You're not so locked up inside your crossword puzzles that you don't see that, are you? This machine we have here — you men — you are the best and only hope this country has. God help her." + ~ losttemper = true + I sit back, startled by the force of his outburst. His carefully sculpted expression has curled to angry disgust. He really does hate me, I think. He'll have my blood for the taste of it. + * * [Placate] + "Now steady on," I reply, gesturing for him to be calm. + + * * [Mock] + "I can imagine how being surrounded by clever men is pretty threatening for you, Commander," I reply with a sneer. "They don't train you to think in the Armed Forces." + ~ raise(forceful) + + * * [Dismiss] + "Then I'll be going, on and getting on with my job of saving her, shall I?" I even rise half to my feet, before he slams the tabletop. + + - - "Talk," Harris demands. "Talk now. Tell me where you've hidden it or who you passed it to. Or God help me, I'll take your wretched pansy body to pieces looking for it." + -> harris_demands_you_speak + + + + +=== harris_has_seen_it_before + "I've seen it before. A young man like you — clever, removed. The kind that doesn't go to parties. Who takes himself too seriously. Who takes things too far." + He slides his thumb between two fingers. + "Now they own you." + + * [Agree] + "What could I do?" I'm shaking now. The night is cold and the heat—lamp in the Hut has been removed. "{ forceful > 2:I won't|I don't want to} go to prison." + "Smart man," he replies. "You wouldn't last. + + * [Disagree] + "I can still fix this." + Harris shakes his head. "You'll do nothing. This is beyond you now. You may go to prison or may go to firing squad - or we can change your name and move you somewhere where your indiscretions can't hurt you. But right now, none of that matters. What happens to you doesn't matter. All that matters is where that component is. + + * { not drugged } [Lie] + "I wanted to tell you," I tell him. "I thought I could find out who they were. Lead you to them." + Harris looks at me with contempt. "You wretch. You'll pay for what you've done to this country today. If a single man loses his life because of your pride and your perversions then God help your soul. + + * {drugged} {forceful < 0} [Apologise] + "Harris, I..." + ~lower(forceful) + "Stop it," he interrupts. "There's no jury here to sway. And there's no time. + +- (tell_me_now) <> So why don't you tell me, right now. Where is it?" + -> harris_demands_you_speak + + + + +=== harris_demands_you_speak + His eyes bear down like carbonised drill—bits. + * [Confess] + { forceful > 1 : + "You want me to tell you what happened? You'll be disgusted." + -else: + "All right. I'll tell you what happened." And never mind my shame. + } + "I can imagine how it starts," he replies. + + * { not drugged } [Dissemble] -> claim_hooper_took_component + * { drugged } [Dissemble] + My plan now is to blame Hooper, but I cannot seem to tell the story. Whatever they put in my tea, it rules my tongue. { forceful >1:I fight it as hard as I can but it does no good.|I am desperate to tell him everything. I am weeping with shame.} + + ~ lower(forceful) +- -> i_met_a_young_man + + + + +=== i_met_a_young_man + // Explain Story + * [Talk] + "There was a young man. I met him in the town. A few months ago now. We got to talking. Not about work. And I used my cover story, but he seemed to know it wasn't true. That got me wondering if he might be one of us." + - Harris is not letting me off any more. + "You seriously entertained that possibility?" + * [Yes] + "Yes, I considered it. <> + * [No] + "No. Not for more than a moment, of course. Everyone here is marked out by how little we would be willing to say about it." + "Only you told this young man more than a little, didn't you?" + I nod. "<> + * [Lie] + "I was quite certain, after a while. After we'd been talking. <> +- He seemed to know all about me. He... he was quite enchanted by my achievements." + The way Harris is staring I expect him to strike me, but he does not. He replies, "I can see how that must have been attractive to you," with such plain—spokeness that I think I must have misheard. + + * [Yes] "It's a lonely life in this place," I reply. "Lonely - and still one never gets a moment to oneself." + "That's how it is in the Service," Harris answers. + * * [Argue] "I'm not in the Service." + Harris shakes his head. "Yes, you are." + * * [Agree] "Perhaps. But I didn't choose this life." + Harris shakes his head. "No. And there's plenty of others who didn't who are suffering far worse." + - - Then he waves the thought aside. + + * (nope) { not drugged } [No] "The boy was a pretty simpleton. Quite inferior. His good opinion meant nothing to be. Harris, do not misunderstand. I was simply after his body." + ~ raise(evasive) + Harris, to his credit, doesn't flinch; but I can see he will have nightmares of this moment later tonight. I'm tempted to reach out and take his hand to worsen it for him. + + * { drugged } [No] + "It wasn't," I reply. "But I doubt you'd understand." + He simply nods. + * { not drugged } [Lie] -> nope + +- "Go on with your confession." +- (paused) + { not nope: + That gives me pause. I hadn't thought of it as such. But I suppose he's right. I am about to admit what I did. + } + "There's not much else to say. I took the part from Bombe computing device. You seem to know that already. I had to. He was going to expose me if I didn't." + // So blackmail? + "This young man was blackmailing you over your affair?" + + ~ temp harris_thinks_youre_drugged = drugged + + { drugged: + ~ drugged = false + As Harris speaks I find myself suddenly sharply aware, as if waking from a long sleep. The table, the corrugated walls of the hut, everything seems suddenly more tangible than a moment before. + Whatever it was they put in my drink is wearing off. + } + + * (yes) [Yes] + "Yes. I suppose he was their agent. I should have realised but I didn't. Then he threatened to tell you. I thought you would have me locked up: I couldn't bear the thought of it. I love working here. I've never been so happy, so successful, anywhere before. I didn't want to lose it." + "So what did you do with the component?" Harris talks urgently. He grips his gloves tightly in one hand, perhaps prepared to lift them and strike if it is required. "Have you passed it to this man already? Have you left it somewhere for him to find?" + * * (still_have) [I have it] + "I still have it. Not on me, of course. -> reveal_location_of_component + + * * (dont_have) [I don't have it] -> i_dont_have_it + * * [Lie] -> dont_have + * * [Tell the truth] -> still_have + + * (notright) [No] + "No, Harris. The young man wasn't blackmailing me." I take a deep breath. "It was Hooper." + { not hooper_mentioned: + "Hooper!" Harris exclaims, in surprise. {harris_thinks_youre_drugged:He does not doubt me for a moment.} + - else: + "Now look here," Harris interrupts. "Don't start that again." + } + "It's the truth, Harris. If I'm going to jail, so be it, but I won't hang at Traitor's Gate. Hooper was the one who told the boy about our work. Hooper put the boy on to me. { forceful < 2:I should have realised, of course. These things don't happen by chance. I was a fool to think they might.} And then, once he had me compromised, he demanded I steal the part from the machine." + ~ revealedhooperasculprit = true + "Which you did." Harris leans forward. "And then what? You still have it? You've stashed it somewhere?" + * * (didnt_have_long) [Yes] + "Yes. I only had a moment. -> reveal_location_of_component + + * * (passed_on) [No] -> passed_onto_hooper + * * [Lie] -> passed_on + * * [Evade] + "I can't remember." + He draws his gun and lays it lightly on the field table. + "I'm sorry to threaten you, friend. But His Majesty needs that brain of yours, and that brain alone. There are plenty of other parts to you that our country could do better without. Now I'll ask you again. Did you hide the component?" + * * * [Yes] -> didnt_have_long + * * * (nope_didnt_hide) [No] + "Very well then." I swallow nervously, to make it look more genuine. -> passed_onto_hooper + * * * [Lie] -> nope_didnt_hide + + * * * [Evade] -> i_dont_have_it + + * [Tell the truth] -> yes + * [Lie] -> notright + += i_dont_have_it + "I don't have it any more. I passed it through the fence to my contact straight after taking it, before it was discovered to be missing. It would have been idiocy to do differently. It's long gone, I'm afraid." + "You fool, Manning," Harris curses, getting quickly to his feet. "You utter fool. Do you suppose you will be any better off living under Hitler? It's men like you who will get us all killed. Men too feeble, too weak in their hearts to stand up and take a man's responsibility for the world. You're happier to stay a child all your life and play with your little childish toys." + * [Answer back] + "Really, Commander," I reply. "It rather sounds like you want to spank me." + "For God's sake," he declares with thick disgust, then swoops away out of the room. + + * [Say nothing] + I say nothing. It's true, isn't it? I can't deny that I know there is a world out there, a complicated world of pain and suffering. And I can't deny that I don't think about it a moment longer than I have to. What use is thinking on a problem that cannot be solved? It is precisely our ability to avoid such endless spirals that makes us human and not machine. + "God have mercy on your soul," Harris says finally, as he gets to his feet and heads for the door. "I fear no—one else will." + + - -> left_alone + += passed_onto_hooper + ~ hooper_mentioned = true + "No. I passed it on to Hooper." + "I see. And what did he do with it?" + * [Evade] + "I don't know." + "You can do better than that. Remember, there's a hangman's noose waiting for traitors." + * * [Theorise] + "Well, then," I answer, nervously. "What would he do? Either get rid of it straight away — or if that wasn't possible, which it probably wouldn't be, since he'd have to arrange things with his contacts — so most likely, he'd hide it somewhere and wait, until you had the rope around my neck and he could be sure he was safe." + -> claim_hooper_took_component.harris_being_convinced + + * * [Shrug] -> claim_hooper_took_component.its_your_problem + + * [Tell the truth] + "I don't think Hooper could have planned this in advance. So he'd need to get word to whoever he's working with, and that would take time. So I think he would have hidden it somewhere, and be waiting to make sure I soundly take the fall. That way, if anything goes wrong, he can arrange for the part to be conveniently re—found." + -> claim_hooper_took_component.harris_being_convinced + + * [Lie] + "I'm sure I saw him this evening, talking to someone by the fence on the woodland side of the compound. He's probably passed it on already. You'll have to ask him." + + -> claim_hooper_took_component.harrumphs + + +/*-------------------------------------------------------------------------------- + Trying to frame Hooper +--------------------------------------------------------------------------------*/ + + +=== claim_hooper_took_component +// Blame Hooper + "I saw Hooper take it." + ~ hooper_mentioned = true + { losttemper : + "Did you?" + The worst of his rage is passing; he is now moving into a kind of contemptuous despair. I can imagine him wrapping up our interview soon, leaving the hut, locking the door, and dropping the key down the well in the yard. + And why wouldn't he? With my name tarnished they will not let me back to work on the Bombe — if there is the slightest smell of treachery about my name I would be lucky not be locked up for the remainder of the war. + - else: + "I see." He is starting to lose his patience. I have seen Harris angry a few times, with lackeys and secretaries. But never with us. With the 'brains' he has always been cautious, treating us like children. + And now I see that, like a father, he wants to smack us when we disobey him. + } + "Just get to the truth, man. Every minute matters." + * { admitblackmail } [Persist with this] + "I know what you're thinking. If I've transgressed once then I must be guilty of everything else... But I'm not. We were close to cracking the 13th's intercept. We were getting correlations in the data. Then Hooper disappeared for a moment, and next minute the machine was down." + + * [Tell the truth] + "Very well. I see there's no point in covering up. You know everything anyway." + Harris nods, and waits for me to continue. + -> i_met_a_young_man + + * { not admitblackmail } [Persist with this] + "This is the truth." + + - I have become, somehow, an accustomed liar — the words roll easily off my tongue. Perhaps I am a traitor, I think, now that I dissemble as easily as one. + "Go on," Harris says, giving me no indication of whether he believes my tale. + * [Assert] "I saw him take it," I continue. "Collins was outside having a cigarette. Peterson was at the table. But I was at the front of the machine. I saw Hooper go around the side. He leant down and pulled something free. I even challenged him. I said, 'What's that? Someone put a nail somewhere they shouldn't have?' He didn't reply." + Harris watches me for a long moment. + + * [Imply] "At the moment the machine halted, Peterson was at the bench and Collins was outside having a smoke. I was checking the dip—switches. Hooper was the only one at the back of the Bombe. No—one else could have done it." + "That's not quite the same as seeing him do it," Harris remarks. + * * [Logical] + "When you have eliminated the impossible..." I begin, but Harris cuts me off. + + * * [Persuasive] + "You have to believe me." + "We don't have to believe anyone," Harris returns. "I will only be happy with the truth, and your story doesn't tie up. We know you've been leaving yourself open to pressure. We've been watching your activities for some time. But we thought you were endangering the reputation of this site; not risking the country herself. Perhaps I put too much trust in your intellectual pride." + He pauses for a moment, considering something. Then he continues: + "It might have been Hooper. It might have been you. -> we_wont_guess + + * * [Confident] + "Ask the others," I reply, leaning back. "They'll tell you. If they haven't already, that's only because they're protecting Hooper. Hoping he'll come to his senses and stop being an idiot. I hope he does too. And if you lock him up in a freezing hut like you've done me, I'm sure he will." + "We have," Harris replies simply. + It's all I can do not to gape. + -> hoopers_hut_3 + + - "We are left with two possibilities. You, or Hooper." The Commander pauses to smooth down his moustache. <> + - (hoopers_hut_3) "Hooper's in Hut 3 with the Captain, having a similar conversation." + + * "And the other men?["] Do we have a hut each? Are there enough senior officers to go round?" + "Collins was outside when it happened, and Peterson can't get round the machine in that chair of his," Harris replies. "That leaves you and Hooper. + * "Then you know I'm right.["] You knew all along. Why did you threaten me?" + "All we know is that we have a traitor, holding the fate of the country in his hands. + - (we_wont_guess) <> We're not in the business of guessing here at Bletchley. We are military intelligence. We get answers." Harris points a finger. "And if that component has left these grounds, then every minute is critical." + * [Co-operate] + "I'd be happy to help," I answer, leaning forwards. "I'm sure there's something I could do." + "Like what, exactly?" + * * "Put me in with Hooper." + -> putmein + * * "Tell Hooper I've confessed.["] Better yet. Let him see you marching me off in handcuffs. Then let him go, and see what he does. Ten to one he'll go straight to wherever he's hidden that component and his game will be up." + Harris nods slowly, chewing over the idea. It isn't a bad plan even — except, of course, Hooper has not hidden the component, and won't lead them anywhere. But that's a problem I might be able to solve once I'm out of this place; and once they're too busy dogging Hooper's steps from hut to hut. + "Interesting," the Commander muses. "But I'm not so sure he'd be that stupid. And if he's already passed the part on, the whole thing will only be a waste of time." + * * * "Trust me. He hasn't.["] If I know that man, and I do, he'll be wanting to keep his options open as long as possible. If the component's gone then he's in it up to his neck. He'll take a week at least to make sure he's escaped suspicion. Then he'll pass it on." + "And if we keep applying pressure to him, you think the component will eventually just turn up?" + * * * * "Yes.["] Probably under my bunk." + Harris smiles wryly. "We'll know that for a fake, then. We've looked there already. + * * * * "Or be thrown into the river." + "Hmm." Harris chews his moustache thoughtfully. "Well, that would put us in a spot, seeing as how we'd never know for certain. We'd have to be ready to change our whole approach just in case the part had got through to the Germans. + - - - - <> I don't mind telling you, this is a disaster, this whole thing. What I want is to find that little bit of mechanical trickery. I don't care where. In your luncheon box or under Hooper's pillow. Just somewhere, and within the grounds of this place." + * * * * "Then let him he think he's off the hook.["] Make a show of me. And then you'll get your man." + Somehow, I think. But that's the part I need to work. + -> harris_takes_you_to_hooper + + * * * * "Then you'd better get searching[."]," I reply, tiring of his complaining. A war is a war, you have to expect an enemy. -> its_your_problem + + * * * "You're right. Let me talk to him[."], then. As a colleague. Maybe I can get something useful out of him." + -> putmein + + * * * "You're right." -> shake_head + + * [Block] -> its_your_problem + + += harris_being_convinced + "Makes sense," Harris agrees, cautiously. { evasive > 1:I can see he's still not entirely convinced by my tale, as well he might not be — I've hardly been entirely straight with him.|I can see he's still not certain whether he can trust me.} "Which means the question is, what can we do to rat him out?" + * [Offer to help] + "Maybe I can help with that." + "Oh, yes? And how, exactly?" + * * "I'll talk to him." + "What?" + "Put me in with Hooper with him. Maybe I can get something useful out of him." + -> putmein + * * "We'll fool him.["] He's waiting to be sure that I've been strung up for this, so let's give him what he wants. If he sees me taken away, clapped in irons — he'll go straight to that component and set about getting rid of it." + -> harris_takes_you_to_hooper + + * [Don't offer to help] + I lean back. -> its_your_problem + += putmein + Harris shakes his head. + "He despises you. I don't see why he'd give himself up to you." + * [Insist] "Try me. Just me and him." + -> go_in_alone + * [Give in] "You're right." + -> shake_head + + += shake_head + // Can't help + <> I shake my head. "You're right. I don't see how I can help you. So there's only one conclusion." + "Oh, yes? And what's that?" + -> its_your_problem + + += its_your_problem +// Won't Help + "It's your problem. Your security breach. So much for your careful vetting process." + I lean back in my chair and fold my arms so the way they shake will not be visible. + "You'd better get on with solving it, instead of wasting your time in here with me." + -> harrumphs + += harrumphs + Harris harrumphs. He's thinking it all over. + * { putmein } [Wait] + "All right," he declares, gruffly. "We'll try it. But if this doesn't work, I might just put the both of you in front of a firing squad and be done with these games. Worse things happen in time of war, you know." + "Alone," I add. + -> go_in_alone + + * { not putmein } [Wait] + "No," Harris declares, finally. "I think you're lying about Hooper. I think you're a clever, scheming young man — that's why we hired you — and you're looking for the only reasonable out this situation has to offer. But I'm not taking it. We know you were in the room with the machine, we know you're of a perverted persuasion, we know you have compromised yourself. There's nothing more to say here. Either you tell me what you've done with that component, or we will hang you and search just as hard. It's your choice." + -> harris_threatens_lynching + + += go_in_alone + "Alone?" + "Alone." + Harris considers it. I watch his eyes, flicking backwards and forwards over mine, like a ribbon—reader loading its program. + * [Patient] "Well?" + * [Impatient] "For God's sake, man, what do you have to lose?" + ~ raise(forceful) + - "We'll be outside the door," Harris replies, seriously. "The first sign of any funny business and we'll have you both on the floor in minutes. You understand? The country needs your brain, but it's not too worried about your legs. Remember that." + Then he gets to his feet, and opens the door, and marches me out across the yard. The evening is drawing in and there's a chill in the air. My mind is racing. I have one opportunity here — a moment in which to put the fear of God into Hooper and make him do something foolish that places him in harm's way. But how to achieve it? + "You ready?" Harris demands. + * (yes) [Yes] + "Absolutely." + * [No] + "No." + "Too bad." + * [Lie] -> yes + + - -> inside_hoopers_hut + + +/*-------------------------------------------------------------------------------- + Quick visit to see Hooper +--------------------------------------------------------------------------------*/ + +=== harris_takes_you_to_hooper + // Past Hooper + Harris gets to his feet. "All right," he says. "I should no better than to trust a clever man, but we'll give it a go." + Then, he smiles, with all his teeth, like a wolf. + { claim_hooper_took_component.hoopers_hut_3: + "Especially since this is a plan that involves keeping you in handcuffs. I don't see what I have to lose." + - else: + "Hooper's in Hut 3 being debriefed by the Captain. Let's see if we can't get his attention somehow." + } + // Leading you past Hooper + He raps on the door for the guard and gives the man a quick instruction. He returns a moment later with a cool pair of iron cuffs. + "Put 'em up," Harris instructs, and I do so. The metal closes around my wrists like a trap. I stand and follow Harris willingly out through the door. + But whatever I'm doing with my body, my mind is scheming. Somehow, I'm thinking, I have to get away from these men long enough to get that component behind Hut 2 and put it somewhere Hooper will go. Or, otherwise, somehow get Hooper to go there himself... + Harris marches me over to Hut 3, and gestures for the guard to stand aside. Pushing me forward, he opens the door nice and wide. + // Hut 3 + "Captain. Manning talked. If you'd step out for a moment?" + * [Play the part, head down] + From where he's sitting, I know Hooper can see me, so I keep my head down and look guilty as sin. The bastard is probably smiling. + + + * [Look inside the hut] + I look in through the door and catch Hooper's expression. I had half expected him to be smiling be he isn't. He looks shocked, almost hurt. "Iain," he murmurs. "You couldn't..." + + * (shouted) [Call to Hooper] + I have a single moment to shout something to Hooper before the door closes. + "I'll get you Hooper, you'll see!" I cry. Then: + + * * "Queen to rook two, checkmate!"[] I call, then laugh viciously, as if I am damning him straight to hell. + ~ hooperClueType = CHESS + - - (only_catch) I only catch Hooper's reaction for a moment — his eyebrow lifts in surprise and alarm. Good. If he thinks it is a threat then he just might be careless enough to go looking for what it might mean. + + * * "Ask not for whom the bell tolls!" + He stares back at me, as if were a madman and perhaps for a split second I see him shudder. + + + * * "Two words: messy, without one missing!"[] I cry, laughing. It isn't the best clue, hardly worthy of The Times, but it will have to do. + ~ hooperClueType = CROSSWORD + -> only_catch + +- The Captain comes outside, pulling the door to. "What's this?" he asks. "A confession? Just like that?" + "No," the Commander admits, in a low voice. "I'm afraid not. Rather more a scheme. The idea is to let Hooper go and see what he does. If he believes we have Manning here in irons, he'll try to shift the component." + "If he has it." + "Indeed." + The Captain peers at me for a moment, like I was some kind of curious insect. + "Sometimes, I think you people are magicians," he remarks. "Other times you seem more like witches. Very well." + With that he opens the door to the Hut and goes back inside. The Commander uses the moment to hustle me roughly forward. + { shouted : + "And what was all that shouting about?" he hisses in my ear as we move towards the barracks. "Are you trying to pull something? Or just make me look incompetent?" + - else: + "This scheme of yours had better come off," he hisses in my ear. "Otherwise the Captain is going to start having men tailing me to see where I go on Saturdays." + } + * [Reassure] + { not shouted : + "It will. Hooper's running scared," I reply, hoping I sound more confident than I feel. + - else: + "Just adding to the drama," I tell him, confidently. "I'm sure you can understand that." + } + "I think we've had enough drama today already," Harris replies. "Let's hope for a clean kill." + + * [Dissuade] + { not shouted: + "The Captain thought it was a good scheme. You'll most likely get a promotion." + - else: + "I'm not trying to do anything except save my neck." + } + "Let's hope things work out," Harris agrees darkly. + + * [Evade] + "We're still in ear—shot if they let Hooper go. Best get us inside and then we can talk, if we must." + "I've had enough of your voice for one day," Harris replies grimly. <> + + * [Say nothing] + I let him have his rant. <> +- He hustles me up the steps of the barracks, keeping me firmly gripped as if I had any chance of giving him, a trained military man, the slip. It's all I can do not to fall into the room. + -> slam_door_shut_and_gone + + + + +=== inside_hoopers_hut + - Harris opens the door and pushes me inside. "Captain," he calls. "Could I have a moment?" + The Captain, looking puzzled, steps out. The door is closed. Hooper stares at me, open—mouthed, about to say something. I probably have less than a minute before the Captain storms back in and declares this plan to be bunkum. + * [Threaten] + "Listen to me, Hooper. We were the only men in that hut today, so we know what happened. But I want you to know this. I put the component inside a breeze—block in the foundations of Hut 2, wrapped in one of your shirts. They're going to find it eventually, and that's going to be what tips the balance. And there's nothing you can do to stop any of that from happening." + ~ hooperClueType = STRAIGHT + + His eyes bulge with terror. "What did I do, to you? What did I ever do?" + * * [Tell the truth] + "You treated me like vermin. Like something abhorrent." + "You are something abhorrent." + "I wasn't. Not when I came here. And I won't be, once you're gone." + + * * [Lie] + "Nothing," I reply. "You're just the other man in the room. One of us has to get the blame." + + * * [Evade] + "It doesn't matter. Just remember what I said. I've beaten you, Hooper. Remember that." + - - I get to my feet and open the door of the Hut. The Captain storms back inside and I'm quickly thrown out. -> hustled_out + + + * [Bargain] + "Hooper, I'll make a deal with you. We both know what happened in that hut this afternoon. I know because I did it, and you know because you know you didn't. But once this is done I'll be rich, and I'll split that with you. I'll let you have the results, too. Your name on the discovery of the Bombe. And it won't hurt the war effort — you know as well as me that the component on its own is worthless, it's the wiring of the Bombe, the usage, that's what's valuable. So how about it?" + Hooper looks back at me, appalled. "You're asking me to commit treason?" + * * [Yes] + "Yes, perhaps. But also to ensure your name goes down in the annals of mathematics. -> back_of_hut_2 + * * [No] + "No. It's not treason. It's a trade, plain and simple." + + * * (lie) [Lie] + "I'm suggesting you save your own skin. I've wrapped that component in one of your shirts, Hooper. They'll be searching this place top to bottom. They'll find it eventually, and when they do, that's the thing that will swing it against you. So take my advice now. Hut 2." + ~ hooperClueType = STRAIGHT + + * * [Evade] -> lie + - - -> no_chance + + * [Plead] + "Please, Hooper. You don't understand. They have information on me. I don't need to tell you what I've done, you know. Have a soul. And the component — it's nothing. It's not the secret of the Bombe. It's just a part. The German's think it's a weapon — a missile component. Let them have it. Please, man. Just help me." + "Help you?" Hooper stares. "Help you? You're a traitor. A snake in the grass. And you're queer." + * * [Deny] + "I'm no traitor. You know I'm not. How much work have I done here against the Germans? I've given my all. And you know as well as I do, if the Reich were to invade, I would be a dead man. Please, Hooper. I'm not doing any of this lightly." + + * * [Accept] + "I am what I am," I reply. "I'm the way I was made. But they'll hang me unless you help, Hooper. Don't let them hang me." + + * * [Evade] + "That's not important now. What matters is what you do, this evening." + + - - "Assuming I wanted to help you," he replies, carefully. "Which I don't. What would I do?" + "Nothing. Almost nothing. + -> back_of_hut_2 + += back_of_hut_2 + <> All you have to do is go to the back of Hut 2. There's a breeze—block with a cavity. That's where I've put it. I'll be locked up overnight. But you can pick it up and pass it to my contact. He'll be at the south fence around two AM." + ~ hooperClueType = STRAIGHT + -> no_chance + += no_chance + "If you think I'll do that then you're crazy," Hooper replies. + At that moment the door flies open and the Captain comes storming back inside. + -> hustled_out + += hustled_out + // To Barracks + Harris hustles me over to the barracks. "I hope that's the end of it," he mutters. + "Just be sure to let him out," I reply. "And then see where he goes." + -> slam_door_shut_and_gone + + + +/*-------------------------------------------------------------------------------- + Left alone overnight +--------------------------------------------------------------------------------*/ + + +=== slam_door_shut_and_gone + Then they slam the door shut, and it locks. + { hooperClueType == NONE : + <> How am I supposed to manage anything from in here? + * [Try the door] -> try_the_door + * [Try the windows] -> try_the_windows + + - else: + I can only hope that Hooper bites. If he thinks I'm bitter enough to have framed him, and arrogant enough to have taunted him with {hooperClueType > STRAIGHT:a clue to} where the damning evidence is hidden... + If he hates me enough, and is paranoid enough, then he might {hooperClueType > STRAIGHT:unravel my little riddle and} go searching around Hut 2. + } + + * [Wait] -> night_falls + + += try_the_door + I try the door. It's locked, of course. + -> from_outside_heard + += from_outside_heard + From outside, I hear a voice. Hooper's. He's haranguing someone. + - (opts) + * (listened) [Listen at the keyhole] + I put my ear down to the keyhole, but there's nothing now. Probably still a guard outside, of course, but they're keeping mum. + -> opts + + * { not try_the_windows } [Try the window] -> try_the_windows + * { not try_the_door } {listened} [Try the door] -> try_the_door + * { try_the_windows } [Smash the window] -> try_to_smash_the_window + * { try_the_door && try_the_windows } [Wait] + It's useless. There's nothing I can do but hope. I sit down on one corner of the bunk to wait. + -> night_falls + += try_the_windows + I go over to the window and try to jimmy it open. Not much luck, but in my struggling I notice this window only backs on the thin little brook that runs down the back of the compound. Which means, if I smashed it, I might get away with no—one seeing. + -> from_outside_heard + + += try_to_smash_the_window + The window is my only way out of here. I just need a way to smash it. + * [Punch it] + I suppose my fist would do a good enough job. But I'd cut myself to ribbons, most likely. <> + + * (use_bucket) [Find something] + ~ smashingWindowItem = BUCKET + I cast around the small room. There's a bucket in one corner for emergencies — I suppose I could use that. I pick it up but it's not very easy to heft. <> + * [Use something you've got] + I pat down my pockets but all I'm carrying is the intercept, which is no good at all. + * * [Something you're wearing?] + Ah, but of course! I slip off one shoe and heft it by the toe. The heel will make a decent enough hammer, if I give it enough wallop. + ~ smashingWindowItem = SHOE + But I'll cut my hand to ribbons doing it. <> + * * [Look around] -> use_bucket + - And the noise would be terrible. There must be a way of making this easier. I'm supposed to be a thief now. What would a burglar do? + * [Work slowly] + Work carefully? It's difficult to work carefully when all one's has is { smashingWindowItem == BUCKET :a bucket. It's rather like the sledgehammer for the proverbial nut|{ smashingWindowItem == SHOE :a shoe|nothing but brute force}}. + * * [Just do it] -> time_to_move_now + * * [Look around for something] + * [Find something to help] + - -> find_something_to_smash_window + + += time_to_move_now + Enough of this. There isn't any time to lose. Right now they'll be following Hooper as he goes to bed, and goes to sleep; and then that's it. The minute he closes his eyelids and drifts off that's the moment that this trap swings shut on me. + So I punch out the glass with my { smashingWindowItem == BUCKET :bucket|{ smashingWindowItem == SHOE :shoe|fist}} and it shatters with a terrific noise. Then I stop, and wait, to see if anyone will come in through the door. + Nothing. + * (pause) [Wait a little longer] + I pause for a moment longer. It doesn't do to be too careless... + * [Clear the frame of shards] + With my jacket wrapped round my arm, I sweep out the remaining shards of glass. It's not a big window, but I'm not a big man. If I was Harris, I'd be stuffed, but as it is... + + - Then the door locks turns. The door opens. Then Jeremy — one of the guards, rather — sticks his head through the door. "I thought I heard..." + He stops. Looks for a moment. { smashingWindowItem ==BUCKET :Sees the bucket in my hand.|Sees the broken window.} Then without a moment's further thought he blows his shrill whistles and hustles into the hut, grabbing me roughly by my arms. + { pause: + I'll never know if I hadn't have waited that extra moment — maybe I still could have got away. But, how far? + } + I'm hustled into one of the huts. Nowhere to sleep, but they're not interested in my comfort any longer. Harris comes in with the Captain. + "So," Harris remarks. "Looks like your little trap worked. Only it worked to show you out for what you are." + * [Tell the truth] + { i_met_a_young_man : + "Please, Harris. You can't understand the pressure they put me under. You can't understand what it's like, to be in love but be able to do nothing about it..." + - else: + "Harris. They were blackmailing me. They knew about... certain indiscretions. You can understand, can't you, Harris? I was in an impossible bind..." + } + * [Lie] + "I had to get out, Harris. I had to provoke Hooper into doing something that would incriminate himself fully. He's too clever, you see..." + + * [Evade] + "This proves nothing," I reply stubbornly. "You still don't have the component and without it, I don't see what you can hope to prove." + + - "Be quiet, man. We know all about your and your sordid affairs." The Captain curls his lip. "Don't you know there's a war on? Do you know the kind of place they would have sent you if it haven't had been for that brain of yours? Don't you think you owe it to your country to use it a little more?" + + Do I, I wonder? Do I owe this country anything, this country that has spurned who and what am I since the day I became a man? + * [Yes] + My anger deflates like a collapsing equation, all arguments cancelling each other out. The world, of course, owes me nothing; and I owe it everything. + + * (alone) [No] + Of course not. I am alone; that is what they wanted me to be, because of who and what I love. So I have no nation, no country. + + + * [Lie] -> alone + * [Evade] + But what is a country, after all? A country is not a concept, not an ideal. Every country falls, its borders shift and move, its language disappears to be replaced by another. Neither the Reich nor the British Empire will survive forever, so what use is my loyalty to either? + I may as well, therefore, look after myself. Something I have attempted, but failed miserably, to do. + + - // Tell us where + "I'm afraid we have only one option, Manning," Harris says. "Please, man. Tell us where the component is." + ~ notraitor = true + ~ losttemper = false + * [Tell them] + ~ revealedhooperasculprit = false + "All right." I am beaten, after all. "<>-> reveal_location_of_component + + * [Say nothing] -> my_lips_are_sealed + += find_something_to_smash_window + Let me see. There's the bunk, { not smashingWindowItem == BUCKET :a bucket,} nothing else. I have my jacket but nothing in the pockets — no handkerchief, for instance. + - (opts) + * [The bunk] + The bunk has a solid metal frame, a blanket, a pillow, nothing more. + - - (bunk_opts) + * * [The frame] + The frame is heavy and solid. I couldn't lift it or shift it without help from another man. And it wouldn't do me any good here anyway. I can reach the window perfectly well. + -> bunk_opts + * * [The blanket] + The blanket. Perfect. I scoop it up off the bed and hold it in place over the window. -> smash_the_window + * * [The pillow] + The pillow is fat and fluffy. I could put it over the window and it would muffle the sound of breaking glass, certainly; but I wouldn't be able to break any glass through it either. + -> bunk_opts + + * * {bunk_opts > 1} [Something else] -> opts + + * [The jacket] + I slip off my jacket and hold it with one hand over the glass. -> smash_the_window + * { not smashingWindowItem == BUCKET } [The bucket] + The bucket? Hardly. The bucket might do some good if I wanted to sweep up the glass afterwards, but it won't help me smash the glass quietly. + -> opts + + +=== smash_the_window + // Smashing glass + Then I heft { smashingWindowItem == BUCKET :up the bucket — this really is quite a fiddly thing to be doing in cuffs — |{ smashingWindowItem == SHOE : my shoe by its toe, |back my arm, }} and take a strong swing, trying to imagine it's Harris' face on the other side. + ~ smashedglass = true + ~ smashingWindowItem = NONE + * [Smash!] + - The sound of the impact is muffled. With my arm still covered, I sweep out the remaining glass in the frame. + - I'm ready to escape. The only trouble is — when they look in on me in the morning, there will be no question what has happened. It won't help me one jot with shifting suspicion off my back. + * [Wait] + So perhaps I should wait it out, after all. Who knows? I might have a better opportunity later. + -> night_passes + * [Slip out] + Moving quickly and quietly, I hoist myself up onto the window—frame and worm my way outside into the freezing night air. Then I am away, slipping down the paths between the Huts, sticking to the shadows, on my way to Hut 2. + // Out at night + - + * [Go the shortest way] + There's no time to lose. Throwing caution to the wind I make my way quickly to Hut 2, and around the back. I don't think I've been seen but if I have it is too late. My actions are suspicious enough for the noose. I have no choice but to follow through. + * [Take a longer route] + In case I'm being followed, I divert around the perimeter of the compound. It's a much longer path, and it takes me across some terrain that's difficult to negotiate in the dark — muddy, and thick with thistles and nestles. + ~ muddyshoes = true + Still, I can be confident no—one is behind me. I crouch down behind the rear wall of Hut 2. <> + - The component is still there, wrapped in a tea—towel and shoved into a cavity in a breeze—block at the base of the Hut wall. + * [Take it] + Quickly, I pull it free, and slip it into the pocket of my jacket. + ~ gotcomponent = true + + * [Leave it] + Still there means no—one has found it, which means it is probably well—hidden. And short of skipping the compound now, I can afford to leave it hidden there a while longer. So I leave it in place. + - Where now? + * [Back to the barracks] -> return_to_room_after_excursion + * { gotcomponent } [Go to Hooper's dorm] -> go_to_hoopers_dorm + * [Escape the compound] + Enough of this place. Time for me to get moving. I can get to the train station on foot, catch the postal train to Scotland and be somewhere else before anyone realises that I'm gone. + + Of course, then they'll be looking for me in earnest. { not framedhooper :As a confirmed traitor.|Perhaps not as a traitor — they might take the idea that Hooper was involved with the theft — but certainly as a valuable mind, one containing valuable secrets and all too easily threatened. They will think I am running away because of my indiscretions. I suppose, in fairness, that I am.} + * * [Go] -> live_on_the_run + * * [Don't go] + It's no good. That's only half a solution. I couldn't be happy with that. + * * * [Back to the barracks] -> return_to_room_after_excursion + * * * { gotcomponent && not go_to_hoopers_dorm } [To Hooper's dorm] -> go_to_hoopers_dorm + + +/*-------------------------------------------------------------------------------- + Visit Hooper's dorm overnight +--------------------------------------------------------------------------------*/ + + +=== go_to_hoopers_dorm + // Hooper's Dorm + I creep around the outside of the huts towards Hooper's dorm. Time to wrap up this little game once and for all. A few guards patrol the area at night but not many — after all, very few know this place even exists. + Our quarters are arranged away from the main house; where we sleep is of less importance than where we work. We each have our own hut, through some are less permanent than others. Hooper's is a military issue tent: quite a large canopy, with two rooms inside and a short porch area where he insists people leave their shoes. It's all zipped up for the night and no light shines from inside. + I hang back for a moment. If Harris is keeping to the terms of our deal then someone will be watching this place. But I can see no—one. + * (outer_zip) [Open the outer zip] + I creep forward to the tent, intent on lifting the zip to the front porch area just a little — enough to slip the component inside, and without the risk of the noise waking Hooper from his snoring. + The work is careful, and more than little fiddly — Hooper has tied the zips down on the inside, the fastidious little bastard! — but after a little work I manage to make a hole large enough for my hand. + * * [Slip in the component] + I slide the component into the tent, work the zip closed, and move quickly away into the shadows. It takes a few minutes for my breath to slow, and my heart to stop hammering, but I see no other movement. If anyone is watching Hooper's tent, they are asleep at their posts. + ~ putcomponentintent = true + ~ gotcomponent = false + -> return_to_room_after_excursion + * * [No, some other way] + Then pause. This is too transparent. Too blatant. If I leave it here, like this, Hooper will never be seen to go looking for it: he will stumble over it in plain sight, and the men watching will wonder why it was not there when he went to bed. + No, I must try something else — or nothing at all. + * * * [On top of the tent] -> put_component_on_tent + * * * [Throw the component into the long grass] + From inspiration — or desperation, I am not certain — a simple approach occurs to me. -> toss_component_into_bushes + * * * [Give up] + There is nothing to be gained here. I have the component now; maybe it will be of some value tomorrow. + * * * * [Return to my barrack] -> return_to_room_after_excursion + * * * * [Escape the compound] -> live_on_the_run + + * (wide_circuit) [Look for another opening] + Making a wide circuit I creep around the tent. It has plenty of other flaps and openings, tied down with Gordian complexity. But nothing afford itself to slipping the component inside. + * * [Try the porch zip] -> outer_zip + * * [Try on top of the tent] -> put_component_on_tent + * * [Give up] + It's no good. Nothing I can do will be any less than obvious — something appearing where something was not there before. The men watching Hooper will know it is a deception and Hooper's protestations will be taken at face value. + If I can't find a way for Hooper to pick the component up, as if from a hiding place of his own devising, and be caught doing it, then I have no plan at all. + * * * [Return to my barrack] -> return_to_room_after_excursion + * * * [Escape the compound] -> live_on_the_run + * * * [Toss the component into the bushes] -> toss_component_into_bushes + + * [Hide the component somewhere] + If I leave the component here somewhere it should be somewhere I can rely on Hooper finding it, but no—one before Hooper. In particular. + * * [Behind the tent] -> wide_circuit + * * [Inside the porch section] -> outer_zip + * * [On top of the canvas] -> put_component_on_tent + + += put_component_on_tent + A neat idea strikes me. If I could place it on top of the canvas, somewhere in the middle where it would bow the cloth inwards, then it would be invisible to anyone passing by. But to Hooper, it would be above him: a shadow staring him in the face as he awoke. What could be more natural than getting up, coming out, and looking to see what had fallen on him during the night? + + It's the work of a moment. I was once an excellent bowler for the second XI back at school. This time I throw underarm, of course, but I still land the vital missing component exactly where I want it to go. + ~ framedhooper = true + ~ gotcomponent = false + For a second I hold my breath, but nothing and no—one stirs. -> return_to_room_after_excursion + + += toss_component_into_bushes + I toss the component away into the bushes behind Hooper's tent and return to my barrack, wishing myself a long sleep followed by a morning, free of this business. + ~ gotcomponent = false + ~ throwncomponentaway = true + -> return_to_room_after_excursion + +/*-------------------------------------------------------------------------------- + Ending: Run away from the camp +--------------------------------------------------------------------------------*/ + + +=== live_on_the_run + Better to live on the run than die on the spit. Creeping around the edge of the compound{ gotcomponent :, the Bombe component heavy in my pocket}, I make my way to the front gate. As always, it's manned by two guards, but I slip past their box by crawling on my belly. + And then I'm on the road. Walking, not running. Silent. Free. + // End - Run Away + For the moment, at least. + -> END + +/*-------------------------------------------------------------------------------- + Return to room after slipping out +--------------------------------------------------------------------------------*/ + + +=== return_to_room_after_excursion + { gotcomponent :The weight of the Bombe component safely in my jacket|Satisfied}, I return the short way up the paths between the huts to the barrack block and the broken window. + It's a little harder getting back through — the window is higher off the ground than the floor inside — but after a decent bit of jumping and hauling I manage to get my elbows up, and then one leg, and finally I collapse inside, quite winded and out breath. + * [Wait] -> night_passes + +/*-------------------------------------------------------------------------------- + Night passes +--------------------------------------------------------------------------------*/ + + +=== night_passes +// In room smashed glass + The rest of the night passes slowly. I sleep a little, dozing mostly. Then I'm woken by the rooster in the yard. The door opens, and Harris comes in. He takes one look at the broken window and frowns with puzzlement. + { putcomponentintent: -> put_component_inside_tent } + + "What happened there?" + * [Confess] + "I broke it," I reply. There doesn't seem any use in trying to lie. "I thought I could escape. But I couldn't get myself through." + The Commander laughs. -> glad_youre_here + + * (deny) [Deny] + "I'm not sure. I was asleep: I woke up when someone broke the window. I looked out to see who it was, but they were already gone." + Harris looks at me with puzzlement. "Someone came by to break the window, and then ran off? That's absurd. That's utterly absurd. Admit it, Manning. You tried to escape and you couldn't get through." + * * [Admit it] + "All right. {forceful>1:Damn you.} That's exactly it." + -> glad_youre_here + + * * { not framedhooper } [Deny it] + "If I wanted to escape, I would have made damn sure that I could," I tell him sternly. + -> harris_certain_is_you + + * * { framedhooper } [Deny it] + "I tell you, someone broke it. Someone wanted to threaten me, I think." + Harris shakes his head. "Well, we can look into that matter later. For now, you probably want to hear the more pressing news. -> found_missing_component + + * { gotcomponent } [Show him the component] -> someone_threw_component + += put_component_inside_tent + He takes one look around, and sighs, a deep, wistful sigh. + "Things just get worse and worse for you, Manning," he remarks. "You are your own worst enemy." + * [Agree] + "I've thought so before." { admitblackmail :Certainly in the matter of getting blackmailed.} + "Let me tell you what happened this morning. <> + + * [Disagree] + "Right now, I think you take that role, Harris," I reply coolly. + - - (droll) "Very droll," he replies. "Let me tell you what happened this morning. It will take the smile off your face. <> + + * [Evade] + "I'm looking forward to having a wash and a change of clothes; which should make me a little less evil to be around." + -> droll + + - Our men watching Hooper's tent saw Hooper wake up, get dressed, clamber out of his tent and then step on something in at the entrance of his tent." + ~ piecereturned = true + * [Be interested] + "You mean he didn't even hide it? He put it in his shoe?" + - - (not_that) "No," Harris replies. "That isn't really what I mean. <> + + * [Be dismissive] + "So he's an idiot, and he hid it in his shoe." + -> not_that + + * [Say nothing] + I say quiet, listening, not sure how this will go. + "In case I'm not making myself clear," Harris continues, "<> + + - I mean, he managed to find it, by accident, somewhere where it wasn't the night before. And at the same time, you're sitting here with your window broken. So, I rather think you've played your last hand and lost. It's utterly implausible that Hooper stole that component and then left it lying around in the doorway of his tent. So I came to tell you that the game is up, for you." + He nods and gets to his feet. -> left_alone + + + += someone_threw_component + "Someone threw this in through the window over night," I reply, and open my jacket to reveal the component from the Bombe. "I couldn't see who, it was too dark. But I know what it is." + He reaches out and takes it. "Well, I'll be damned," he murmurs. "That's it all right. And you didn't have it on you when we put you in here. But it can't have been Hooper — I had men watching him all night. And there's no—one else it could have been." + He turns the component over in his hands, bemused. + ~ piecereturned = true + * [Suggest something] + "Perhaps Hooper had an accomplice. Someone else who works on site." + Harris shakes his head, distractedly. "That doesn't make sense," he says. "Why go to all the trouble of stealing it only to give it back? And why like this?" + * * [Suggest something] + "Perhaps the accomplice thought it was Hooper being kept in here. Maybe they saw the guard..." + -> all_too_farfetched + * * [Suggest nothing] + * [Suggest nothing] + - I shrug, eloquently. + - -> all_too_farfetched + + += glad_youre_here + "Shame," he remarks. "I should have left that window open and put a guard on you. Might have been interesting to see where you went. Anyway, I'm glad you're still here, even if you do smell like a dog." + + * { not framedhooper } [Be optimistic] + -> night_falls.morning_not_saved.optimism + * { not framedhooper } [Be pessimistic] + -> night_falls.morning_not_saved.pessimism + + * { framedhooper } [Be optimistic] + "I'm looking forward to having a bath." + // Framed Hooper + "Well, you should enjoy it. <> + + * { framedhooper } [Be pessimistic] + "I imagine I'll smell worse after another couple of days of this." + "That won't be necessary. <> + - -> found_missing_component + + += found_missing_component + // Framed Hooper + We found the missing component. Or rather, Hooper found it for us. He snuck out and retrieved it from on top. Of all the damnest places — you would never have known it was there. He claimed ignorance when we jumped him, of course. But it's good enough for me." + * (devil) [Approve] + "I can't tell you enough, I'm glad to hear it. I've had a devil of a night." + His gaze flicks to the broken window, but only for a moment. I think he genuinely cannot believe I could have done it. + * [Disapprove] + "You should never have hired him. A below-average intelligence can't be expected to cope with the pressure of our work." + - Harris rolls his eyes, but he might almost be smiling. "You'd better get along, { devil :and work through your devils|Mr Intelligent}. There's a 24—hour—late message to be tackled and we're a genius short. So you'd better be ready to work twice as hard." + * [Thank him] + "I'll enjoy it. Thank you for helping me clear this up." + "Don't thank me yet. There's still a war to fight. Now get a move on." + I nod, and hurry out of the door. The air outside has never tasted fresher and more invigorating. <> + + * [Argue with him] + "I'll work as hard as I work." + "Get out," Harris growls. "Before I decide to arrest you as an accessory." + I do as he says. Outside the barrack, the air has never smelt sweeter. + - -> head_for_my_dorm_free + + +=== night_falls === +// Night falls + Night falls. The clockwork of the heavens keeps turning, whatever state I might be in. No—one can steal the components that make the sun go down and the stars come out. I watch it performing its operations. I can't sleep. + { hooperClueType > NONE : + Has Hooper taken my bait? + } + * [Look of out the window] + I peer out of the window, but it looks out onto the little brook at the back of the compound, with no view of the other huts or the House. Who knows if there are men up, searching the base of Hut 2, following one another with flashlights... + {inside_hoopers_hut.back_of_hut_2: + Perhaps Hooper is there, in the dark, trying to help me after all? + } + * [Listen at the door] + I put my ear to the keyhole but can make out nothing. Are there still guards posted? { hooperClueType > NONE :Perhaps, if Hooper has managed to incriminate himself, the guards have been removed?|Perhaps the component has been found and the crisis is over.} + Perhaps the door is unlocked and they left me to sleep? + * * [Try it] I try the handle. No such luck. + * * [Leave it] I don't touch it. I don't want anyone outside thinking I'm trying to escape. + + * [Wait] + There is nothing I can do to speed up time. + + - The night moves at its own pace. I suppose by morning I will know my fate. + * { hooperClueType > NONE } [Wait] + // Hooper now arrested + Morning comes. I'm woken by a rooster calling from the yard behind the House. I must have slept after all. I pull myself up from the bunk, shivering slightly. There is condensation on the inside of the window. I have probably given myself a chill. + Without knocking, Harris comes inside. "You're up," he remarks, and then, "You smell like an animal." + * * [Be friendly] + "I suppose I do rather." I laugh, but Harris does not. + "This damn business gets worse and worse," he says, talking as he goes over to unlock and throw open the window. <> + * * [Be cold] + "So would you," I reply tartly. Harris shrugs. + "I've been through worse than this," he replies matter—of—factly. "It's hardly my fault if you sleep in your clothes." + I glare back. He goes over to the window, unlocks it and throws it open, relishing the fresh air from outside. + - - "Hooper's confessed, you know." + * * [Be eager] + "He has? I knew he would. The worm." + "Steady now. Matters aren't over yet. <> + * * [Be cautious] + "Oh, yes?" + "Yes. For what that's worth. <> + - - (hooper_didnt_give_himself_up) There's still the issue of the component. It hasn't turned up. He didn't lead us to it. I guess he figured you must have had something on him. I don't know." + + He looks quite put out by the whole affair. He is not the kind of man to deal well with probabilities. + * * [Be interested] + "You mean he confessed of his own accord? You didn't catch him?" + + * * [Be disinterested] + "Well, I'm glad his conscience finally caught up with him," I reply dismissively. + - - "The Captain went back into that hut and he confessed immediately. We were so surprised we didn't let you go." He wrinkles his nose. "I'm rather sorry about that now. I suggest you have a wash." + And with that he gestures to the doorway. + * * [Go] + * * [Wait] + I hang back a moment. Something does not seem quite right. After all, Hooper did not steal the component. He has no reason to confess to anything. Perhaps this is another trap? + "Well?" Harris asks. "What are you waiting for? Please don't tell me you want to confess now as well, I don't think my head could stand it." + * * * [Confess] + After a chance like this? A chance — however real — to save my neck? To hand it over — what, to save Hooper's worthless skin? + * * * * [Confess] + I see. Perhaps you think I bullied the man into giving himself up. Perhaps he understood my little clue far enough to know it was a threat against him, but not well enough to understand where he should look to find it. So he took the easy route out and folded. Gave me the hand. + ~ hooperConfessed = true + Hardly sporting, of course. + * * * * * [Confess] + Well, then. I suppose this must be what it feels like to have a conscience. I suppose I had always wondered. + "Harris, sir. I don't know what Hooper's playing at, sir. But I can't let him do this." + "Do what?" + "Take the rope for this. I took it, sir. + ~ revealedhooperasculprit = false + ~ losttemper = false + -> reveal_location_of_component + * * * * * [Don't confess] + * * * * [Don't confess] + * * * [Don't confess] + - - - "I certainly don't. But still, I'm surprised. I had Hooper down for a full—blown double agent, a traitor. He knows he'll face the rope, doesn't he?" + "Don't ask me to explain why he did what he did," Harris sighs. "Just be grateful that he did, and you're now off the hook." + - - Curiouser and curiouser. I nod once to Harris and slip outside into the cold morning air. + { hooperClueType == NONE : + Hooper's confession only makes sense in one fashion{ hooperConfessed :, and that is his being dim—witted and slow| — if I successfully implied to him that I had him framed, but he did not unpack my little clue well enough to go looking for the component. Well, I had figured him for a more intelligent opponent, but a resignation from the game will suffice}. Or perhaps he knew he would be followed if he went to check, and decided he would be doomed either way. + - else: + Hooper's confession only makes sense in one way — and that's that he believed me. He reasoned that he would be followed. To try and uncover the component would have got him arrested, and to confess was the same. + He simply caved, and threw in his hand. + } + // Outside, possibly free + Of course, however, there is only one way to be certain that Harris is telling the truth, and that is to check the breeze—block at the back of Hut 2. + * * [Check] -> go_to_where_component_is_hidden + * * [Don't check] + But there will time for that later. If there is nothing there, then Hooper discovered the component after all and Harris' men will have swooped on him, and the story about his confession is just a ruse to test me out. + And if the component is still there — well. It will be just as valuable to my contact in a week's time, and his deadline of the 31st is not yet upon us. + -> head_for_my_dorm_free + + * { hooperClueType == NONE } [Wait] -> morning_not_saved + += morning_not_saved + // Not saved + Morning comes with the call of a rooster from the yard of the House. I must have slept after all. I pull myself up off the bunk, shivering slightly. There is condensation on the inside of the window. I have probably given myself a chill. + It's not long after that Harris enters the hut. He closes the door behind him, careful as ever, then takes a chair across from me. + "You smell like a dog," he remarks. + * (optimism) [Be optimistic] + "I'm looking forward to a long bath," I reply. "And getting back to work." + * (pessimism) [Be pessimistic] + "So would you after the night I've had." + + - -> harris_certain_is_you + + +=== harris_certain_is_you + "Well, I'm afraid it is going to get worse for you," Harris replies soberly. "We followed Hooper, and he took himself neatly to bed and slept like a boy scout. Which puts us back to square one, and you firmly in the frame. And I'm afraid I don't have time for any more games. I want you to tell me where that component is, or we will hang you as a traitor." + ~ revealedhooperasculprit = false + ~ losttemper = false + -> harris_threatens_lynching + + + + +/*--------------------------------------------------------------- + Ending: they don't think it was you +---------------------------------------------------------------*/ + + +=== head_for_my_dorm_free +I head for my dorm, intent on a bath, breakfast, a glance at the crossword before the other men get to it, and then on with work. They should have replaced the component in the Bombe by now. We will only be a day behind. + { not framedhooper : + And then everything will proceed as before. The component will mean nothing to the Germans — this is the one fact I could never have explained to a man like Harris, even though the principle behind the Bombe is the same as the principle behind the army. The individual pieces — the men, the components — do not matter. They are identical. It is how they are arranged that counts. +} +I bump into Russell in the dorm hut. +"Did you hear?" he whispers. "Terrible news about Hooper. Absolutely terrible." + * [Yes] + "Quite terrible. I would never have guessed." + "Well." Russell harrumphs. + - - (quince) "Quince was saying this morning, apparently his grandfather was German. So perhaps it's to be expected. See you there?" + + * [No] + + "Heard what?" + - - (hooper_taken) "Hooper's been taken away. They caught him, uncovering that missing Bombe component from a hiding place somewhere, apparently about to take it to his contact." Russell harrumphs. -> quince + * [Lie] + "I don't know what you're talking about." + -> hooper_taken + * [Evade] + "If you'll excuse me, Russell. I was about to take a bath." + "Oh, of course. Worked all night, did you? Well, you'll hear soon enough. Can hardly hide the fact there'll only be three of us from now on." + +- I wave to him and move away, my thoughts turning to the young man in the village. My lover. My contact. My blackmailer. Hooper may have taken the fall for the missing component, but { not framedhooper :if he did recover it from Hut 2 then | its recovery does mean }I have nothing to sell to save my reputation{ i_met_a_young_man :, if I have any left}. + { not framedhooper : +If he didn't, of course, and Harris was telling the truth about his sudden confession, then I will be able to buy my freedom once and for all. +} + * { not framedhooper } [Get the component] -> go_to_where_component_is_hidden + * { not framedhooper } [Leave it] + I will have to leave that question for another day. To return there now, when they're probably watching my every step, would be suicide. After all, if Hooper { hooperClueType == STRAIGHT :followed|understood} my clue, he will have explained it to them to save his neck. They won't believe him — but they won't quite disbelieve him either. We're locked in a cycle now, him and me, of half—truth and probability. There's nothing either of us can do to put the other entirely into blame. + -> ending_return_to_normal + * [Act normal] + But there is nothing to be done about it. -> ending_return_to_normal + + + + +=== ending_return_to_normal +Nothing, that is, except to act as if there is no game being played. I'll have a bath, then start work as normal. I've got a week to find something to give my blackmailer{ i_met_a_young_man : — or give him nothing: it seems my superiors know about my indiscretions now already}. + * [Co-operate] + Something will turn up. It always does. An opportunity will present itself, and more easily now that Hooper is out of the way. + But for now, there's yesterday's intercept to be resolved. + + * [Dissemble] + Or perhaps I might hand my young blackmailer over my superiors instead for being the spy he is. + Perhaps that would be the moral thing to do, even, and not just the most smart. + But not today. Today, there's an intercept to resolve. + + * [Lie] + In a week's time, this whole affair will be in the past and quite forgotten. I'm quite sure of that. -> moreimportant + * (moreimportant) [Evade] I've more important problems to think about now. There's still yesterday's intercept to be resolved. +- The Bombe needs to be set up once more and set running. +It's time I tackled a problem I can solve. +// End - Scot Free +-> END + + +=== go_to_where_component_is_hidden + It won't take a moment to settle the matter. I can justify a walk past Hut 2 as part of my morning stroll. It will be obvious in a moment if the component is still there. + On my way across the paddocks, between the huts and the House, I catch sight of young Miss Lyon, arriving for work on her bicycle. She giggles as she sees me and waves. + * [Wave back] + I wave cheerily back and she giggles, almost drops her bicycle, then dashes away inside the House. Judging by the clock on the front gable, she's running a little late this morning. + * [Ignore her] + I give no reaction. She sighs to herself, as if this kind of behaviour is normal, and trots away inside the House to begin her duties. + - I turn the corner of Hut 3 and walk down the short gravel path to Hut 2. It was a good spot to choose — Hut 2 is where the electricians work, and they're generally focussed on what they're doing. They don't often come outside to smoke a cigarette so it's easy to slip past the doorway unnoticed. + * [Check inside] + I hop up the steps and put my head inside all the same. Nobody about. Still too early in the AM for sparks, I suppose. <> + * [Go around the back] + + - I head on around the back of the hut. The breeze—block with the cavity is on the left side. + * (check) [Check] + No time to waste. I drop to my knees and check the breeze—block. Sure enough, there's nothing there. Hooper took the bait. + Suddenly, there's a movement behind me. I look up to see, first a snub pistol, and then, Harris. + + * [Look around] + I pause to glance around, and catch a glimpse of movement. Someone ducking around the corner of the hut. Or a canvas sheet flapping in the light breeze. Impossible to be sure. + * * [Check the breeze—block] -> check + * * [Check around the side of the hut] + But too important to guess. I move back around the side of the hut. + Harris is there, leaning in against the wall. He holds a stub pistol in his hand. + + - { hooperClueType > STRAIGHT : + "{ hooperClueType == CHESS:Queen to rook two|Messy without one missing whatever it was}," he declares. "I wouldn't have fathomed it but Hooper did. Explained it right after we sprung him doing what you're doing now. We weren't sure what to believe but now, you seem to have resolved that for us." + - else: + "Hooper said you'd told him where to look. I didn't believe him. Or, well. I wasn't sure what to believe. Now I rather think you've settled it." + } + * [Agree] + "I have, rather." I put my hands into my pockets. "I seem to have done exactly that." + "I'm afraid my little story about Hooper confessing wasn't true. I wanted to see if you'd go to retrieve the part." Harris gestures me to start walking. "You were close, Manning, I'll give you that. I wanted to believe you. But I'm glad I didn't." + -> done + * [Lie] + "I spoke to Russell. He said he saw Hooper doing something round here. I wanted to see what it was." + + * [Evade] + "Harris, you'd better watch out. He's planted a time—bomb here." + Harris stares at me for a moment, then laughs. "Oh, goodness. That's rich." + I almost wish I had a way to make the hut explode, but of course I don't. + + - "Enough." Harris gestures for me to start walking. "This story couldn't be simpler. You took it to cover your back. You hid it. You lied to get Hooper into trouble, and when you thought you'd won, you came to scoop your prize. A good hand but ultimately, { hooperClueType <= STRAIGHT :if it hadn't have been you who hid the component, then you wouldn't be here now|you told Hooper where to look with your little riddle}." + + - (done) + // End - Caught in AM + He leads me across the yard. Back towards Hut 5 to be decoded, and taken to pieces, once again. + -> END + + +/*--------------------------------------------------------------- + Ending: they think it was you +---------------------------------------------------------------*/ + +=== harris_threatens_lynching + { harris_certain_is_you:He passes a hand across his eyes with a long look of despair.|He gets to his feet, and gathers his gloves from the table top.} + "I'm going to go outside and organise a rope. That'll take about twelve minutes. That's how long you have to decide." + * [Protest] + "You can't do this!" I cry. "It's murder! I demand a trial, a lawyer; for God's sake, man, you can't just throw me overboard, we're not barbarians...!" + - - (too_clever) "You leave me no choice," Harris snaps back, eyes cold as gun—metal. "You and your damn cyphers. Your damn clever problems. If men like you didn't exist, if we could just all be straight with one another." He gets to his feet and heads for the door. "I fear for the future of this world, with men like you in. Reich or no Reich, Mr Manning, people like you simply complicate matters." + -> left_alone + * { not gotcomponent && not throwncomponentaway } [Confess] + I nod. "I don't need twelve minutes. -> reveal_location_of_component + * [Stay silent] -> my_lips_are_sealed + * { gotcomponent } [Show him the component] + "I don't need twelve minutes. Here it is." + I open my jacket and pull the Bombe component out of my pocket. Harris takes it from me, whistling, curious. + "Well, I'll be. That's it all right." + "That's it." + "But you didn't have it on you yesterday." + * * [Explain] + "I climbed out of the window overnight," I explain. "I went and got this from where it was hidden, and brought it back here." + * * [Don't explain] + "No. I didn't." + - -> all_too_farfetched + + * { throwncomponentaway } [Confess] + "I don't need twelve minutes. The component is in the long grass behind Hooper's tent. I threw it there hoping to somehow frame him, but now I see that won't be possible. I was naive, I suppose." + ~ piecereturned = true + -> reveal_location_of_component.harris_believes + + * { throwncomponentaway } [Frame Hooper] + "Look, I know where it is. The missing piece of the Bombe is in the long grasses behind Hooper's tent. I saw him throw it there right after we finished work. He knew you'd scour the camp but I suppose he thought you'd more obvious places first. I suppose he was right about that. Look there. That proves his guilt." + ~ longgrasshooperframe = true + ~ piecereturned = true + "That doesn't prove anything," Harris returns sharply. "But we'll check what you say, all the same." He gets to his feet and heads out of the door. + -> left_alone + + + +=== reveal_location_of_component + <> The missing component of the Bombe computer is hidden in a small cavity in a breeze—block supporting the left rear post of Hut 2. I put in there anticipating a search. I intended to { revealedhooperasculprit:pass it to Hooper|dispose of it} once the fuss had died down. I suppose I was foolish to think that it might." + ~ piecereturned = true + -> harris_believes += harris_believes + { not night_falls.hooper_didnt_give_himself_up : + "Indeed. And Mr Manning: God help you if you're lying to me." + - else: + "I thought as much. I hadn't expected you to give it out so easily, however. You understand, Hooper has said nothing, of course. In fact, he went to Hut 2 directly after we released him and uncovered the component. But he told us you had instructed him where to go. Hence my little double bluff. Frankly, I'll be glad when I'm shot of the lot of you mathematicians." + } + Harris stands, and slips away smartly. -> left_alone + + + +=== my_lips_are_sealed + I say nothing, my lips tightly, firmly sealed. It's true I am a traitor, to the very laws of nature. The world has taught me that since a very early age. But not to my country — should the Reich win this war, I would hardly be treated as an honoured hero. I was doomed from the very start. + ~ notraitor = true + I explain none of this. How could a man like Harris understand? + The Commander takes one look back from the doorway as he pulls it to. + "It's been a pleasure working with you, Mr Manning," he declares. "You've done a great service to this country. If we come through, I'm sure they'll remember you name. I'm sorry it had to end this way and I'll do my best to keep it quiet. No—one need know what you did." + -> left_alone + + + + +=== all_too_farfetched + // Returned Component + "This is all too far—fetched," Harris says. "I'm glad to have this back, but I need to think." + Getting to his feet, he nods once. "You'll have to wait a little longer, I'm afraid, Manning." + Then he steps out of the door, muttering to himself. + -> make_your_peace + + + +=== left_alone + // Alone, about to die + { slam_door_shut_and_gone.time_to_move_now :The Commander holds the door for his superior, and follows him out.} Then the door closes. I am alone again, as I have been for most of my short life. + -> make_your_peace + + +=== make_your_peace + * [Make your peace] + - I am waiting again. I have no God to make my peace with. I find it difficult to believe in goodness of any kind, in a world such as this. + { not notraitor: + ~ notraitor = true + But I am no traitor. Not to my country. To my sex, perhaps. But how could I support the Reich? If the Nazis were to come to power, I would be worse off than ever. + } + { harris_threatens_lynching.too_clever: + In truth, it is men like Harris who are complex, not men like me. I live to make things ordered, systematic. I like my pencils sharpened and lined up in a row. I do not deal in difficult borders, or uncertainties, or alliances. If I could, I would reduce the world to something easier to understand, something finite. + But I cannot, not even here, in our little haven from the horrors of the war. + } + I have no place here. No way to fit. I am caught, in the middle, cryptic and understood only thinly, through my machines. + * I must seem very calm. + * Perhaps I should try to escape.[] But escape to where? I am already a prisoner. Jail would be a blessing. -> monastic + - <> I suppose I do not believe they will hang me. They will lock me up and continue to use my brain, if they can. I wonder what they will tell the world — perhaps that I have taken my own life. That would be simplest. The few who know me would believe it. + Well, then. Not a bad existence, in prison. Removed from temptation. + - (monastic) A monastic life, with plenty of problems to keep me going. + I wonder what else I might yet unravel before I'm done? + * The door is opening.[] Harris is returning. Our little calculation here is complete. { not piecereturned: I can only hope one of the others will be able to explain to him that the part I stole will mean nothing to the Germans.|We are just pieces in this machine; interchangeable and prone to wear.} + - That is the true secret of the calculating engine, and the source of its power. It is not the components that matter, they are quite repetitive. What matters is how they are wired; the diversity of the patterns and structures they can form. Much like people — it is how they connect that determines our victories and tragedies, and not their genius. + Which makes me wonder. Should I give { i_met_a_young_man :up my beautiful young man|the young man who put me in this spot} to them as well as myself? + * [Yes] + But of course I will. { forceful > 2:Perhaps I can persuade them to put him in my cell.|A little vengeance, disguised as doing something good.} + * [No] + No. What would be the use? He will be long gone, and the name he told me is no doubt hokum. No: I was alone before in guilt, and I am thus alone again. + * [Lie] + No. Why would I? He is no doubt an innocent himself, trapped by some dire circumstance. Forced to act the way he did. I have every sympathy for him. + Of course I do. + * [Evade] + It depends, perhaps, on what his name his worth. If it were to prove valuable, well; perhaps I can concoct a few more such lovers with which to ease my later days. + { hooper_mentioned: Hooper, perhaps. He wouldn't like that. } + - { not longgrasshooperframe : + Harris put the cuffs around my wrists. "I still have the intercept in my pocket," I remark. "Wherever we're going, could I have a pencil?" + - else: + "We recovered the part, just where you said it was," Harris reports, as he puts the cuffs around my wrists. "Of course, a couple of the men swear blind they searched there yesterday, so I'm afraid, what with the broken window... we've formed a perfectly good theory which doesn't bode well for you." + } + ~ piecereturned = true + { longgrasshooperframe : + "I see." It doesn't seem worth arguing any further. "I still have the intercept in my pocket," I remark. "Wherever we're going, could I have a pencil?" + } + He looks me in the eye. + { not losttemper : + "Of course. And one of your computing things, if I get my way. And when we're old, and smoking pipes together in The Rag like heroes, I'll explain to you the way that decent men have affairs. + - else: + "I'll give you a stone to chisel notches in the wall. And that's all the calculations you'll be doing. And as you sit there, pissing into a bucket and growing a beard down to your toes, you have a think about how a smart man would conduct his illicit affairs. With a bit of due decorum you could have learnt off any squaddie. + } + <> You scientists." + He drags me up to my feet. + "You think you have to re—invent everything." + With that, he hustles me out of the door and I can't help thinking that, with a little more strategy, I could still have won the day. But too late now, of course. + -> END diff --git a/data/ink/kaiserpunk.ink.json b/data/ink/kaiserpunk.ink.json new file mode 100644 index 0000000..77a9821 --- /dev/null +++ b/data/ink/kaiserpunk.ink.json @@ -0,0 +1 @@ +{"inkVersion":21,"root":[[{"->":"intro_train"},["done",{"#n":"g-0"}],null],"done",{"intro_train":[["^The train has left Vienna behind, though Vienna has not yet left you. ","#","^chapter[Eibenreith] ","/#","#","^music[Kaiserpunk Waltz.mp3](crossfade, loop, lead=8)","/#","\n","^It clings to the black gloss of your travelling boots, to the cut of your coat, to the stiff little prison of your gloves. It lives in the seal upon the letter folded inside your reticule, in the thin scent of coal smoke that has insinuated itself even into first-class upholstery, in the fact that Herr Viktor Nowak sits opposite you as if the carriage were a field office and not a compartment lined in velvet, polished wood, and brass.","\n","^Outside the window, the last outskirts of the capital have broken apart into winter-browned fields and villages with church towers too small to compete with the engine's whistle. The rails take the land without asking permission. Embankments cut through orchards. Telegraph poles pass at regular intervals, each one vanishing behind you like a thought dismissed too quickly. ","#","^sfx[steam-whistle.ogg]","/#","\n","^You had expected the train to feel like a triumph of the age.","\n","^Instead it feels like an argument. ","#","^image[suedbahn.png](landscape)","/#","\n","^The machine throws itself southward with a violence that polite society would never admit to admiring. The lamps tremble in their fittings. Your cup rattles against its saucer. Beyond the glass, the country begins to rise, first gently, then with a firmer will, until the line itself seems to negotiate with the mountains through stone arches, black tunnels, and viaducts thrown across ravines with all the confidence of imperial engineering.","\n","^Viktor has not looked impressed once.","\n","^His civilian clothes are correct enough to pass without comment: dark frock coat, sober waistcoat, gloves, collar immaculate, the posture of a man who has never truly sat at ease in his life. But no tailor can disguise discipline. It remains in his shoulders, in the economy of his movements, in the way his eyes measure doors, windows, luggage rack, corridor, your face, then the door again.","\n","^On the paperwork he is your secretary and travelling companion.","\n","^In truth, he is an officer lent to a delicate matter by channels that prefer not to be named. Rittmeister Viktor Alois Nowak, though no one at Jagdhaus Hohenreith is expected to call him that. Your hosts have asked for a medium. The Cabinet has sent them you. The military has sent him to make certain that you do not become a scandal before you become useful.","\n","^He folds the newspaper, though you are quite certain he had not been reading it.","\n","^\"You have been very quiet, gnädiges Fräulein.\"","\n","^The form of address is technically correct if you are noble, excessive if you are not, and perfectly chosen because he does not yet know which part of you is useful, which part is costume, and which part is threat.","\n","^\"For a lady on her first official journey,\" he adds, \"you show remarkable restraint.\"","\n","^You look around the compartment before you answer. The answer comes from somewhere older than the letter in your reticule. It comes from the place you began.","\n","ev","str","^The compartment seems built for people who never wonder whether they belong in it.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^You count the cost of each detail before you can stop yourself.","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^You notice first how clean everything is, and how carefully one must sit so as not to betray noticing.","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","#","^class:noble","/#","\n","ev","str","^noble","/str","/ev",{"VAR=":"birth_class","re":true},"ev",{"VAR?":"class_confidence"},2,"+",{"VAR=":"class_confidence","re":true},"/ev","ev",{"VAR?":"court_loyalty"},1,"+",{"VAR=":"court_loyalty","re":true},"/ev","^It is not luxury that unsettles you. Luxury is only wood, cloth, brass, service, silence. What matters is whether the servants glance twice, whether the guard lowers his voice, whether another passenger weighs your gloves and decides not to ask your business.","\n","^You were born among people who understood such things before they understood kindness.","\n",{"->":"class_noble_background"},{"#f":5}],"c-1":["^ ","#","^class:middle","/#","\n","ev","str","^middle","/str","/ev",{"VAR=":"birth_class","re":true},"ev",{"VAR?":"class_confidence"},1,"+",{"VAR=":"class_confidence","re":true},"/ev","^The upholstery, the lamps, the polished veneer, the quiet attendance at stations: none of it is magical. It is paid for. Accounted for. Itemised somewhere by someone with ink on his cuffs and a wife who knows how long candles may be burned before the household budget complains.","\n","^You were not born to this compartment, but you were born close enough to study its rules.","\n",{"->":"class_middle_background"},{"#f":5}],"c-2":["^ ","#","^class:working","/#","\n","ev","str","^working","/str","/ev",{"VAR=":"birth_class","re":true},"ev",{"VAR?":"class_confidence"},1,"-",{"VAR=":"class_confidence","re":true},"/ev","^The velvet looks soft enough to swallow fingerprints. The brass fittings have been polished by hands that will never sit here. The little curtain strap is worn where other travellers, all of them more certain than you, have touched it without gratitude.","\n","^You were not born on this side of service.","\n",{"->":"class_working_background"},{"#f":5}]}],null],"class_noble_background":["^\"Restraint is not a virtue, Herr Nowak,\" you say. \"It is often only good breeding with its mouth shut.\"","\n","^His brows move almost imperceptibly.","\n","^You learned young that every room contains a court, even when no emperor is present. A girl of your rank is trained to enter, to bow, to be introduced, to be placed, to speak only enough, to understand more than she admits, and to know that a family name can be both a key and a chain.","\n","^Your own family possesses no grand seat, no army of retainers, no ancient right to command provinces. But your name opened drawing-room doors in Vienna, and once inside those rooms you learned to make people repeat stories they had meant only to hint at. You learned how widows speak when priests are absent, how officers lie when flattered, how old men confess when they believe themselves admired, and how a young woman may be underestimated so consistently that underestimation becomes a profession.","\n","^Your reputation as a medium did not descend from heaven. It was assembled from half-lights, correct guesses, careful silences, and the willingness of better-born fools to mistake performance for revelation.","\n","^Before the court could use you, society had first to invent you.","\n","^Now choose the name by which Vienna invented you.","\n",{"->":"choose_name_noble"},null],"class_middle_background":["^\"Restraint,\" you say, \"is easier when one has learned that every mistake is remembered by someone better placed.\"","\n","^Viktor watches you more closely.","\n","^You were born in that broad, anxious territory between deference and ambition. Your family had books, invoices, respectability, perhaps a piano no one played well enough, perhaps a father with an office, a mother with callers, brothers who were expected to advance, and daughters who were expected not to make advancement look hungry.","\n","^You learned accounts before etiquette, etiquette before French, and French before you learned how easily a woman with a calm voice could make men explain themselves. You rose because you listened. You rose because you understood that fraud, faith, medicine, gossip, politics, and grief all use the same doors into the human mind.","\n","^The court does not like to admit that it needs middle-class competence. It prefers to borrow it, dress it properly, and call it discretion.","\n","^Your reputation as a medium gave them a word that sounded less dangerous than investigator.","\n","^Now choose the name under which you entered the salons that first laughed at you, then invited you back.","\n",{"->":"choose_name_middle"},null],"class_working_background":["^\"Restraint,\" you say, \"is what people praise when they prefer not to see the effort.\"","\n","^The newspaper in Viktor's hand creases once.","\n","^You were born among people who owned little but obligations. Work had a sound before it had a meaning: water, broom, bootsteps, breath, the clatter of dishes, the cough of men coming in from cold yards, women counting coins under their breath. You learned early that the high-born are not more observant than others. They are merely less often required to observe.","\n","^That was your first advantage.","\n","^A servant knows which door matters because she uses the others. A seamstress learns bodies because she measures them. A maid learns secrets because fine people leave their souls lying about like gloves, certain that no one beneath them has hands.","\n","^You rose by talent, patronage, imitation, nerve, and the terrible convenience of being believed harmless. By the time Vienna began whispering that you saw more than respectable people saw, you had already spent years seeing what respectable people missed.","\n","^The court has placed you in first class because it needs what birth did not give you.","\n","^Now choose the name you carried upward, altered perhaps in pronunciation, never quite cleansed of where it began.","\n",{"->":"choose_name_working"},null],"choose_name_noble":[["ev","str","^Valerie Eleonore Josepha","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Helene Cäcilie Franziska","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Clara Theresia Leopoldine","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Sophie Eleonore Auguste","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Mathilde Josepha Henriette","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Therese Valerie Franziska","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Ilona Theresia Eleonore","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Zdenka Eleonore Josepha","/str","/ev",{"*":".^.c-7","flg":20},{"c-0":["\n","ev","str","^Valerie Eleonore Josepha","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Valerie","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-1":["\n","ev","str","^Helene Cäcilie Franziska","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Helene","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-2":["\n","ev","str","^Clara Theresia Leopoldine","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Clara","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-3":["\n","ev","str","^Sophie Eleonore Auguste","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Sophie","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-4":["\n","ev","str","^Mathilde Josepha Henriette","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Mathilde","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-5":["\n","ev","str","^Therese Valerie Franziska","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Therese","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-6":["\n","ev","str","^Ilona Theresia Eleonore","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Ilona","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}],"c-7":["\n","ev","str","^Zdenka Eleonore Josepha","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Zdenka","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_noble"},{"#f":5}]}],null],"choose_surname_noble":[["^Your title is fixed by birth and by the careful modesty of your family: not countess, not princess, not one of the brilliant names that gather ambassadors and creditors like dust.","\n","^A Freiin. Baronial. Usable. Admitted, but not enthroned.","\n","ev","str","^Freiin von Rauhenfels","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Freiin von Traunegg","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Freiin von Ebenwald","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Freiin von Arnsberg","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Freiin von Reichenau","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Freiin von Waldstätten","/str","/ev",{"*":".^.c-5","flg":20},{"c-0":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Rauhenfels","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-1":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Traunegg","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-2":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Ebenwald","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-3":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Arnsberg","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-4":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Reichenau","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-5":["\n","ev","str","^Freiin von","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Waldstätten","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}]}],null],"choose_name_middle":[["ev","str","^Clara Eleonore","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Anna Katharina","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Helene Theresia","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Rosa Franziska","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Johanna Elise","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Katharina Sophie","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Therese Leopoldine","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Magdalena Cäcilie","/str","/ev",{"*":".^.c-7","flg":20},{"c-0":["\n","ev","str","^Clara Eleonore","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Clara","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-1":["\n","ev","str","^Anna Katharina","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Anna","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-2":["\n","ev","str","^Helene Theresia","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Helene","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-3":["\n","ev","str","^Rosa Franziska","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Rosa","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-4":["\n","ev","str","^Johanna Elise","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Johanna","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-5":["\n","ev","str","^Katharina Sophie","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Katharina","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-6":["\n","ev","str","^Therese Leopoldine","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Therese","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}],"c-7":["\n","ev","str","^Magdalena Cäcilie","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Magdalena","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_middle"},{"#f":5}]}],null],"choose_surname_middle":[["^Your family name contains no particle to soften the ascent. It must stand upright by itself.","\n","ev","str","^Leitner","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Wagner","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Kellner","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Baumgartner","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Fischer","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Schmid","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Pichler","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Rosenfeld","/str","/ev",{"*":".^.c-7","flg":20},{"c-0":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Leitner","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-1":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Wagner","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-2":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Kellner","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-3":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Baumgartner","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-4":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Fischer","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-5":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Schmid","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-6":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Pichler","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-7":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Rosenfeld","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}]}],null],"choose_name_working":[["ev","str","^Anna","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Klara","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Agnes","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Leni","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Rosa","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Gertrud","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Elisabeth","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Franziska","/str","/ev",{"*":".^.c-7","flg":20},{"c-0":["\n","ev","str","^Anna","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Anna","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-1":["\n","ev","str","^Klara","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Klara","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-2":["\n","ev","str","^Agnes","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Agnes","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-3":["\n","ev","str","^Leni","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Leni","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-4":["\n","ev","str","^Rosa","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Rosa","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-5":["\n","ev","str","^Gertrud","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Gertrud","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-6":["\n","ev","str","^Elisabeth","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Elisabeth","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}],"c-7":["\n","ev","str","^Franziska","/str","/ev",{"VAR=":"given_names","re":true},"ev","str","^Franziska","/str","/ev",{"VAR=":"common_name","re":true},{"->":"choose_surname_working"},{"#f":5}]}],null],"choose_surname_working":[["^A simple name can be a burden in Vienna. It tells people how little they must pretend to respect you before you have spoken.","\n","ev","str","^Pichler","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Huber","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Maier","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Gruber","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Schuster","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Krenn","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Wolf","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Moser","/str","/ev",{"*":".^.c-7","flg":20},{"c-0":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Pichler","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-1":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Huber","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-2":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Maier","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-3":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Gruber","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-4":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Schuster","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-5":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Krenn","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-6":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Wolf","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}],"c-7":["\n","ev","str","^Fräulein","/str","/ev",{"VAR=":"title_part","re":true},"ev","str","^Moser","/str","/ev",{"VAR=":"surname","re":true},{"->":"assemble_full_name"},{"#f":5}]}],null],"assemble_full_name":["ev",{"VAR?":"birth_class"},"str","^noble","/str","==","/ev",[{"->":".^.b","c":true},{"b":["\n","ev",{"VAR?":"given_names"},"str","^ ","/str","+",{"VAR?":"title_part"},"+","str","^ ","/str","+",{"VAR?":"surname"},"+","/ev",{"VAR=":"full_name","re":true},{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["\n","ev",{"VAR?":"title_part"},"str","^ ","/str","+",{"VAR?":"given_names"},"+","str","^ ","/str","+",{"VAR?":"surname"},"+","/ev",{"VAR=":"full_name","re":true},{"->":".^.^.^.9"},null]}],"nop","\n","ev",{"VAR?":"birth_class"},"str","^noble","/str","==","/ev",[{"->":".^.b","c":true},{"b":["\n","^On visiting cards, in letters, in the cautious mouths of servants, you are ","ev",{"VAR?":"full_name"},"out","/ev","^.","\n",{"->":".^.^.^.20"},null]}],[{"->":".^.b"},{"b":["\n","^On railway documents, hotel ledgers, and the tongues of people who have not yet decided how much respect you deserve, you are ","ev",{"VAR?":"full_name"},"out","/ev","^.","\n",{"->":".^.^.^.20"},null]}],"nop","\n","^But in the private chamber where a name is first answered before it is performed, you are ","ev",{"VAR?":"common_name"},"out","/ev","^.","\n","^Viktor has waited through your silence with a soldier's patience and a jailer's courtesy. The train enters another tunnel. For several seconds the compartment window gives you back only your own reflection: your hat, your pale face above the dark collar, your eyes too steady or not steady enough.","\n","^When the mountains return, they seem closer.","\n",{"->":"supernatural_stance"},null],"supernatural_stance":[["^The letter of commission in your reticule does not call you an investigator.","\n","^It calls you, in prose dry enough to pass through any number of offices, a woman whose unusual spiritual reputation has recommended her to a delicate household matter. The phrasing is exquisite. It neither affirms nor denies. It permits everyone involved to believe afterward that they had believed nothing improper.","\n","^The comital family at Jagdhaus Hohenreith has asked for discretion. Vienna has answered with a sealed letter, a woman reputed to speak with what is hidden, and a man opposite her who has orders of his own.","\n","^Before this journey, before this train, before the mountains began taking the sky piece by piece, what did you believe?","\n","ev","str","^The dead are not silent. The living are merely poor listeners.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^The supernatural is usually pain, fraud, fever, inheritance, or bad ventilation.","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Belief is a costume. You wear it because men insist on dressing you in it.","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^You have learned not to decide too early.","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ","#","^supernatural:believer","/#","\n","ev","str","^believer","/str","/ev",{"VAR=":"supernatural_belief","re":true},"ev",{"VAR?":"medium_reputation"},1,"+",{"VAR=":"medium_reputation","re":true},"/ev","ev",{"VAR?":"supernatural_exposure"},1,"+",{"VAR=":"supernatural_exposure","re":true},"/ev","^You have always thought disbelief a provincial arrogance of the educated. There are pressures in rooms where grief has been. There are words people speak before they know they have spoken. There are dreams that arrive with mud on their hems.","\n","^Perhaps the world is not haunted. Perhaps it is simply crowded.","\n",{"->":"spiritual_senses"},{"#f":5}],"c-1":["^ ","#","^supernatural:sceptic ","/#","#","^route:detective","/#","\n","ev","str","^sceptic","/str","/ev",{"VAR=":"supernatural_belief","re":true},"ev",{"VAR?":"detective"},1,"+",{"VAR=":"detective","re":true},"/ev","^The word spirit covers too much and explains too little. You have watched respectable people call an echo a message, a coincidence a sign, a trembling hand an angelic visitation. Men of science can be fools, but fools with candles and planchettes are no improvement.","\n","^If Hohenreith has ghosts, you expect them to keep accounts, write letters, leave footprints, and benefit someone.","\n",{"->":"spiritual_senses"},{"#f":5}],"c-2":["^ ","#","^supernatural:performer","/#","\n","ev","str","^performer","/str","/ev",{"VAR=":"supernatural_belief","re":true},"ev",{"VAR?":"medium_reputation"},2,"+",{"VAR=":"medium_reputation","re":true},"/ev","^You discovered early that men who distrust a woman's mind will sometimes worship her nerves. A conclusion from evidence irritates them. A vision, sighed through lowered lashes, makes them lean closer.","\n","^Very well. Let them lean.","\n",{"->":"spiritual_senses"},{"#f":5}],"c-3":["^ ","#","^supernatural:undecided","/#","\n","ev","str","^undecided","/str","/ev",{"VAR=":"supernatural_belief","re":true},"^There are things you can explain, things you cannot yet explain, and things that explanation damages before it helps. You have made a profession of standing at thresholds with a face composed enough for both sides to continue speaking.","\n","^Hohenreith will have to show you what kind of case it is.","\n",{"->":"spiritual_senses"},{"#f":5}]}],null],"spiritual_senses":[["^Belief is one matter. Experience is another.","\n","^People call a woman sensitive when they want her perceptions to sound like an illness. They call her hysterical when those perceptions inconvenience them. They call her inspired when they need her, and unstable when they do not.","\n","^What, beneath reputation and performance, has truly happened to you?","\n","ev","str","^There have been moments you cannot explain away.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Everything you do can be explained by observation, timing, and nerve.","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Something happens, but never when summoned.","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^You buried the first signs so thoroughly that even you do not know what remains.","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ","#","^powers:genuine","/#","\n","ev","str","^genuine","/str","/ev",{"VAR=":"supernatural_senses","re":true},"ev",{"VAR?":"supernatural_exposure"},2,"+",{"VAR=":"supernatural_exposure","re":true},"/ev","^Once, as a child, you knew before the telegram came. Once, in a crowded room, a stranger's grief entered you with such force that your own knees failed. Once, in a mirror, you saw a door behind you that was not in the room when you turned.","\n","^You learned caution after that. It is unwise for a woman to know things before a man has asked her opinion.","\n",{"->":"viktor_first_exchange"},{"#f":5}],"c-1":["^ ","#","^powers:faked ","/#","#","^route:detective","/#","\n","ev","str","^faked","/str","/ev",{"VAR=":"supernatural_senses","re":true},"ev",{"VAR?":"detective"},1,"+",{"VAR=":"detective","re":true},"/ev","^You notice rings removed too recently, mourning gloves worn too carefully, letters folded and refolded until the crease gives away the reader's obsession. You hear servants misname guests, mothers pause before daughters' rooms, officers lie by becoming too exact.","\n","^The dead have never told you anything. The living cannot stop telling you everything.","\n",{"->":"viktor_first_exchange"},{"#f":5}],"c-2":["^ ","#","^powers:ambiguous","/#","\n","ev","str","^ambiguous","/str","/ev",{"VAR=":"supernatural_senses","re":true},"ev",{"VAR?":"supernatural_exposure"},1,"+",{"VAR=":"supernatural_exposure","re":true},"/ev","^Your reputation depends upon command. The truth, if truth it is, has no respect for appointments.","\n","^Sometimes a room changes pressure around you. Sometimes a face acquires an old expression no living person taught it. Sometimes names arrive before introductions. But the harder you reach, the more ordinary the world becomes.","\n",{"->":"viktor_first_exchange"},{"#f":5}],"c-3":["^ ","#","^powers:repressed ","/#","#","^route:eccentric","/#","\n","ev","str","^repressed","/str","/ev",{"VAR=":"supernatural_senses","re":true},"ev",{"VAR?":"eccentric"},1,"+",{"VAR=":"eccentric","re":true},"/ev","^There are childhood memories sealed behind politeness: a nursery mirror turned to the wall, a nurse dismissed without reference, your mother's hand tightening around your wrist until the bones complained.","\n","^You became strange afterward in ways society found easier to admire than understand.","\n",{"->":"viktor_first_exchange"},{"#f":5}]}],null],"viktor_first_exchange":[["^The train emerges from the tunnel into a pale afternoon cut by dark firs and white rock. Far below, water shows itself only in flashes. The valley is no longer a view from a salon painting. It has depth enough to hide things.","\n","^Viktor opens a leather folder and removes a memorandum. He does not hand it to you at once.","\n","^\"When we leave the railway,\" he says, \"we will be met by a coach from Hohenreith. From that moment, appearances matter. Your hosts have been told that I assist with correspondence, travel, and practical arrangements. They need not be troubled with military definitions.\"","\n","^\"And the villagers?\" you ask.","\n","^\"The villagers need not be troubled with anything.\"","\n","^There it is: the empire in miniature. A man, a folder, a locked sentence.","\n","^\"You will be addressed according to the station you present,\" he continues. \"The Graf's household will observe rank. Servants will observe what the household observes. Villagers may observe less and remember more. I advise restraint.\"","\n","^The advice is sound. That makes it no less irritating.","\n","^How do you answer him?","\n","ev","str","^\"If gentlemen were less easily led, Herr Nowak, ladies would require fewer methods.\"","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^\"If you wish me to pass as harmless, you must stop warning me like a gaoler.\"","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^\"Then let us be exact. What do they know, what do they suspect, and what am I permitted to verify?\"","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^\"I shall do my best not to faint unless it is useful.\"","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^\"Restraint is what timid people call obedience after they have forgotten who trained them.\"","/str","/ev",{"*":".^.c-4","flg":20},{"c-0":["^ ","#","^route:lover","/#","\n","ev",{"VAR?":"lover"},1,"+",{"VAR=":"lover","re":true},"/ev","ev","str","^provocation","/str","/ev",{"VAR=":"viktor_relation","re":true},"ev",{"VAR?":"viktor_trust"},1,"-",{"VAR=":"viktor_trust","re":true},"/ev","ev",{"VAR?":"viktor_suspicion"},1,"+",{"VAR=":"viktor_suspicion","re":true},"/ev","^For the first time, amusement almost reaches his mouth.","\n","^\"A dangerous doctrine.\"","\n","^\"A practical one.\"","\n","^\"You intend to practice it at Hohenreith?\"","\n","^\"Only where patriotism requires sacrifice.\"","\n","^He looks down at the memorandum, but not quickly enough to conceal that he is reassessing you.","\n",{"->":"viktor_explains_orders"},{"#f":5}],"c-1":["^ ","#","^route:sapphic","/#","\n","ev",{"VAR?":"sapphic"},1,"+",{"VAR=":"sapphic","re":true},"/ev","ev","str","^tension","/str","/ev",{"VAR=":"viktor_relation","re":true},"ev",{"VAR?":"viktor_suspicion"},1,"+",{"VAR=":"viktor_suspicion","re":true},"/ev","^His gaze sharpens.","\n","^\"I am not your gaoler.\"","\n","^\"No. A gaoler is at least honest about the key.\"","\n","^The words surprise you by leaving a mark. Not on him, perhaps. On yourself. The closer the train carries you to Amalia's world, though you do not yet know her face, the more intolerable it seems that every female life there might be guarded by men who call the guarding concern.","\n","^Viktor folds the memorandum once, precisely.","\n",{"->":"viktor_explains_orders"},{"#f":5}],"c-2":["^ ","#","^route:detective","/#","\n","ev",{"VAR?":"detective"},1,"+",{"VAR=":"detective","re":true},"/ev","ev","str","^professional","/str","/ev",{"VAR=":"viktor_relation","re":true},"ev",{"VAR?":"viktor_trust"},1,"+",{"VAR=":"viktor_trust","re":true},"/ev","^He gives the smallest nod, as if you have chosen the only answer fit for adults.","\n","^\"They know that you come recommended. They suspect that you may be able to settle disturbances without police, priest, or press. You are permitted to verify fraud, coercion, threat to public order, or credible phenomena not presently classifiable.\"","\n","^\"Credible phenomena not presently classifiable.\"","\n","^\"That is the phrase.\"","\n","^\"A bureaucratic ghost.\"","\n","^\"The safest kind.\"","\n",{"->":"viktor_explains_orders"},{"#f":5}],"c-3":["^ ","#","^route:careless","/#","\n","ev",{"VAR?":"careless"},1,"+",{"VAR=":"careless","re":true},"/ev","ev","str","^dependence","/str","/ev",{"VAR=":"viktor_relation","re":true},"ev",{"VAR?":"viktor_trust"},1,"-",{"VAR=":"viktor_trust","re":true},"/ev","^Something in his expression tightens; not contempt exactly, but readiness.","\n","^\"I would prefer you did not faint at all.\"","\n","^\"How ungallant.\"","\n","^\"How practical.\"","\n","^\"Then you must be practical for both of us. I have never trusted the floor in strange houses.\"","\n","^His answer is delayed by half a breath.","\n","^\"That, gnädiges Fräulein, is precisely what concerns me.\"","\n",{"->":"viktor_explains_orders"},{"#f":5}],"c-4":["^ ","#","^route:eccentric","/#","\n","ev",{"VAR?":"eccentric"},1,"+",{"VAR=":"eccentric","re":true},"/ev","ev","str","^challenge","/str","/ev",{"VAR=":"viktor_relation","re":true},"ev",{"VAR?":"viktor_suspicion"},2,"+",{"VAR=":"viktor_suspicion","re":true},"/ev","^Viktor studies you as he might study an unfamiliar weapon found in luggage.","\n","^\"You enjoy making enemies.\"","\n","^\"No. I dislike the laziness of letting fools remain undecided.\"","\n","^\"At Hohenreith, that dislike may become expensive.\"","\n","^\"Then the Graf should have invited someone cheaper.\"","\n","^The wheels strike a curve. The compartment leans. For a moment the two of you are held in the same narrow imbalance.","\n",{"->":"viktor_explains_orders"},{"#f":5}]}],null],"viktor_explains_orders":["^Viktor gives you the memorandum at last.","\n","^The document is not long. That is part of its menace. Long documents invite argument; short ones carry authority.","\n","^A comital household. A hunting residence in Upper Styria, not the family's principal seat. Reports of disturbances among servants and villagers. No police action requested. No public ecclesiastical inquiry desired. No press. No correspondence beyond approved channels. Your presence to be explained as a discreet consultation requested by the family. Herr Nowak to assist in practical matters.","\n","^No one has written the word ghost.","\n","^No one has written the word fraud.","\n","^No one has written the word daughter.","\n","^Yet the omissions arrange themselves around the page like furniture around a corpse.","\n","^\"There is another instruction,\" you say.","\n","^Viktor does not ask how you know.","\n","^\"There is always another instruction,\" he says.","\n","^\"For you.\"","\n","^\"Yes.\"","\n","^\"Concerning me?\"","\n","^\"Partly.\"","\n","^The train begins to slow. The rhythm changes first in the floor, then in the window, then in the body. Houses gather beside the line. A station roof appears between drifting smoke and the dark combs of forested slopes. ","#","^sfx[steam-whistle.ogg]","/#","\n","^\"Then I shall try to be worth the ink,\" you say.","\n","^\"I sincerely hope so.\"","\n","^You cannot decide whether it is an insult, a prayer, or his first honest sentence.","\n",{"->":"railway_station"},null],"railway_station":["^The station is small enough that the train seems briefly embarrassed to stop there. ","#","^chapter[The Station] ","/#","#","^image[muerzzuschlag.png](portrait)","/#","\n","^A porter in a cap too large for him hurries along the platform. A woman with a basket steps back from the steam as if from an animal. Somewhere beyond the station building, a cart horse stamps at frozen mud. The signboard gives the place a name you have seen in the timetable but will not remember with affection.","\n","^Your luggage descends in stages: trunk, hatbox, smaller travelling case, dispatch case, folded rug, a narrow black case whose contents would embarrass both a priest and a conjurer if either searched it without imagination. Viktor oversees the transfer with clipped civility. He does not carry like a servant. He directs like a man pretending not to command.","\n","^The coach from Hohenreith waits beyond the station yard: dark green paint, black wheels, the comital crest discreetly worn on the door, and two horses already restless beneath harness. The driver removes his hat when he sees you. Not too deeply. Deep enough for rank, not deep enough for reverence. ","#","^sfx[horse-neigh.ogg]","/#","\n","^\"Gnädiges Fräulein? Herr Sekretär?\"","\n","ev",{"VAR?":"birth_class"},"str","^noble","/str","==","/ev",[{"->":".^.b","c":true},{"b":["\n","^He has been told enough to place you. That is a courtesy. It is also a warning.","\n",{"->":".^.^.^.28"},null]}],[{"->":".^.b"},{"b":["\n","^He hesitates over you by the smallest measure. The hesitation is not rudeness. It is calculation. First-class carriage, court letter, no title beyond Fräulein, and a man beside you who looks like he has arrested people for less than staring.","\n",{"->":".^.^.^.28"},null]}],"nop","\n","^Viktor answers before you can.","\n","^\"From Jagdhaus Hohenreith?\"","\n","^\"Jawohl, Herr Sekretär. The road is passable. If the mist holds, we should reach Eibenreith before dark.\"","\n","^The word enters the air without ceremony.","\n","^Eibenreith.","\n","^Not Hohenreith, the name printed on the invitation in a clean hand. Eibenreith: the village below it. A smaller name. Older in the mouth. A name with roots rather than stationery.","\n",{"->":"coach_journey"},null],"coach_journey":[["^The coach leaves the station behind and with it the last easy evidence of empire. ","#","^chapter[The Graben] ","/#","#","^music[Kaiserpunk Jodler.mp3](crossfade, loop, lead=4)","/#","\n","^At first the road follows a valley where telegraph wire still keeps company with it and the river moves in a pale, stony bed. Sawmills, fenced meadows, and farmhouses appear and vanish behind stands of spruce. The mountains do not rise all at once. They advance by jurisdiction. A wooded slope claims the left-hand sky, then a grey wall of limestone closes the north, then another ridge gathers to the east until even the clouds seem to have entered service.","\n","^The driver names places when Viktor asks, but the names are local and practical, meant for men who know which bridge floods and which farm breeds stubborn horses. Somewhere beyond the visible ridges, he says, lies the great white back of the Hochschwab. Eastward, beyond forest and pass, the Hohe Veitsch keeps its own weather. He says this not as a guide would say it, but as a man explaining neighbours who may or may not be in a temper.","\n","^The main valley narrows.","\n","^The road turns from it into a side Graben, and the change is immediate. Sound alters. The wheels no longer ring against open distance but grind between banks, roots, and wet stone. The air smells of leaf mould, resin, and cold water. Yews appear among the firs in dark, improbable patience, their needles too black for the afternoon.","\n","^\"Eibenreither Graben,\" the driver says, and crosses himself so quickly that the gesture might have been meant for a rut in the road.","\n","^Viktor notices. Of course he notices.","\n","^\"Bad road?\" he asks.","\n","^\"Old road,\" the driver says.","\n","^No one speaks for a while.","\n","^You watch the trees.","\n","^There are forests that invite stories because they are pretty, and forests that reject stories because whatever happened there did not require witnesses. This one belongs to the second kind. Its trunks stand close, not wildly, but with the air of a crowd making room for something carried through it long ago. The snow that remains in hollows is not clean. It has gathered needles, bark, and a yellowish stain where water has risen underneath.","\n","^On a slope above the road, half swallowed by undergrowth, you glimpse stone.","\n","^A shrine, perhaps. A boundary marker. A figure. The coach has passed before your eyes can persuade themselves of its shape. For one instant you are left with the impression of a woman's head inclined not in prayer, but in listening. ","#","^image[statue.png](square)","/#","\n","ev",{"VAR?":"supernatural_senses"},"str","^genuine","/str","==",{"VAR?":"supernatural_senses"},"str","^ambiguous","/str","==","||",{"VAR?":"supernatural_senses"},"str","^repressed","/str","==","||","/ev",[{"->":".^.b","c":true},{"b":["\n","^The back of your neck tightens.","\n","^Not fear. Recognition would be worse.","\n","ev",{"VAR?":"supernatural_exposure"},1,"+",{"VAR=":"supernatural_exposure","re":true},"/ev",{"->":".^.^.^.58"},null]}],[{"->":".^.b"},{"b":["\n","^You tell yourself that old stone, seen through moving branches, will become whatever the mind is cowardly enough to supply.","\n",{"->":".^.^.^.58"},null]}],"nop","\n","^Viktor has turned slightly toward the same slope.","\n","^\"Did you see something?\" he asks.","\n","ev","str","^\"A woman in the wood, perhaps. Or a stone that wanted to be one.\"","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^\"A marker. I would like to know where that path leads.\"","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^\"Only trees. The sort that make one grateful for gentlemen with revolvers.\"","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^\"Would you believe me if I said I had?\"","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^\"No.\" ","/str","/ev",{"*":".^.c-4","flg":20},{"c-0":["^ ","#","^route:eccentric ","/#","#","^statue_hint","/#","\n","ev",{"VAR?":"eccentric"},1,"+",{"VAR=":"eccentric","re":true},"/ev","ev",{"VAR?":"viktor_suspicion"},1,"+",{"VAR=":"viktor_suspicion","re":true},"/ev","^He studies the passing trees.","\n","^\"A local shrine?\"","\n","^\"If it is a shrine, it has not been loved recently.\"","\n","^\"You speak as if stones notice neglect.\"","\n","^\"Do soldiers not?\"","\n","^He does not answer.","\n",{"->":"coach_nears_village"},{"#f":5}],"c-1":["^ ","#","^route:detective ","/#","#","^statue_hint","/#","\n","ev",{"VAR?":"detective"},1,"+",{"VAR=":"detective","re":true},"/ev","ev",{"VAR?":"viktor_trust"},1,"+",{"VAR=":"viktor_trust","re":true},"/ev","^\"You saw a path?\"","\n","^\"Not clearly. Enough to ask later.\"","\n","^Viktor looks back through the small rear window. The bend has already erased the slope.","\n","^\"Ask carefully. Places people fail to mention are often more informative than those they recommend.\"","\n",{"->":"coach_nears_village"},{"#f":5}],"c-2":["^ ","#","^route:careless","/#","\n","ev",{"VAR?":"careless"},1,"+",{"VAR=":"careless","re":true},"/ev","ev","str","^dependence","/str","/ev",{"VAR=":"viktor_relation","re":true},"^His expression darkens by one official degree.","\n","^\"A revolver is a poor instrument against trees.\"","\n","^\"Then I shall rely on your conversation to intimidate them.\"","\n","^The driver pretends not to hear. His shoulders, however, hear everything.","\n",{"->":"coach_nears_village"},{"#f":5}],"c-3":["^ ","#","^route:lover","/#","\n","ev",{"VAR?":"lover"},1,"+",{"VAR=":"lover","re":true},"/ev","ev",{"VAR?":"viktor_suspicion"},1,"+",{"VAR=":"viktor_suspicion","re":true},"/ev","^\"That would depend on what advantage you expected from the answer.\"","\n","^\"Herr Nowak. You wound me.\"","\n","^\"Not yet.\"","\n","^It is the first thing he has said all day that almost sounds like flirtation, though perhaps only because danger has a talent for borrowing warmer clothes.","\n",{"->":"coach_nears_village"},{"#f":5}],"c-4":["^ ","#","^route:sapphic","/#","\n","ev",{"VAR?":"sapphic"},1,"+",{"VAR=":"sapphic","re":true},"/ev","^The denial is too quick, and you both hear it.","\n","^You are not thinking of the stone now. You are thinking of the young woman waiting somewhere ahead: the Graf's daughter, the reason carefully not written into the memorandum, the stranger whose household has summoned you under a title both absurd and useful.","\n","^If this place keeps women in stone, you think, what does it do to them in houses?","\n",{"->":"coach_nears_village"},{"#f":5}]}],null],"coach_nears_village":["^The Graben opens reluctantly.","\n","^First comes the smell of smoke. Then a roof, low and dark with weather. Then another. Then a church tower, not high, not graceful, but thick-shouldered and pale against the slope behind it. Its walls look older than the village around them and less certain of victory. The windows are small. The churchyard wall holds the road at a distance, as if the dead require fortification from the living, or the living from something else. ","#","^chapter[Eibenreith Village] ","/#","#","^sfx[church-bells.ogg](max=8, fade) ","/#","#","^image[eibenreith.png](landscape)","/#","\n","^Eibenreith appears not as a village in a picture appears, all at once and composed for admiration, but by fragments.","\n","^A woman in a dark kerchief pauses with a pail in her hand. A boy stops driving geese and lets them complain around his boots. Two men outside a shed end their conversation at the same moment without looking at each other. Curtains stir in windows where no one admits to standing. A blacksmith's sign moves slightly in air you cannot feel. Water runs somewhere under boards, under stone, under the road itself, quick and cold and hidden.","\n","^The houses are not poor, not exactly. Many are solid, whitewashed, shingled, kept with the stubborn decency of people who repair what they cannot replace. Yet something in their arrangement troubles the eye. They turn toward the church but not fully. They keep the road but lean from it. They leave, between yard and fence and woodpile, narrow passages where shadow gathers too early.","\n","^The coach slows.","\n","^No one runs to greet it.","\n","^No one needs to. News has already entered the village by means faster than railway, telegraph, or imperial seal.","\n","^You sit very straight as Eibenreith takes its first look at you.","\n","^Beside you, Viktor lowers his voice.","\n","^\"Remember: at Hohenreith, every courtesy will mean something. Here, every silence will.\"","\n","^The horses draw the coach past the churchyard wall. Above it, on the old plaster beside the gate, a faded painted woman looks down from beneath a flaking blue mantle. Her hands are folded in prayer. Her eyes, damaged by weather, no longer point in the same direction.","\n","^For one breath, as the wheels pass over a buried runnel of water, the painted face seems less like the Holy Mother than like a mask put on something that had been waiting longer.","\n","^Then the coach enters the village proper, and the road bends toward the unseen height where Jagdhaus Hohenreith stands above Eibenreith under its newer name.","\n","end",null],"global decl":["ev","str","^unset","/str",{"VAR=":"birth_class"},"str","^","/str",{"VAR=":"title_part"},"str","^","/str",{"VAR=":"given_names"},"str","^","/str",{"VAR=":"common_name"},"str","^","/str",{"VAR=":"surname"},"str","^","/str",{"VAR=":"full_name"},"str","^unset","/str",{"VAR=":"supernatural_belief"},"str","^unset","/str",{"VAR=":"supernatural_senses"},"str","^unset","/str",{"VAR=":"viktor_relation"},0,{"VAR=":"lover"},0,{"VAR=":"sapphic"},0,{"VAR=":"detective"},0,{"VAR=":"careless"},0,{"VAR=":"eccentric"},0,{"VAR=":"class_confidence"},0,{"VAR=":"medium_reputation"},0,{"VAR=":"court_loyalty"},0,{"VAR=":"viktor_trust"},0,{"VAR=":"viktor_suspicion"},0,{"VAR=":"supernatural_exposure"},"/ev","end",null]}],"listDefs":{}} \ No newline at end of file diff --git a/data/ink/story.ink.json b/data/ink/story.ink.json new file mode 100644 index 0000000..d360f20 --- /dev/null +++ b/data/ink/story.ink.json @@ -0,0 +1 @@ +{"inkVersion":21,"root":[["ev",{"VAR?":"DEBUG"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^IN DEBUG MODE!","\n","ev","str","^Beginning...","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Framing Hooper...","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^In with Hooper...","/str","/ev",{"*":".^.c-2","flg":20},{"->":"0.5"},{"c-0":["^\t",{"->":"start"},"\n",{"#f":5}],"c-1":["^ ",{"->":"claim_hooper_took_component"},"\n",{"#f":5}],"c-2":["^ ",{"->":"inside_hoopers_hut"},"\n",{"#f":5}]}]}],[{"->":".^.b"},{"b":["\n",{"->":"start"},{"->":"0.5"},null]}],"nop","\n",["done",{"#n":"g-0"}],null],"done",{"lower":[{"temp=":"x"},"ev",{"VAR?":"x"},1,"-","/ev",{"temp=":"x","re":true},null],"raise":[{"temp=":"x"},"ev",{"VAR?":"x"},1,"+","/ev",{"temp=":"x","re":true},null],"start":[[["^They are keeping me waiting.","\n",["ev",{"^->":"start.0.g-0.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^Hut 14",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"start.0.g-0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"^. The door was locked after I sat down. ","\n","^I don't even have a pen to do any work. There's a copy of the morning's intercept in my pocket, but staring at the jumbled letters will only drive me mad.","\n","^I am not a machine, whatever they say about me.","\n",{"->":".^.^.^.opts"},{"#f":5}],"#n":"g-0"}],{"opts":[["ev","visit",2,"MIN","/ev","ev","du",0,"==","/ev",{"->":".^.s0","c":true},"ev","du",1,"==","/ev",{"->":".^.s1","c":true},"ev","du",2,"==","/ev",{"->":".^.s2","c":true},"nop",{"s0":["pop",{"->":".^.^.23"},null],"s1":["pop","^I rattle my fingers on the field table.",{"->":".^.^.23"},null],"s2":["pop",{"->":".^.^.23"},null],"#f":5}],"\n","ev","str","^Think","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Plan","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Wait","/str","/ev",{"*":".^.c-3","flg":20},{"c-1":["^ ","\n","^They suspect me to be a traitor. They think I stole the component from the calculating machine. They will be searching my bunk and cases.","\n","^When they don't find it, ","ev",{"CNT?":".^.^.c-2"},"/ev",[{"->":".^.b","c":true},{"b":["^then",{"->":".^.^.^.9"},null]}],"nop","^ they'll come back and demand I talk.","\n",{"->":".^.^"},{"->":".^.^.^.g-1"},{"#f":5}],"c-2":["\n","ev",{"CNT?":".^.^.c-1"},"!","/ev",[{"->":".^.b","c":true},{"b":["^What I am is",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^I am",{"->":".^.^.^.7"},null]}],"nop","^ a problem—solver. Good with figures, quick with crosswords, excellent at chess.","\n","^But in this scenario — in this trap — what is the winning play?","\n",["ev","str","^Co—operate","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Dissemble","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Divert","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^I must co—operate. My credibility is my main asset. To contradict myself, or another source, would be fatal.","\n","^I must simply hope they do not ask the questions I do not want to answer.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":"start.0.g-1"},{"#f":5}],"c-1":["^ ","\n","^Misinformation, then. Just as the war in Europe is one of plans and interceptions, not planes and bombs.","\n","^My best hope is a story they prefer to the truth.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":"start.0.g-1"},{"#f":5}],"c-2":["^ ","\n","^Avoidance and delay. The military machine never fights on a single front. If I move slowly enough, things will resolve themselves some other way, my reputation intact.","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":"start.0.g-1"},{"#f":5}]}],{"#f":5}],"c-3":["^\t\t","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":[{"->":"start.waited"},null]}],{"waited":[[["^Half an hour goes by before Commander Harris returns. He closes the door behind him quickly, as though afraid a loose word might slip inside.","\n","^\"Well, then,\" he begins, awkwardly. This is an unseemly situation.","\n",["ev",{"^->":"start.waited.0.g-0.4.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^\"Commander.\"",{"->":"$r","var":true},null]}],["ev",{"^->":"start.waited.0.g-0.5.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str",{"CNT?":"start.0.opts.c-2.12.c-2"},"!","/ev",{"*":".^.^.c-1","flg":19},{"s":["^\"Tell me what this is about.\"",{"->":"$r","var":true},null]}],"ev","str","^Wait","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["ev",{"^->":"start.waited.0.g-0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.4.s"},[{"#n":"$r2"}],"\n","^He nods. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-1":["ev",{"^->":"start.waited.0.g-0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.5.s"},[{"#n":"$r2"}],"\n","^He shakes his head.","\n","^\"Now, don't let's pretend.\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-2":["\n","^I say nothing.","\n",{"->":".^.^.^.g-1"},{"#f":5}],"#n":"g-0"}],{"g-1":["^He has brought two cups of tea in metal mugs: he sets them down on the tabletop between us.","\n","ev","str","^Deny","/str",{"CNT?":".^.^.g-0.c-1"},"/ev",{"*":".^.c-3","flg":21},"ev","str","^Take one","/str","/ev",{"*":".^.c-4","flg":20},["ev",{"^->":"start.waited.0.g-1.15.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str",{"CNT?":".^.^.^.g-0.c-1"},"!","/ev",{"*":".^.^.c-5","flg":19},{"s":["^\"What's going on?\"",{"->":"$r","var":true},null]}],"ev","str","^Wait","/str","/ev",{"*":".^.c-6","flg":20},{"c-3":["^ \"I'm not pretending anything.\"","\n","ev",{"CNT?":"start.0.opts.c-2.12.c-0"},"/ev",[{"->":".^.b","c":true},{"b":["^I'm lying already, despite my good intentions.",{"->":".^.^.^.6"},null]}],"nop","\n","^Harris looks disapproving. ",{"->":".^.^.c-6.3.pushes_cup"},"\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-4":["\n","ev",true,"/ev",{"VAR=":"teacup","re":true},"^I take a mug and warm my hands. It's ","<>","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-5":["ev",{"^->":"start.waited.0.g-1.c-5.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.15.s"},[{"#n":"$r2"}],"\n","^\"You know already.\"","\n",{"->":".^.^.c-6.3.pushes_cup"},{"->":".^.^.^.g-2"},{"#f":5}],"c-6":["\n","^I wait for him to speak.","\n",[["^He pushes one mug halfway towards me: ","<>","\n",{"->":".^.^.^.^.^.g-2"},{"#n":"pushes_cup"}],null],{"#f":5}]}],"g-2":["^a small gesture of friendship.","\n","^Enough to give me hope?","\n","ev","str","^Take it","/str",{"VAR?":"teacup"},"!","/ev",{"*":".^.c-7","flg":21},"ev","str","^Don't take it","/str",{"VAR?":"teacup"},"!","/ev",{"*":".^.c-8","flg":21},"ev","str","^Drink","/str",{"VAR?":"teacup"},"/ev",{"*":".^.c-9","flg":21},"ev","str","^Wait","/str",{"VAR?":"teacup"},"/ev",{"*":".^.c-10","flg":21},{"c-7":["^ ","\n","^I ","ev",{"CNT?":".^.^.^.g-1.c-4"},"/ev",[{"->":".^.b","c":true},{"b":["^lift the mug",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["^take the mug,",{"->":".^.^.^.8"},null]}],"nop","^ and blow away the steam. It is too hot to drink.","\n","^Harris picks his own up and just holds it.","\n","ev",true,"/ev",{"VAR=":"teacup","re":true},"ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-8":["^ ","\n","^Just a cup of insipid canteen tea. I leave it where it is.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-9":["^ ","\n","^I raise the cup to my mouth but it's too hot to drink.","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-10":["^ \t\t","\n","^I say nothing as ",{"->":".^.^.c-7"},"\n",{"->":".^.^.^.g-3"},{"#f":5}]}],"g-3":["^\"Quite a difficult situation,\" ","ev",{"CNT?":".^.^.g-2.c-7"},"/ev",[{"->":".^.b","c":true},{"b":["^he",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["^Harris",{"->":".^.^.^.6"},null]}],"nop","^ begins","ev",{"VAR?":"forceful"},0,"<=","/ev",[{"->":".^.b","c":true},{"b":["^, sternly",{"->":".^.^.^.14"},null]}],"nop","^. I've seen him adopt this stiff tone of voice before, but only when talking to the brass. \"I'm sure you agree.\"","\n","ev","str","^Agree","/str","/ev",{"*":".^.c-11","flg":20},"ev","str","^Disagree","/str","/ev",{"*":".^.c-12","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-13","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-14","flg":20},{"c-11":["^ ","\n","^\"Awkward,\" I reply","\n",{"->":".^.^.^.g-4"},{"#f":5}],"c-12":["^ ","\n","^\"I don't see why,\" I reply","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.^.g-4"},{"#f":5}],"c-13":["^ ",{"->":".^.^.c-12"},"\n",{"->":".^.^.^.g-4"},{"#f":5}],"c-14":["^ ","\n","^\"I'm sure you've handled worse,\" I reply casually","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.^.g-4"},{"#f":5}]}],"g-4":["ev",{"VAR?":"teacup"},"/ev",[{"->":".^.b","c":true},{"b":["\n","ev",true,"/ev",{"VAR=":"drugged","re":true},"<>","^, sipping at my tea as though we were old friends","\n",{"->":".^.^.^.4"},null]}],"nop","\n","<>","^.","\n",["ev","str","^Watch him","/str","/ev",{"*":".^.c-15","flg":20},"ev","str","^Wait","/str","/ev",{"*":".^.c-16","flg":20},"ev","str","^Smile","/str",{"CNT?":".^.^.^.g-3.c-12"},"!","/ev",{"*":".^.c-17","flg":21},{"c-15":["\n","^His face is telling me nothing. I've seen Harris broad and full of laughter. Today he is tight, as much part of the military machine as the device in Hut 5.","\n",{"->":".^.^.^.^.g-6"},{"#f":5}],"c-16":["\n","^I wait to see how he'll respond.","\n",{"->":".^.^.^.^.g-6"},{"#f":5}],"c-17":["\n","^I try a weak smile. It is not returned.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":".^.^.^.^.g-6"},{"#f":5}],"#n":"g-5"}],null],"g-6":["^\"We need that component,\" he says.","\n",["ev",{"CNT?":"missing_reel"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n",{"->t->":"missing_reel"},{"->":"harris_demands_component"},{"->":".^.^.^.5"},null]}],"nop","\n",["ev","str","^Yes","/str","/ev",{"*":".^.c-18","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-19","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-20","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-21","flg":20},{"c-18":["\n","^\"Of course I do,\" I answer.","\n",{"->":".^.^.^.^.^.g-9"},{"#f":5}],"c-19":["\n","^\"No I don't. And I've got work to do...\"","\n","^\"Work that will be rather difficult for you to do, don't you think?\" Harris interrupts.","\n",{"->":".^.^.^.^.^.g-9"},{"#f":5}],"c-20":["\n",{"->":"here_at_bletchley_diversion"},{"->":".^.^.^.^.^.g-9"},{"#f":5}],"c-21":["^ ","\n",{"->":".^.^.c-19"},{"->":".^.^.^.^.^.g-9"},{"#f":5}],"#n":"g-8"}],{"#n":"g-7"}],null],"g-9":[{"->t->":"missing_reel"},{"->":"harris_demands_component"},null]}],null]}],"missing_reel":[["ev","str","^The stolen component...","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Shrug","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["\n","^I shrug.","\n","ev","void","/ev","->->",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^The reel went missing from the Bombe this afternoon. The four of us were in the Hut, working on the latest German intercept. The results were garbage. It was Russell who found the gap in the plugboard.","\n",["^Any of us could have taken it; and no one else would have known its worth.","\n","ev","str","^Panic","/str",{"VAR?":"forceful"},0,"<=","/ev",{"*":".^.c-2","flg":21},"ev","str","^Calculate","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Deny","/str",{"VAR?":"evasive"},0,">=","/ev",{"*":".^.c-4","flg":21},{"c-2":["^ They will pin it on me. They need a scapegoat so that the work can continue. I'm a likely target. Weaker than the rest. ","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":".^.^.^.^.g-2"},{"#f":5}],"c-3":["^ My odds, then, are one in four. Not bad; although the stakes themselves are higher than I would like.","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.^.^.g-2"},{"#f":5}],"c-4":["^ But this is still a mere formality. The work will not stop. A replacement component will be made and we will all be put back to work. We are too valuable to shoot. ","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.^.^.g-2"},{"#f":5}],"#n":"g-1"}],null],"g-2":["ev","void","/ev","->->",null]}],{"#f":1}],"here_at_bletchley_diversion":[["^\"Here at Bletchley? Of course.\"","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","^\"Here, now,\" Harris corrects. \"We are not talking to everyone. I can imagine you might feel pretty sore about that. I can imagine you feeling picked on. ","ev",{"VAR?":"forceful"},0,"<","/ev",[{"->":".^.b","c":true},{"b":["^You're a sensitive soul.",{"->":".^.^.^.21"},null]}],"nop","^\"","\n",["ev",{"^->":"here_at_bletchley_diversion.0.24.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str","/ev",{"*":".^.^.c-0","flg":22},{"s":["^\"I'm fine",{"->":"$r","var":true},null]}],["ev",{"^->":"here_at_bletchley_diversion.0.25.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str",{"VAR?":"forceful"},0,"<","/ev",{"*":".^.^.c-1","flg":19},{"s":["^\"What do you mean by that?\"",{"->":"$r","var":true},null]}],["ev",{"^->":"here_at_bletchley_diversion.0.26.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str",{"VAR?":"forceful"},0,">=","/ev",{"*":".^.^.c-2","flg":23},{"s":["^\"Damn right",{"->":"$r","var":true},null]}],"ev","str","^Be honest","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-4","flg":20},{"c-0":["ev",{"^->":"here_at_bletchley_diversion.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.24.s"},[{"#n":"$r2"}],"^,\" I reply. \"This is all some misunderstanding and the quicker we have it cleared up the better.\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","^\"I couldn't agree more.\" And then he comes right out with it, with an accusation.","\n",{"->":".^.^.done"},{"#f":5}],"c-1":["ev",{"^->":"here_at_bletchley_diversion.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.25.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.done"},{"#f":5}],"c-2":["ev",{"^->":"here_at_bletchley_diversion.0.c-2.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.26.s"},[{"#n":"$r2"}],"^ I'm sore. Was it one of the others who put you up to this? Was it Hooper? He's always been jealous of me. He's...\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n","ev",true,"/ev",{"VAR=":"hooper_mentioned","re":true},"^The Commander moustache bristles as he purses his lips. \"Has he now? Of your achievements, do you think?\"","\n","^It's difficult not to shake the sense that he's ","ev",{"VAR?":"evasive"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^mocking",{"->":".^.^.^.28"},null]}],[{"->":".^.b"},{"b":["^simply humouring",{"->":".^.^.^.28"},null]}],"nop","^ me.","\n","^\"Or of your brain? Or something else?\"","\n",[["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-0","flg":22},{"s":["^\"Of my genius.",{"->":"$r","var":true},null]}],["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.1.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-1","flg":22},{"s":["^\"Of my standing.",{"->":"$r","var":true},null]}],"ev","str","^Evade","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"^ Hooper simply can't stand that I'm cleverer than he is. We work so closely together, cooped up in that Hut all day. It drives him to distraction. To worse.\"","\n","^\"You're suggesting Hooper would sabotage this country's future simply to spite you?\" Harris chooses his words like the military man he is, each lining up to create a ring around me.","\n",["ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ \t\t\t","\n","^\"","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^He's petty enough, certainly",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^I wouldn't put it past him",{"->":".^.^.^.10"},null]}],"nop","^. He's a creep.\" ","ev",{"VAR?":"teacup"},"/ev",[{"->":".^.b","c":true},{"b":["^ I set the teacup down.",{"->":".^.^.^.17"},null]}],[{"->":".^.b"},{"b":["^I wipe a hand across my forehead.",{"->":".^.^.^.17"},null]}],"nop","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n","ev",false,"/ev",{"VAR=":"teacup","re":true},{"->":".^.^.suggest_its_a_lie"},{"#f":5}],"c-1":["^ \t\t\t","\n","^\"No, ","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^of course not",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^I suppose not",{"->":".^.^.^.10"},null]}],"nop","^.\" ","ev",{"VAR?":"teacup"},"/ev",[{"->":".^.b","c":true},{"b":["^I put the teacup back down on the table",{"->":".^.^.^.17"},null]}],[{"->":".^.b"},{"b":["^I push the teacup around on its base",{"->":".^.^.^.17"},null]}],"nop","^.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","ev",false,"/ev",{"VAR=":"teacup","re":true},{"->":".^.^.suggest_its_a_lie"},{"#f":5}],"c-2":["^ \t\t","\n","^\"I don't know what I'm suggesting. I don't understand what's going on.\"","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n","^\"But of course you do.\" Harris narrows his eyes.","\n",{"->":".^.^.^.^.^.^.done"},{"->":".^.^.suggest_its_a_lie"},{"#f":5}],"suggest_its_a_lie":["^\"All I can say is, ever since I arrived here, he's been looking to ways to bring me down a peg. I wouldn't be surprised if he set this whole affair up just to have me court—martialled.\"","\n","^\"We don't court—martial civilians,\" Harris replies. \"Traitors are simply hung at her Majesty's pleasure.\"","\n",["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-0.10.suggest_its_a_lie.4.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str","/ev",{"*":".^.^.c-3","flg":22},{"s":["^\"Quite right",{"->":"$r","var":true},null]}],["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-0.10.suggest_its_a_lie.5.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str","/ev",{"*":".^.^.c-4","flg":22},{"s":["^\"I'm no traitor",{"->":"$r","var":true},null]}],"ev","str","^Lie","/str","/ev",{"*":".^.c-5","flg":20},{"c-3":["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-0.10.suggest_its_a_lie.c-3.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.4.s"},[{"#n":"$r2"}],"^,\" I answer smartly.","\n",{"->":".^.^.^.g-0"},{"#f":5}],"c-4":["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-0.10.suggest_its_a_lie.c-4.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.5.s"},[{"#n":"$r2"}],"^,\" I answer","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^smartly",{"->":".^.^.^.14"},null]}],[{"->":".^.b"},{"b":["^, voice quivering. \"For God's sake!\"",{"->":".^.^.^.14"},null]}],"nop","\n",{"->":".^.^.^.g-0"},{"#f":5}],"c-5":["^ ",{"->":".^.^.c-4"},"\n",{"->":".^.^.^.g-0"},{"#f":5}]}],"g-0":["^He stares back at me.","\n",{"->":".^.^.^.^.^.^.done"},null]}],{"#f":5}],"c-1":["ev",{"^->":"here_at_bletchley_diversion.0.c-2.33.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.1.s"},[{"#n":"$r2"}],"^ My reputation.\" ","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^I'm aware of how arrogant I must sound but I plough on all the same.",{"->":".^.^.^.14"},null]}],[{"->":".^.b"},{"b":["^I don't like to talk of myself like this, but I carry on all the same.",{"->":".^.^.^.14"},null]}],"nop","^ \"Hooper simply can't bear knowing that, once all this is over, I'll be the one receiving the knighthood and he...\"","\n","^\"No—one will be getting a knighthood if the Germans make landfall,\" Harris answers sharply. He casts a quick eye to the door of the Hut to check the latch is still down, then continues in more of a murmur: \"Not you and not Hooper. Now answer me.\"","\n","^For the first time since the door closed, I wonder what the threat might be if I do not.","\n",{"->":".^.^.^.^.done"},{"#f":5}],"c-2":["^ \t\t\t\t","\n","ev",false,"/ev",{"VAR=":"teacup","re":true},"ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n","^\"How should I know?\" I reply, defensively. ","ev",{"VAR?":"teacup"},"/ev",[{"->":".^.b","c":true},{"b":["^I set the teacup back on the table.",{"->":".^.^.^.17"},null]}],"nop","^ ",{"->":".^.^.c-0.10.suggest_its_a_lie"},"\n",{"->":".^.^.^.^.done"},{"#f":5}]}],{"#f":5}],"c-3":["^ \t",{"->":".^.^.c-2"},"\n",{"->":".^.^.done"},{"#f":5}],"c-4":["^ \t\t",{"->":".^.^.c-0"},"\n",{"->":".^.^.done"},{"#f":5}],"done":[{"->":"harris_demands_component"},null]}],{"#f":1}],"harris_demands_component":[["^\"","ev",{"CNT?":"here_at_bletchley_diversion"},"/ev",[{"->":".^.b","c":true},{"b":["^Please",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["^So",{"->":".^.^.^.6"},null]}],"nop","^. Do you have it?\" Harris is ","ev",{"VAR?":"forceful"},3,">","/ev",[{"->":".^.b","c":true},{"b":["^sweating slightly",{"->":".^.^.^.15"},null]}],[{"->":".^.b"},{"b":["^wasting no time",{"->":".^.^.^.15"},null]}],"nop","^: Bletchley is his watch. \"Do you know where it is?\"","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["\n","^\"I do.\"","\n",{"->":"admitted_to_something"},{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ \"I have no idea.\" ","\n",{"->":".^.^.silence"},{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ \t\t",{"->":".^.^.c-1"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-3":["^ \t\t","\n","^\"The component?\"","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","^\"Don't play stupid,\" he replies. \"","ev",{"CNT?":"missing_reel"},"!","/ev",[{"->":".^.b","c":true},{"b":["^The component that went missing this afternoon. ",{"->":".^.^.^.22"},null]}],"nop","^Where is it?\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["ev",{"CNT?":"missing_reel"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n",{"->t->":"missing_reel"},{"->":".^.^.^.5"},null]}],"nop","\n","ev","str","^Co-operate","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Delay","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-7","flg":20},{"c-4":["^ \"I know where it is.\"","\n",{"->":"admitted_to_something"},{"->":".^.^.^.silence"},{"#f":5}],"c-5":["^ \"I know nothing about it.\" My voice shakes","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^ with anger",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["^; I'm unaccustomed to facing off against men with holstered guns",{"->":".^.^.^.8"},null]}],"nop","^. ","\n",{"->":".^.^.^.silence"},{"#f":5}],"c-6":["^ ",{"->":".^.^.c-5"},"\n",{"->":".^.^.^.silence"},{"#f":5}],"c-7":["^ ","\n","^\"I don't know what gives you the right to pick on me. ","ev",{"VAR?":"forceful"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^I demand a lawyer.",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^I want a lawyer.",{"->":".^.^.^.10"},null]}],"nop","^\"","\n","^\"This is time of war,\" Harris answers. \"And by God, if I have to shoot you to recover the component, I will. Understand?\" He points at the mug, ",{"->":".^.^.^.silence.drinkit"},"\n",{"->":".^.^.^.silence"},{"#f":5}]}],"silence":["^There's an icy silence. ","ev",{"VAR?":"forceful"},2,">","/ev",[{"->":".^.b","c":true},{"b":["^I've cracked him a little.",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["ev",{"VAR?":"evasive"},2,">","/ev",[{"->":".^.b","c":true},{"b":["^He's tiring of my evasiveness.",{"->":".^.^.^.6"},null]}],"nop",{"->":".^.^.^.8"},null]}],"nop","\n",["^\"Now drink your tea and talk.\"","\n","ev","str","^Drink","/str",{"VAR?":"teacup"},"/ev",{"*":".^.c-8","flg":21},"ev","str","^Put the cup down","/str",{"VAR?":"teacup"},"/ev",{"*":".^.c-9","flg":21},"ev","str","^Take the cup","/str",{"VAR?":"teacup"},"!","/ev",{"*":".^.c-10","flg":21},"ev","str","^Don't take it","/str",{"VAR?":"teacup"},"!","/ev",{"*":".^.c-11","flg":21},{"c-8":["^ \t\t\t",{"->":".^.^.c-10.2.drinkfromcup"},"\n",{"->":".^.^.^.^.g-1"},{"#f":5}],"c-9":["^ ","\n","^I set the cup carefully down on the table once more.","\n","ev",false,"/ev",{"VAR=":"teacup","re":true},"ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.c-11.10.whatsinit"},{"->":".^.^.^.^.g-1"},{"#f":5}],"c-10":["^ ","\n",[["^I lift the cup ","ev",{"VAR?":"teacup"},"/ev",[{"->":".^.b","c":true},{"b":["^to my lips ",{"->":".^.^.^.5"},null]}],"nop","^and sip. He waits for me to swallow before speaking again.","\n","ev",true,"/ev",{"VAR=":"drugged","re":true},"ev",true,"/ev",{"VAR=":"teacup","re":true},{"->":".^.^.^.^.^.^.g-1"},{"#f":5,"#n":"drinkfromcup"}],null],{"#f":5}],"c-11":["^ ","\n","^I leave the cup where it is.","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",[["^\"Why?\" I ask coldly. \"What's in it?\"","\n",{"->":".^.^.^.^.^.^.g-1"},{"#n":"whatsinit"}],null],{"#f":5}],"#n":"drinkit"}],null],"g-1":["^\"Lapsang Souchong,\" he ","ev",{"CNT?":".^.^.silence.drinkit.c-10.2.drinkfromcup"},"/ev",[{"->":".^.b","c":true},{"b":["^remarks",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["^replies",{"->":".^.^.^.6"},null]}],"nop","^, placing his own cup back on the table untouched. \"Such a curious flavour. It might almost not be tea at all. You might say it hides a multitude of sins. As do you. Isn't that right?\"","\n","ev","str","^Agree","/str","/ev",{"*":".^.c-12","flg":20},"ev","str","^Disagree","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-13","flg":21},"ev","str","^Disagree","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-14","flg":21},"ev","str","^Lie","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-15","flg":21},"ev","str","^Lie","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-16","flg":21},"ev","str","^Evade","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-17","flg":21},"ev","str","^Evade","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-18","flg":21},{"c-12":["^ ","\n","^\"I suppose so,\" I reply. \"I've done things I shouldn't have done.\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":"harris_presses_for_details"},{"#f":5}],"c-13":["\n","^\"I've done nothing that I'm ashamed of.\"","\n",{"->":"harris_asks_for_theory"},{"#f":5}],"c-14":["^ ","\n","^I open my mouth to disagree, but the words I want won't come. It is like Harris has taken a screwdriver to the sides of my jaw.","\n",{"->":"admitted_to_something.ive_done_things"},{"#f":5}],"c-15":["^ \t",{"->":".^.^.c-14"},"\n",{"#f":5}],"c-16":["^ \t",{"->":".^.^.c-13"},"\n",{"#f":5}],"c-17":["^ ",{"->":".^.^.c-14"},"\n",{"#f":5}],"c-18":["^ ","\n","^\"None of us are blameless, Harris. ","ev",{"VAR?":"forceful"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^But you're not my priest and I'm not yours",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^But I've done nothing to deserve this treatment",{"->":".^.^.^.10"},null]}],"nop","^. Now, please. Let me go. I'll help you find this damn component, of course I will.\"","\n","^He appears to consider the offer.","\n",{"->":"harris_asks_for_theory"},{"#f":5}]}]}],null],"harris_presses_for_details":[["^\"You mean you've left yourself open,\" Harris answers. \"To pressure. Is that what you're saying?\"","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^No","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-2","flg":21},"ev","str","^Evade","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-3","flg":21},"ev","str","^Evade","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-4","flg":21},{"c-0":["^ ",{"->":".^.^.^.admit_open_to_pressure"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"I'm not saying anything of the sort,\" I snap back. \"What is this, Harris? You're accusing me of treachery but I don't see a shred of evidence for it! Why don't you put your cards on the table?\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^I shake my head violently, to say no, that's not it, but whatever is wrong with tongue is wrong with neck too. I look across at the table at Harris' face and realise with a start how sympathetic he is. Such a kind, generous man. How can I hold anything back from him?","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","^I take another mouthful of the bitter, strange—tasting tea before answering.","\n",{"->":".^.^.^.admit_open_to_pressure"},{"->":".^.^.g-0"},{"#f":5}],"c-3":["^ ","\n","^\"You're the one applying pressure here,\" I answer ","ev",{"VAR?":"forceful"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^smartly",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^somewhat miserably",{"->":".^.^.^.10"},null]}],"nop","^. \"I'm just waiting until you tell me what is really going on.\"","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.g-0"},{"#f":5}],"c-4":["^ \t\t\t\t ","\n","^\"We're all under pressure here.\"","\n","^He looks at me with pity. ",{"->":"harris_has_seen_it_before"},"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"It's simple enough,\" Harris says. ",{"->":"harris_has_seen_it_before"},"\n",null]}],{"admit_open_to_pressure":["^\"That's it,\" I reply. \"There are some things... which a man shouldn't do.\"","\n","ev",true,"/ev",{"VAR=":"admitblackmail","re":true},"^Harris doesn't stiffen. Doesn't lean away, as though my condition might be infectious. I had thought they trained them in the army to shoot my kind on sight.","\n","^He offers no sympathy either. He nods, once. His understanding of me is a mere turning cog in his calculations, with no meaning to it.","\n",{"->":"harris_has_seen_it_before"},null]}],"admitted_to_something":[["ev",{"VAR?":"drugged"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^Harris stares back at me. ","ev",{"VAR?":"evasive"},0,"==","/ev",[{"->":".^.b","c":true},{"b":["^He cannot have expected it to be so easy to break me.",{"->":".^.^.^.8"},null]}],"nop","\n",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["\n","^Harris smiles with satisfaction, as if your willingness to talk was somehow his doing.","\n",{"->":".^.^.^.6"},null]}],"nop","\n","^\"I see.\"","\n","^There's a long pause, like the delay between feeding a line of cypher into the Bombe and waiting for its valves to warm up enough to begin processing.","\n","^\"You want to explain that?\"","\n","ev","str","^Explain","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't explain","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^Lie","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-2","flg":21},"ev","str","^Evade","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-3","flg":21},"ev","str","^Say nothing","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-4","flg":21},{"c-0":["^ ","\n","^I pause a moment, trying to choose my words. To just come out and say it, after a lifetime of hiding... that is a circle I cannot square.","\n",["ev","str","^Explain","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Say nothing","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-1","flg":21},"ev","str","^Lie","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-2","flg":21},{"c-0":["^ \t",{"->":".^.^.^.^.^.ive_done_things"},"\n",{"#f":5}],"c-1":["^ \t",{"->":".^.^.^.^.c-4"},"\n",{"#f":5}],"c-2":["^ \t",{"->":"claim_hooper_took_component"},"\n",{"#f":5}]}],{"#f":5}],"c-1":["\n","^\"There's nothing to explain,\" I reply stiffly. ",{"->":".^.^.^.i_know_where"},"\n",{"#f":5}],"c-2":["^ ",{"->":"claim_hooper_took_component"},"\n",{"#f":5}],"c-3":["\n","^\"Explain what you should be doing, do you mean, rather than bullying me? Certainly.\" I fold my arms. ",{"->":".^.^.^.i_know_where"},"\n",{"#f":5}],"c-4":["\n","^I fold my arms, intended firmly to say nothing. But somehow, watching Harris' face, I cannot bring myself to do it. I want to confess. I want to tell him everything I can, to explain myself to him, to earn his forgiveness. The sensation is so strong my will is powerless in the face of it.","\n","^Something is wrong with me, I am sure of it. There is a strange, bitter flavour on my tongue. I taste it as words start to form.","\n",{"->":".^.^.^.ive_done_things"},{"#f":5}]}],{"i_know_where":["^\"I know where your component is because it's obvious where your component is. That doesn't mean I took it, just because I can figure out a simple problem, any more than it means I'm a German spy because I can crack their codes.\"","\n",{"->":"harris_asks_for_theory"},null],"ive_done_things":["^\"I've done things,\" I begin","ev",{"CNT?":"harris_demands_component.0.g-1.c-14"},"/ev",[{"->":".^.b","c":true},{"b":["^ helplessly",{"->":".^.^.^.5"},null]}],"nop","^. \"Things I didn't want to do. I tried not to. But in the end, it felt like cutting off my own arm to resist.\"","\n",{"->":"harris_presses_for_details"},null]}],"harris_asks_for_theory":[["^\"Tell me, then,\" he asks. \"What's your theory? You're a smart fellow — as smart as they come around here, and that's saying something. What's your opinion on the missing component? Accident, perhaps? Or do you blame one of the other men? ","ev",{"VAR?":"hooper_mentioned"},"/ev",[{"->":".^.b","c":true},{"b":["^Hooper?",{"->":".^.^.^.5"},null]}],"nop","^\"","\n","ev","str","^Blame no—one","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Blame someone","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n",{"->":".^.^.^.an_accident"},{"#f":5}],"c-1":["^ ",{"->":"claim_hooper_took_component"},"\n",{"#f":5}]}],{"an_accident":[["^\"An accident, naturally.\" I risk a smile. \"That damned machine is made from spare parts and string. Even these Huts leak when it rains. It wouldn't take more than one fellow to trip over a cable to shake out a component. Have you tried looking under the thing?\"","\n","^\"Do you believe we haven't?\"","\n","^In a sudden moment I understand that his reply is a threat.","\n","^\"Now,\" he continues. \"Are you sure there isn't anything you want to tell me?\"","\n","ev","str","^Co-operate","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Evade","/str",{"VAR?":"evasive"},0,">","/ev",{"*":".^.c-1","flg":21},{"c-0":["\n","^\"All right.\" With a sigh, your defiance collapses. \"If you're searched my things then I suppose you've found ","ev",{"VAR?":"evasive"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^ what you need",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["^my letters. Haven't you? In fact, if you haven't, don't tell me",{"->":".^.^.^.9"},null]}],"nop","^.","\n","ev",true,"/ev",{"VAR=":"admitblackmail","re":true},"^Harris nods once.","\n","<>","^ ",{"->":"harris_has_seen_it_before"},"\n",{"#f":5}],"c-1":["^ \"Only that you're being unreasonable, and behaving like a swine.\"","\n","^\"You imbecile,\" Harris replies, with sudden force. He is half out of his chair. \"You know the situation as well as I do. Why the fencing? The Hun are poised like rats, ready to run all over this country. They'll destroy everything. You understand that, don't you? You're not so locked up inside your crossword puzzles that you don't see that, are you? This machine we have here — you men — you are the best and only hope this country has. God help her.\"","\n","ev",true,"/ev",{"VAR=":"losttemper","re":true},"^I sit back, startled by the force of his outburst. His carefully sculpted expression has curled to angry disgust. He really does hate me, I think. He'll have my blood for the taste of it.","\n",["ev","str","^Placate","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Mock","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Dismiss","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","^\"Now steady on,\" I reply, gesturing for him to be calm.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"I can imagine how being surrounded by clever men is pretty threatening for you, Commander,\" I reply with a sneer. \"They don't train you to think in the Armed Forces.\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["\n","^\"Then I'll be going, on and getting on with my job of saving her, shall I?\" I even rise half to my feet, before he slams the tabletop.","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"Talk,\" Harris demands. \"Talk now. Tell me where you've hidden it or who you passed it to. Or God help me, I'll take your wretched pansy body to pieces looking for it.\"","\n",{"->":"harris_demands_you_speak"},null]}],{"#f":5}]}],null]}],"harris_has_seen_it_before":[["^\"I've seen it before. A young man like you — clever, removed. The kind that doesn't go to parties. Who takes himself too seriously. Who takes things too far.\"","\n","^He slides his thumb between two fingers.","\n","^\"Now they own you.\"","\n","ev","str","^Agree","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Disagree","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-2","flg":21},"ev","str","^Apologise","/str",{"VAR?":"drugged"},{"VAR?":"forceful"},0,"<","&&","/ev",{"*":".^.c-3","flg":21},{"c-0":["^ ","\n","^\"What could I do?\" I'm shaking now. The night is cold and the heat—lamp in the Hut has been removed. \"","ev",{"VAR?":"forceful"},2,">","/ev",[{"->":".^.b","c":true},{"b":["^I won't",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^I don't want to",{"->":".^.^.^.10"},null]}],"nop","^ go to prison.\"","\n","^\"Smart man,\" he replies. \"You wouldn't last.","\n",{"->":".^.^.tell_me_now"},{"#f":5}],"c-1":["^ ","\n","^\"I can still fix this.\"","\n","^Harris shakes his head. \"You'll do nothing. This is beyond you now. You may go to prison or may go to firing squad - or we can change your name and move you somewhere where your indiscretions can't hurt you. But right now, none of that matters. What happens to you doesn't matter. All that matters is where that component is.","\n",{"->":".^.^.tell_me_now"},{"#f":5}],"c-2":["^ ","\n","^\"I wanted to tell you,\" I tell him. \"I thought I could find out who they were. Lead you to them.\"","\n","^Harris looks at me with contempt. \"You wretch. You'll pay for what you've done to this country today. If a single man loses his life because of your pride and your perversions then God help your soul.","\n",{"->":".^.^.tell_me_now"},{"#f":5}],"c-3":["\n","^\"Harris, I...\"","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n","^\"Stop it,\" he interrupts. \"There's no jury here to sway. And there's no time.","\n",{"->":".^.^.tell_me_now"},{"#f":5}],"tell_me_now":["<>","^ So why don't you tell me, right now. Where is it?\"","\n",{"->":"harris_demands_you_speak"},null]}],null],"harris_demands_you_speak":[["^His eyes bear down like carbonised drill—bits.","\n","ev","str","^Confess","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Dissemble","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^Dissemble","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-2","flg":21},{"c-0":["^ ","\n","ev",{"VAR?":"forceful"},1,">","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"You want me to tell you what happened? You'll be disgusted.\"","\n",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["\n","^\"All right. I'll tell you what happened.\" And never mind my shame.","\n",{"->":".^.^.^.9"},null]}],"nop","\n","^\"I can imagine how it starts,\" he replies.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ",{"->":"claim_hooper_took_component"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["\n","^My plan now is to blame Hooper, but I cannot seem to tell the story. Whatever they put in my tea, it rules my tongue. ","ev",{"VAR?":"forceful"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^I fight it as hard as I can but it does no good.",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["^I am desperate to tell him everything. I am weeping with shame.",{"->":".^.^.^.9"},null]}],"nop","\n","ev",{"^var":"forceful","ci":-1},{"f()":"lower"},"pop","/ev","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":[{"->":"i_met_a_young_man"},null]}],null],"i_met_a_young_man":[["ev","str","^Talk","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^\"There was a young man. I met him in the town. A few months ago now. We got to talking. Not about work. And I used my cover story, but he seemed to know it wasn't true. That got me wondering if he might be one of us.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^Harris is not letting me off any more.","\n","^\"You seriously entertained that possibility?\"","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-3","flg":20},{"c-1":["\n","^\"Yes, I considered it. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-2":["^ ","\n","^\"No. Not for more than a moment, of course. Everyone here is marked out by how little we would be willing to say about it.\"","\n","^\"Only you told this young man more than a little, didn't you?\"","\n","^I nod. \"","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-3":["^ ","\n","^\"I was quite certain, after a while. After we'd been talking. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["^He seemed to know all about me. He... he was quite enchanted by my achievements.\"","\n","^The way Harris is staring I expect him to strike me, but he does not. He replies, \"I can see how that must have been attractive to you,\" with such plain—spokeness that I think I must have misheard.","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^No","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-5","flg":21},"ev","str","^No","/str",{"VAR?":"drugged"},"/ev",{"*":".^.c-6","flg":21},"ev","str","^Lie","/str",{"VAR?":"drugged"},"!","/ev",{"*":".^.c-7","flg":21},{"c-4":["^ \"It's a lonely life in this place,\" I reply. \"Lonely - and still one never gets a moment to oneself.\"","\n","^\"That's how it is in the Service,\" Harris answers.","\n",["ev","str","^Argue","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Agree","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ \"I'm not in the Service.\"","\n","^Harris shakes his head. \"Yes, you are.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ \"Perhaps. But I didn't choose this life.\" ","\n","^Harris shakes his head. \"No. And there's plenty of others who didn't who are suffering far worse.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^Then he waves the thought aside.","\n",{"->":".^.^.^.^.^.g-2"},null]}],{"#f":5}],"c-5":["^ \"The boy was a pretty simpleton. Quite inferior. His good opinion meant nothing to be. Harris, do not misunderstand. I was simply after his body.\"","\n","ev",{"^var":"evasive","ci":-1},{"f()":"raise"},"pop","/ev","\n","^Harris, to his credit, doesn't flinch; but I can see he will have nightmares of this moment later tonight. I'm tempted to reach out and take his hand to worsen it for him.","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-6":["^ ","\n","^\"It wasn't,\" I reply. \"But I doubt you'd understand.\"","\n","^He simply nods.","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-7":["^ ",{"->":".^.^.c-5"},"\n",{"->":".^.^.^.g-2"},{"#f":5}]}],"g-2":["^\"Go on with your confession.\"","\n",["ev",{"CNT?":".^.^.^.g-1.c-5"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^That gives me pause. I hadn't thought of it as such. But I suppose he's right. I am about to admit what I did.","\n",{"->":".^.^.^.5"},null]}],"nop","\n","^\"There's not much else to say. I took the part from Bombe computing device. You seem to know that already. I had to. He was going to expose me if I didn't.\"","\n","^\"This young man was blackmailing you over your affair?\"","\n","ev",{"VAR?":"drugged"},"/ev",{"temp=":"harris_thinks_youre_drugged"},"ev",{"VAR?":"drugged"},"/ev",[{"->":".^.b","c":true},{"b":["\n","ev",false,"/ev",{"VAR=":"drugged","re":true},"^As Harris speaks I find myself suddenly sharply aware, as if waking from a long sleep. The table, the corrugated walls of the hut, everything seems suddenly more tangible than a moment before.","\n","^Whatever it was they put in my drink is wearing off.","\n",{"->":".^.^.^.19"},null]}],"nop","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-8","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-9","flg":20},"ev","str","^Tell the truth","/str","/ev",{"*":".^.c-10","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-11","flg":20},{"c-8":["^ ","\n","^\"Yes. I suppose he was their agent. I should have realised but I didn't. Then he threatened to tell you. I thought you would have me locked up: I couldn't bear the thought of it. I love working here. I've never been so happy, so successful, anywhere before. I didn't want to lose it.\"","\n","^\"So what did you do with the component?\" Harris talks urgently. He grips his gloves tightly in one hand, perhaps prepared to lift them and strike if it is required. \"Have you passed it to this man already? Have you left it somewhere for him to find?\"","\n",["ev","str","^I have it","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^I don't have it","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Tell the truth","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ \t","\n","^\"I still have it. Not on me, of course. ",{"->":"reveal_location_of_component"},"\n",{"#f":5}],"c-1":["^ \t",{"->":".^.^.^.^.^.^.^.i_dont_have_it"},"\n",{"#f":5}],"c-2":["^ \t\t\t\t\t\t\t",{"->":".^.^.c-1"},"\n",{"#f":5}],"c-3":["^ \t\t\t\t",{"->":".^.^.c-0"},"\n",{"#f":5}]}],{"#f":5}],"c-9":["^ ","\n","^\"No, Harris. The young man wasn't blackmailing me.\" I take a deep breath. \"It was Hooper.\"","\n","ev",{"VAR?":"hooper_mentioned"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Hooper!\" Harris exclaims, in surprise. ","ev",{"VAR?":"harris_thinks_youre_drugged"},"/ev",[{"->":".^.b","c":true},{"b":["^He does not doubt me for a moment.",{"->":".^.^.^.6"},null]}],"nop","\n",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["\n","^\"Now look here,\" Harris interrupts. \"Don't start that again.\"","\n",{"->":".^.^.^.10"},null]}],"nop","\n","^\"It's the truth, Harris. If I'm going to jail, so be it, but I won't hang at Traitor's Gate. Hooper was the one who told the boy about our work. Hooper put the boy on to me. ","ev",{"VAR?":"forceful"},2,"<","/ev",[{"->":".^.b","c":true},{"b":["^I should have realised, of course. These things don't happen by chance. I was a fool to think they might.",{"->":".^.^.^.19"},null]}],"nop","^ And then, once he had me compromised, he demanded I steal the part from the machine.\"","\n","ev",true,"/ev",{"VAR=":"revealedhooperasculprit","re":true},"^\"Which you did.\" Harris leans forward. \"And then what? You still have it? You've stashed it somewhere?\"","\n",["ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ","\n","^\"Yes. I only had a moment. ",{"->":"reveal_location_of_component"},"\n",{"#f":5}],"c-1":["^ ",{"->":".^.^.^.^.^.^.^.passed_onto_hooper"},"\n",{"#f":5}],"c-2":["^ \t\t\t",{"->":".^.^.c-1"},"\n",{"#f":5}],"c-3":["^ \t\t","\n","^\"I can't remember.\"","\n","^He draws his gun and lays it lightly on the field table.","\n","^\"I'm sorry to threaten you, friend. But His Majesty needs that brain of yours, and that brain alone. There are plenty of other parts to you that our country could do better without. Now I'll ask you again. Did you hide the component?\"","\n",["ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ",{"->":".^.^.^.^.c-0"},"\n",{"#f":5}],"c-1":["^ ","\n","^\"Very well then.\" I swallow nervously, to make it look more genuine. ",{"->":"i_met_a_young_man.passed_onto_hooper"},"\n",{"#f":5}],"c-2":["^ ",{"->":".^.^.c-1"},"\n",{"#f":5}],"c-3":["^ ",{"->":"i_met_a_young_man.i_dont_have_it"},"\n",{"#f":5}]}],{"#f":5}]}],{"#f":5}],"c-10":["^ \t",{"->":".^.^.c-8"},"\n",{"#f":5}],"c-11":["^ \t\t\t\t",{"->":".^.^.c-9"},"\n",{"#f":5}],"#n":"paused"}],null]}],{"i_dont_have_it":[["^\"I don't have it any more. I passed it through the fence to my contact straight after taking it, before it was discovered to be missing. It would have been idiocy to do differently. It's long gone, I'm afraid.\"","\n","^\"You fool, Manning,\" Harris curses, getting quickly to his feet. \"You utter fool. Do you suppose you will be any better off living under Hitler? It's men like you who will get us all killed. Men too feeble, too weak in their hearts to stand up and take a man's responsibility for the world. You're happier to stay a child all your life and play with your little childish toys.\"","\n","ev","str","^Answer back","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Say nothing","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^\"Really, Commander,\" I reply. \"It rather sounds like you want to spank me.\"","\n","^\"For God's sake,\" he declares with thick disgust, then swoops away out of the room.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^I say nothing. It's true, isn't it? I can't deny that I know there is a world out there, a complicated world of pain and suffering. And I can't deny that I don't think about it a moment longer than I have to. What use is thinking on a problem that cannot be solved? It is precisely our ability to avoid such endless spirals that makes us human and not machine.","\n","^\"God have mercy on your soul,\" Harris says finally, as he gets to his feet and heads for the door. \"I fear no—one else will.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":[{"->":"left_alone"},null]}],null],"passed_onto_hooper":[["ev",true,"/ev",{"VAR=":"hooper_mentioned","re":true},"^\"No. I passed it on to Hooper.\"","\n","^\"I see. And what did he do with it?\"","\n","ev","str","^Evade","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Tell the truth","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^\"I don't know.\"","\n","^\"You can do better than that. Remember, there's a hangman's noose waiting for traitors.\"","\n",["ev","str","^Theorise","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Shrug","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"Well, then,\" I answer, nervously. \"What would he do? Either get rid of it straight away — or if that wasn't possible, which it probably wouldn't be, since he'd have to arrange things with his contacts — so most likely, he'd hide it somewhere and wait, until you had the rope around my neck and he could be sure he was safe.\"","\n",{"->":"claim_hooper_took_component.harris_being_convinced"},{"#f":5}],"c-1":["^ ",{"->":"claim_hooper_took_component.its_your_problem"},"\n",{"#f":5}]}],{"#f":5}],"c-1":["^ ","\n","^\"I don't think Hooper could have planned this in advance. So he'd need to get word to whoever he's working with, and that would take time. So I think he would have hidden it somewhere, and be waiting to make sure I soundly take the fall. That way, if anything goes wrong, he can arrange for the part to be conveniently re—found.\"","\n",{"->":"claim_hooper_took_component.harris_being_convinced"},{"#f":5}],"c-2":["\n","^\"I'm sure I saw him this evening, talking to someone by the fence on the woodland side of the compound. He's probably passed it on already. You'll have to ask him.\"","\n",{"->":"claim_hooper_took_component.harrumphs"},{"#f":5}]}],null],"#f":1}],"claim_hooper_took_component":[["^\"I saw Hooper take it.\"","\n","ev",true,"/ev",{"VAR=":"hooper_mentioned","re":true},"ev",{"VAR?":"losttemper"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Did you?\"","\n","^The worst of his rage is passing; he is now moving into a kind of contemptuous despair. I can imagine him wrapping up our interview soon, leaving the hut, locking the door, and dropping the key down the well in the yard.","\n","^And why wouldn't he? With my name tarnished they will not let me back to work on the Bombe — if there is the slightest smell of treachery about my name I would be lucky not be locked up for the remainder of the war.","\n",{"->":".^.^.^.11"},null]}],[{"->":".^.b"},{"b":["\n","^\"I see.\" He is starting to lose his patience. I have seen Harris angry a few times, with lackeys and secretaries. But never with us. With the 'brains' he has always been cautious, treating us like children.","\n","^And now I see that, like a father, he wants to smack us when we disobey him.","\n",{"->":".^.^.^.11"},null]}],"nop","\n","^\"Just get to the truth, man. Every minute matters.\"","\n","ev","str","^Persist with this","/str",{"VAR?":"admitblackmail"},"/ev",{"*":".^.c-0","flg":21},"ev","str","^Tell the truth","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Persist with this","/str",{"VAR?":"admitblackmail"},"!","/ev",{"*":".^.c-2","flg":21},{"c-0":["\n","^\"I know what you're thinking. If I've transgressed once then I must be guilty of everything else... But I'm not. We were close to cracking the 13th's intercept. We were getting correlations in the data. Then Hooper disappeared for a moment, and next minute the machine was down.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"Very well. I see there's no point in covering up. You know everything anyway.\"","\n","^Harris nods, and waits for me to continue.","\n",{"->":"i_met_a_young_man"},{"->":".^.^.g-0"},{"#f":5}],"c-2":["\n","^\"This is the truth.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I have become, somehow, an accustomed liar — the words roll easily off my tongue. Perhaps I am a traitor, I think, now that I dissemble as easily as one.","\n","^\"Go on,\" Harris says, giving me no indication of whether he believes my tale.","\n","ev","str","^Assert","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Imply","/str","/ev",{"*":".^.c-4","flg":20},{"c-3":["^ \"I saw him take it,\" I continue. \"Collins was outside having a cigarette. Peterson was at the table. But I was at the front of the machine. I saw Hooper go around the side. He leant down and pulled something free. I even challenged him. I said, 'What's that? Someone put a nail somewhere they shouldn't have?' He didn't reply.\"","\n","^Harris watches me for a long moment.","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-4":["^ \"At the moment the machine halted, Peterson was at the bench and Collins was outside having a smoke. I was checking the dip—switches. Hooper was the only one at the back of the Bombe. No—one else could have done it.\"","\n","^\"That's not quite the same as seeing him do it,\" Harris remarks.","\n",["ev","str","^Logical","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Persuasive","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Confident","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","^\"When you have eliminated the impossible...\" I begin, but Harris cuts me off.","\n",{"->":".^.^.^.^.^.g-1"},{"#f":5}],"c-1":["^ ","\n","^\"You have to believe me.\"","\n","^\"We don't have to believe anyone,\" Harris returns. \"I will only be happy with the truth, and your story doesn't tie up. We know you've been leaving yourself open to pressure. We've been watching your activities for some time. But we thought you were endangering the reputation of this site; not risking the country herself. Perhaps I put too much trust in your intellectual pride.\"","\n","^He pauses for a moment, considering something. Then he continues:","\n","^\"It might have been Hooper. It might have been you. ",{"->":".^.^.^.^.^.we_wont_guess"},"\n",{"->":".^.^.^.^.^.g-1"},{"#f":5}],"c-2":["^ ","\n","^\"Ask the others,\" I reply, leaning back. \"They'll tell you. If they haven't already, that's only because they're protecting Hooper. Hoping he'll come to his senses and stop being an idiot. I hope he does too. And if you lock him up in a freezing hut like you've done me, I'm sure he will.\"","\n","^\"We have,\" Harris replies simply.","\n","^It's all I can do not to gape.","\n",{"->":".^.^.^.^.^.g-1.hoopers_hut_3"},{"->":".^.^.^.^.^.g-1"},{"#f":5}]}],{"#f":5}]}],"g-1":["^\"We are left with two possibilities. You, or Hooper.\" The Commander pauses to smooth down his moustache. ","<>","\n",["^\"Hooper's in Hut 3 with the Captain, having a similar conversation.\"","\n",["ev",{"^->":"claim_hooper_took_component.0.g-1.hoopers_hut_3.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-5","flg":22},{"s":["^\"And the other men?",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.g-1.hoopers_hut_3.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-6","flg":22},{"s":["^\"Then you know I'm right.",{"->":"$r","var":true},null]}],{"c-5":["ev",{"^->":"claim_hooper_took_component.0.g-1.hoopers_hut_3.c-5.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"^ Do we have a hut each? Are there enough senior officers to go round?\"","\n","^\"Collins was outside when it happened, and Peterson can't get round the machine in that chair of his,\" Harris replies. \"That leaves you and Hooper.","\n",{"->":".^.^.^.^.we_wont_guess"},{"#f":5}],"c-6":["ev",{"^->":"claim_hooper_took_component.0.g-1.hoopers_hut_3.c-6.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"^ You knew all along. Why did you threaten me?\"","\n","^\"All we know is that we have a traitor, holding the fate of the country in his hands.","\n",{"->":".^.^.^.^.we_wont_guess"},{"#f":5}],"#f":5,"#n":"hoopers_hut_3"}],null],"we_wont_guess":["<>","^ We're not in the business of guessing here at Bletchley. We are military intelligence. We get answers.\" Harris points a finger. \"And if that component has left these grounds, then every minute is critical.\"","\n","ev","str","^Co-operate","/str","/ev",{"*":".^.c-7","flg":20},"ev","str","^Block","/str","/ev",{"*":".^.c-8","flg":20},{"c-7":["^ ","\n","^\"I'd be happy to help,\" I answer, leaning forwards. \"I'm sure there's something I could do.\"","\n","^\"Like what, exactly?\"","\n",[["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^\"Put me in with Hooper.\"",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.1.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-1","flg":22},{"s":["^\"Tell Hooper I've confessed.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.^.^.^.^.putmein"},{"#f":5}],"c-1":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.1.s"},[{"#n":"$r2"}],"^ Better yet. Let him see you marching me off in handcuffs. Then let him go, and see what he does. Ten to one he'll go straight to wherever he's hidden that component and his game will be up.\"","\n","^Harris nods slowly, chewing over the idea. It isn't a bad plan even — except, of course, Hooper has not hidden the component, and won't lead them anywhere. But that's a problem I might be able to solve once I'm out of this place; and once they're too busy dogging Hooper's steps from hut to hut.","\n","^\"Interesting,\" the Commander muses. \"But I'm not so sure he'd be that stupid. And if he's already passed the part on, the whole thing will only be a waste of time.\"","\n",[["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-0","flg":22},{"s":["^\"Trust me. He hasn't.",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.1.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str","/ev",{"*":".^.^.c-1","flg":22},{"s":["^\"You're right. Let me talk to him",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-2","flg":18},{"s":["^\"You're right.\" ",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"^ If I know that man, and I do, he'll be wanting to keep his options open as long as possible. If the component's gone then he's in it up to his neck. He'll take a week at least to make sure he's escaped suspicion. Then he'll pass it on.\"","\n","^\"And if we keep applying pressure to him, you think the component will eventually just turn up?\"","\n",[["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-0","flg":22},{"s":["^\"Yes.",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.1.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^\"Or be thrown into the river.\" ",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"^ Probably under my bunk.\"","\n","^Harris smiles wryly. \"We'll know that for a fake, then. We've looked there already.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.1.s"},[{"#n":"$r2"}],"\n","^\"Hmm.\" Harris chews his moustache thoughtfully. \"Well, that would put us in a spot, seeing as how we'd never know for certain. We'd have to be ready to change our whole approach just in case the part had got through to the Germans.","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["<>","^ I don't mind telling you, this is a disaster, this whole thing. What I want is to find that little bit of mechanical trickery. I don't care where. In your luncheon box or under Hooper's pillow. Just somewhere, and within the grounds of this place.\"","\n",["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.g-0.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-2","flg":22},{"s":["^\"Then let him he think he's off the hook.",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.g-0.4.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^.\"","/str","/ev",{"*":".^.^.c-3","flg":22},{"s":["^\"Then you'd better get searching",{"->":"$r","var":true},null]}],{"c-2":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.g-0.c-2.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"^ Make a show of me. And then you'll get your man.\"","\n","^Somehow, I think. But that's the part I need to work.","\n",{"->":"harris_takes_you_to_hooper"},{"#f":5}],"c-3":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-0.10.g-0.c-3.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.4.s"},[{"#n":"$r2"}],"^,\" I reply, tiring of his complaining. A war is a war, you have to expect an enemy. ",{"->":".^.^.^.^.^.^.^.^.^.^.^.its_your_problem"},"\n",{"#f":5}]}]}],{"#f":5}],"c-1":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.1.s"},[{"#n":"$r2"}],"^, then. As a colleague. Maybe I can get something useful out of him.\"","\n",{"->":".^.^.^.^.^.^.^.^.putmein"},{"#f":5}],"c-2":["ev",{"^->":"claim_hooper_took_component.0.we_wont_guess.c-7.6.c-1.12.c-2.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],{"->":".^.^.^.^.^.^.^.^.shake_head"},"\n",{"#f":5}]}],{"#f":5}]}],{"#f":5}],"c-8":["^ ",{"->":".^.^.^.^.its_your_problem"},"\n",{"#f":5}]}]}],{"harris_being_convinced":[["^\"Makes sense,\" Harris agrees, cautiously. ","ev",{"VAR?":"evasive"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^I can see he's still not entirely convinced by my tale, as well he might not be — I've hardly been entirely straight with him.",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["^I can see he's still not certain whether he can trust me.",{"->":".^.^.^.8"},null]}],"nop","^ \"Which means the question is, what can we do to rat him out?\"","\n","ev","str","^Offer to help","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't offer to help","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"Maybe I can help with that.\"","\n","^\"Oh, yes? And how, exactly?\"","\n",[["ev",{"^->":"claim_hooper_took_component.harris_being_convinced.0.c-0.6.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^\"I'll talk to him.\" ",{"->":"$r","var":true},null]}],["ev",{"^->":"claim_hooper_took_component.harris_being_convinced.0.c-0.6.1.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","str","^\"","/str","/ev",{"*":".^.^.c-1","flg":22},{"s":["^\"We'll fool him.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"claim_hooper_took_component.harris_being_convinced.0.c-0.6.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"\n","^\"What?\"","\n","^\"Put me in with Hooper with him. Maybe I can get something useful out of him.\"","\n",{"->":".^.^.^.^.^.^.putmein"},{"#f":5}],"c-1":["ev",{"^->":"claim_hooper_took_component.harris_being_convinced.0.c-0.6.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.1.s"},[{"#n":"$r2"}],"^ He's waiting to be sure that I've been strung up for this, so let's give him what he wants. If he sees me taken away, clapped in irons — he'll go straight to that component and set about getting rid of it.\"","\n",{"->":"harris_takes_you_to_hooper"},{"#f":5}]}],{"#f":5}],"c-1":["\n","^I lean back. ",{"->":".^.^.^.^.its_your_problem"},"\n",{"#f":5}]}],null],"putmein":[["^Harris shakes his head.","\n","^\"He despises you. I don't see why he'd give himself up to you.\"","\n","ev","str","^Insist","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Give in","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ \"Try me. Just me and him.\" ","\n",{"->":".^.^.^.^.go_in_alone"},{"#f":5}],"c-1":["^ \"You're right.\" ","\n",{"->":".^.^.^.^.shake_head"},{"#f":5}]}],{"#f":1}],"shake_head":["<>","^ I shake my head. \"You're right. I don't see how I can help you. So there's only one conclusion.\"","\n","^\"Oh, yes? And what's that?\"","\n",{"->":".^.^.its_your_problem"},null],"its_your_problem":["^\"It's your problem. Your security breach. So much for your careful vetting process.\"","\n","^I lean back in my chair and fold my arms so the way they shake will not be visible.","\n","^\"You'd better get on with solving it, instead of wasting your time in here with me.\"","\n",{"->":".^.^.harrumphs"},null],"harrumphs":[["^Harris harrumphs. He's thinking it all over.","\n","ev","str","^Wait","/str",{"CNT?":".^.^.^.putmein"},"/ev",{"*":".^.c-0","flg":21},"ev","str","^Wait","/str",{"CNT?":".^.^.^.putmein"},"!","/ev",{"*":".^.c-1","flg":21},{"c-0":["^ ","\n","^\"All right,\" he declares, gruffly. \"We'll try it. But if this doesn't work, I might just put the both of you in front of a firing squad and be done with these games. Worse things happen in time of war, you know.\"","\n","^\"Alone,\" I add.","\n",{"->":".^.^.^.^.go_in_alone"},{"#f":5}],"c-1":["^ ","\n","^\"No,\" Harris declares, finally. \"I think you're lying about Hooper. I think you're a clever, scheming young man — that's why we hired you — and you're looking for the only reasonable out this situation has to offer. But I'm not taking it. We know you were in the room with the machine, we know you're of a perverted persuasion, we know you have compromised yourself. There's nothing more to say here. Either you tell me what you've done with that component, or we will hang you and search just as hard. It's your choice.\"","\n",{"->":"harris_threatens_lynching"},{"#f":5}]}],null],"go_in_alone":[["^\"Alone?\"","\n","^\"Alone.\"","\n","^Harris considers it. I watch his eyes, flicking backwards and forwards over mine, like a ribbon—reader loading its program.","\n","ev","str","^Patient","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Impatient","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ \"Well?\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ \"For God's sake, man, what do you have to lose?\" ","\n","ev",{"^var":"forceful","ci":-1},{"f()":"raise"},"pop","/ev","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"We'll be outside the door,\" Harris replies, seriously. \"The first sign of any funny business and we'll have you both on the floor in minutes. You understand? The country needs your brain, but it's not too worried about your legs. Remember that.\"","\n","^Then he gets to his feet, and opens the door, and marches me out across the yard. The evening is drawing in and there's a chill in the air. My mind is racing. I have one opportunity here — a moment in which to put the fear of God into Hooper and make him do something foolish that places him in harm's way. But how to achieve it?","\n","^\"You ready?\" Harris demands.","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-4","flg":20},{"c-2":["\n","^\"Absolutely.\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-3":["\n","^\"No.\"","\n","^\"Too bad.\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-4":["^ ",{"->":".^.^.c-2"},"\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":[{"->":"inside_hoopers_hut"},null]}],null]}],"harris_takes_you_to_hooper":[["^Harris gets to his feet. \"All right,\" he says. \"I should no better than to trust a clever man, but we'll give it a go.\"","\n","^Then, he smiles, with all his teeth, like a wolf.","\n","ev",{"CNT?":"claim_hooper_took_component.0.g-1.hoopers_hut_3"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Especially since this is a plan that involves keeping you in handcuffs. I don't see what I have to lose.\"","\n",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["\n","^\"Hooper's in Hut 3 being debriefed by the Captain. Let's see if we can't get his attention somehow.\"","\n",{"->":".^.^.^.9"},null]}],"nop","\n","^He raps on the door for the guard and gives the man a quick instruction. He returns a moment later with a cool pair of iron cuffs.","\n","^\"Put 'em up,\" Harris instructs, and I do so. The metal closes around my wrists like a trap. I stand and follow Harris willingly out through the door.","\n","^But whatever I'm doing with my body, my mind is scheming. Somehow, I'm thinking, I have to get away from these men long enough to get that component behind Hut 2 and put it somewhere Hooper will go. Or, otherwise, somehow get Hooper to go there himself...","\n","^Harris marches me over to Hut 3, and gestures for the guard to stand aside. Pushing me forward, he opens the door nice and wide.","\n","^\"Captain. Manning talked. If you'd step out for a moment?\"","\n","ev","str","^Play the part, head down","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Look inside the hut","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Call to Hooper","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","^From where he's sitting, I know Hooper can see me, so I keep my head down and look guilty as sin. The bastard is probably smiling.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["\n","^I look in through the door and catch Hooper's expression. I had half expected him to be smiling be he isn't. He looks shocked, almost hurt. \"Iain,\" he murmurs. \"You couldn't...\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^I have a single moment to shout something to Hooper before the door closes.","\n","^\"I'll get you Hooper, you'll see!\" I cry. Then:","\n",[["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^\"Queen to rook two, checkmate!\"",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"^ I call, then laugh viciously, as if I am damning him straight to hell.","\n","ev",2,"/ev",{"VAR=":"hooperClueType","re":true},{"->":".^.^.only_catch"},{"#f":5}],"only_catch":["^I only catch Hooper's reaction for a moment — his eyebrow lifts in surprise and alarm. Good. If he thinks it is a threat then he just might be careless enough to go looking for what it might mean.","\n",["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.only_catch.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^\"Ask not for whom the bell tolls!\"",{"->":"$r","var":true},null]}],["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.only_catch.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-2","flg":18},{"s":["^\"Two words: messy, without one missing!\"",{"->":"$r","var":true},null]}],{"c-1":["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.only_catch.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"\n","^He stares back at me, as if were a madman and perhaps for a split second I see him shudder.","\n",{"->":".^.^.^.^.^.g-0"},{"#f":5}],"c-2":["ev",{"^->":"harris_takes_you_to_hooper.0.c-2.6.only_catch.c-2.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"^ I cry, laughing. It isn't the best clue, hardly worthy of The Times, but it will have to do.","\n","ev",3,"/ev",{"VAR=":"hooperClueType","re":true},{"->":".^.^"},{"->":".^.^.^.^.^.g-0"},{"#f":5}]}]}],{"#f":5}],"g-0":["^The Captain comes outside, pulling the door to. \"What's this?\" he asks. \"A confession? Just like that?\"","\n","^\"No,\" the Commander admits, in a low voice. \"I'm afraid not. Rather more a scheme. The idea is to let Hooper go and see what he does. If he believes we have Manning here in irons, he'll try to shift the component.\"","\n","^\"If he has it.\"","\n","^\"Indeed.\"","\n","^The Captain peers at me for a moment, like I was some kind of curious insect.","\n","^\"Sometimes, I think you people are magicians,\" he remarks. \"Other times you seem more like witches. Very well.\"","\n","^With that he opens the door to the Hut and goes back inside. The Commander uses the moment to hustle me roughly forward.","\n","ev",{"CNT?":".^.^.c-2"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^\"And what was all that shouting about?\" he hisses in my ear as we move towards the barracks. \"Are you trying to pull something? Or just make me look incompetent?\"","\n",{"->":".^.^.^.19"},null]}],[{"->":".^.b"},{"b":["\n","^\"This scheme of yours had better come off,\" he hisses in my ear. \"Otherwise the Captain is going to start having men tailing me to see where I go on Saturdays.\"","\n",{"->":".^.^.^.19"},null]}],"nop","\n","ev","str","^Reassure","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Dissuade","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Say nothing","/str","/ev",{"*":".^.c-6","flg":20},{"c-3":["^ ","\n","ev",{"CNT?":".^.^.^.c-2"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"It will. Hooper's running scared,\" I reply, hoping I sound more confident than I feel.","\n",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["\n","^\"Just adding to the drama,\" I tell him, confidently. \"I'm sure you can understand that.\"","\n",{"->":".^.^.^.8"},null]}],"nop","\n","^\"I think we've had enough drama today already,\" Harris replies. \"Let's hope for a clean kill.\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-4":["^ ","\n","ev",{"CNT?":".^.^.^.c-2"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"The Captain thought it was a good scheme. You'll most likely get a promotion.\"","\n",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["\n","^\"I'm not trying to do anything except save my neck.\"","\n",{"->":".^.^.^.8"},null]}],"nop","\n","^\"Let's hope things work out,\" Harris agrees darkly.","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-5":["^ ","\n","^\"We're still in ear—shot if they let Hooper go. Best get us inside and then we can talk, if we must.\"","\n","^\"I've had enough of your voice for one day,\" Harris replies grimly. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-6":["\n","^I let him have his rant. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["^He hustles me up the steps of the barracks, keeping me firmly gripped as if I had any chance of giving him, a trained military man, the slip. It's all I can do not to fall into the room.","\n",{"->":"slam_door_shut_and_gone"},null]}],null],"inside_hoopers_hut":[[["^Harris opens the door and pushes me inside. \"Captain,\" he calls. \"Could I have a moment?\"","\n","^The Captain, looking puzzled, steps out. The door is closed. Hooper stares at me, open—mouthed, about to say something. I probably have less than a minute before the Captain storms back in and declares this plan to be bunkum.","\n","ev","str","^Threaten","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Bargain","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Plead","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","^\"Listen to me, Hooper. We were the only men in that hut today, so we know what happened. But I want you to know this. I put the component inside a breeze—block in the foundations of Hut 2, wrapped in one of your shirts. They're going to find it eventually, and that's going to be what tips the balance. And there's nothing you can do to stop any of that from happening.\"","\n","ev",1,"/ev",{"VAR=":"hooperClueType","re":true},"^His eyes bulge with terror. \"What did I do, to you? What did I ever do?\"","\n",["ev","str","^Tell the truth","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^\"You treated me like vermin. Like something abhorrent.\"","\n","^\"You are something abhorrent.\"","\n","^\"I wasn't. Not when I came here. And I won't be, once you're gone.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"Nothing,\" I reply. \"You're just the other man in the room. One of us has to get the blame.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^\"It doesn't matter. Just remember what I said. I've beaten you, Hooper. Remember that.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I get to my feet and open the door of the Hut. The Captain storms back inside and I'm quickly thrown out. ",{"->":".^.^.^.^.^.^.hustled_out"},"\n",null]}],{"#f":5}],"c-1":["^ ","\n","^\"Hooper, I'll make a deal with you. We both know what happened in that hut this afternoon. I know because I did it, and you know because you know you didn't. But once this is done I'll be rich, and I'll split that with you. I'll let you have the results, too. Your name on the discovery of the Bombe. And it won't hurt the war effort — you know as well as me that the component on its own is worthless, it's the wiring of the Bombe, the usage, that's what's valuable. So how about it?\"","\n","^Hooper looks back at me, appalled. \"You're asking me to commit treason?\"","\n",["ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["\n","^\"Yes, perhaps. But also to ensure your name goes down in the annals of mathematics. ",{"->":".^.^.^.^.^.^.back_of_hut_2"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"No. It's not treason. It's a trade, plain and simple.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^\"I'm suggesting you save your own skin. I've wrapped that component in one of your shirts, Hooper. They'll be searching this place top to bottom. They'll find it eventually, and when they do, that's the thing that will swing it against you. So take my advice now. Hut 2.\"","\n","ev",1,"/ev",{"VAR=":"hooperClueType","re":true},{"->":".^.^.g-0"},{"#f":5}],"c-3":["^ ",{"->":".^.^.c-2"},"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":[{"->":".^.^.^.^.^.^.no_chance"},null]}],{"#f":5}],"c-2":["^ ","\n","^\"Please, Hooper. You don't understand. They have information on me. I don't need to tell you what I've done, you know. Have a soul. And the component — it's nothing. It's not the secret of the Bombe. It's just a part. The German's think it's a weapon — a missile component. Let them have it. Please, man. Just help me.\"","\n","^\"Help you?\" Hooper stares. \"Help you? You're a traitor. A snake in the grass. And you're queer.\"","\n",["ev","str","^Deny","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Accept","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^\"I'm no traitor. You know I'm not. How much work have I done here against the Germans? I've given my all. And you know as well as I do, if the Reich were to invade, I would be a dead man. Please, Hooper. I'm not doing any of this lightly.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["\n","^\"I am what I am,\" I reply. \"I'm the way I was made. But they'll hang me unless you help, Hooper. Don't let them hang me.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^\"That's not important now. What matters is what you do, this evening.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"Assuming I wanted to help you,\" he replies, carefully. \"Which I don't. What would I do?\"","\n","^\"Nothing. Almost nothing.","\n",{"->":".^.^.^.^.^.^.back_of_hut_2"},null]}],{"#f":5}],"#n":"g-0"}],null],{"back_of_hut_2":["<>","^ All you have to do is go to the back of Hut 2. There's a breeze—block with a cavity. That's where I've put it. I'll be locked up overnight. But you can pick it up and pass it to my contact. He'll be at the south fence around two AM.\"","\n","ev",1,"/ev",{"VAR=":"hooperClueType","re":true},{"->":".^.^.no_chance"},{"#f":1}],"no_chance":["^\"If you think I'll do that then you're crazy,\" Hooper replies.","\n","^At that moment the door flies open and the Captain comes storming back inside.","\n",{"->":".^.^.hustled_out"},null],"hustled_out":["^Harris hustles me over to the barracks. \"I hope that's the end of it,\" he mutters.","\n","^\"Just be sure to let him out,\" I reply. \"And then see where he goes.\"","\n",{"->":"slam_door_shut_and_gone"},null]}],"slam_door_shut_and_gone":[["^Then they slam the door shut, and it locks.","\n","ev",{"VAR?":"hooperClueType"},0,"==","/ev",[{"->":".^.b","c":true},{"b":["\n","<>","^ How am I supposed to manage anything from in here?","\n","ev","str","^Try the door","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Try the windows","/str","/ev",{"*":".^.c-1","flg":20},{"->":".^.^.^.9"},{"c-0":["^ ",{"->":".^.^.^.^.^.try_the_door"},"\n",{"#f":5}],"c-1":["^ ",{"->":".^.^.^.^.^.try_the_windows"},"\n",{"#f":5}]}]}],[{"->":".^.b"},{"b":["\n","^I can only hope that Hooper bites. If he thinks I'm bitter enough to have framed him, and arrogant enough to have taunted him with ","ev",{"VAR?":"hooperClueType"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^a clue to",{"->":".^.^.^.8"},null]}],"nop","^ where the damning evidence is hidden...","\n","^If he hates me enough, and is paranoid enough, then he might ","ev",{"VAR?":"hooperClueType"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^unravel my little riddle and",{"->":".^.^.^.18"},null]}],"nop","^ go searching around Hut 2.","\n",{"->":".^.^.^.9"},null]}],"nop","\n","ev","str","^Wait","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["^ \t",{"->":"night_falls"},"\n",{"#f":5}]}],{"try_the_door":["^I try the door. It's locked, of course.","\n",{"->":".^.^.from_outside_heard"},{"#f":1}],"from_outside_heard":[["^From outside, I hear a voice. Hooper's. He's haranguing someone.","\n",["ev","str","^Listen at the keyhole","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Try the window","/str",{"CNT?":".^.^.^.^.try_the_windows"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^Try the door","/str",{"CNT?":".^.^.^.^.try_the_door"},"!",{"CNT?":".^.c-0"},"&&","/ev",{"*":".^.c-2","flg":21},"ev","str","^Smash the window","/str",{"CNT?":".^.^.^.^.try_the_windows"},"/ev",{"*":".^.c-3","flg":21},"ev","str","^Wait","/str",{"CNT?":".^.^.^.^.try_the_door"},{"CNT?":".^.^.^.^.try_the_windows"},"&&","/ev",{"*":".^.c-4","flg":21},{"c-0":["^ ","\n","^I put my ear down to the keyhole, but there's nothing now. Probably still a guard outside, of course, but they're keeping mum.","\n",{"->":".^.^"},{"#f":5}],"c-1":["^ ",{"->":".^.^.^.^.^.try_the_windows"},"\n",{"#f":5}],"c-2":["^ ",{"->":".^.^.^.^.^.try_the_door"},"\n",{"#f":5}],"c-3":["^ ",{"->":".^.^.^.^.^.try_to_smash_the_window"},"\n",{"#f":5}],"c-4":["^ ","\n","^It's useless. There's nothing I can do but hope. I sit down on one corner of the bunk to wait.","\n",{"->":"night_falls"},{"#f":5}],"#n":"opts"}],null],null],"try_the_windows":["^I go over to the window and try to jimmy it open. Not much luck, but in my struggling I notice this window only backs on the thin little brook that runs down the back of the compound. Which means, if I smashed it, I might get away with no—one seeing.","\n",{"->":".^.^.from_outside_heard"},{"#f":1}],"try_to_smash_the_window":[["^The window is my only way out of here. I just need a way to smash it.","\n","ev","str","^Punch it","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Find something","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Use something you've got","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^I suppose my fist would do a good enough job. But I'd cut myself to ribbons, most likely. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","ev",2,"/ev",{"VAR=":"smashingWindowItem","re":true},"^I cast around the small room. There's a bucket in one corner for emergencies — I suppose I could use that. I pick it up but it's not very easy to heft. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^I pat down my pockets but all I'm carrying is the intercept, which is no good at all.","\n",["ev","str","^Something you're wearing?","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Look around","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^Ah, but of course! I slip off one shoe and heft it by the toe. The heel will make a decent enough hammer, if I give it enough wallop.","\n","ev",1,"/ev",{"VAR=":"smashingWindowItem","re":true},"^But I'll cut my hand to ribbons doing it. ","<>","\n",{"->":".^.^.^.^.g-0"},{"#f":5}],"c-1":["^ ",{"->":".^.^.^.^.c-1"},"\n",{"->":".^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"g-0":["^And the noise would be terrible. There must be a way of making this easier. I'm supposed to be a thief now. What would a burglar do?","\n","ev","str","^Work slowly","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Find something to help","/str","/ev",{"*":".^.c-4","flg":20},{"c-3":["^ ","\n","^Work carefully? It's difficult to work carefully when all one's has is ","ev",{"VAR?":"smashingWindowItem"},2,"==","/ev",[{"->":".^.b","c":true},{"b":["^a bucket. It's rather like the sledgehammer for the proverbial nut",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["ev",{"VAR?":"smashingWindowItem"},1,"==","/ev",[{"->":".^.b","c":true},{"b":["^a shoe",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^nothing but brute force",{"->":".^.^.^.7"},null]}],"nop",{"->":".^.^.^.10"},null]}],"nop","^.","\n",["ev","str","^Just do it","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Look around for something","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ",{"->":".^.^.^.^.^.^.^.time_to_move_now"},"\n",{"->":".^.^.^.^.^.g-1"},{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.^.^.^.g-1"},{"#f":5}]}],{"#f":5}],"c-4":["^ ","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":[{"->":".^.^.^.^.find_something_to_smash_window"},null]}],null],"time_to_move_now":[["^Enough of this. There isn't any time to lose. Right now they'll be following Hooper as he goes to bed, and goes to sleep; and then that's it. The minute he closes his eyelids and drifts off that's the moment that this trap swings shut on me.","\n","^So I punch out the glass with my ","ev",{"VAR?":"smashingWindowItem"},2,"==","/ev",[{"->":".^.b","c":true},{"b":["^bucket",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["ev",{"VAR?":"smashingWindowItem"},1,"==","/ev",[{"->":".^.b","c":true},{"b":["^shoe",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^fist",{"->":".^.^.^.7"},null]}],"nop",{"->":".^.^.^.10"},null]}],"nop","^ and it shatters with a terrific noise. Then I stop, and wait, to see if anyone will come in through the door.","\n","^Nothing.","\n","ev","str","^Wait a little longer","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Clear the frame of shards","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^I pause for a moment longer. It doesn't do to be too careless...","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["\n","^With my jacket wrapped round my arm, I sweep out the remaining shards of glass. It's not a big window, but I'm not a big man. If I was Harris, I'd be stuffed, but as it is...","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^Then the door locks turns. The door opens. Then Jeremy — one of the guards, rather — sticks his head through the door. \"I thought I heard...\"","\n","^He stops. Looks for a moment. ","ev",{"VAR?":"smashingWindowItem"},2,"==","/ev",[{"->":".^.b","c":true},{"b":["^Sees the bucket in my hand.",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^Sees the broken window.",{"->":".^.^.^.10"},null]}],"nop","^ Then without a moment's further thought he blows his shrill whistles and hustles into the hut, grabbing me roughly by my arms.","\n","ev",{"CNT?":".^.^.c-0"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^I'll never know if I hadn't have waited that extra moment — maybe I still could have got away. But, how far?","\n",{"->":".^.^.^.17"},null]}],"nop","\n","^I'm hustled into one of the huts. Nowhere to sleep, but they're not interested in my comfort any longer. Harris comes in with the Captain.","\n","^\"So,\" Harris remarks. \"Looks like your little trap worked. Only it worked to show you out for what you are.\"","\n","ev","str","^Tell the truth","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-4","flg":20},{"c-2":["^ ","\n","ev",{"CNT?":"i_met_a_young_man"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Please, Harris. You can't understand the pressure they put me under. You can't understand what it's like, to be in love but be able to do nothing about it...\"","\n",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["\n","^\"Harris. They were blackmailing me. They knew about... certain indiscretions. You can understand, can't you, Harris? I was in an impossible bind...\"","\n",{"->":".^.^.^.7"},null]}],"nop","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-3":["\n","^\"I had to get out, Harris. I had to provoke Hooper into doing something that would incriminate himself fully. He's too clever, you see...\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-4":["^ ","\n","^\"This proves nothing,\" I reply stubbornly. \"You still don't have the component and without it, I don't see what you can hope to prove.\"","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["^\"Be quiet, man. We know all about your and your sordid affairs.\" The Captain curls his lip. \"Don't you know there's a war on? Do you know the kind of place they would have sent you if it haven't had been for that brain of yours? Don't you think you owe it to your country to use it a little more?\"","\n","^Do I, I wonder? Do I owe this country anything, this country that has spurned who and what am I since the day I became a man?","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-7","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-8","flg":20},{"c-5":["^ ","\n","^My anger deflates like a collapsing equation, all arguments cancelling each other out. The world, of course, owes me nothing; and I owe it everything.","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-6":["^ ","\n","^Of course not. I am alone; that is what they wanted me to be, because of who and what I love. So I have no nation, no country.","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-7":["^ \t",{"->":".^.^.c-6"},"\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-8":["^ \t","\n","^But what is a country, after all? A country is not a concept, not an ideal. Every country falls, its borders shift and move, its language disappears to be replaced by another. Neither the Reich nor the British Empire will survive forever, so what use is my loyalty to either? ","\n","^I may as well, therefore, look after myself. Something I have attempted, but failed miserably, to do.","\n",{"->":".^.^.^.g-2"},{"#f":5}]}],"g-2":["^\"I'm afraid we have only one option, Manning,\" Harris says. \"Please, man. Tell us where the component is.\"","\n","ev",true,"/ev",{"VAR=":"notraitor","re":true},"ev",false,"/ev",{"VAR=":"losttemper","re":true},"ev","str","^Tell them","/str","/ev",{"*":".^.c-9","flg":20},"ev","str","^Say nothing","/str","/ev",{"*":".^.c-10","flg":20},{"c-9":["\n","ev",false,"/ev",{"VAR=":"revealedhooperasculprit","re":true},"^\"All right.\" I am beaten, after all. \"","<>",{"->":"reveal_location_of_component"},"\n",{"#f":5}],"c-10":["^ ",{"->":"my_lips_are_sealed"},"\n",{"#f":5}]}]}],{"#f":1}],"find_something_to_smash_window":[["^Let me see. There's the bunk, ","ev",{"VAR?":"smashingWindowItem"},"!",2,"==","/ev",[{"->":".^.b","c":true},{"b":["^a bucket,",{"->":".^.^.^.8"},null]}],"nop","^ nothing else. I have my jacket but nothing in the pockets — no handkerchief, for instance.","\n",["ev","str","^The bunk","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^The jacket","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^The bucket","/str",{"VAR?":"smashingWindowItem"},"!",2,"==","/ev",{"*":".^.c-2","flg":21},{"c-0":["^ \t","\n","^The bunk has a solid metal frame, a blanket, a pillow, nothing more.","\n",[["ev","str","^The frame","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^The blanket","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^The pillow","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Something else","/str",{"CNT?":".^"},1,">","/ev",{"*":".^.c-3","flg":21},{"c-0":["\n","^The frame is heavy and solid. I couldn't lift it or shift it without help from another man. And it wouldn't do me any good here anyway. I can reach the window perfectly well.","\n",{"->":".^.^"},{"#f":5}],"c-1":["^ ","\n","^The blanket. Perfect. I scoop it up off the bed and hold it in place over the window. ",{"->":"smash_the_window"},"\n",{"#f":5}],"c-2":["^ ","\n","^The pillow is fat and fluffy. I could put it over the window and it would muffle the sound of breaking glass, certainly; but I wouldn't be able to break any glass through it either.","\n",{"->":".^.^"},{"#f":5}],"c-3":["^ ",{"->":".^.^.^.^.^"},"\n",{"#f":5}],"#f":5,"#n":"bunk_opts"}],null],{"#f":5}],"c-1":["^ ","\n","^I slip off my jacket and hold it with one hand over the glass. ",{"->":"smash_the_window"},"\n",{"#f":5}],"c-2":["^ ","\n","^The bucket? Hardly. The bucket might do some good if I wanted to sweep up the glass afterwards, but it won't help me smash the glass quietly.","\n",{"->":".^.^"},{"#f":5}],"#n":"opts"}],null],null]}],"smash_the_window":[["^Then I heft ","ev",{"VAR?":"smashingWindowItem"},2,"==","/ev",[{"->":".^.b","c":true},{"b":["^up the bucket — this really is quite a fiddly thing to be doing in cuffs — ",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["ev",{"VAR?":"smashingWindowItem"},1,"==","/ev",[{"->":".^.b","c":true},{"b":["^ my shoe by its toe, ",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^back my arm, ",{"->":".^.^.^.7"},null]}],"nop",{"->":".^.^.^.8"},null]}],"nop","^ and take a strong swing, trying to imagine it's Harris' face on the other side.","\n","ev",true,"/ev",{"VAR=":"smashedglass","re":true},"ev",0,"/ev",{"VAR=":"smashingWindowItem","re":true},"ev","str","^Smash!","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^The sound of the impact is muffled. With my arm still covered, I sweep out the remaining glass in the frame.","\n",["^I'm ready to escape. The only trouble is — when they look in on me in the morning, there will be no question what has happened. It won't help me one jot with shifting suspicion off my back.","\n","ev","str","^Wait","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Slip out","/str","/ev",{"*":".^.c-2","flg":20},{"c-1":["\n","^So perhaps I should wait it out, after all. Who knows? I might have a better opportunity later.","\n",{"->":"night_passes"},{"->":".^.^.^.^.g-2"},{"#f":5}],"c-2":["^ ","\n","^Moving quickly and quietly, I hoist myself up onto the window—frame and worm my way outside into the freezing night air. Then I am away, slipping down the paths between the Huts, sticking to the shadows, on my way to Hut 2.","\n",{"->":".^.^.^.^.g-2"},{"#f":5}],"#n":"g-1"}],null],"g-2":["ev","str","^Go the shortest way","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Take a longer route","/str","/ev",{"*":".^.c-4","flg":20},{"c-3":["^ ","\n","^There's no time to lose. Throwing caution to the wind I make my way quickly to Hut 2, and around the back. I don't think I've been seen but if I have it is too late. My actions are suspicious enough for the noose. I have no choice but to follow through.","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-4":["\n","^In case I'm being followed, I divert around the perimeter of the compound. It's a much longer path, and it takes me across some terrain that's difficult to negotiate in the dark — muddy, and thick with thistles and nestles.","\n","ev",true,"/ev",{"VAR=":"muddyshoes","re":true},"^Still, I can be confident no—one is behind me. I crouch down behind the rear wall of Hut 2. ","<>","\n",{"->":".^.^.^.g-3"},{"#f":5}]}],"g-3":["^The component is still there, wrapped in a tea—towel and shoved into a cavity in a breeze—block at the base of the Hut wall.","\n","ev","str","^Take it","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Leave it","/str","/ev",{"*":".^.c-6","flg":20},{"c-5":["^ ","\n","^Quickly, I pull it free, and slip it into the pocket of my jacket.","\n","ev",true,"/ev",{"VAR=":"gotcomponent","re":true},{"->":".^.^.^.g-4"},{"#f":5}],"c-6":["^ ","\n","^Still there means no—one has found it, which means it is probably well—hidden. And short of skipping the compound now, I can afford to leave it hidden there a while longer. So I leave it in place.","\n",{"->":".^.^.^.g-4"},{"#f":5}]}],"g-4":["^Where now?","\n","ev","str","^Back to the barracks","/str","/ev",{"*":".^.c-7","flg":20},"ev","str","^Go to Hooper's dorm","/str",{"VAR?":"gotcomponent"},"/ev",{"*":".^.c-8","flg":21},"ev","str","^Escape the compound","/str","/ev",{"*":".^.c-9","flg":20},{"c-7":["^ ",{"->":"return_to_room_after_excursion"},"\n",{"#f":5}],"c-8":["^ ",{"->":"go_to_hoopers_dorm"},"\n",{"#f":5}],"c-9":["^ ","\n","^Enough of this place. Time for me to get moving. I can get to the train station on foot, catch the postal train to Scotland and be somewhere else before anyone realises that I'm gone.","\n","^Of course, then they'll be looking for me in earnest. ","ev",{"VAR?":"framedhooper"},"!","/ev",[{"->":".^.b","c":true},{"b":["^As a confirmed traitor.",{"->":".^.^.^.11"},null]}],[{"->":".^.b"},{"b":["^Perhaps not as a traitor — they might take the idea that Hooper was involved with the theft — but certainly as a valuable mind, one containing valuable secrets and all too easily threatened. They will think I am running away because of my indiscretions. I suppose, in fairness, that I am.",{"->":".^.^.^.11"},null]}],"nop","\n",["ev","str","^Go","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't go","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ \t\t\t",{"->":"live_on_the_run"},"\n",{"#f":5}],"c-1":["^ ","\n","^It's no good. That's only half a solution. I couldn't be happy with that.","\n",["ev","str","^Back to the barracks","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^To Hooper's dorm","/str",{"VAR?":"gotcomponent"},{"CNT?":"go_to_hoopers_dorm"},"!","&&","/ev",{"*":".^.c-1","flg":21},{"c-0":["^ \t\t\t",{"->":"return_to_room_after_excursion"},"\n",{"#f":5}],"c-1":["^ ",{"->":"go_to_hoopers_dorm"},"\n",{"#f":5}]}],{"#f":5}]}],{"#f":5}]}]}],null],"go_to_hoopers_dorm":[["^I creep around the outside of the huts towards Hooper's dorm. Time to wrap up this little game once and for all. A few guards patrol the area at night but not many — after all, very few know this place even exists.","\n","^Our quarters are arranged away from the main house; where we sleep is of less importance than where we work. We each have our own hut, through some are less permanent than others. Hooper's is a military issue tent: quite a large canopy, with two rooms inside and a short porch area where he insists people leave their shoes. It's all zipped up for the night and no light shines from inside.","\n","^I hang back for a moment. If Harris is keeping to the terms of our deal then someone will be watching this place. But I can see no—one.","\n","ev","str","^Open the outer zip","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Look for another opening","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Hide the component somewhere","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^I creep forward to the tent, intent on lifting the zip to the front porch area just a little — enough to slip the component inside, and without the risk of the noise waking Hooper from his snoring.","\n","^The work is careful, and more than little fiddly — Hooper has tied the zips down on the inside, the fastidious little bastard! — but after a little work I manage to make a hole large enough for my hand.","\n",["ev","str","^Slip in the component","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No, some other way","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ \t\t","\n","^I slide the component into the tent, work the zip closed, and move quickly away into the shadows. It takes a few minutes for my breath to slow, and my heart to stop hammering, but I see no other movement. If anyone is watching Hooper's tent, they are asleep at their posts.","\n","ev",true,"/ev",{"VAR=":"putcomponentintent","re":true},"ev",false,"/ev",{"VAR=":"gotcomponent","re":true},{"->":"return_to_room_after_excursion"},{"#f":5}],"c-1":["^ \t\t\t","\n","^Then pause. This is too transparent. Too blatant. If I leave it here, like this, Hooper will never be seen to go looking for it: he will stumble over it in plain sight, and the men watching will wonder why it was not there when he went to bed.","\n","^No, I must try something else — or nothing at all.","\n",["ev","str","^On top of the tent","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Throw the component into the long grass","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Give up","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ",{"->":".^.^.^.^.^.^.^.put_component_on_tent"},"\n",{"#f":5}],"c-1":["^ ","\n","^From inspiration — or desperation, I am not certain — a simple approach occurs to me. ",{"->":".^.^.^.^.^.^.^.toss_component_into_bushes"},"\n",{"#f":5}],"c-2":["^ ","\n","^There is nothing to be gained here. I have the component now; maybe it will be of some value tomorrow.","\n",["ev","str","^Return to my barrack","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Escape the compound","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ",{"->":"return_to_room_after_excursion"},"\n",{"#f":5}],"c-1":["^ ",{"->":"live_on_the_run"},"\n",{"#f":5}]}],{"#f":5}]}],{"#f":5}]}],{"#f":5}],"c-1":["^ ","\n","^Making a wide circuit I creep around the tent. It has plenty of other flaps and openings, tied down with Gordian complexity. But nothing afford itself to slipping the component inside.","\n",["ev","str","^Try the porch zip","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Try on top of the tent","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Give up","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ \t\t\t",{"->":".^.^.^.^.c-0"},"\n",{"#f":5}],"c-1":["^ \t\t",{"->":".^.^.^.^.^.put_component_on_tent"},"\n",{"#f":5}],"c-2":["^ \t\t\t\t\t\t","\n","^It's no good. Nothing I can do will be any less than obvious — something appearing where something was not there before. The men watching Hooper will know it is a deception and Hooper's protestations will be taken at face value.","\n","^If I can't find a way for Hooper to pick the component up, as if from a hiding place of his own devising, and be caught doing it, then I have no plan at all.","\n",["ev","str","^Return to my barrack","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Escape the compound","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Toss the component into the bushes","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ",{"->":"return_to_room_after_excursion"},"\n",{"#f":5}],"c-1":["^ ",{"->":"live_on_the_run"},"\n",{"#f":5}],"c-2":["^ ",{"->":".^.^.^.^.^.^.^.toss_component_into_bushes"},"\n",{"#f":5}]}],{"#f":5}]}],{"#f":5}],"c-2":["^ ","\n","^If I leave the component here somewhere it should be somewhere I can rely on Hooper finding it, but no—one before Hooper. In particular.","\n",["ev","str","^Behind the tent","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Inside the porch section","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^On top of the canvas","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^\t\t\t \t",{"->":".^.^.^.^.c-1"},"\n",{"#f":5}],"c-1":["^ \t\t",{"->":".^.^.^.^.c-0"},"\n",{"#f":5}],"c-2":["^ \t\t\t",{"->":".^.^.^.^.^.put_component_on_tent"},"\n",{"#f":5}]}],{"#f":5}]}],{"put_component_on_tent":["^A neat idea strikes me. If I could place it on top of the canvas, somewhere in the middle where it would bow the cloth inwards, then it would be invisible to anyone passing by. But to Hooper, it would be above him: a shadow staring him in the face as he awoke. What could be more natural than getting up, coming out, and looking to see what had fallen on him during the night?","\n","^It's the work of a moment. I was once an excellent bowler for the second XI back at school. This time I throw underarm, of course, but I still land the vital missing component exactly where I want it to go.","\n","ev",true,"/ev",{"VAR=":"framedhooper","re":true},"ev",false,"/ev",{"VAR=":"gotcomponent","re":true},"^For a second I hold my breath, but nothing and no—one stirs. ",{"->":"return_to_room_after_excursion"},"\n",null],"toss_component_into_bushes":["^I toss the component away into the bushes behind Hooper's tent and return to my barrack, wishing myself a long sleep followed by a morning, free of this business.","\n","ev",false,"/ev",{"VAR=":"gotcomponent","re":true},"ev",true,"/ev",{"VAR=":"throwncomponentaway","re":true},{"->":"return_to_room_after_excursion"},null],"#f":1}],"live_on_the_run":["^Better to live on the run than die on the spit. Creeping around the edge of the compound","ev",{"VAR?":"gotcomponent"},"/ev",[{"->":".^.b","c":true},{"b":["^, the Bombe component heavy in my pocket",{"->":".^.^.^.5"},null]}],"nop","^, I make my way to the front gate. As always, it's manned by two guards, but I slip past their box by crawling on my belly.","\n","^And then I'm on the road. Walking, not running. Silent. Free.","\n","^For the moment, at least.","\n","end",null],"return_to_room_after_excursion":[["ev",{"VAR?":"gotcomponent"},"/ev",[{"->":".^.b","c":true},{"b":["^The weight of the Bombe component safely in my jacket",{"->":".^.^.^.5"},null]}],[{"->":".^.b"},{"b":["^Satisfied",{"->":".^.^.^.5"},null]}],"nop","^, I return the short way up the paths between the huts to the barrack block and the broken window.","\n","^It's a little harder getting back through — the window is higher off the ground than the floor inside — but after a decent bit of jumping and hauling I manage to get my elbows up, and then one leg, and finally I collapse inside, quite winded and out breath.","\n","ev","str","^Wait","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["^ \t",{"->":"night_passes"},"\n",{"#f":5}]}],null],"night_passes":[["^The rest of the night passes slowly. I sleep a little, dozing mostly. Then I'm woken by the rooster in the yard. The door opens, and Harris comes in. He takes one look at the broken window and frowns with puzzlement.","\n","ev",{"VAR?":"putcomponentintent"},"/ev",[{"->":".^.b","c":true},{"b":["^ ",{"->":".^.^.^.^.put_component_inside_tent"},{"->":".^.^.^.6"},null]}],"nop","\n","^\"What happened there?\"","\n","ev","str","^Confess","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Deny","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Show him the component","/str",{"VAR?":"gotcomponent"},"/ev",{"*":".^.c-2","flg":21},{"c-0":["^ ","\n","^\"I broke it,\" I reply. There doesn't seem any use in trying to lie. \"I thought I could escape. But I couldn't get myself through.\"","\n","^The Commander laughs. ",{"->":".^.^.^.glad_youre_here"},"\n",{"#f":5}],"c-1":["^ ","\n","^\"I'm not sure. I was asleep: I woke up when someone broke the window. I looked out to see who it was, but they were already gone.\"","\n","^Harris looks at me with puzzlement. \"Someone came by to break the window, and then ran off? That's absurd. That's utterly absurd. Admit it, Manning. You tried to escape and you couldn't get through.\"","\n",["ev","str","^Admit it","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Deny it","/str",{"VAR?":"framedhooper"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^Deny it","/str",{"VAR?":"framedhooper"},"/ev",{"*":".^.c-2","flg":21},{"c-0":["\n","^\"All right. ","ev",{"VAR?":"forceful"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^Damn you.",{"->":".^.^.^.8"},null]}],"nop","^ That's exactly it.\"","\n",{"->":".^.^.^.^.^.glad_youre_here"},{"#f":5}],"c-1":["\n","^\"If I wanted to escape, I would have made damn sure that I could,\" I tell him sternly.","\n",{"->":"harris_certain_is_you"},{"#f":5}],"c-2":["^ ","\n","^\"I tell you, someone broke it. Someone wanted to threaten me, I think.\"","\n","^Harris shakes his head. \"Well, we can look into that matter later. For now, you probably want to hear the more pressing news. ",{"->":".^.^.^.^.^.found_missing_component"},"\n",{"#f":5}]}],{"#f":5}],"c-2":["^ ",{"->":".^.^.^.someone_threw_component"},"\n",{"#f":5}]}],{"put_component_inside_tent":[["^He takes one look around, and sighs, a deep, wistful sigh.","\n","^\"Things just get worse and worse for you, Manning,\" he remarks. \"You are your own worst enemy.\"","\n","ev","str","^Agree","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Disagree","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^\"I've thought so before.\" ","ev",{"VAR?":"admitblackmail"},"/ev",[{"->":".^.b","c":true},{"b":["^Certainly in the matter of getting blackmailed.",{"->":".^.^.^.7"},null]}],"nop","\n","^\"Let me tell you what happened this morning. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["\n","^\"Right now, I think you take that role, Harris,\" I reply coolly.","\n",[["^\"Very droll,\" he replies. \"Let me tell you what happened this morning. It will take the smile off your face. ","<>","\n",{"->":".^.^.^.^.g-0"},{"#n":"droll"}],null],{"#f":5}],"c-2":["^ ","\n","^\"I'm looking forward to having a wash and a change of clothes; which should make me a little less evil to be around.\"","\n",{"->":".^.^.c-1.3.droll"},{"->":".^.^.g-0"},{"#f":5}],"g-0":["^Our men watching Hooper's tent saw Hooper wake up, get dressed, clamber out of his tent and then step on something in at the entrance of his tent.\"","\n","ev",true,"/ev",{"VAR=":"piecereturned","re":true},"ev","str","^Be interested","/str","/ev",{"*":".^.c-3","flg":20},"ev","str","^Be dismissive","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Say nothing","/str","/ev",{"*":".^.c-5","flg":20},{"c-3":["^ ","\n","^\"You mean he didn't even hide it? He put it in his shoe?\"","\n",[["^\"No,\" Harris replies. \"That isn't really what I mean. ","<>","\n",{"->":".^.^.^.^.^.g-1"},{"#n":"not_that"}],null],{"#f":5}],"c-4":["\n","^\"So he's an idiot, and he hid it in his shoe.\"","\n",{"->":".^.^.c-3.4.not_that"},{"->":".^.^.^.g-1"},{"#f":5}],"c-5":["^ ","\n","^I say quiet, listening, not sure how this will go.","\n","^\"In case I'm not making myself clear,\" Harris continues, \"","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["^I mean, he managed to find it, by accident, somewhere where it wasn't the night before. And at the same time, you're sitting here with your window broken. So, I rather think you've played your last hand and lost. It's utterly implausible that Hooper stole that component and then left it lying around in the doorway of his tent. So I came to tell you that the game is up, for you.\"","\n","^He nods and gets to his feet. ",{"->":"left_alone"},"\n",null]}],null],"someone_threw_component":[["^\"Someone threw this in through the window over night,\" I reply, and open my jacket to reveal the component from the Bombe. \"I couldn't see who, it was too dark. But I know what it is.\"","\n","^He reaches out and takes it. \"Well, I'll be damned,\" he murmurs. \"That's it all right. And you didn't have it on you when we put you in here. But it can't have been Hooper — I had men watching him all night. And there's no—one else it could have been.\"","\n","^He turns the component over in his hands, bemused.","\n","ev",true,"/ev",{"VAR=":"piecereturned","re":true},"ev","str","^Suggest something","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Suggest nothing","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"Perhaps Hooper had an accomplice. Someone else who works on site.\"","\n","^Harris shakes his head, distractedly. \"That doesn't make sense,\" he says. \"Why go to all the trouble of stealing it only to give it back? And why like this?\"","\n",["ev","str","^Suggest something","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Suggest nothing","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"Perhaps the accomplice thought it was Hooper being kept in here. Maybe they saw the guard...\"","\n",{"->":"all_too_farfetched"},{"->":".^.^.^.^.g-0"},{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I shrug, eloquently.","\n",[{"->":"all_too_farfetched"},{"#n":"g-1"}],null]}],null],"glad_youre_here":[["^\"Shame,\" he remarks. \"I should have left that window open and put a guard on you. Might have been interesting to see where you went. Anyway, I'm glad you're still here, even if you do smell like a dog.\"","\n","ev","str","^Be optimistic","/str",{"VAR?":"framedhooper"},"!","/ev",{"*":".^.c-0","flg":21},"ev","str","^Be pessimistic","/str",{"VAR?":"framedhooper"},"!","/ev",{"*":".^.c-1","flg":21},"ev","str","^Be optimistic","/str",{"VAR?":"framedhooper"},"/ev",{"*":".^.c-2","flg":21},"ev","str","^Be pessimistic","/str",{"VAR?":"framedhooper"},"/ev",{"*":".^.c-3","flg":21},{"c-0":["^ ","\n",{"->":"night_falls.morning_not_saved.0.c-0"},{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n",{"->":"night_falls.morning_not_saved.0.c-1"},{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ","\n","^\"I'm looking forward to having a bath.\"","\n","^\"Well, you should enjoy it. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"c-3":["\n","^\"I imagine I'll smell worse after another couple of days of this.\"","\n","^\"That won't be necessary. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":[{"->":".^.^.^.^.found_missing_component"},null]}],null],"found_missing_component":[["^We found the missing component. Or rather, Hooper found it for us. He snuck out and retrieved it from on top. Of all the damnest places — you would never have known it was there. He claimed ignorance when we jumped him, of course. But it's good enough for me.\"","\n","ev","str","^Approve","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Disapprove","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^\"I can't tell you enough, I'm glad to hear it. I've had a devil of a night.\"","\n","^His gaze flicks to the broken window, but only for a moment. I think he genuinely cannot believe I could have done it.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"You should never have hired him. A below-average intelligence can't be expected to cope with the pressure of our work.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^Harris rolls his eyes, but he might almost be smiling. \"You'd better get along, ","ev",{"CNT?":".^.^.c-0"},"/ev",[{"->":".^.b","c":true},{"b":["^and work through your devils",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["^Mr Intelligent",{"->":".^.^.^.6"},null]}],"nop","^. There's a 24—hour—late message to be tackled and we're a genius short. So you'd better be ready to work twice as hard.\"","\n","ev","str","^Thank him","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Argue with him","/str","/ev",{"*":".^.c-3","flg":20},{"c-2":["^ \t","\n","^\"I'll enjoy it. Thank you for helping me clear this up.\"","\n","^\"Don't thank me yet. There's still a war to fight. Now get a move on.\"","\n","^I nod, and hurry out of the door. The air outside has never tasted fresher and more invigorating. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-3":["^ ","\n","^\"I'll work as hard as I work.\"","\n","^\"Get out,\" Harris growls. \"Before I decide to arrest you as an accessory.\"","\n","^I do as he says. Outside the barrack, the air has never smelt sweeter.","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":[{"->":"head_for_my_dorm_free"},null]}],null]}],"night_falls":[["^Night falls. The clockwork of the heavens keeps turning, whatever state I might be in. No—one can steal the components that make the sun go down and the stars come out. I watch it performing its operations. I can't sleep.","\n","ev",{"VAR?":"hooperClueType"},0,">","/ev",[{"->":".^.b","c":true},{"b":["\n","^Has Hooper taken my bait?","\n",{"->":".^.^.^.8"},null]}],"nop","\n","ev","str","^Look of out the window","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Listen at the door","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Wait","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["^ ","\n","^I peer out of the window, but it looks out onto the little brook at the back of the compound, with no view of the other huts or the House. Who knows if there are men up, searching the base of Hut 2, following one another with flashlights...","\n","ev",{"CNT?":"inside_hoopers_hut.back_of_hut_2"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^Perhaps Hooper is there, in the dark, trying to help me after all?","\n",{"->":".^.^.^.8"},null]}],"nop","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ \t","\n","^I put my ear to the keyhole but can make out nothing. Are there still guards posted? ","ev",{"VAR?":"hooperClueType"},0,">","/ev",[{"->":".^.b","c":true},{"b":["^Perhaps, if Hooper has managed to incriminate himself, the guards have been removed?",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^Perhaps the component has been found and the crisis is over.",{"->":".^.^.^.10"},null]}],"nop","\n","^Perhaps the door is unlocked and they left me to sleep?","\n",["ev","str","^Try it","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Leave it","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ I try the handle. No such luck.","\n",{"->":".^.^.^.^.g-0"},{"#f":5}],"c-1":["^ I don't touch it. I don't want anyone outside thinking I'm trying to escape.","\n",{"->":".^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"c-2":["^ \t\t\t\t\t","\n","^There is nothing I can do to speed up time.","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^The night moves at its own pace. I suppose by morning I will know my fate.","\n","ev","str","^Wait","/str",{"VAR?":"hooperClueType"},0,">","/ev",{"*":".^.c-3","flg":21},"ev","str","^Wait","/str",{"VAR?":"hooperClueType"},0,"==","/ev",{"*":".^.c-4","flg":21},{"c-3":["^ ","\n","^Morning comes. I'm woken by a rooster calling from the yard behind the House. I must have slept after all. I pull myself up from the bunk, shivering slightly. There is condensation on the inside of the window. I have probably given myself a chill.","\n","^Without knocking, Harris comes inside. \"You're up,\" he remarks, and then, \"You smell like an animal.\"","\n",["ev","str","^Be friendly","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Be cold","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"I suppose I do rather.\" I laugh, but Harris does not.","\n","^\"This damn business gets worse and worse,\" he says, talking as he goes over to unlock and throw open the window. ","<>","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"So would you,\" I reply tartly. Harris shrugs.","\n","^\"I've been through worse than this,\" he replies matter—of—factly. \"It's hardly my fault if you sleep in your clothes.\"","\n","^I glare back. He goes over to the window, unlocks it and throws it open, relishing the fresh air from outside.","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"Hooper's confessed, you know.\"","\n","ev","str","^Be eager","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Be cautious","/str","/ev",{"*":".^.c-3","flg":20},{"c-2":["^ ","\n","^\"He has? I knew he would. The worm.\"","\n","^\"Steady now. Matters aren't over yet. ","<>","\n",{"->":".^.^.^.hooper_didnt_give_himself_up"},{"#f":5}],"c-3":["^ ","\n","^\"Oh, yes?\"","\n","^\"Yes. For what that's worth. ","<>","\n",{"->":".^.^.^.hooper_didnt_give_himself_up"},{"#f":5}]}],"hooper_didnt_give_himself_up":["^There's still the issue of the component. It hasn't turned up. He didn't lead us to it. I guess he figured you must have had something on him. I don't know.\"","\n","^He looks quite put out by the whole affair. He is not the kind of man to deal well with probabilities.","\n","ev","str","^Be interested","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Be disinterested","/str","/ev",{"*":".^.c-5","flg":20},{"c-4":["^ ","\n","^\"You mean he confessed of his own accord? You didn't catch him?\"","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-5":["^ ","\n","^\"Well, I'm glad his conscience finally caught up with him,\" I reply dismissively.","\n",{"->":".^.^.^.g-1"},{"#f":5}],"#f":5}],"g-1":["^\"The Captain went back into that hut and he confessed immediately. We were so surprised we didn't let you go.\" He wrinkles his nose. \"I'm rather sorry about that now. I suggest you have a wash.\"","\n","^And with that he gestures to the doorway.","\n","ev","str","^Go","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Wait","/str","/ev",{"*":".^.c-7","flg":20},{"c-6":["^ ","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-7":["^ ","\n","^I hang back a moment. Something does not seem quite right. After all, Hooper did not steal the component. He has no reason to confess to anything. Perhaps this is another trap?","\n","^\"Well?\" Harris asks. \"What are you waiting for? Please don't tell me you want to confess now as well, I don't think my head could stand it.\"","\n",["ev","str","^Confess","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't confess","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^After a chance like this? A chance — however real — to save my neck? To hand it over — what, to save Hooper's worthless skin?","\n",["ev","str","^Confess","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't confess","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^I see. Perhaps you think I bullied the man into giving himself up. Perhaps he understood my little clue far enough to know it was a threat against him, but not well enough to understand where he should look to find it. So he took the easy route out and folded. Gave me the hand.","\n","ev",true,"/ev",{"VAR=":"hooperConfessed","re":true},"^Hardly sporting, of course.","\n",["ev","str","^Confess","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't confess","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^Well, then. I suppose this must be what it feels like to have a conscience. I suppose I had always wondered.","\n","^\"Harris, sir. I don't know what Hooper's playing at, sir. But I can't let him do this.\"","\n","^\"Do what?\"","\n","^\"Take the rope for this. I took it, sir.","\n","ev",false,"/ev",{"VAR=":"revealedhooperasculprit","re":true},"ev",false,"/ev",{"VAR=":"losttemper","re":true},{"->":"reveal_location_of_component"},{"->":".^.^.^.^.^.^.g-0"},{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"c-1":["^ ","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^\"I certainly don't. But still, I'm surprised. I had Hooper down for a full—blown double agent, a traitor. He knows he'll face the rope, doesn't he?\"","\n","^\"Don't ask me to explain why he did what he did,\" Harris sighs. \"Just be grateful that he did, and you're now off the hook.\"","\n",{"->":".^.^.^.^.^.g-2"},null]}],{"#f":5}]}],"g-2":["^Curiouser and curiouser. I nod once to Harris and slip outside into the cold morning air.","\n","ev",{"VAR?":"hooperClueType"},0,"==","/ev",[{"->":".^.b","c":true},{"b":["\n","^Hooper's confession only makes sense in one fashion","ev",{"VAR?":"hooperConfessed"},"/ev",[{"->":".^.b","c":true},{"b":["^, and that is his being dim—witted and slow",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^ — if I successfully implied to him that I had him framed, but he did not unpack my little clue well enough to go looking for the component. Well, I had figured him for a more intelligent opponent, but a resignation from the game will suffice",{"->":".^.^.^.7"},null]}],"nop","^. Or perhaps he knew he would be followed if he went to check, and decided he would be doomed either way.","\n",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["\n","^Hooper's confession only makes sense in one way — and that's that he believed me. He reasoned that he would be followed. To try and uncover the component would have got him arrested, and to confess was the same.","\n","^He simply caved, and threw in his hand.","\n",{"->":".^.^.^.9"},null]}],"nop","\n","^Of course, however, there is only one way to be certain that Harris is telling the truth, and that is to check the breeze—block at the back of Hut 2.","\n","ev","str","^Check","/str","/ev",{"*":".^.c-8","flg":20},"ev","str","^Don't check","/str","/ev",{"*":".^.c-9","flg":20},{"c-8":["^ ",{"->":"go_to_where_component_is_hidden"},"\n",{"#f":5}],"c-9":["\n","^But there will time for that later. If there is nothing there, then Hooper discovered the component after all and Harris' men will have swooped on him, and the story about his confession is just a ruse to test me out.","\n","^And if the component is still there — well. It will be just as valuable to my contact in a week's time, and his deadline of the 31st is not yet upon us.","\n",{"->":"head_for_my_dorm_free"},{"#f":5}]}]}],{"#f":5}],"c-4":["^ ",{"->":".^.^.^.^.morning_not_saved"},"\n",{"#f":5}]}]}],{"morning_not_saved":[["^Morning comes with the call of a rooster from the yard of the House. I must have slept after all. I pull myself up off the bunk, shivering slightly. There is condensation on the inside of the window. I have probably given myself a chill.","\n","^It's not long after that Harris enters the hut. He closes the door behind him, careful as ever, then takes a chair across from me.","\n","^\"You smell like a dog,\" he remarks.","\n","ev","str","^Be optimistic","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Be pessimistic","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"I'm looking forward to a long bath,\" I reply. \"And getting back to work.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^\"So would you after the night I've had.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":[{"->":"harris_certain_is_you"},null]}],null]}],"harris_certain_is_you":["^\"Well, I'm afraid it is going to get worse for you,\" Harris replies soberly. \"We followed Hooper, and he took himself neatly to bed and slept like a boy scout. Which puts us back to square one, and you firmly in the frame. And I'm afraid I don't have time for any more games. I want you to tell me where that component is, or we will hang you as a traitor.\"","\n","ev",false,"/ev",{"VAR=":"revealedhooperasculprit","re":true},"ev",false,"/ev",{"VAR=":"losttemper","re":true},{"->":"harris_threatens_lynching"},{"#f":1}],"head_for_my_dorm_free":[["^I head for my dorm, intent on a bath, breakfast, a glance at the crossword before the other men get to it, and then on with work. They should have replaced the component in the Bombe by now. We will only be a day behind.","\n","ev",{"VAR?":"framedhooper"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^And then everything will proceed as before. The component will mean nothing to the Germans — this is the one fact I could never have explained to a man like Harris, even though the principle behind the Bombe is the same as the principle behind the army. The individual pieces — the men, the components — do not matter. They are identical. It is how they are arranged that counts.","\n",{"->":".^.^.^.7"},null]}],"nop","\n","^I bump into Russell in the dorm hut.","\n","^\"Did you hear?\" he whispers. \"Terrible news about Hooper. Absolutely terrible.\"","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ","\n","^\"Quite terrible. I would never have guessed.\"","\n","^\"Well.\" Russell harrumphs.","\n",[["^\"Quince was saying this morning, apparently his grandfather was German. So perhaps it's to be expected. See you there?\"","\n",{"->":".^.^.^.^.g-0"},{"#n":"quince"}],null],{"#f":5}],"c-1":["\n","^\"Heard what?\"","\n",[["^\"Hooper's been taken away. They caught him, uncovering that missing Bombe component from a hiding place somewhere, apparently about to take it to his contact.\" Russell harrumphs. ",{"->":".^.^.^.^.c-0.6.quince"},"\n",{"->":".^.^.^.^.g-0"},{"#n":"hooper_taken"}],null],{"#f":5}],"c-2":["^ ","\n","^\"I don't know what you're talking about.\"","\n",{"->":".^.^.c-1.3.hooper_taken"},{"->":".^.^.g-0"},{"#f":5}],"c-3":["\n","^\"If you'll excuse me, Russell. I was about to take a bath.\"","\n","^\"Oh, of course. Worked all night, did you? Well, you'll hear soon enough. Can hardly hide the fact there'll only be three of us from now on.\"","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I wave to him and move away, my thoughts turning to the young man in the village. My lover. My contact. My blackmailer. Hooper may have taken the fall for the missing component, but ","ev",{"VAR?":"framedhooper"},"!","/ev",[{"->":".^.b","c":true},{"b":["^if he did recover it from Hut 2 then ",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^ its recovery does mean ",{"->":".^.^.^.7"},null]}],"nop","^I have nothing to sell to save my reputation","ev",{"CNT?":"i_met_a_young_man"},"/ev",[{"->":".^.b","c":true},{"b":["^, if I have any left",{"->":".^.^.^.13"},null]}],"nop","^.","\n","ev",{"VAR?":"framedhooper"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^If he didn't, of course, and Harris was telling the truth about his sudden confession, then I will be able to buy my freedom once and for all.","\n",{"->":".^.^.^.21"},null]}],"nop","\n","ev","str","^Get the component","/str",{"VAR?":"framedhooper"},"!","/ev",{"*":".^.c-4","flg":21},"ev","str","^Leave it","/str",{"VAR?":"framedhooper"},"!","/ev",{"*":".^.c-5","flg":21},"ev","str","^Act normal","/str","/ev",{"*":".^.c-6","flg":20},{"c-4":["^ ",{"->":"go_to_where_component_is_hidden"},"\n",{"#f":5}],"c-5":["^ ","\n","^I will have to leave that question for another day. To return there now, when they're probably watching my every step, would be suicide. After all, if Hooper ","ev",{"VAR?":"hooperClueType"},1,"==","/ev",[{"->":".^.b","c":true},{"b":["^followed",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^understood",{"->":".^.^.^.10"},null]}],"nop","^ my clue, he will have explained it to them to save his neck. They won't believe him — but they won't quite disbelieve him either. We're locked in a cycle now, him and me, of half—truth and probability. There's nothing either of us can do to put the other entirely into blame.","\n",{"->":"ending_return_to_normal"},{"#f":5}],"c-6":["^ ","\n","^But there is nothing to be done about it. ",{"->":"ending_return_to_normal"},"\n",{"#f":5}]}]}],null],"ending_return_to_normal":[["^Nothing, that is, except to act as if there is no game being played. I'll have a bath, then start work as normal. I've got a week to find something to give my blackmailer","ev",{"CNT?":"i_met_a_young_man"},"/ev",[{"->":".^.b","c":true},{"b":["^ — or give him nothing: it seems my superiors know about my indiscretions now already",{"->":".^.^.^.5"},null]}],"nop","^.","\n","ev","str","^Co-operate","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Dissemble","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-3","flg":20},{"c-0":["^ ","\n","^Something will turn up. It always does. An opportunity will present itself, and more easily now that Hooper is out of the way.","\n","^But for now, there's yesterday's intercept to be resolved.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^Or perhaps I might hand my young blackmailer over my superiors instead for being the spy he is.","\n","^Perhaps that would be the moral thing to do, even, and not just the most smart.","\n","^But not today. Today, there's an intercept to resolve.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["\n","^In a week's time, this whole affair will be in the past and quite forgotten. I'm quite sure of that. ",{"->":".^.^.c-3"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-3":["^ I've more important problems to think about now. There's still yesterday's intercept to be resolved. ","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^The Bombe needs to be set up once more and set running.","\n","^It's time I tackled a problem I can solve.","\n","end",null]}],null],"go_to_where_component_is_hidden":[["^It won't take a moment to settle the matter. I can justify a walk past Hut 2 as part of my morning stroll. It will be obvious in a moment if the component is still there.","\n","^On my way across the paddocks, between the huts and the House, I catch sight of young Miss Lyon, arriving for work on her bicycle. She giggles as she sees me and waves.","\n","ev","str","^Wave back","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Ignore her","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^I wave cheerily back and she giggles, almost drops her bicycle, then dashes away inside the House. Judging by the clock on the front gable, she's running a little late this morning.","\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["^ ","\n","^I give no reaction. She sighs to herself, as if this kind of behaviour is normal, and trots away inside the House to begin her duties.","\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I turn the corner of Hut 3 and walk down the short gravel path to Hut 2. It was a good spot to choose — Hut 2 is where the electricians work, and they're generally focussed on what they're doing. They don't often come outside to smoke a cigarette so it's easy to slip past the doorway unnoticed.","\n","ev","str","^Check inside","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Go around the back","/str","/ev",{"*":".^.c-3","flg":20},{"c-2":["^ \t\t","\n","^I hop up the steps and put my head inside all the same. Nobody about. Still too early in the AM for sparks, I suppose. ","<>","\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-3":["^ ","\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["^I head on around the back of the hut. The breeze—block with the cavity is on the left side.","\n","ev","str","^Check","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^Look around","/str","/ev",{"*":".^.c-5","flg":20},{"c-4":["^ \t\t","\n","^No time to waste. I drop to my knees and check the breeze—block. Sure enough, there's nothing there. Hooper took the bait.","\n","^Suddenly, there's a movement behind me. I look up to see, first a snub pistol, and then, Harris.","\n",{"->":".^.^.^.g-2"},{"#f":5}],"c-5":["^ ","\n","^I pause to glance around, and catch a glimpse of movement. Someone ducking around the corner of the hut. Or a canvas sheet flapping in the light breeze. Impossible to be sure.","\n",["ev","str","^Check the breeze—block","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Check around the side of the hut","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ",{"->":".^.^.^.^.c-4"},"\n",{"->":".^.^.^.^.^.g-2"},{"#f":5}],"c-1":["^ ","\n","^But too important to guess. I move back around the side of the hut.","\n","^Harris is there, leaning in against the wall. He holds a stub pistol in his hand.","\n",{"->":".^.^.^.^.^.g-2"},{"#f":5}]}],{"#f":5}]}],"g-2":["ev",{"VAR?":"hooperClueType"},1,">","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"","ev",{"VAR?":"hooperClueType"},2,"==","/ev",[{"->":".^.b","c":true},{"b":["^Queen to rook two",{"->":".^.^.^.9"},null]}],[{"->":".^.b"},{"b":["^Messy without one missing whatever it was",{"->":".^.^.^.9"},null]}],"nop","^,\" he declares. \"I wouldn't have fathomed it but Hooper did. Explained it right after we sprung him doing what you're doing now. We weren't sure what to believe but now, you seem to have resolved that for us.\"","\n",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["\n","^\"Hooper said you'd told him where to look. I didn't believe him. Or, well. I wasn't sure what to believe. Now I rather think you've settled it.\"","\n",{"->":".^.^.^.7"},null]}],"nop","\n","ev","str","^Agree","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-7","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-8","flg":20},{"c-6":["^ ","\n","^\"I have, rather.\" I put my hands into my pockets. \"I seem to have done exactly that.\"","\n","^\"I'm afraid my little story about Hooper confessing wasn't true. I wanted to see if you'd go to retrieve the part.\" Harris gestures me to start walking. \"You were close, Manning, I'll give you that. I wanted to believe you. But I'm glad I didn't.\"","\n",{"->":".^.^.^.g-3.done"},{"->":".^.^.^.g-3"},{"#f":5}],"c-7":["^ ","\n","^\"I spoke to Russell. He said he saw Hooper doing something round here. I wanted to see what it was.\"","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-8":["^ ","\n","^\"Harris, you'd better watch out. He's planted a time—bomb here.\"","\n","^Harris stares at me for a moment, then laughs. \"Oh, goodness. That's rich.\"","\n","^I almost wish I had a way to make the hut explode, but of course I don't.","\n",{"->":".^.^.^.g-3"},{"#f":5}]}],"g-3":["^\"Enough.\" Harris gestures for me to start walking. \"This story couldn't be simpler. You took it to cover your back. You hid it. You lied to get Hooper into trouble, and when you thought you'd won, you came to scoop your prize. A good hand but ultimately, ","ev",{"VAR?":"hooperClueType"},1,"<=","/ev",[{"->":".^.b","c":true},{"b":["^if it hadn't have been you who hid the component, then you wouldn't be here now",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["^you told Hooper where to look with your little riddle",{"->":".^.^.^.8"},null]}],"nop","^.\"","\n",["^He leads me across the yard. Back towards Hut 5 to be decoded, and taken to pieces, once again.","\n","end",{"#n":"done"}],null]}],null],"harris_threatens_lynching":[["ev",{"CNT?":"harris_certain_is_you"},"/ev",[{"->":".^.b","c":true},{"b":["^He passes a hand across his eyes with a long look of despair.",{"->":".^.^.^.5"},null]}],[{"->":".^.b"},{"b":["^He gets to his feet, and gathers his gloves from the table top.",{"->":".^.^.^.5"},null]}],"nop","\n","^\"I'm going to go outside and organise a rope. That'll take about twelve minutes. That's how long you have to decide.\"","\n","ev","str","^Protest","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Confess","/str",{"VAR?":"gotcomponent"},"!",{"VAR?":"throwncomponentaway"},"!","&&","/ev",{"*":".^.c-1","flg":21},"ev","str","^Stay silent","/str","/ev",{"*":".^.c-2","flg":20},"ev","str","^Show him the component","/str",{"VAR?":"gotcomponent"},"/ev",{"*":".^.c-3","flg":21},{"c-0":["^ ","\n","^\"You can't do this!\" I cry. \"It's murder! I demand a trial, a lawyer; for God's sake, man, you can't just throw me overboard, we're not barbarians...!\"","\n",[["^\"You leave me no choice,\" Harris snaps back, eyes cold as gun—metal. \"You and your damn cyphers. Your damn clever problems. If men like you didn't exist, if we could just all be straight with one another.\" He gets to his feet and heads for the door. \"I fear for the future of this world, with men like you in. Reich or no Reich, Mr Manning, people like you simply complicate matters.\"","\n",{"->":"left_alone"},{"->":".^.^.^.^.g-0"},{"#f":5,"#n":"too_clever"}],null],{"#f":5}],"c-1":["^ ","\n","^I nod. \"I don't need twelve minutes. ",{"->":"reveal_location_of_component"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-2":["^ ",{"->":"my_lips_are_sealed"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-3":["^ ","\n","^\"I don't need twelve minutes. Here it is.\"","\n","^I open my jacket and pull the Bombe component out of my pocket. Harris takes it from me, whistling, curious.","\n","^\"Well, I'll be. That's it all right.\"","\n","^\"That's it.\"","\n","^\"But you didn't have it on you yesterday.\"","\n",["ev","str","^Explain","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Don't explain","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","^\"I climbed out of the window overnight,\" I explain. \"I went and got this from where it was hidden, and brought it back here.\"","\n",{"->":".^.^.^.^.g-0"},{"#f":5}],"c-1":["\n","^\"No. I didn't.\"","\n",{"->":".^.^.^.^.g-0"},{"#f":5}]}],{"#f":5}],"g-0":[{"->":"all_too_farfetched"},"ev","str","^Confess","/str",{"VAR?":"throwncomponentaway"},"/ev",{"*":".^.c-4","flg":21},"ev","str","^Frame Hooper","/str",{"VAR?":"throwncomponentaway"},"/ev",{"*":".^.c-5","flg":21},{"c-4":["\n","^\"I don't need twelve minutes. The component is in the long grass behind Hooper's tent. I threw it there hoping to somehow frame him, but now I see that won't be possible. I was naive, I suppose.\"","\n","ev",true,"/ev",{"VAR=":"piecereturned","re":true},{"->":"reveal_location_of_component.harris_believes"},{"#f":5}],"c-5":["^ ","\n","^\"Look, I know where it is. The missing piece of the Bombe is in the long grasses behind Hooper's tent. I saw him throw it there right after we finished work. He knew you'd scour the camp but I suppose he thought you'd more obvious places first. I suppose he was right about that. Look there. That proves his guilt.\"","\n","ev",true,"/ev",{"VAR=":"longgrasshooperframe","re":true},"ev",true,"/ev",{"VAR=":"piecereturned","re":true},"^\"That doesn't prove anything,\" Harris returns sharply. \"But we'll check what you say, all the same.\" He gets to his feet and heads out of the door.","\n",{"->":"left_alone"},{"#f":5}]}]}],null],"reveal_location_of_component":["<>","^ The missing component of the Bombe computer is hidden in a small cavity in a breeze—block supporting the left rear post of Hut 2. I put in there anticipating a search. I intended to ","ev",{"VAR?":"revealedhooperasculprit"},"/ev",[{"->":".^.b","c":true},{"b":["^pass it to Hooper",{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["^dispose of it",{"->":".^.^.^.7"},null]}],"nop","^ once the fuss had died down. I suppose I was foolish to think that it might.\"","\n","ev",true,"/ev",{"VAR=":"piecereturned","re":true},{"->":".^.harris_believes"},{"harris_believes":["ev",{"CNT?":"night_falls.0.g-0.c-3.6.hooper_didnt_give_himself_up"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Indeed. And Mr Manning: God help you if you're lying to me.\"","\n",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["\n","^\"I thought as much. I hadn't expected you to give it out so easily, however. You understand, Hooper has said nothing, of course. In fact, he went to Hut 2 directly after we released him and uncovered the component. But he told us you had instructed him where to go. Hence my little double bluff. Frankly, I'll be glad when I'm shot of the lot of you mathematicians.\"","\n",{"->":".^.^.^.6"},null]}],"nop","\n","^Harris stands, and slips away smartly. ",{"->":"left_alone"},"\n",null]}],"my_lips_are_sealed":["^I say nothing, my lips tightly, firmly sealed. It's true I am a traitor, to the very laws of nature. The world has taught me that since a very early age. But not to my country — should the Reich win this war, I would hardly be treated as an honoured hero. I was doomed from the very start.","\n","ev",true,"/ev",{"VAR=":"notraitor","re":true},"^I explain none of this. How could a man like Harris understand?","\n","^The Commander takes one look back from the doorway as he pulls it to.","\n","^\"It's been a pleasure working with you, Mr Manning,\" he declares. \"You've done a great service to this country. If we come through, I'm sure they'll remember you name. I'm sorry it had to end this way and I'll do my best to keep it quiet. No—one need know what you did.\"","\n",{"->":"left_alone"},null],"all_too_farfetched":["^\"This is all too far—fetched,\" Harris says. \"I'm glad to have this back, but I need to think.\"","\n","^Getting to his feet, he nods once. \"You'll have to wait a little longer, I'm afraid, Manning.\"","\n","^Then he steps out of the door, muttering to himself.","\n",{"->":"make_your_peace"},null],"left_alone":["ev",{"CNT?":"slam_door_shut_and_gone.time_to_move_now"},"/ev",[{"->":".^.b","c":true},{"b":["^The Commander holds the door for his superior, and follows him out.",{"->":".^.^.^.4"},null]}],"nop","^ Then the door closes. I am alone again, as I have been for most of my short life.","\n",{"->":"make_your_peace"},null],"make_your_peace":[["ev","str","^Make your peace","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^I am waiting again. I have no God to make my peace with. I find it difficult to believe in goodness of any kind, in a world such as this.","\n","ev",{"VAR?":"notraitor"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","ev",true,"/ev",{"VAR=":"notraitor","re":true},"^But I am no traitor. Not to my country. To my sex, perhaps. But how could I support the Reich? If the Nazis were to come to power, I would be worse off than ever.","\n",{"->":".^.^.^.7"},null]}],"nop","\n","ev",{"CNT?":"harris_threatens_lynching.0.c-0.4.too_clever"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^In truth, it is men like Harris who are complex, not men like me. I live to make things ordered, systematic. I like my pencils sharpened and lined up in a row. I do not deal in difficult borders, or uncertainties, or alliances. If I could, I would reduce the world to something easier to understand, something finite.","\n","^But I cannot, not even here, in our little haven from the horrors of the war.","\n",{"->":".^.^.^.13"},null]}],"nop","\n","^I have no place here. No way to fit. I am caught, in the middle, cryptic and understood only thinly, through my machines.","\n",["ev",{"^->":"make_your_peace.0.g-0.17.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^I must seem very calm. \t\t\t",{"->":"$r","var":true},null]}],["ev",{"^->":"make_your_peace.0.g-0.18.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-2","flg":18},{"s":["^Perhaps I should try to escape.",{"->":"$r","var":true},null]}],{"c-1":["ev",{"^->":"make_your_peace.0.g-0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.17.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.^.g-1"},{"#f":5}],"c-2":["ev",{"^->":"make_your_peace.0.g-0.c-2.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.18.s"},[{"#n":"$r2"}],"^ But escape to where? I am already a prisoner. Jail would be a blessing. ",{"->":".^.^.^.g-1.monastic"},"\n",{"->":".^.^.^.g-1"},{"#f":5}]}],"g-1":["<>","^ I suppose I do not believe they will hang me. They will lock me up and continue to use my brain, if they can. I wonder what they will tell the world — perhaps that I have taken my own life. That would be simplest. The few who know me would believe it.","\n","^Well, then. Not a bad existence, in prison. Removed from temptation.","\n",["^A monastic life, with plenty of problems to keep me going.","\n","^I wonder what else I might yet unravel before I'm done?","\n",["ev",{"^->":"make_your_peace.0.g-1.monastic.4.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-3","flg":18},{"s":["^The door is opening.",{"->":"$r","var":true},null]}],{"c-3":["ev",{"^->":"make_your_peace.0.g-1.monastic.c-3.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.4.s"},[{"#n":"$r2"}],"^ Harris is returning. Our little calculation here is complete. ","ev",{"VAR?":"piecereturned"},"!","/ev",[{"->":".^.b","c":true},{"b":["^ I can only hope one of the others will be able to explain to him that the part I stole will mean nothing to the Germans.",{"->":".^.^.^.13"},null]}],[{"->":".^.b"},{"b":["^We are just pieces in this machine; interchangeable and prone to wear.",{"->":".^.^.^.13"},null]}],"nop","\n",{"->":".^.^.^.^.g-2"},{"#f":5}],"#n":"monastic"}],null],"g-2":["^That is the true secret of the calculating engine, and the source of its power. It is not the components that matter, they are quite repetitive. What matters is how they are wired; the diversity of the patterns and structures they can form. Much like people — it is how they connect that determines our victories and tragedies, and not their genius.","\n","^Which makes me wonder. Should I give ","ev",{"CNT?":"i_met_a_young_man"},"/ev",[{"->":".^.b","c":true},{"b":["^up my beautiful young man",{"->":".^.^.^.8"},null]}],[{"->":".^.b"},{"b":["^the young man who put me in this spot",{"->":".^.^.^.8"},null]}],"nop","^ to them as well as myself?","\n","ev","str","^Yes","/str","/ev",{"*":".^.c-4","flg":20},"ev","str","^No","/str","/ev",{"*":".^.c-5","flg":20},"ev","str","^Lie","/str","/ev",{"*":".^.c-6","flg":20},"ev","str","^Evade","/str","/ev",{"*":".^.c-7","flg":20},{"c-4":["^ ","\n","^But of course I will. ","ev",{"VAR?":"forceful"},2,">","/ev",[{"->":".^.b","c":true},{"b":["^Perhaps I can persuade them to put him in my cell.",{"->":".^.^.^.10"},null]}],[{"->":".^.b"},{"b":["^A little vengeance, disguised as doing something good.",{"->":".^.^.^.10"},null]}],"nop","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-5":["^ ","\n","^No. What would be the use? He will be long gone, and the name he told me is no doubt hokum. No: I was alone before in guilt, and I am thus alone again.","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-6":["^ ","\n","^No. Why would I? He is no doubt an innocent himself, trapped by some dire circumstance. Forced to act the way he did. I have every sympathy for him.","\n","^Of course I do.","\n",{"->":".^.^.^.g-3"},{"#f":5}],"c-7":["^ ","\n","^It depends, perhaps, on what his name his worth. If it were to prove valuable, well; perhaps I can concoct a few more such lovers with which to ease my later days.","\n","ev",{"VAR?":"hooper_mentioned"},"/ev",[{"->":".^.b","c":true},{"b":["^ Hooper, perhaps. He wouldn't like that. ",{"->":".^.^.^.8"},null]}],"nop","\n",{"->":".^.^.^.g-3"},{"#f":5}]}],"g-3":["ev",{"VAR?":"longgrasshooperframe"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^Harris put the cuffs around my wrists. \"I still have the intercept in my pocket,\" I remark. \"Wherever we're going, could I have a pencil?\"","\n",{"->":".^.^.^.6"},null]}],[{"->":".^.b"},{"b":["\n","^\"We recovered the part, just where you said it was,\" Harris reports, as he puts the cuffs around my wrists. \"Of course, a couple of the men swear blind they searched there yesterday, so I'm afraid, what with the broken window... we've formed a perfectly good theory which doesn't bode well for you.\"","\n",{"->":".^.^.^.6"},null]}],"nop","\n","ev",true,"/ev",{"VAR=":"piecereturned","re":true},"ev",{"VAR?":"longgrasshooperframe"},"/ev",[{"->":".^.b","c":true},{"b":["\n","^\"I see.\" It doesn't seem worth arguing any further. \"I still have the intercept in my pocket,\" I remark. \"Wherever we're going, could I have a pencil?\"","\n",{"->":".^.^.^.16"},null]}],"nop","\n","^He looks me in the eye.","\n","ev",{"VAR?":"losttemper"},"!","/ev",[{"->":".^.b","c":true},{"b":["\n","^\"Of course. And one of your computing things, if I get my way. And when we're old, and smoking pipes together in The Rag like heroes, I'll explain to you the way that decent men have affairs.","\n",{"->":".^.^.^.26"},null]}],[{"->":".^.b"},{"b":["\n","^\"I'll give you a stone to chisel notches in the wall. And that's all the calculations you'll be doing. And as you sit there, pissing into a bucket and growing a beard down to your toes, you have a think about how a smart man would conduct his illicit affairs. With a bit of due decorum you could have learnt off any squaddie.","\n",{"->":".^.^.^.26"},null]}],"nop","\n","<>","^ You scientists.\"","\n","^He drags me up to my feet.","\n","^\"You think you have to re—invent everything.\"","\n","^With that, he hustles me out of the door and I can't help thinking that, with a little more strategy, I could still have won the day. But too late now, of course.","\n","end",null]}],null],"global decl":["ev",0,{"VAR=":"forceful"},0,{"VAR=":"evasive"},false,{"VAR=":"teacup"},false,{"VAR=":"gotcomponent"},false,{"VAR=":"drugged"},false,{"VAR=":"hooper_mentioned"},false,{"VAR=":"losttemper"},false,{"VAR=":"admitblackmail"},0,{"VAR=":"hooperClueType"},false,{"VAR=":"hooperConfessed"},0,{"VAR=":"smashingWindowItem"},false,{"VAR=":"notraitor"},false,{"VAR=":"revealedhooperasculprit"},false,{"VAR=":"smashedglass"},false,{"VAR=":"muddyshoes"},false,{"VAR=":"framedhooper"},false,{"VAR=":"putcomponentintent"},false,{"VAR=":"throwncomponentaway"},false,{"VAR=":"piecereturned"},false,{"VAR=":"longgrasshooperframe"},false,{"VAR=":"DEBUG"},"/ev","end",null]}],"listDefs":{}} \ No newline at end of file diff --git a/data/worlds/example_world.yml b/data/worlds/example_world.yml index d01d257..32b666d 100644 --- a/data/worlds/example_world.yml +++ b/data/worlds/example_world.yml @@ -2,43 +2,45 @@ title: The Mysterious Mansion author: AI Interactive Fiction version: 1.0.0 introduction: | - ::music[crossfade, loop, lead=10](Dark Jodler.mp3) - ::chapter[The Mysterious Mansion] + #chapter[The Mysterious Mansion] + #music[Dark Jodler.mp3](lead=10) The last thing you remember is the letter: heavy paper, black wax, your name written in a hand you almost recognized. It asked you to come after dusk, alone, and promised that the house would answer what the sender could not. - Now you stand beyond the wrought iron gate, with rain cooling your face and the hill rising before you. - At its crest waits the old Victorian mansion, every dark window turned toward the path as if the building has been expecting you. - - The gate gives under your hand with no protest, though its ironwork is wet enough to shine black. - Gravel shifts beneath your boots as you pass between the pillars, and the garden closes behind you with the soft finality of a curtain. - - Halfway up the path, you stop and listen. - The rain has thinned to a whisper, but the house answers with other sounds: timber settling, gutters ticking, and something deep inside the walls that might be machinery or breath. - - For a heartbeat you think the mansion is about to speak ... but only the wind moves through the ivy. - It drags the leaves across the brickwork in slow strokes, as if wiping dust from an old name. - -# Room definitions -rooms: + Now you stand beyond the wrought iron gate, with rain cooling your face and the hill rising before you. + At its crest waits the old Victorian mansion, every dark window turned toward the path as if the building has been expecting you. + + The gate gives under your hand with no protest, though its ironwork is wet enough to shine black. + Gravel shifts beneath your boots as you pass between the pillars, and the garden closes behind you with the soft finality of a curtain. + + Halfway up the path, you stop and listen. + The rain has thinned to a whisper, but the house answers with other sounds: timber settling, gutters ticking, and something deep inside the walls that might be machinery or breath. + + For a heartbeat you think the mansion is about to speak ... but only the wind moves through the ivy. + It drags the leaves across the brickwork in slow strokes, as if wiping dust from an old name. + +# Room definitions +rooms: # Starting area front_yard: name: Front Yard description: | You follow the gravel path up the hill. The rain softens to a drizzle, and moonlight peeks through gaps in the clouds. - Ancient oak trees frame the property, their branches swaying in the gentle breeze. - At the top of three worn stone steps, the mansion's front door waits under a sagging porch roof. - The porch boards are swollen with rain, each one bending under your weight before it remembers its shape. - A brass knocker hangs at eye level, polished bright at the edges where countless hands have touched it and left no warmth behind. - The letter in your pocket presses against your ribs. - You remember the last line now: come before the clocks learn your name. - Somewhere above you, behind a blind upper window, a pale shape passes from left to right and is gone. - You tell yourself it was a reflection, then look back at the path and find no light behind you bright enough to make one. - The house waits. - When you reach for the handle, it turns before your fingers touch it, and the door opens {{sfx:squeaky-door.ogg}} with a long, complaining squeak. + Ancient oak trees frame the property, their branches swaying in the gentle breeze. + At the top of three worn stone steps, the mansion's front door waits under a sagging porch roof. + The porch boards are swollen with rain, each one bending under your weight before it remembers its shape. + A brass knocker hangs at eye level, polished bright at the edges where countless hands have touched it and left no warmth behind. + The letter in your pocket presses against your ribs. + You remember the last line now: come before the clocks learn your name. + Somewhere above you, behind a blind upper window, a pale shape passes from left to right and is gone. + You tell yourself it was a reflection, then look back at the path and find no light behind you bright enough to make one. + The house waits. + + #sfx[squeaky-door.ogg] + When you reach for the handle, it turns before your fingers touch it, and the door opens with a long, complaining squeak. exits: - direction: north targetRoomId: entrance_hall diff --git a/dist/config/game-config.d.ts b/dist/config/game-config.d.ts new file mode 100644 index 0000000..a6d838f --- /dev/null +++ b/dist/config/game-config.d.ts @@ -0,0 +1,38 @@ +export type EngineName = 'yaml' | 'ink' | 'zork' | string; +export interface GameMetadata { + title: string; + author?: string; + subtitle?: string; + version?: string; + copyright?: string; +} +export interface GamePaths { + mainGameFile: string; + inkSource?: string; + inkCompiled?: string; + promptDir?: string; + music?: string; + sfx?: string; + images?: string; + [key: string]: string | undefined; +} +export interface GameEngineConfig { + engine: EngineName; + locale: 'en_US' | 'de_DE' | string; + paths: GamePaths; + metadata: GameMetadata; +} +export declare function projectPath(relativeOrAbsolutePath: string): string; +export declare function loadGameConfig(configPath: string, engine: EngineName): GameEngineConfig; +export declare function ensureConfiguredAssetDirectories(config: GameEngineConfig): void; +export declare function clientGameConfig(config: GameEngineConfig): { + engine: string; + locale: string; + metadata: GameMetadata; + assets: { + music: string; + sfx: string; + sounds: string; + images: string; + }; +}; diff --git a/dist/config/game-config.js b/dist/config/game-config.js new file mode 100644 index 0000000..e31d763 --- /dev/null +++ b/dist/config/game-config.js @@ -0,0 +1,94 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.projectPath = projectPath; +exports.loadGameConfig = loadGameConfig; +exports.ensureConfiguredAssetDirectories = ensureConfiguredAssetDirectories; +exports.clientGameConfig = clientGameConfig; +const path_1 = __importDefault(require("path")); +const fs_1 = require("fs"); +const PROJECT_ROOT = path_1.default.resolve(__dirname, '../..'); +function fallbackConfig(engine) { + return { + engine, + locale: 'en_US', + paths: { + mainGameFile: engine === 'ink' + ? 'data/ink/story.ink.json' + : engine === 'zork' + ? 'data/z-code/zork1.bin' + : 'data/worlds/example_world.yml', + music: 'public/music', + sfx: 'public/sounds', + images: 'public/images', + }, + metadata: { + title: 'AI Interactive Fiction', + author: 'Generative AI', + subtitle: 'An open-world text adventure', + version: '1.0.0', + copyright: '', + }, + }; +} +function projectPath(relativeOrAbsolutePath) { + return path_1.default.isAbsolute(relativeOrAbsolutePath) + ? relativeOrAbsolutePath + : path_1.default.resolve(PROJECT_ROOT, relativeOrAbsolutePath); +} +function loadGameConfig(configPath, engine) { + const absolutePath = projectPath(configPath); + if (!(0, fs_1.existsSync)(absolutePath)) { + console.warn(`[config] Missing ${absolutePath}; using ${engine} defaults.`); + return fallbackConfig(engine); + } + const parsed = JSON.parse((0, fs_1.readFileSync)(absolutePath, 'utf8')); + const fallback = fallbackConfig(engine); + return { + engine: parsed.engine ?? fallback.engine, + locale: parsed.locale ?? fallback.locale, + paths: { + ...fallback.paths, + ...(parsed.paths ?? {}), + }, + metadata: { + ...fallback.metadata, + ...(parsed.metadata ?? {}), + }, + }; +} +function ensureConfiguredAssetDirectories(config) { + const directories = [ + config.paths.music, + config.paths.sfx, + config.paths.images, + config.paths.inkSource ? path_1.default.dirname(config.paths.inkSource) : undefined, + config.paths.inkCompiled ? path_1.default.dirname(config.paths.inkCompiled) : undefined, + config.paths.mainGameFile ? path_1.default.dirname(config.paths.mainGameFile) : undefined, + config.paths.promptDir, + ]; + for (const directory of directories) { + if (!directory) + continue; + const absolutePath = projectPath(directory); + if (!(0, fs_1.existsSync)(absolutePath)) { + (0, fs_1.mkdirSync)(absolutePath, { recursive: true }); + } + } +} +function clientGameConfig(config) { + return { + engine: config.engine, + locale: config.locale, + metadata: config.metadata, + assets: { + music: '/music/', + sfx: '/sounds/', + sounds: '/sounds/', + images: '/images/', + }, + }; +} +//# sourceMappingURL=game-config.js.map \ No newline at end of file diff --git a/dist/config/game-config.js.map b/dist/config/game-config.js.map new file mode 100644 index 0000000..2d52eee --- /dev/null +++ b/dist/config/game-config.js.map @@ -0,0 +1 @@ +{"version":3,"file":"game-config.js","sourceRoot":"","sources":["../../src/config/game-config.ts"],"names":[],"mappings":";;;;;AA0DA,kCAIC;AAED,wCAqBC;AAED,4EAkBC;AAED,4CAYC;AAvHD,gDAAwB;AACxB,2BAAyD;AA8BzD,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAEtD,SAAS,cAAc,CAAC,MAAkB;IACxC,OAAO;QACL,MAAM;QACN,MAAM,EAAE,OAAO;QACf,KAAK,EAAE;YACL,YAAY,EACV,MAAM,KAAK,KAAK;gBACd,CAAC,CAAC,yBAAyB;gBAC3B,CAAC,CAAC,MAAM,KAAK,MAAM;oBACjB,CAAC,CAAC,uBAAuB;oBACzB,CAAC,CAAC,+BAA+B;YACvC,KAAK,EAAE,cAAc;YACrB,GAAG,EAAE,eAAe;YACpB,MAAM,EAAE,eAAe;SACxB;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,wBAAwB;YAC/B,MAAM,EAAE,eAAe;YACvB,QAAQ,EAAE,8BAA8B;YACxC,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,EAAE;SACd;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,WAAW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I,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QACzE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;QAC/E,MAAM,CAAC,KAAK,CAAC,SAAS;KACvB,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACpC,IAAI,CAAC,SAAS;YAAE,SAAS;QACzB,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAA,eAAU,EAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,IAAA,cAAS,EAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAAwB;IACvD,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE;YACN,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,UAAU;YACf,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,UAAU;SACnB;KACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/dist/engine/ink-engine.d.ts b/dist/engine/ink-engine.d.ts new file mode 100644 index 0000000..c05a056 --- /dev/null +++ b/dist/engine/ink-engine.d.ts @@ -0,0 +1,20 @@ +import { TurnResult } from '../interfaces/turn-result'; +export interface InkCompileResult { + sourcePath: string; + outputPath: string; + warningCount: number; +} +export declare function compileInkSource(sourcePath: string, outputPath: string): InkCompileResult; +export declare class InkEngine { + private readonly storyPath; + private story; + private nextTurnId; + constructor(storyPath: string); + isRunning(): boolean; + newGame(): TurnResult; + chooseChoice(choiceIndex: number): TurnResult; + saveGame(): string; + loadGame(savedState: string): TurnResult; + private loadStory; + private continueStory; +} diff --git a/dist/engine/ink-engine.js b/dist/engine/ink-engine.js new file mode 100644 index 0000000..e4f43ed --- /dev/null +++ b/dist/engine/ink-engine.js @@ -0,0 +1,143 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InkEngine = void 0; +exports.compileInkSource = compileInkSource; +const fs_1 = require("fs"); +const path_1 = __importDefault(require("path")); +const inkjs_1 = require("inkjs"); +const tag_parser_1 = require("../utils/tag-parser"); +const { Compiler } = require('inkjs/full'); +function compileInkSource(sourcePath, outputPath) { + const resolvedSource = path_1.default.resolve(sourcePath); + const resolvedOutput = path_1.default.resolve(outputPath); + if (!(0, fs_1.existsSync)(resolvedSource)) { + throw new Error(`Ink source file not found: ${resolvedSource}`); + } + const warnings = []; + const errors = []; + const source = (0, fs_1.readFileSync)(resolvedSource, 'utf8').replace(/^\uFEFF/, ''); + const sourceDir = path_1.default.dirname(resolvedSource); + const fileHandler = { + ResolveInkFilename: (filename) => path_1.default.isAbsolute(filename) ? filename : path_1.default.resolve(sourceDir, filename), + LoadInkFileContents: (filename) => (0, fs_1.readFileSync)(path_1.default.isAbsolute(filename) ? filename : path_1.default.resolve(sourceDir, filename), 'utf8') + .replace(/^\uFEFF/, ''), + }; + const compiler = new Compiler(source, { + sourceFilename: resolvedSource, + fileHandler, + errorHandler: (message, type) => { + if (type === 1) { + warnings.push(message); + } + else { + errors.push(message); + } + }, + }); + const story = compiler.Compile(); + if (!story || errors.length > 0) { + throw new Error(`Ink compilation failed:\n${errors.join('\n')}`); + } + if (warnings.length > 0) { + warnings.forEach((warning) => console.warn(`[ink] ${warning}`)); + } + (0, fs_1.mkdirSync)(path_1.default.dirname(resolvedOutput), { recursive: true }); + (0, fs_1.writeFileSync)(resolvedOutput, story.ToJson(), 'utf8'); + return { + sourcePath: resolvedSource, + outputPath: resolvedOutput, + warningCount: warnings.length, + }; +} +class InkEngine { + constructor(storyPath) { + this.storyPath = storyPath; + this.story = null; + this.nextTurnId = 1; + } + isRunning() { + if (!this.story) + return false; + return this.story.canContinue || this.story.currentChoices.length > 0; + } + newGame() { + this.story = this.loadStory(); + this.nextTurnId = 1; + return this.continueStory(); + } + chooseChoice(choiceIndex) { + if (!this.story) { + throw new Error('No active Ink story'); + } + const choice = this.story.currentChoices.find((item) => item.index === choiceIndex); + if (!choice) { + throw new Error(`Ink choice ${choiceIndex} is not available`); + } + this.story.ChooseChoiceIndex(choice.index); + return this.continueStory(); + } + saveGame() { + if (!this.story) { + throw new Error('No active Ink story to save'); + } + return this.story.state.toJson(); + } + loadGame(savedState) { + this.story = this.loadStory(); + this.story.state.LoadJson(savedState); + return this.continueStory(); + } + loadStory() { + const resolvedPath = path_1.default.resolve(this.storyPath); + if (!(0, fs_1.existsSync)(resolvedPath)) { + throw new Error(`Ink story file not found: ${resolvedPath}`); + } + const storyJson = JSON.parse((0, fs_1.readFileSync)(resolvedPath, 'utf8')); + return new inkjs_1.Story(storyJson); + } + continueStory() { + if (!this.story) { + throw new Error('No active Ink story'); + } + const paragraphs = []; + const globalTags = []; + while (this.story.canContinue) { + const rawText = this.story.Continue(); + const text = String(rawText || '').trim(); + const tags = (0, tag_parser_1.parseTags)(this.story.currentTags || []); + tags + .filter((tag) => tag.key === 'title' || tag.key === 'author') + .forEach((tag) => globalTags.push(tag)); + if (text) { + paragraphs.push({ text, tags }); + } + else { + tags.forEach((tag) => globalTags.push(tag)); + } + } + const choices = this.story.currentChoices.map((choice) => { + const tags = (0, tag_parser_1.parseTags)(choice.tags || []); + const category = (0, tag_parser_1.getTagValue)(tags, 'action'); + const letter = (0, tag_parser_1.getTagValue)(tags, 'letter'); + return { + index: choice.index, + text: String(choice.text || '').trim(), + tags, + category, + letter, + }; + }); + return { + turnId: this.nextTurnId++, + paragraphs, + choices, + inputMode: choices.length > 0 ? 'choice' : 'end', + globalTags: globalTags.length > 0 ? globalTags : undefined, + }; + } +} +exports.InkEngine = InkEngine; +//# sourceMappingURL=ink-engine.js.map \ No newline at end of file diff --git a/dist/engine/ink-engine.js.map b/dist/engine/ink-engine.js.map new file mode 100644 index 0000000..c1d0506 --- /dev/null +++ b/dist/engine/ink-engine.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ink-engine.js","sourceRoot":"","sources":["../../src/engine/ink-engine.ts"],"names":[],"mappings":";;;;;;AA4BA,4CA8CC;AA1ED,2BAAwE;AACxE,gDAAwB;AACxB,iCAA8B;AAM9B,oDAA6D;AAE7D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAUgB,CAAC;AAQ1D,SAAgB,gBAAgB,CAAC,UAAkB,EAAE,UAAkB;IACrE,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,IAAA,eAAU,EAAC,cAAc,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,8BAA8B,cAAc,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAA,iBAAY,EAAC,cAAc,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG;QAClB,kBAAkB,EAAE,CAAC,QAAgB,EAAE,EAA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ACzB,UAAU;YACV,OAAO;YACP,SAAS,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;YAChD,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;SAC3D,CAAC;IACJ,CAAC;CACF;AAnGD,8BAmGC"} \ No newline at end of file diff --git a/dist/engine/zork-llm-engine.d.ts b/dist/engine/zork-llm-engine.d.ts index 06a0ab2..d0ed251 100644 --- a/dist/engine/zork-llm-engine.d.ts +++ b/dist/engine/zork-llm-engine.d.ts @@ -12,6 +12,7 @@ * ZORK_HISTORY_SIZE – player-facing outputs stored per room (default: 5) * OPENROUTER_API_KEY, OPENROUTER_MODEL – required */ +import { TurnResult } from '../interfaces/turn-result'; export interface ZorkSession { characterDescription: string; notes: string[]; @@ -26,18 +27,7 @@ export interface ZorkSession { currentRoom: string; running: boolean; } -/** Subset of the unified TurnResult protocol understood by the client. */ -export interface ZorkTurnResult { - paragraphs: Array<{ - text: string; - tags: unknown[]; - }>; - choices: unknown[]; - inputMode: 'text' | 'end'; - gameState?: { - statusLine?: string; - }; -} +export type ZorkTurnResult = TurnResult; export declare class ZorkLlmEngine { private zork; private session; @@ -48,9 +38,13 @@ export declare class ZorkLlmEngine { private llmCallCounter; private maxRetries; private historySize; + private nextTurnId; private storyPath; private static readonly DEPRECATED_MODEL_REPLACEMENTS; - constructor(); + constructor(options?: { + storyPath?: string; + promptDir?: string; + }); private createCompletion; private resolveFallbackModel; isRunning(): boolean; diff --git a/dist/engine/zork-llm-engine.js b/dist/engine/zork-llm-engine.js index 75d11b2..b9d0231 100644 --- a/dist/engine/zork-llm-engine.js +++ b/dist/engine/zork-llm-engine.js @@ -58,6 +58,7 @@ const os = __importStar(require("os")); const yaml = __importStar(require("js-yaml")); const axios_1 = __importDefault(require("axios")); const dotenv = __importStar(require("dotenv")); +const turn_result_1 = require("../interfaces/turn-result"); dotenv.config(); const DEBUG_ENABLED = /^(1|true|yes|on)$/i.test(process.env.ZORK_DEBUG ?? ''); function debugLog(message, details) { @@ -348,11 +349,12 @@ function logLlmError(scope, err) { // ZorkLlmEngine // --------------------------------------------------------------------------- class ZorkLlmEngine { - constructor() { + constructor(options = {}) { this.zork = new ZorkProcess(); this.session = null; this.resolvedFallbackModel = null; this.llmCallCounter = 0; + this.nextTurnId = 1; const apiKey = process.env.OPENROUTER_API_KEY; const model = process.env.OPENROUTER_MODEL; if (!apiKey || !model) { @@ -372,8 +374,8 @@ class ZorkLlmEngine { }); this.maxRetries = parseInt(process.env.ZORK_MAX_RETRIES ?? '3', 10); this.historySize = parseInt(process.env.ZORK_HISTORY_SIZE ?? '5', 10); - this.storyPath = path.resolve(process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin'); - const promptDir = path.resolve('./data/zork-prompts'); + this.storyPath = path.resolve(options.storyPath ?? process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin'); + const promptDir = path.resolve(options.promptDir ?? './data/zork-prompts'); this.prompts = loadPrompts(promptDir); this.llm = axios_1.default.create({ baseURL: 'https://openrouter.ai/api/v1', @@ -486,6 +488,7 @@ class ZorkLlmEngine { // Kill any existing game if (this.zork.isAlive()) this.zork.kill(); + this.nextTurnId = 1; if (!fs.existsSync(this.storyPath)) { throw new Error(`Story file not found: ${this.storyPath}\n` + 'Place zork1.bin in ./data/z-code/ (see README in that folder).'); @@ -968,8 +971,10 @@ class ZorkLlmEngine { const alive = this.zork.isAlive(); if (!alive && this.session) this.session.running = false; + const paragraphs = (0, turn_result_1.textToParagraphs)(text); return { - paragraphs: [{ text, tags: [] }], + turnId: this.nextTurnId++, + paragraphs, choices: [], inputMode: alive ? 'text' : 'end', gameState: { statusLine: this.session?.currentRoom }, diff --git a/dist/engine/zork-llm-engine.js.map b/dist/engine/zork-llm-engine.js.map index 1069c82..7b9798b 100644 --- a/dist/engine/zork-llm-engine.js.map +++ b/dist/engine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AC5B,gBAAgB,CAAC,CAAC,SAAS,EAAE;gBAC7B,0BAA0B,CAAC,CAAC,OAAO,EAAE;aACtC,CAAC,IAAI,CAAC,IAAI,CAAC;SACb,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QACzD,OAAO;YACL,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YAChC,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;YACjC,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE;SACrD,CAAC;IACJ,CAAC;;AA1uBH,sCA2uBC;AA/tByB,2CAA6B,GAA2B;IAC9E,kCAAkC,EAAE,gBAAgB;IACpD,qBAAqB,EAAE,gBAAgB;CACxC,AAHoD,CAGnD"} \ No newline at end of file +{"version":3,"file":"zork-llm-engine.js","sourceRoot":"","sources":["../../src/engine/zork-llm-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAoD;AACpD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,8CAAgC;AAChC,kDAAyD;AACzD,+CAAiC;AACjC,2DAGmC;AAEnC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AAE9E,SAAS,QAAQ,CAAC,OAAe,EAAE,OAAiB;IAClD,IAAI,CAAC,aAAa;QAAE,OAAO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AgB,EAAC,IAAI,CAAC,CAAC;QAC1C,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE;YACzB,UAAU;YACV,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;YACjC,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE;SACrD,CAAC;IACJ,CAAC;;AA9uBH,sCA+uBC;AAluByB,2CAA6B,GAA2B;IAC9E,kCAAkC,EAAE,gBAAgB;IACpD,qBAAqB,EAAE,gBAAgB;CACxC,AAHoD,CAGnD"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index a47a471..e8293a8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -40,6 +40,7 @@ const dotenv = __importStar(require("dotenv")); const game_runner_1 = require("./cli/game-runner"); // Import the server module and the startServer function for the web interface const server_1 = require("./server"); +const game_config_1 = require("./config/game-config"); // Load environment variables console.log('Loading environment variables...'); try { @@ -59,8 +60,9 @@ async function main() { console.log('=== AI Interactive Fiction ==='); console.log('A modern take on classic text adventures with LLM-powered interactions'); console.log(''); - // Get the world file path from environment variables or use default - const worldFile = process.env.DEFAULT_WORLD_FILE || './data/worlds/example_world.yml'; + // Get the world file path from the YAML engine config, with environment override. + const engineConfig = (0, game_config_1.loadGameConfig)(process.env.YAML_CONFIG_FILE || './config/engines/yaml.json', 'yaml'); + const worldFile = (0, game_config_1.projectPath)(process.env.DEFAULT_WORLD_FILE || engineConfig.paths.mainGameFile); console.log(`Using world file: ${worldFile}`); console.log(`OpenRouter API Key: ${process.env.OPENROUTER_API_KEY ? '✓ Found' : '✗ Missing'}`); console.log(`OpenRouter Model: ${process.env.OPENROUTER_MODEL || '✗ Not specified'}`); @@ -85,7 +87,7 @@ async function main() { // Get port configuration const DEFAULT_PORT = 3000; const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; - const PORT_RANGE = 10; + const PORT_RANGE = 300; // Start the web server with port fallback console.log('Starting web server...'); await (0, server_1.startServer)(PORT, PORT_RANGE); diff --git a/dist/index.js.map b/dist/index.js.map index 7b4a50d..77a425d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,+CAAiC;AACjC,mDAA+C;AAC/C,8EAA8E;AAC9E,qCAAuC;AAEvC,6BAA6B;AAC7B,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAChD,IAAI,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAC/B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEhB,oEAAoE;QACpE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,iCAAiC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,qBAAqB,SAAS,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,uBAAuB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC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AO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/interfaces/turn-result.d.ts b/dist/interfaces/turn-result.d.ts new file mode 100644 index 0000000..c844010 --- /dev/null +++ b/dist/interfaces/turn-result.d.ts @@ -0,0 +1,32 @@ +export type InputMode = 'text' | 'choice' | 'end'; +export interface StoryTag { + key: string; + value?: string; + param?: string; +} +export interface ParagraphResult { + text: string; + tags: StoryTag[]; +} +export interface ChoiceResult { + index: number; + text: string; + tags: StoryTag[]; + category?: string; + letter?: string; +} +export interface TurnResult { + turnId: number; + paragraphs: ParagraphResult[]; + choices: ChoiceResult[]; + inputMode: InputMode; + globalTags?: StoryTag[]; + gameState?: { + currentRoomId?: string; + score?: number; + moves?: number; + statusLine?: string; + }; + suggestions?: string[]; +} +export declare function textToParagraphs(text: string, tags?: StoryTag[]): ParagraphResult[]; diff --git a/dist/interfaces/turn-result.js b/dist/interfaces/turn-result.js new file mode 100644 index 0000000..452413f --- /dev/null +++ b/dist/interfaces/turn-result.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.textToParagraphs = textToParagraphs; +/** + * Shared engine-to-client turn protocol. + */ +const tag_parser_1 = require("../utils/tag-parser"); +function textToParagraphs(text, tags = []) { + return String(text || '') + .replace(/\r\n?/g, '\n') + .split(/\n{2,}/) + .map((paragraph) => paragraph.trim()) + .filter(Boolean) + .map((paragraph) => { + const lines = paragraph.split('\n'); + const paragraphTags = [...tags]; + const textLines = []; + let tagPrefixOpen = true; + for (const line of lines) { + const trimmed = line.trim(); + const maybeTag = tagPrefixOpen && trimmed.startsWith('#') ? (0, tag_parser_1.parseTag)(trimmed) : null; + if (maybeTag) { + paragraphTags.push(maybeTag); + } + else { + tagPrefixOpen = false; + textLines.push(line); + } + } + return { + text: textLines.join('\n').trim(), + tags: paragraphTags, + }; + }); +} +//# sourceMappingURL=turn-result.js.map \ No newline at end of file diff --git a/dist/interfaces/turn-result.js.map b/dist/interfaces/turn-result.js.map new file mode 100644 index 0000000..6472681 --- /dev/null +++ b/dist/interfaces/turn-result.js.map @@ -0,0 +1 @@ +{"version":3,"file":"turn-result.js","sourceRoot":"","sources":["../../src/interfaces/turn-result.ts"],"names":[],"mappings":";;AAyCA,4CA6BC;AAtED;;GAEG;AACH,oDAA+C;AAsC/C,SAAgB,gBAAgB,CAAC,IAAY,EAAE,OAAmB,EAAE;IAClE,OAAO,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SACtB,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;SACvB,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;SACpC,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACjB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,aAAa,GAAe,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,IAAI,aAAa,GAAG,IAAI,CAAC;QAEzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,qBAAQ,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAErF,IAAI,QAAQ,EAAE,CAAC;gBACb,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,aAAa,GAAG,KAAK,CAAC;gBACtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YACjC,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"} \ No newline at end of file diff --git a/dist/server-ink.d.ts b/dist/server-ink.d.ts new file mode 100644 index 0000000..e3439af --- /dev/null +++ b/dist/server-ink.d.ts @@ -0,0 +1,13 @@ +/** + * Ink Engine Server + * + * Serves the shared client UI and runs a compiled Ink JSON story through the + * unified TurnResult socket protocol. + */ +import http from 'http'; +import { Server as SocketIOServer } from 'socket.io'; +declare const app: import("express-serve-static-core").Express; +declare const server: http.Server; +declare const io: SocketIOServer; +export declare function startServer(initialPort: number, range: number): Promise; +export { app, server, io }; diff --git a/dist/server-ink.js b/dist/server-ink.js new file mode 100644 index 0000000..8495302 --- /dev/null +++ b/dist/server-ink.js @@ -0,0 +1,272 @@ +"use strict"; +/** + * Ink Engine Server + * + * Serves the shared client UI and runs a compiled Ink JSON story through the + * unified TurnResult socket protocol. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.io = exports.server = exports.app = void 0; +exports.startServer = startServer; +const path_1 = __importDefault(require("path")); +const http_1 = __importDefault(require("http")); +const express_1 = __importDefault(require("express")); +const socket_io_1 = require("socket.io"); +const dotenv = __importStar(require("dotenv")); +const fs_1 = require("fs"); +const ink_engine_1 = require("./engine/ink-engine"); +const game_config_1 = require("./config/game-config"); +dotenv.config(); +const app = (0, express_1.default)(); +exports.app = app; +const server = http_1.default.createServer(app); +exports.server = server; +const io = new socket_io_1.Server(server); +exports.io = io; +const DEFAULT_PORT = 3003; +const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : DEFAULT_PORT; +const PORT_RANGE = 300; +const engineConfig = (0, game_config_1.loadGameConfig)(process.env.INK_CONFIG_FILE || './config/engines/ink.json', 'ink'); +app.use(express_1.default.static(path_1.default.join(__dirname, '../public'), { + etag: false, + lastModified: false, + setHeaders: (res) => { + res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate'); + res.setHeader('Pragma', 'no-cache'); + res.setHeader('Expires', '0'); + }, +})); +app.get('/api/game-config', (_req, res) => { + res.json((0, game_config_1.clientGameConfig)(engineConfig)); +}); +const sessions = new Map(); +const saveSlots = new Map(); +function normalizeSaveSlot(slot) { + const n = Number(slot); + return Number.isInteger(n) && n > 0 ? n : 1; +} +function getStoryPath() { + return (0, game_config_1.projectPath)(process.env.INK_STORY_FILE || + engineConfig.paths.inkCompiled || + engineConfig.paths.mainGameFile); +} +function getSourcePath() { + return (0, game_config_1.projectPath)(process.env.INK_SOURCE_FILE || engineConfig.paths.inkSource || ''); +} +function compileConfiguredStory() { + const sourcePath = getSourcePath(); + const outputPath = getStoryPath(); + const result = (0, ink_engine_1.compileInkSource)(sourcePath, outputPath); + console.log(`[ink] Compiled ${result.sourcePath} -> ${result.outputPath}` + + (result.warningCount > 0 ? ` (${result.warningCount} warnings)` : '')); +} +function getSlots(socketId) { + let slots = saveSlots.get(socketId); + if (!slots) { + slots = new Map(); + saveSlots.set(socketId, slots); + } + return slots; +} +function getOrCreateEngine(socketId) { + let engine = sessions.get(socketId); + if (!engine) { + engine = new ink_engine_1.InkEngine(getStoryPath()); + sessions.set(socketId, engine); + } + return engine; +} +async function handleGameApi(socket, method, args) { + const slots = getSlots(socket.id); + switch (method) { + case 'newGame': + case 'newGame()': { + const engine = new ink_engine_1.InkEngine(getStoryPath()); + sessions.set(socket.id, engine); + socket.emit('narrativeResponse', engine.newGame()); + return { success: true, result: true, running: true, canLoad: slots.size > 0 }; + } + case 'chooseChoice': + case 'chooseChoice()': { + const engine = sessions.get(socket.id); + if (!engine?.isRunning()) { + return { success: false, error: 'game_not_running', result: false }; + } + const choiceIndex = Number(args[0]); + if (!Number.isInteger(choiceIndex)) { + return { success: false, error: 'invalid_choice', result: false }; + } + socket.emit('narrativeResponse', engine.chooseChoice(choiceIndex)); + return { success: true, result: true }; + } + case 'loadGame': + case 'loadGame()': { + const slot = normalizeSaveSlot(args[0]); + if (!slots.has(slot)) { + return { success: false, error: 'missing_save', result: false }; + } + const engine = getOrCreateEngine(socket.id); + socket.emit('narrativeResponse', engine.loadGame(slots.get(slot))); + socket.emit('gameLoaded', { slot }); + return { success: true, result: true, running: true, slot }; + } + case 'saveGame': + case 'saveGame()': { + const engine = sessions.get(socket.id); + if (!engine?.isRunning()) { + return { success: false, error: 'game_not_running', result: false }; + } + const slot = normalizeSaveSlot(args[0]); + slots.set(slot, engine.saveGame()); + socket.emit('gameSaved', { slot }); + return { success: true, result: true, slot }; + } + case 'hasSaveGame': + case 'hasSaveGame()': { + const slot = normalizeSaveSlot(args[0]); + return { success: true, result: slots.has(slot), slot }; + } + case 'getSaveGames': + case 'getSaveGames()': + return { success: true, result: Array.from(slots.keys()).sort((a, b) => a - b) }; + case 'isGameRunning': + case 'isGameRunning()': + return { success: true, result: sessions.get(socket.id)?.isRunning() ?? false }; + default: + return { success: false, error: `unknown_method:${method}` }; + } +} +io.on('connection', (socket) => { + console.log(`[ink] Client connected: ${socket.id}`); + socket.emit('gameConfig', (0, game_config_1.clientGameConfig)(engineConfig)); + socket.on('gameApi', async (request, respond) => { + try { + const result = await handleGameApi(socket, String(request?.method ?? ''), Array.isArray(request?.args) ? request.args : []); + if (typeof respond === 'function') + respond(result); + } + catch (error) { + console.error('[ink] gameApi error:', error); + if (typeof respond === 'function') { + respond({ + success: false, + error: error instanceof Error ? error.message : String(error), + }); + } + } + }); + socket.on('disconnect', () => { + console.log(`[ink] Client disconnected: ${socket.id}`); + sessions.delete(socket.id); + saveSlots.delete(socket.id); + }); +}); +function ensureDirectories() { + const dirs = [ + path_1.default.join(__dirname, '../public'), + path_1.default.join(__dirname, '../public/js'), + path_1.default.join(__dirname, '../public/css'), + path_1.default.join(__dirname, '../public/images'), + path_1.default.join(__dirname, '../public/music'), + path_1.default.join(__dirname, '../public/sounds'), + path_1.default.join(__dirname, '../public/fonts'), + ]; + for (const dir of dirs) { + if (!(0, fs_1.existsSync)(dir)) + (0, fs_1.mkdirSync)(dir, { recursive: true }); + } + (0, game_config_1.ensureConfiguredAssetDirectories)(engineConfig); +} +function ensureKokoroJs() { + const source = path_1.default.join(__dirname, '../node_modules/kokoro-js/dist/index.js'); + const destination = path_1.default.join(__dirname, '../public/js/kokoro-js.js'); + if ((0, fs_1.existsSync)(source) && !(0, fs_1.existsSync)(destination)) { + (0, fs_1.copyFileSync)(source, destination); + } +} +async function startServer(initialPort, range) { + ensureDirectories(); + try { + ensureKokoroJs(); + } + catch { /* optional */ } + compileConfiguredStory(); + if (!(0, fs_1.existsSync)(getStoryPath())) { + console.error(`[ink] Story file missing: ${getStoryPath()}`); + console.error('[ink] Set INK_SOURCE_FILE or configure paths.inkSource in config/engines/ink.json.'); + } + let port = initialPort; + while (port < initialPort + range) { + try { + await new Promise((resolve, reject) => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { + console.log(`[ink] Ink server running on http://localhost:${port}`); + resolve(); + }); + server.once('error', (error) => { + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${port} unavailable (${error.code}), trying ${port + 1}...`); + server.close(); + port++; + reject(); + } + else { + reject(error); + } + }); + server.listen(port); + }); + return; + } + catch { + if (port >= initialPort + range - 1) { + throw new Error(`Failed to start server on ports ${initialPort} to ${initialPort + range - 1}`); + } + } + } +} +if (require.main === module) { + startServer(PORT, PORT_RANGE).catch((error) => { + console.error('[ink] Failed to start:', error); + process.exit(1); + }); +} +//# sourceMappingURL=server-ink.js.map \ No newline at end of file diff --git a/dist/server-ink.js.map b/dist/server-ink.js.map new file mode 100644 index 0000000..8c6796c --- /dev/null +++ b/dist/server-ink.js.map @@ -0,0 +1 @@ +{"version":3,"file":"server-ink.js","sourceRoot":"","sources":["../src/server-ink.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmOH,kCAwCC;AAzQD,gDAAwB;AACxB,gDAAwB;AACxB,sDAA8B;AAC9B,yCAAqD;AACrD,+CAAiC;AACjC,2BAAyD;AACzD,oDAAkE;AAClE,sDAK8B;AAE9B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAkQb,kBAAG;AAjQZ,MAAM,MAAM,GAAG,cAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAiQxB,wBAAM;AAhQpB,MAAM,EAAE,GAAG,IAAI,k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AC;QAAC,MAAM,CAAC;YACP,IAAI,IAAI,IAAI,WAAW,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,OAAO,WAAW,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;YAClG,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5C,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/dist/server-zork.js b/dist/server-zork.js index 6ef0cce..1653e09 100644 --- a/dist/server-zork.js +++ b/dist/server-zork.js @@ -58,14 +58,16 @@ const socket_io_1 = require("socket.io"); const dotenv = __importStar(require("dotenv")); const fs_1 = require("fs"); const zork_llm_engine_1 = require("./engine/zork-llm-engine"); +const game_config_1 = require("./config/game-config"); dotenv.config(); const app = (0, express_1.default)(); const server = http_1.default.createServer(app); const io = new socket_io_1.Server(server); const DEFAULT_PORT = 3002; const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : DEFAULT_PORT; -const PORT_RANGE = 10; +const PORT_RANGE = 300; const DEBUG_ENABLED = /^(1|true|yes|on)$/i.test(process.env.ZORK_DEBUG ?? ''); +const engineConfig = (0, game_config_1.loadGameConfig)(process.env.ZORK_CONFIG_FILE || './config/engines/zork.json', 'zork'); function debugLog(message, details) { if (!DEBUG_ENABLED) return; @@ -85,18 +87,18 @@ app.use(express_1.default.static(path_1.default.join(__dirname, '../public'), { res.setHeader('Expires', '0'); }, })); +app.get('/api/game-config', (_req, res) => { + res.json((0, game_config_1.clientGameConfig)(engineConfig)); +}); // One engine instance per connected socket const sessions = new Map(); // Save-game slot maps: socketId → Map const saveSlots = new Map(); -function toLegacyNarrative(turn) { - const text = (turn.paragraphs ?? []) - .map((p) => String(p?.text ?? '').trim()) - .filter(Boolean) - .join('\n\n'); +function toClientTurn(turn) { return { - text, + ...turn, gameState: { + ...turn.gameState, currentRoomId: turn.gameState?.statusLine, statusLine: turn.gameState?.statusLine, }, @@ -109,7 +111,10 @@ function normalizeSaveSlot(slot) { function getOrCreateEngine(socketId) { let engine = sessions.get(socketId); if (!engine) { - engine = new zork_llm_engine_1.ZorkLlmEngine(); + engine = new zork_llm_engine_1.ZorkLlmEngine({ + storyPath: (0, game_config_1.projectPath)(process.env.ZORK_STORY_FILE || engineConfig.paths.mainGameFile), + promptDir: (0, game_config_1.projectPath)(engineConfig.paths.promptDir || 'data/zork-prompts'), + }); sessions.set(socketId, engine); } return engine; @@ -130,7 +135,7 @@ async function handleGameApi(socket, method, args) { case 'newGame()': { const engine = getOrCreateEngine(socket.id); const turn = await engine.newGame(); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); return { success: true, result: true, @@ -146,7 +151,7 @@ async function handleGameApi(socket, method, args) { } const engine = getOrCreateEngine(socket.id); const turn = await engine.loadGame(slots.get(slot)); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); socket.emit('gameLoaded', { slot }); return { success: true, result: true, running: true, slot }; } @@ -184,8 +189,8 @@ async function handleGameApi(socket, method, args) { } } function checkRuntimeConfiguration() { - const storyPath = path_1.default.resolve(process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin'); - const promptDir = path_1.default.resolve('./data/zork-prompts'); + const storyPath = (0, game_config_1.projectPath)(process.env.ZORK_STORY_FILE ?? engineConfig.paths.mainGameFile); + const promptDir = (0, game_config_1.projectPath)(engineConfig.paths.promptDir || 'data/zork-prompts'); const promptFiles = [ 'character-generation.yml', 'text-rewriter.yml', @@ -221,6 +226,7 @@ function checkRuntimeConfiguration() { } io.on('connection', (socket) => { console.log(`[zork] Client connected: ${socket.id}`); + socket.emit('gameConfig', (0, game_config_1.clientGameConfig)(engineConfig)); socket.on('gameApi', async (request, respond) => { try { const result = await handleGameApi(socket, String(request?.method ?? ''), Array.isArray(request?.args) ? request.args : []); @@ -257,7 +263,7 @@ io.on('connection', (socket) => { paragraphs: turn.paragraphs.length, statusLine: turn.gameState?.statusLine, }); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); } catch (error) { console.error('[zork] playerCommand error:', error); @@ -291,6 +297,7 @@ function ensureDirectories() { if (!(0, fs_1.existsSync)(dir)) (0, fs_1.mkdirSync)(dir, { recursive: true }); } + (0, game_config_1.ensureConfiguredAssetDirectories)(engineConfig); } function ensureKokoroJs() { const src = path_1.default.join(__dirname, '../node_modules/kokoro-js/dist/index.js'); @@ -309,13 +316,15 @@ async function startServer(initialPort, range) { while (port < initialPort + range) { try { await new Promise((resolve, reject) => { - server.listen(port, () => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { console.log(`[zork] Zork Narrator server running on http://localhost:${port}`); resolve(); }); - server.on('error', (err) => { - if (err.code === 'EADDRINUSE') { - console.log(`Port ${port} in use, trying ${port + 1}…`); + server.once('error', (err) => { + if (err.code === 'EADDRINUSE' || err.code === 'EACCES') { + console.log(`Port ${port} unavailable (${err.code}), trying ${port + 1}...`); server.close(); port++; reject(); @@ -324,6 +333,7 @@ async function startServer(initialPort, range) { reject(err); } }); + server.listen(port); }); return; } diff --git a/dist/server-zork.js.map b/dist/server-zork.js.map index 961f633..9acb9a9 100644 --- a/dist/server-zork.js.map +++ b/dist/server-zork.js.map @@ -1 +1 @@ -{"version":3,"file":"server-zork.js","sourceRoot":"","sources":["../src/server-zork.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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MAAM,EAAE,CAAC;oBACX,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,IAAI,IAAI,WAAW,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CACb,mCAAmC,WAAW,IAAI,WAAW,GAAG,KAAK,GAAG,CAAC,EAAE,CAC5E,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC1C,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/dist/server.js b/dist/server.js index d0b42dc..0d2daee 100644 --- a/dist/server.js +++ b/dist/server.js @@ -49,6 +49,8 @@ const socket_io_1 = require("socket.io"); const dotenv = __importStar(require("dotenv")); const game_runner_1 = require("./cli/game-runner"); const fs_1 = require("fs"); +const turn_result_1 = require("./interfaces/turn-result"); +const game_config_1 = require("./config/game-config"); // Load environment variables dotenv.config(); // Create Express application @@ -61,7 +63,8 @@ exports.io = io; // Get port from environment variables or use default const DEFAULT_PORT = 3001; const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; -const PORT_RANGE = 10; // Try up to 10 ports starting from the default +const PORT_RANGE = 300; // Try enough ports to skip OS-excluded ranges. +const engineConfig = (0, game_config_1.loadGameConfig)(process.env.YAML_CONFIG_FILE || './config/engines/yaml.json', 'yaml'); // Serve static files from the public directory. During local development the // browser must not keep stale ES modules, otherwise UI fixes appear to do // nothing until a hard cache clear. @@ -74,22 +77,51 @@ app.use(express_1.default.static(path_1.default.join(__dirname, '../public'), { res.setHeader('Expires', '0'); } })); +app.get('/api/game-config', (_req, res) => { + res.json((0, game_config_1.clientGameConfig)(engineConfig)); +}); // Set up game sessions const gameSessions = new Map(); +const nextTurnIds = new Map(); +function nextTurnId(socketId) { + const current = nextTurnIds.get(socketId) || 1; + nextTurnIds.set(socketId, current + 1); + return current; +} +function createTextTurn(socketId, text, gameState = {}, suggestions) { + const paragraphs = (0, turn_result_1.textToParagraphs)(text); + return { + turnId: nextTurnId(socketId), + paragraphs, + choices: [], + inputMode: 'text', + gameState, + suggestions, + }; +} function normalizeSaveSlot(slot) { const value = Number(slot); return Number.isInteger(value) && value > 0 ? value : 1; } async function startDemoGameForSocket(socket) { + nextTurnIds.set(socket.id, 1); const gameRunner = new game_runner_1.GameRunner(); - const worldFile = process.env.DEFAULT_WORLD_FILE || './data/worlds/example_world.yml'; + const worldFile = (0, game_config_1.projectPath)(process.env.DEFAULT_WORLD_FILE || engineConfig.paths.mainGameFile); await gameRunner.initialize(worldFile); gameSessions.set(socket.id, gameRunner); const gameState = gameRunner.getGameState(); - socket.emit('gameIntroduction', { - introduction: gameState.world.introduction, - initialRoomDescription: gameRunner.getCurrentRoomDescription(), - currentRoomId: gameState.currentRoomId + const paragraphs = [ + ...(0, turn_result_1.textToParagraphs)(gameState.world.introduction), + ...(0, turn_result_1.textToParagraphs)(gameRunner.getCurrentRoomDescription()), + ]; + socket.emit('narrativeResponse', { + turnId: nextTurnId(socket.id), + paragraphs, + choices: [], + inputMode: 'text', + gameState: { + currentRoomId: gameState.currentRoomId, + }, }); return gameRunner; } @@ -140,6 +172,7 @@ async function handleGameApi(socket, method, args = []) { // Handle socket connections io.on('connection', (socket) => { console.log(`New client connected: ${socket.id}`); + socket.emit('gameConfig', (0, game_config_1.clientGameConfig)(engineConfig)); socket.data.saveGames = new Map(); socket.on('gameApi', async (request, respond) => { try { @@ -176,13 +209,9 @@ io.on('connection', (socket) => { const command = String(data?.command || '').trim(); // During typography and animation work, mirror the command back through // the real socket path so the UI pipeline can be tested end to end. - socket.emit('narrativeResponse', { - text: command, - gameState: { - currentRoomId: gameRunner.getGameState().currentRoomId - }, - suggestions: gameRunner.getSuggestions() - }); + socket.emit('narrativeResponse', createTextTurn(socket.id, command, { + currentRoomId: gameRunner.getGameState().currentRoomId + }, gameRunner.getSuggestions())); } catch (error) { console.error('Error processing command:', error); @@ -232,6 +261,7 @@ io.on('connection', (socket) => { if (gameSessions.has(socket.id)) { gameSessions.delete(socket.id); } + nextTurnIds.delete(socket.id); }); }); // Ensure required asset folders exist @@ -250,6 +280,7 @@ function ensureDirectories() { (0, fs_1.mkdirSync)(dir, { recursive: true }); } } + (0, game_config_1.ensureConfiguredAssetDirectories)(engineConfig); } // Copy kokoro-js library from node_modules if not already present function ensureKokoroJs() { @@ -278,14 +309,16 @@ async function startServer(initialPort, range) { } // Try to start the server on the current port await new Promise((resolve, reject) => { - server.listen(currentPort, () => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { console.log(`AI Interactive Fiction web server running on http://localhost:${currentPort}`); resolve(); }); - server.on('error', (error) => { + server.once('error', (error) => { // If port is in use, try next port - if (error.code === 'EADDRINUSE') { - console.log(`Port ${currentPort} is in use, trying next port...`); + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${currentPort} is unavailable (${error.code}), trying next port...`); server.close(); currentPort++; reject(); @@ -296,6 +329,7 @@ async function startServer(initialPort, range) { reject(error); } }); + server.listen(currentPort); }); // If we reach here, server started successfully return; diff --git a/dist/server.js.map b/dist/server.js.map index b9f4592..8f473c0 100644 --- a/dist/server.js.map +++ b/dist/server.js.map @@ -1 +1 @@ -{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;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CAAC,KAAK,CAAC,EAAE;QAC1C,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/dist/test-server.js b/dist/test-server.js index 872f94d..0b3575c 100644 --- a/dist/test-server.js +++ b/dist/test-server.js @@ -47,6 +47,7 @@ const http_1 = __importDefault(require("http")); const socket_io_1 = require("socket.io"); const dotenv = __importStar(require("dotenv")); const fs_1 = require("fs"); +const turn_result_1 = require("./interfaces/turn-result"); // Load environment variables dotenv.config(); // Create Express application @@ -59,7 +60,7 @@ exports.io = io; // Get port from environment variables or use default const DEFAULT_PORT = 3001; const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; -const PORT_RANGE = 10; // Try up to 10 ports starting from the default +const PORT_RANGE = 300; // Try enough ports to skip OS-excluded ranges. // Serve static files from the public directory. Keep browser modules uncached // during local development so fixes are visible without a hard cache clear. app.use(express_1.default.static(path_1.default.join(__dirname, '../public'), { @@ -82,14 +83,23 @@ io.on('connection', (socket) => { console.log(`New client connected: ${socket.id}`); let currentParagraphIndex = 0; let gameRunning = false; + let nextTurnId = 1; const saveGames = new Set(); const startDemoGame = () => { gameRunning = true; + nextTurnId = 1; currentParagraphIndex = 0; - socket.emit('gameIntroduction', { - introduction: "::chapter[Interactive Fiction Test]\n\nWelcome to the Interactive Fiction Test. This is a simplified version that sends predefined paragraphs instead of using an LLM.", - initialRoomDescription: TEST_PARAGRAPHS[0], - currentRoomId: "test-room" + socket.emit('narrativeResponse', { + turnId: nextTurnId++, + paragraphs: [ + ...(0, turn_result_1.textToParagraphs)("#chapter[Interactive Fiction Test]\n\nWelcome to the Interactive Fiction Test. This is a simplified version that sends predefined paragraphs instead of using an LLM."), + ...(0, turn_result_1.textToParagraphs)(TEST_PARAGRAPHS[0]), + ], + choices: [], + inputMode: 'text', + gameState: { + currentRoomId: 'test-room', + }, }); }; const normalizeSaveSlot = (slot) => { @@ -174,7 +184,10 @@ io.on('connection', (socket) => { console.log(`Received command: ${data.command}`); // Send narrative response to client socket.emit('narrativeResponse', { - text: data.command, + turnId: nextTurnId++, + paragraphs: (0, turn_result_1.textToParagraphs)(String(data.command || '')), + choices: [], + inputMode: 'text', gameState: { currentRoomId: "test-room" }, @@ -235,15 +248,17 @@ async function startServer(initialPort, range) { } // Try to start the server on the current port await new Promise((resolve, reject) => { - server.listen(currentPort, () => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { console.log(`AI Interactive Fiction TEST SERVER running on http://localhost:${currentPort}`); console.log('This server is sending predefined test paragraphs instead of using an LLM'); resolve(); }); - server.on('error', (error) => { + server.once('error', (error) => { // If port is in use, try next port - if (error.code === 'EADDRINUSE') { - console.log(`Port ${currentPort} is in use, trying next port...`); + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${currentPort} is unavailable (${error.code}), trying next port...`); server.close(); currentPort++; reject(); @@ -254,6 +269,7 @@ async function startServer(initialPort, range) { reject(error); } }); + server.listen(currentPort); }); // If we reach here, server started successfully return; diff --git a/dist/test-server.js.map b/dist/test-server.js.map index 398e836..c9a1cc3 100644 --- a/dist/test-server.js.map +++ b/dist/test-server.js.map @@ -1 +1 @@ -{"version":3,"file":"test-server.js","sourceRoot":"","sources":["../src/test-server.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,sDAA8B;AAC9B,gDAAwB;AACxB,yCAAqD;AACrD,+CAAiC;AACjC,2BAAyD;AAEzD,6BAA6B;AAC7B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,6BAA6B;AAC7B,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAmPb,kBAAG;AAlPZ,MAAM,MAAM,GAAG,cAAI,CAAC,YAAY,CAAC,GAAG,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AC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/dist/utils/tag-parser.d.ts b/dist/utils/tag-parser.d.ts new file mode 100644 index 0000000..9db6f8d --- /dev/null +++ b/dist/utils/tag-parser.d.ts @@ -0,0 +1,4 @@ +import type { StoryTag } from '../interfaces/turn-result'; +export declare function parseTag(raw: string): StoryTag | null; +export declare function parseTags(rawTags: unknown[] | undefined): StoryTag[]; +export declare function getTagValue(tags: StoryTag[], key: string): string | undefined; diff --git a/dist/utils/tag-parser.js b/dist/utils/tag-parser.js new file mode 100644 index 0000000..72c458e --- /dev/null +++ b/dist/utils/tag-parser.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseTag = parseTag; +exports.parseTags = parseTags; +exports.getTagValue = getTagValue; +const LEGACY_TAG_ALIASES = { + audio: 'sfx', + audioloop: 'music', + separator: 'section', +}; +function normalizeKey(key) { + const normalized = key.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, '-'); + return LEGACY_TAG_ALIASES[normalized] || normalized; +} +function parseTag(raw) { + const text = String(raw || '').trim().replace(/^#\s*/, ''); + if (!text) + return null; + const bracketMatch = text.match(/^([A-Za-z][\w-]*)(?:\[([^\]]*)\])?(?:\(([^)]*)\))?$/); + if (bracketMatch) { + const tag = { key: normalizeKey(bracketMatch[1]) }; + if (typeof bracketMatch[2] !== 'undefined') + tag.value = bracketMatch[2].trim(); + if (typeof bracketMatch[3] !== 'undefined') + tag.param = bracketMatch[3].trim(); + return tag; + } + const bareMatch = text.match(/^[A-Za-z][\w-]*$/); + if (bareMatch) { + return { key: normalizeKey(text) }; + } + return null; +} +function parseTags(rawTags) { + if (!Array.isArray(rawTags)) + return []; + return rawTags + .map((raw) => parseTag(String(raw ?? ''))) + .filter((tag) => Boolean(tag)); +} +function getTagValue(tags, key) { + const normalizedKey = normalizeKey(key); + return tags.find((tag) => tag.key === normalizedKey)?.value; +} +//# sourceMappingURL=tag-parser.js.map \ No newline at end of file diff --git a/dist/utils/tag-parser.js.map b/dist/utils/tag-parser.js.map new file mode 100644 index 0000000..a968669 --- /dev/null +++ b/dist/utils/tag-parser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tag-parser.js","sourceRoot":"","sources":["../../src/utils/tag-parser.ts"],"names":[],"mappings":";;AAaA,4BAkBC;AAED,8BAMC;AAED,kCAGC;AA1CD,MAAM,kBAAkB,GAA2B;IACjD,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,SAAS,YAAY,CAAC,GAAW;IAC/B,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IAC1E,OAAO,kBAAkB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AACtD,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAW;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACvF,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,GAAG,GAAa,EAAE,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,IAAI,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,WAAW;YAAE,GAAG,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/E,IAAI,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,WAAW;YAAE,GAAG,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACjD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,SAAS,CAAC,OAA8B;IACtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IAEvC,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;SACzC,MAAM,CAAC,CAAC,GAAG,EAAmB,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAgB,WAAW,CAAC,IAAgB,EAAE,GAAW;IACvD,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,aAAa,CAAC,EAAE,KAAK,CAAC;AAC9D,CAAC"} \ No newline at end of file diff --git a/ink_inclusion.md b/ink_inclusion.md index 1dc42c0..9dbbb86 100644 --- a/ink_inclusion.md +++ b/ink_inclusion.md @@ -56,6 +56,8 @@ This means: All engines author tags using the same `key[value]` bracket convention. For Ink this maps directly to native `# key[value]` tags. For YAML and Z-Code the server synthesises equivalent tag objects. +Ink choice text uses square brackets for its own display/control syntax. For choice-local tags, the integration therefore also accepts the prototype form `# key: value` and normalises it to the same structured tag object. Prefer `# letter: o` and `# action: examine` on choices when inkjs treats bracketed tags as choice text. + | Tag | Scope | Meaning | |---|---|---| | `music[filename]` | paragraph or global | Start looping music track | @@ -70,6 +72,7 @@ All engines author tags using the same `key[value]` bracket convention. For Ink | `title[text]` | global (first turn) | Set document/story title | | `author[text]` | global (first turn) | Set byline | | `action[category]` | choice | Sort this choice into a named column | +| `letter[x]` | choice | Reserve keyboard letter `x` for this choice | ### 1.3 Parsed Tag Object Shape @@ -109,7 +112,7 @@ These work identically on all three servers: | Direction | Event | Payload | |---|---|---| | client → server | `gameApi` | `{ method, args }` → `respond(result)` | -| server → client | `gameIntroduction` | `{ title, author, inputMode }` | +| server → client | `narrativeResponse` | `TurnResult` | | server → client | `gameSaved` | `{ slot }` | | server → client | `gameLoaded` | `{ slot }` | | server → client | `error` | `{ message }` | @@ -128,6 +131,7 @@ This is the core change. Previously `narrativeResponse` carried `{ text, gameSta ```ts interface TurnResult { + turnId: number; // Unique ascending id within the game session paragraphs: ParagraphResult[]; // Ordered list of story paragraphs this turn choices: ChoiceResult[]; // Available choices (empty in text-input mode) inputMode: 'choice' | 'text' | 'end'; @@ -149,10 +153,11 @@ interface ChoiceResult { text: string; // Display text (SmartyPants applied) tags: StoryTag[]; // Per-choice tags, e.g. action[examine] category?: string; // Derived from action[...] tag for column grouping + letter?: string; // Optional reserved keyboard letter, derived from letter[x] } ``` -The old `{ text }` field is removed. For backward compatibility during transition, the server may also emit a flattened `text` field containing all paragraph texts joined with newlines. +The old flattened `{ text }` field is removed. Servers must emit `TurnResult` only. ### 2.3 `playerCommand` vs `chooseChoice` @@ -245,6 +250,34 @@ async function handleGameApi(socket, method, args): Promise { ## 5. Client-Side Changes +### 5.0 Choice UI Architecture + +The first Ink integration should ship with the simplest useful choice UI: + +- Display all available choices in one ordered list. +- Ignore choice grouping tags visually for now. +- Assign every visible choice a keyboard letter. +- Allow at most 26 visible choices (`A` through `Z`), which is enough for the current interaction model. +- Choices with explicit `letter[x]` tags reserve that letter first. +- Remaining choices receive letters in ascending screen order, skipping letters already reserved by tags. +- The chosen letter is shown in the UI and pressing that letter selects the same choice as clicking it. +- Letter matching is case-insensitive. + +The architecture must still be ready for later choice templates. The choice renderer should normalize choices into a presentation model: + +```ts +interface ChoicePresentation { + index: number; + text: string; + tags: StoryTag[]; + category?: string; + letter: string; + templateCell: string; // initially always "default" +} +``` + +The first implemented template has exactly one full-size cell named `default`. It receives every choice whose tags do not match a registered template cell. A later template can register cells such as `examine`, `ask`, `inventory`, or `reflect`, and route choices by `action[...]`, `category`, or a future `cell[...]` tag without changing the server protocol. + ### 5.1 Tag Event Dispatch **Modified: `game-loop-module.js`** (or `socket-client-module.js`) @@ -288,12 +321,13 @@ Remove all tag-detection regex from the text stream. The module now only applies **Effort: ~150 lines new** -Renders choice columns, exactly as in the prototype's `createChoiceContainer`. Registered in `module-registry.js`. +Renders available choices from the canonical `TurnResult.choices` array. Registered in `module-registry.js`. - Listens for a `story:choices` event (dispatched by `game-loop-module.js` from the `TurnResult.choices` array). -- Groups choices by `category` field into named columns with localised headers. -- Registers keyboard shortcuts (A/B/C... or 1/2/3... depending on whether choices are categorised). +- Uses a template object with one initial full-size `default` cell. +- Assigns keyboard letters from `letter[x]` tags first, then fills remaining choices with `A` through `Z` in visible order. - On click/keypress: calls `socketClient.sendChoice(index)` → `gameApi { method: 'chooseChoice', args: [index] }`. +- Future grouped or column layouts should be implemented by adding more template cells and routing rules, not by changing the server protocol. ### 5.6 `ui-input-handler-module.js` @@ -361,13 +395,14 @@ On `narrativeResponse`: ## 8. Recommended Implementation Order -1. Extract `server-base.ts`; verify YAML engine still works. -2. Define `TurnResult` + `StoryTag` interfaces. -3. Write `tag-parser.ts`; unit test it. -4. Rewrite `GameRunner` to produce `TurnResult`; update `server.ts` to emit it. -5. Update `game-loop-module.js` to consume `TurnResult` and dispatch tag events. -6. Update `audio-manager-module.js` and `ui-display-handler-module.js` to listen for tag events. -7. Remove tag parsing from `markup-parser-module.js`. -8. Build `choice-display-module.js` and `ui-input-handler` mode switching. -9. Build `InkEngine` and `server-ink.ts`; smoke-test with a compiled `.ink.json`. -10. Add Z-Code server (see `zcode_inclusion.md`). +1. Define `TurnResult` + `StoryTag` interfaces. +2. Write `tag-parser.ts`; parse the single canonical tag shape `key[value](param)`. +3. Update the client socket pipeline to consume canonical `TurnResult` objects only. +4. Dispatch structured `story:tag`, `story:choices`, and `story:input-mode` events from the socket adapter. +5. Add `choice-display-module.js` with the single-cell default template and letter assignment described in §5.0. +6. Update `audio-manager-module.js` and `ui-display-handler-module.js` to listen for `story:tag` events by translating them into the current media/display paths. +7. Convert Zork server emission from flattened text to canonical `TurnResult`. +8. Convert YAML server introduction/responses to canonical `TurnResult`. +9. Extract `server-base.ts`; verify YAML and Zork still work. +10. Build `InkEngine` and `server-ink.ts`; smoke-test with a compiled `.ink.json`. +11. Once all engines emit structured tags, remove structural tag parsing from `markup-parser-module.js`. diff --git a/package-lock.json b/package-lock.json index 270c4b5..f184848 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "express": "^5.1.0", "hyphenopoly": "^6.0.0", "ifvms": "^1.1.6", + "inkjs": "^2.4.0", "js-yaml": "^4.1.0", "kokoro-js": "^1.2.0", "openai": "^4.91.0", @@ -4533,6 +4534,15 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/inkjs": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/inkjs/-/inkjs-2.4.0.tgz", + "integrity": "sha512-EoPCYESIbMtfI8SqEDZCJwn+A5is0QozMLw250iic1ReJCgZpRKIezWj0VqgRUzAx0f3MmEbsUjY/ILe2815JQ==", + "license": "MIT", + "bin": { + "inkjs-compiler": "bin/inkjs-compiler.js" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", diff --git a/package.json b/package.json index d269bdb..9edb460 100644 --- a/package.json +++ b/package.json @@ -13,18 +13,34 @@ "start:cli": "node dist/index.js --cli", "predev": "npm run check:node", "dev": "nodemon --watch src --ext ts,json --exec \"ts-node src/index.ts\"", + "predev:yaml": "npm run check:node", + "dev:yaml": "nodemon --watch src --watch data/worlds --watch config/engines/yaml.json --ext ts,json,yml --exec \"ts-node src/server.ts\"", + "dev:yaml:debug": "powershell -NoProfile -Command \"$env:YAML_DEBUG='1'; npm run dev:yaml\"", + "dev:yaml:inspect": "powershell -NoProfile -Command \"$env:YAML_DEBUG='1'; nodemon --watch src --watch data/worlds --watch config/engines/yaml.json --ext ts,json,yml --exec \\\"node --inspect=127.0.0.1:9230 -r ts-node/register src/server.ts\\\"\"", "predev:web": "npm run check:node", "dev:web": "nodemon --watch src --ext ts,json --exec \"ts-node src/index.ts\"", "predev:cli": "npm run check:node", "dev:cli": "nodemon --watch src --ext ts,json --exec \"ts-node src/index.ts --cli\"", "predev:zork": "npm run check:node", - "dev:zork": "nodemon --watch src --watch data/zork-prompts --ext ts,json,yml --exec \"ts-node src/server-zork.ts\"", + "dev:zork": "nodemon --watch src --watch data/zork-prompts --watch config/engines/zork.json --ext ts,json,yml --exec \"ts-node src/server-zork.ts\"", "dev:zork:debug": "powershell -NoProfile -Command \"$env:ZORK_DEBUG='1'; npm run dev:zork\"", - "dev:zork:inspect": "powershell -NoProfile -Command \"$env:ZORK_DEBUG='1'; nodemon --watch src --watch data/zork-prompts --ext ts,json,yml --exec \\\"node --inspect=127.0.0.1:9229 -r ts-node/register src/server-zork.ts\\\"\"", + "dev:zork:inspect": "powershell -NoProfile -Command \"$env:ZORK_DEBUG='1'; nodemon --watch src --watch data/zork-prompts --watch config/engines/zork.json --ext ts,json,yml --exec \\\"node --inspect=127.0.0.1:9229 -r ts-node/register src/server-zork.ts\\\"\"", + "predev:ink": "npm run check:node", + "dev:ink": "nodemon --watch src --watch data/ink-src --watch config/engines/ink.json --ext ts,json,ink --exec \"ts-node src/server-ink.ts\"", + "dev:ink:debug": "powershell -NoProfile -Command \"$env:INK_DEBUG='1'; npm run dev:ink\"", + "dev:ink:inspect": "powershell -NoProfile -Command \"$env:INK_DEBUG='1'; nodemon --watch src --watch data/ink-src --watch config/engines/ink.json --ext ts,json,ink --exec \\\"node --inspect=127.0.0.1:9231 -r ts-node/register src/server-ink.ts\\\"\"", + "prestart:yaml": "npm run check:node && npm run build", + "start:yaml": "node dist/server.js", + "start:yaml:debug": "powershell -NoProfile -Command \"$env:YAML_DEBUG='1'; npm run start:yaml\"", + "start:yaml:inspect": "powershell -NoProfile -Command \"$env:YAML_DEBUG='1'; node --inspect=127.0.0.1:9230 dist/server.js\"", "prestart:zork": "npm run check:node && npm run build", "start:zork": "node dist/server-zork.js", "start:zork:debug": "powershell -NoProfile -Command \"$env:ZORK_DEBUG='1'; npm run start:zork\"", "start:zork:inspect": "powershell -NoProfile -Command \"$env:ZORK_DEBUG='1'; node --inspect=127.0.0.1:9229 dist/server-zork.js\"", + "prestart:ink": "npm run check:node && npm run build", + "start:ink": "node dist/server-ink.js", + "start:ink:debug": "powershell -NoProfile -Command \"$env:INK_DEBUG='1'; npm run start:ink\"", + "start:ink:inspect": "powershell -NoProfile -Command \"$env:INK_DEBUG='1'; node --inspect=127.0.0.1:9231 dist/server-ink.js\"", "pretest-server": "npm run check:node", "test-server": "ts-node src/test-server.ts", "build": "tsc", @@ -60,6 +76,7 @@ "express": "^5.1.0", "hyphenopoly": "^6.0.0", "ifvms": "^1.1.6", + "inkjs": "^2.4.0", "js-yaml": "^4.1.0", "kokoro-js": "^1.2.0", "openai": "^4.91.0", diff --git a/public/css/style.css b/public/css/style.css index 47f46c0..7a79810 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -421,6 +421,54 @@ ol.choice { overflow-anchor: none; } +.story-image-block { + box-sizing: border-box; + margin: 0 auto; + padding: 0; + overflow: hidden; + background: transparent; +} + +.story-image-block img { + display: block; + width: 100%; + height: 100%; + object-fit: contain; + mix-blend-mode: multiply; + filter: contrast(1.05); +} + +.story-image-landscape, +.story-image-square { + clear: both; + margin-left: auto; + margin-right: auto; +} + +.story-image-portrait { + float: left; + margin-left: 0; + margin-right: 0; + shape-outside: inset(0); +} + +.story-image-portrait.story-image-float-right { + float: right; + margin-left: 0; + margin-right: 0; +} + +.story-image-pending img { + opacity: 0; + clip-path: polygon(0 0, 0 0, 0 0); +} + +.story-image-visible img { + opacity: 1; + clip-path: polygon(0 0, 220% 0, 0 220%); + transition: opacity 900ms ease, clip-path 900ms ease; +} + /* #story p span { font-feature-settings: 'kern' on, 'liga' on, 'onum' on, 'clig' on, 'hlig' on; } */ @@ -547,10 +595,22 @@ ol.choice { position: absolute; left: 0; right: 0; - bottom: 0; + bottom: 0.65rem; text-align: center; margin: 0 auto; background-color: transparent; + line-height: 1.1; + pointer-events: none; +} + +#remark_hint { + font-size: 0.82rem; +} + +#game_legal { + margin-top: 0.18rem; + font-size: 0.72rem; + color: rgba(0, 0, 0, 0.62); } #lighting { @@ -596,6 +656,17 @@ body:not([data-game-running="true"]) #command_history { #command_history .history-item { margin-bottom: 0.25rem; color: rgba(0, 0, 0, 0.82); + cursor: pointer; + transition: color 160ms ease, opacity 160ms ease; +} + +#command_history .history-item:hover, +#command_history .history-item.active { + color: rgba(0, 0, 0, 1); +} + +#command_history .history-item.active { + font-weight: 600; } #command_history::-webkit-scrollbar { @@ -633,6 +704,76 @@ body:not([data-game-running="true"]) #command_history { pointer-events: none; /* Prevent interaction while faded out */ } +.story-choices { + width: 100%; + margin: 0 0 1rem 0; + opacity: 0; + transition: opacity 0.45s ease; + pointer-events: none; +} + +.story-choices[hidden] { + display: none; +} + +html[data-process-state="waiting-generating"] .story-choices, +html[data-process-state="playing-generating"] .story-choices, +html[data-process-state="playing-ready"] .story-choices, +html[data-process-state="command-waiting"] .story-choices { + opacity: 0; + pointer-events: none; +} + +html[data-process-state="ready"] .story-choices[data-choice-ready="true"] { + opacity: 1; + pointer-events: auto; +} + +.choice-list { + list-style: none; + margin: 0; + padding: 0; +} + +.choice-list-item { + margin: 0 0 0.45rem 0; +} + +.choice-list .choice-button { + display: grid; + grid-template-columns: 1.8em 1fr; + align-items: baseline; + gap: 0.45rem; + width: 100%; + padding: 0.15rem 0; + border: 0; + background: transparent; + color: rgba(37, 31, 24, 0.72); + font-family: inherit; + font-size: 1rem; + line-height: 1.25; + text-align: left; + cursor: pointer; + transition: color 0.25s ease, opacity 0.25s ease; +} + +.choice-list .choice-button:hover, +.choice-list .choice-button:focus-visible { + color: rgba(0, 0, 0, 0.96); + text-decoration: none; + outline: none; +} + +.choice-list kbd { + display: inline-block; + min-width: 1.4em; + font-family: inherit; + font-size: 0.85em; + font-weight: 700; + text-align: center; + border-bottom: 0; +} + /* Input wrapper for positioning cursor */ .input-wrapper { position: relative; @@ -745,15 +886,18 @@ html[data-process-state="playing-ready"] * { #story p.story-chapter-heading { position: relative; height: auto; - margin: 0 0 1.45em 0; text-align: center; font-size: 1.2rem; font-style: italic; line-height: 1.45; } -#story p.story-textblock-start { - margin-top: 1.45em; +#story p.story-section-heading { + position: relative; + height: auto; + text-align: center; + font-style: normal; + line-height: 1.45; } /* Typography for word elements in rendered paragraphs */ diff --git a/public/images/README.md b/public/images/README.md index 7ca1d35..3aaf264 100644 --- a/public/images/README.md +++ b/public/images/README.md @@ -6,14 +6,15 @@ Story image paths resolve relative to this directory. Image block markup: ```text -::image[widescreen](image-name.jpg) -::image[portrait](image-name.jpg) +#image[image-name.jpg](landscape) +#image[image-name.jpg](portrait) ``` Sizes: -- `widescreen`: exactly 100% of the page width and 50% of the page height. -- `portrait`: exactly 100% of the page width and 100% of the page height. +- `landscape`/`widescreen`: 16:9, centered, near full page width, height snapped to whole line heights. +- `portrait`: 16:9, half page width, height snapped to whole line heights, with following prose flowing beside it. +- `square`: 1:1, centered, near full page width, height snapped to whole line heights. Image markup is parsed and queued by the story markup system, but final image rendering is still future work. Keep assets ready for that renderer by using browser-friendly formats such as `.jpg`, `.png`, `.webp`, or `.avif`. diff --git a/public/images/eibenreith.png b/public/images/eibenreith.png new file mode 100644 index 0000000..f5eff24 Binary files /dev/null and b/public/images/eibenreith.png differ diff --git a/public/images/muerzzuschlag.png b/public/images/muerzzuschlag.png new file mode 100644 index 0000000..142b25c Binary files /dev/null and b/public/images/muerzzuschlag.png differ diff --git a/public/images/passing_the_village.png b/public/images/passing_the_village.png new file mode 100644 index 0000000..eb8ebb7 Binary files /dev/null and b/public/images/passing_the_village.png differ diff --git a/public/images/statue.png b/public/images/statue.png new file mode 100644 index 0000000..ed4759f Binary files /dev/null and b/public/images/statue.png differ diff --git a/public/images/suedbahn.png b/public/images/suedbahn.png new file mode 100644 index 0000000..cd2911e Binary files /dev/null and b/public/images/suedbahn.png differ diff --git a/public/images/the_station.png b/public/images/the_station.png new file mode 100644 index 0000000..46515fb Binary files /dev/null and b/public/images/the_station.png differ diff --git a/public/images/train_cabin.png b/public/images/train_cabin.png new file mode 100644 index 0000000..c84551d Binary files /dev/null and b/public/images/train_cabin.png differ diff --git a/public/index.html b/public/index.html index c5a2249..52d9b5b 100644 --- a/public/index.html +++ b/public/index.html @@ -1,9 +1,9 @@ - + - AI Interactive Fiction + @@ -297,6 +297,6 @@ originalLog.apply(console, args); }; - + diff --git a/public/js/audio-manager-module.js b/public/js/audio-manager-module.js index 8c0bffb..202114b 100644 --- a/public/js/audio-manager-module.js +++ b/public/js/audio-manager-module.js @@ -89,6 +89,14 @@ class AudioManagerModule extends BaseModule { this.handleMediaBlock(event.detail || {}); }); + this.addEventListener(document, 'story:tag', (event) => { + this.handleStoryTag(event.detail || {}); + }); + + this.addEventListener(document, 'game:config', (event) => { + this.applyGameConfig(event.detail || {}); + }); + this.addEventListener(document, 'preference-updated', (event) => { const { category, key, value } = event.detail || {}; if (category !== 'audio') { @@ -131,6 +139,15 @@ class AudioManagerModule extends BaseModule { document.addEventListener('pointerdown', unlock, { passive: true }); document.addEventListener('keydown', unlock); } + + applyGameConfig(config) { + const assets = config?.assets || {}; + this.assetRoots = { + images: assets.images || this.assetRoots.images, + music: assets.music || this.assetRoots.music, + sounds: assets.sounds || assets.sfx || this.assetRoots.sounds + }; + } /** * Set up Web Audio API context if needed @@ -438,7 +455,7 @@ class AudioManagerModule extends BaseModule { } if (cue.type === 'sfx') { - this.playSfx(cue.filename); + this.playSfx(cue.filename, cue); } else if (cue.type === 'music') { this.playMusic(cue.filename, cue.mode || 'crossfade', { loop: cue.loop !== false }); } @@ -452,18 +469,122 @@ class AudioManagerModule extends BaseModule { this.playMusic(block.filename, block.mode || 'crossfade', { loop: block.loop !== false }); } - async playSfx(filename) { + handleStoryTag(tag) { + const key = String(tag?.key || '').toLowerCase(); + const filename = String(tag?.value || tag?.filename || '').trim(); + if (!key || !filename) { + return; + } + + if (key === 'sfx' || key === 'sound' || key === 'audio') { + this.playSfx(filename, this.parseSfxTagOptions(tag.param || tag.options || '')); + return; + } + + if (key === 'music') { + const options = this.parseMusicTagOptions(tag.param || tag.options || ''); + this.playMusic(filename, options.mode, { loop: options.loop }); + } + } + + parseMusicTagOptions(optionText) { + const options = { + mode: 'crossfade', + loop: true + }; + + String(optionText || '') + .split(/[,\s]+/) + .map(token => token.trim().toLowerCase()) + .filter(Boolean) + .forEach(token => { + const [key, value] = token.split('='); + if (['queue', 'crossfade', 'cut'].includes(token)) { + options.mode = token; + } else if (['loop', 'looped', 'repeat'].includes(token)) { + options.loop = true; + } else if (['once', 'single', 'no-loop', 'noloop'].includes(token)) { + options.loop = false; + } else if (key === 'loop') { + options.loop = !['false', '0', 'no', 'once'].includes(value); + } else if (key === 'mode' && ['queue', 'crossfade', 'cut'].includes(value)) { + options.mode = value; + } + }); + + return options; + } + + parseSfxTagOptions(optionText) { + const options = { + maxDurationSeconds: 0, + endMode: 'stop', + fadeDurationSeconds: 2 + }; + + String(optionText || '') + .split(/[,\s]+/) + .map(token => token.trim().toLowerCase()) + .filter(Boolean) + .forEach(token => { + const [key, value] = token.split('='); + if (['fade', 'fadeout', 'fade-out'].includes(token)) { + options.endMode = 'fade'; + } else if (['stop', 'cut', 'halt'].includes(token)) { + options.endMode = 'stop'; + } else if (['max', 'duration', 'max-duration', 'limit', 'stop-after', 'fade-after'].includes(key)) { + const seconds = Number(value); + options.maxDurationSeconds = Number.isFinite(seconds) ? Math.max(0, seconds) : 0; + if (key === 'fade-after') options.endMode = 'fade'; + } else if (/^\d+(\.\d+)?s?$/.test(token)) { + options.maxDurationSeconds = Number(token.replace(/s$/, '')); + } else if (key === 'mode' && ['fade', 'fadeout', 'fade-out', 'stop', 'cut'].includes(value)) { + options.endMode = value.startsWith('fade') ? 'fade' : 'stop'; + } else if (['fade-duration', 'fade-time', 'fade'].includes(key)) { + const seconds = Number(value); + if (Number.isFinite(seconds)) { + options.fadeDurationSeconds = Math.max(0.1, seconds); + options.endMode = 'fade'; + } + } + }); + + return options; + } + + async playSfx(filename, options = {}) { try { const template = await this.preloadSfx(filename); const audio = template.cloneNode(true); audio.volume = this.getSfxVolume(); this.currentAudio = audio; + const maxDuration = Math.max(0, Number(options.maxDurationSeconds || options.maxDuration || 0)) * 1000; + const endMode = String(options.endMode || options.mode || 'stop').toLowerCase().startsWith('fade') ? 'fade' : 'stop'; + const fadeDuration = Math.max(100, Number(options.fadeDurationSeconds || options.fadeDuration || 2) * 1000); + let maxTimer = null; audio.addEventListener('ended', () => { + if (maxTimer) clearTimeout(maxTimer); if (this.currentAudio === audio) { this.currentAudio = null; } }, { once: true }); await audio.play(); + if (maxDuration > 0) { + const timeoutDuration = endMode === 'fade' + ? Math.max(0, maxDuration - fadeDuration) + : maxDuration; + maxTimer = setTimeout(() => { + if (audio.paused || audio.ended) return; + if (endMode === 'fade') { + console.log(`AudioManager: Fading sound effect ${filename} over ${fadeDuration}ms`); + this.fadeOutAudio(audio, fadeDuration); + } else { + audio.pause(); + audio.currentTime = 0; + if (this.currentAudio === audio) this.currentAudio = null; + } + }, timeoutDuration); + } console.log(`AudioManager: Playing sound effect ${filename}`); return audio; } catch (error) { @@ -472,6 +593,27 @@ class AudioManagerModule extends BaseModule { } } + fadeOutAudio(audio, duration = 1000) { + if (!audio) return Promise.resolve(false); + const startVolume = audio.volume; + const startedAt = performance.now(); + return new Promise(resolve => { + const step = () => { + const progress = Math.min(1, (performance.now() - startedAt) / duration); + audio.volume = startVolume * (1 - progress); + if (progress < 1 && !audio.paused && !audio.ended) { + requestAnimationFrame(step); + return; + } + audio.pause(); + audio.currentTime = 0; + if (this.currentAudio === audio) this.currentAudio = null; + resolve(true); + }; + requestAnimationFrame(step); + }); + } + async playMusic(filename, mode = 'crossfade', options = {}) { const url = this.getAssetUrl('music', filename); const shouldLoop = options.loop !== false; diff --git a/public/js/base-module.js b/public/js/base-module.js index bbc5d19..ef7a742 100644 --- a/public/js/base-module.js +++ b/public/js/base-module.js @@ -310,7 +310,13 @@ export class BaseModule { this._trackResource(url); const script = document.createElement('script'); - script.src = url; + const cacheBuster = window.MODULE_CACHE_BUSTER; + if (cacheBuster && /^\/(js|css)\//.test(url)) { + const separator = url.includes('?') ? '&' : '?'; + script.src = `${url}${separator}v=${encodeURIComponent(cacheBuster)}`; + } else { + script.src = url; + } if (isModule) { script.type = 'module'; } diff --git a/public/js/choice-display-module.js b/public/js/choice-display-module.js new file mode 100644 index 0000000..33f41e2 --- /dev/null +++ b/public/js/choice-display-module.js @@ -0,0 +1,261 @@ +/** + * Choice Display Module + * Renders choice-mode interactions from TurnResult choices. + */ +import { BaseModule } from './base-module.js'; + +class ChoiceDisplayModule extends BaseModule { + constructor() { + super('choice-display', 'Choice Display'); + + this.dependencies = ['socket-client']; + this.socketClient = null; + this.container = null; + this.choices = []; + this.inputMode = 'text'; + this.processState = document.documentElement.dataset.processState || 'ready'; + this.template = { + cells: { + default: { + label: '', + match: () => true + } + }, + fallbackCell: 'default' + }; + + this.bindMethods([ + 'initialize', + 'setupContainer', + 'handleChoices', + 'handleInputMode', + 'handleProcessState', + 'handleKeyDown', + 'render', + 'clear', + 'normalizeChoices', + 'assignLetters', + 'selectChoice', + 'getTagValue', + 'getTemplateCell' + ]); + } + + async initialize() { + this.socketClient = this.getModule('socket-client'); + this.setupContainer(); + + this.addEventListener(document, 'story:choices', (event) => { + this.handleChoices(event.detail || []); + }); + this.addEventListener(document, 'story:input-mode', (event) => { + this.handleInputMode(event.detail || 'text'); + }); + this.addEventListener(document, 'story:process-state', (event) => { + this.handleProcessState(event.detail?.state || 'ready'); + }); + this.addEventListener(document, 'keydown', this.handleKeyDown); + + this.reportProgress(100, 'Choice display ready'); + return true; + } + + setupContainer() { + const choicesRoot = document.getElementById('choices'); + if (!choicesRoot) { + return; + } + + this.container = document.getElementById('story_choices'); + if (!this.container) { + this.container = document.createElement('div'); + this.container.id = 'story_choices'; + this.container.className = 'story-choices'; + } + + const commandInput = document.getElementById('command_input'); + if (this.container.parentElement !== choicesRoot) { + choicesRoot.insertBefore(this.container, commandInput || null); + } else if (commandInput && this.container.nextElementSibling !== commandInput) { + choicesRoot.insertBefore(this.container, commandInput); + } else if (!commandInput && this.container !== choicesRoot.lastElementChild) { + choicesRoot.appendChild(this.container); + } + } + + handleChoices(choices) { + this.choices = this.normalizeChoices(Array.isArray(choices) ? choices : []); + this.render(); + } + + handleInputMode(inputMode) { + this.inputMode = ['text', 'choice', 'end'].includes(inputMode) ? inputMode : 'text'; + this.render(); + } + + handleProcessState(state) { + this.processState = state || 'ready'; + this.render(); + } + + handleKeyDown(event) { + if (this.inputMode !== 'choice' || !this.choices.length) { + return; + } + + const optionsModal = document.getElementById('options-modal'); + if (optionsModal && optionsModal.style.display !== 'none') { + return; + } + + if (event.ctrlKey || event.metaKey || event.altKey || event.key.length !== 1) { + return; + } + + const letter = event.key.toUpperCase(); + const choice = this.choices.find((item) => item.letter === letter); + if (!choice) { + return; + } + + event.preventDefault(); + this.selectChoice(choice.index); + } + + normalizeChoices(choices) { + return this.assignLetters(choices.slice(0, 26).map((choice, order) => { + const tags = Array.isArray(choice.tags) ? choice.tags : []; + const category = choice.category || this.getTagValue(tags, 'action'); + return { + index: Number.isInteger(choice.index) ? choice.index : order, + text: String(choice.text || ''), + tags, + category, + letter: '', + templateCell: this.getTemplateCell({ ...choice, tags, category }) + }; + })); + } + + assignLetters(choices) { + const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); + const reserved = new Set(); + + choices.forEach((choice) => { + const explicit = String(choice.letter || this.getTagValue(choice.tags, 'letter') || '') + .trim() + .charAt(0) + .toUpperCase(); + if (alphabet.includes(explicit) && !reserved.has(explicit)) { + choice.letter = explicit; + reserved.add(explicit); + } + }); + + let nextLetterIndex = 0; + choices.forEach((choice) => { + if (choice.letter) return; + while (nextLetterIndex < alphabet.length && reserved.has(alphabet[nextLetterIndex])) { + nextLetterIndex += 1; + } + if (nextLetterIndex < alphabet.length) { + choice.letter = alphabet[nextLetterIndex]; + reserved.add(choice.letter); + nextLetterIndex += 1; + } + }); + + return choices; + } + + getTemplateCell(choice) { + const entries = Object.entries(this.template.cells); + const match = entries.find(([cellName, cell]) => { + if (cellName === this.template.fallbackCell) return false; + return typeof cell.match === 'function' && cell.match(choice); + }); + return match ? match[0] : this.template.fallbackCell; + } + + getTagValue(tags, key) { + const normalizedKey = String(key).toLowerCase(); + const tag = tags.find((item) => String(item?.key || '').toLowerCase() === normalizedKey); + return tag?.value; + } + + render() { + this.setupContainer(); + if (!this.container) return; + + this.container.innerHTML = ''; + const readyForChoices = this.inputMode === 'choice' && this.choices.length > 0 && this.processState === 'ready'; + this.container.hidden = !readyForChoices; + this.container.dataset.choiceReady = readyForChoices ? 'true' : 'false'; + if (this.container.hidden) { + return; + } + + const list = document.createElement('ol'); + list.className = 'choice-list choice-template-default'; + + this.choices.forEach((choice) => { + const item = document.createElement('li'); + item.className = 'choice-list-item'; + item.dataset.choiceIndex = String(choice.index); + item.dataset.choiceLetter = choice.letter; + item.dataset.templateCell = choice.templateCell; + + const button = document.createElement('button'); + button.type = 'button'; + button.className = 'choice-button'; + button.innerHTML = `${choice.letter}${this.escapeHtml(choice.text)}`; + button.addEventListener('click', () => this.selectChoice(choice.index)); + item.appendChild(button); + list.appendChild(item); + }); + + this.container.appendChild(list); + } + + async selectChoice(index) { + if (!this.socketClient) { + this.socketClient = this.getModule('socket-client'); + } + if (!this.socketClient || typeof this.socketClient.chooseChoice !== 'function') { + console.error('ChoiceDisplay: Socket client cannot choose choices'); + return; + } + + this.clear(); + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'command-waiting', reason: 'choice-selected', choiceIndex: index } + })); + await this.socketClient.chooseChoice(index); + } + + clear() { + this.choices = []; + if (this.container) { + this.container.innerHTML = ''; + this.container.hidden = true; + } + } + + escapeHtml(text) { + return String(text) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + } +} + +const choiceDisplay = new ChoiceDisplayModule(); + +export { choiceDisplay as ChoiceDisplay }; + +if (window.moduleRegistry) { + window.moduleRegistry.register(choiceDisplay); +} + +window.ChoiceDisplay = choiceDisplay; diff --git a/public/js/game-config-module.js b/public/js/game-config-module.js new file mode 100644 index 0000000..4f12821 --- /dev/null +++ b/public/js/game-config-module.js @@ -0,0 +1,103 @@ +/** + * Game Config Module + * Loads engine metadata, locale, and asset roots before the UI is created. + */ +import { BaseModule } from './base-module.js'; + +class GameConfigModule extends BaseModule { + constructor() { + super('game-config', 'Game Config'); + this.dependencies = ['localization', 'persistence-manager']; + this.config = null; + + this.bindMethods([ + 'getConfig', + 'getMetadata', + 'getLocale', + 'loadConfig', + 'applyDocumentMetadata' + ]); + } + + async initialize() { + try { + this.reportProgress(20, 'Loading game configuration'); + this.config = await this.loadConfig(); + + const localization = this.getModule('localization'); + if (localization && this.config?.locale) { + await localization.applyServerLocale(this.config.locale); + } + + this.applyDocumentMetadata(); + document.dispatchEvent(new CustomEvent('game:config', { + detail: this.config + })); + + this.reportProgress(100, 'Game configuration ready'); + return true; + } catch (error) { + console.error('GameConfig: Failed to load game configuration:', error); + this.config = { + engine: 'unknown', + locale: 'en_US', + metadata: { + title: 'AI Interactive Fiction', + author: '', + subtitle: '', + version: '', + copyright: '' + }, + assets: { + music: '/music/', + sfx: '/sounds/', + sounds: '/sounds/', + images: '/images/' + } + }; + this.applyDocumentMetadata(); + document.dispatchEvent(new CustomEvent('game:config', { detail: this.config })); + this.reportProgress(100, 'Game configuration fallback ready'); + return true; + } + } + + async loadConfig() { + const response = await fetch('/api/game-config', { cache: 'no-store' }); + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + return response.json(); + } + + applyDocumentMetadata() { + const metadata = this.getMetadata(); + if (metadata?.title) { + document.title = metadata.subtitle + ? `${metadata.title} - ${metadata.subtitle}` + : metadata.title; + } + } + + getConfig() { + return this.config; + } + + getMetadata() { + return this.config?.metadata || {}; + } + + getLocale() { + return this.config?.locale || 'en_US'; + } +} + +const GameConfig = new GameConfigModule(); + +export { GameConfig }; + +if (window.moduleRegistry) { + window.moduleRegistry.register(GameConfig); +} + +window.GameConfig = GameConfig; diff --git a/public/js/game-loop-module.js b/public/js/game-loop-module.js index b5e2668..7bb8f3f 100644 --- a/public/js/game-loop-module.js +++ b/public/js/game-loop-module.js @@ -33,8 +33,7 @@ class GameLoopModule extends BaseModule { 'requestStartGame', 'requestSaveGame', 'requestLoadGame', - 'resetClientPlaybackAndDisplay', - 'addText' + 'resetClientPlaybackAndDisplay' ]); } @@ -109,15 +108,6 @@ class GameLoopModule extends BaseModule { // Text processing is handled by socket-client -> text-buffer -> ui-controller pipeline }); - // Listen for game introduction - socketClient.on('gameIntroduction', (data) => { - console.log("GameLoop: Received gameIntroduction"); - this.gameState.started = true; - this.gameState.canSave = true; - this.updateUIState(); - // Text processing is handled by socket-client -> text-buffer -> ui-controller pipeline - }); - socketClient.on('gameSaved', () => { this.gameState.canLoad = true; this.updateUIState(); @@ -292,22 +282,6 @@ class GameLoopModule extends BaseModule { } } - /** - * Manually add text to the buffer - * Useful for testing or adding local messages - * @param {string} text - Text to add - */ - addText(text) { - // Use parent's getModule method - const textBuffer = this.getModule('text-buffer'); - - if (!textBuffer) { - console.warn("Text buffer not available"); - return; - } - - textBuffer.addText(text); - } } // Create the singleton instance diff --git a/public/js/layout-renderer-module.js b/public/js/layout-renderer-module.js index a325c0e..9190e56 100644 --- a/public/js/layout-renderer-module.js +++ b/public/js/layout-renderer-module.js @@ -96,6 +96,15 @@ class LayoutRendererModule extends BaseModule { } const lineHeight = lineHeightPx || parseFloat(window.getComputedStyle(paragraph).lineHeight) || 24; + if (layoutData.role === 'chapter-heading') { + paragraph.style.marginTop = `${lineHeight * 2}px`; + paragraph.style.marginBottom = `${lineHeight}px`; + } else if (layoutData.role === 'section-heading') { + paragraph.style.marginTop = `${lineHeight}px`; + paragraph.style.marginBottom = `${lineHeight}px`; + } else if (layoutData.addTopSpace) { + paragraph.style.marginTop = `${lineHeight}px`; + } const maxLineWidth = Array.isArray(measures) && measures.length > 0 ? Math.max(...measures) : storyElement.clientWidth; @@ -139,7 +148,9 @@ class LayoutRendererModule extends BaseModule { : lineWidth; const lineOffset = isCentered ? Math.max(0, (maxLineWidth - naturalLineWidth) / 2) - : maxLineWidth - lineWidth; + : Array.isArray(layoutData.lineOffsets) + ? (layoutData.lineOffsets[Math.min(lineIndex, layoutData.lineOffsets.length - 1)] || 0) + : maxLineWidth - lineWidth; let currentLeft = 0; lastChild = null; diff --git a/public/js/loader.js b/public/js/loader.js index 1707102..d4a9218 100644 --- a/public/js/loader.js +++ b/public/js/loader.js @@ -24,7 +24,8 @@ const ModuleState = { ERROR: 'ERROR' }; -const MODULE_CACHE_BUSTER = '20260514-new-game-click'; +const MODULE_CACHE_BUSTER = '20260515-lead-kap-verified'; +window.MODULE_CACHE_BUSTER = MODULE_CACHE_BUSTER; /** * Module Loader - Manages the loading of all modules @@ -102,6 +103,7 @@ const ModuleLoader = (function() { // Core functionality modules { id: 'persistence-manager', script: '/js/persistence-manager-module.js', weight: 12 }, { id: 'localization', script: '/js/localization-module.js', weight: 12 }, + { id: 'game-config', script: '/js/game-config-module.js', weight: 8 }, { id: 'text-processor', script: '/js/text-processor-module.js', weight: 15 }, { id: 'markup-parser', script: '/js/markup-parser-module.js', weight: 5 }, { id: 'paragraph-layout', script: '/js/paragraph-layout-module.js', weight: 17 }, @@ -123,6 +125,7 @@ const ModuleLoader = (function() { { id: 'ui-effects', script: '/js/ui-effects-module.js', weight: 12 }, // Add UI Effects module { id: 'ui-input-handler', script: '/js/ui-input-handler-module.js', weight: 27 }, // Add UI Input Handler module { id: 'ui-display-handler', script: '/js/ui-display-handler-module.js', weight: 27 }, // Add UI Display Handler module + { id: 'choice-display', script: '/js/choice-display-module.js', weight: 8 }, { id: 'ui-controller', script: '/js/ui-controller-module.js', weight: 27 }, { id: 'options-ui', script: '/js/options-ui-module.js', weight: 13 }, { id: 'socket-client', script: '/js/socket-client-module.js', weight: 17 }, diff --git a/public/js/localization-module.js b/public/js/localization-module.js index 6cf1284..58aa9b7 100644 --- a/public/js/localization-module.js +++ b/public/js/localization-module.js @@ -13,20 +13,21 @@ class LocalizationModule extends BaseModule { // Current locale this.translations = {}; - this.defaultLocale = 'en-us'; + this.defaultLocale = 'en_US'; this.currentLocale = this.defaultLocale; this.dependencies = ['persistence-manager']; // Available translations this.languageNames = { - 'en-us': 'English (US)', - 'en-gb': 'English (UK)', - 'de-de': 'Deutsch (Deutschland)' + 'en_US': 'English (US)', + 'de_DE': 'Deutsch (Deutschland)' }; // Bind methods this.bindMethods([ 'setLocale', + 'applyServerLocale', + 'normalizeLocale', 'getLocale', 'translate', 'getAvailableLocales', @@ -44,7 +45,7 @@ class LocalizationModule extends BaseModule { this.reportProgress(10, "Initializing localization"); // Load default English locale - await this.loadTranslations('en-us'); + await this.loadTranslations(this.defaultLocale); this.reportProgress(50, "Loaded default locale"); // Get stored locale from persistence manager if available @@ -53,27 +54,26 @@ class LocalizationModule extends BaseModule { if (persistenceManager) { const storedLocale = persistenceManager.getPreference('app', 'locale'); if (storedLocale) { - console.log(`Localization: Found stored locale: ${storedLocale}`); - await this.loadTranslations(storedLocale); - this.currentLocale = storedLocale; - this.reportProgress(80, `Loaded stored locale: ${storedLocale}`); + const normalizedLocale = this.normalizeLocale(storedLocale); + console.log(`Localization: Found stored locale: ${normalizedLocale}`); + await this.loadTranslations(normalizedLocale); + this.currentLocale = normalizedLocale; + this.reportProgress(80, `Loaded stored locale: ${normalizedLocale}`); } else { - // If no stored locale, ensure en-us is the default and persist it - console.log('Localization: No stored locale found, using default en-us'); - persistenceManager.updatePreference('app', 'locale', 'en-us'); - persistenceManager.updatePreference('tts', 'language', 'en-us'); - this.currentLocale = 'en-us'; - this.reportProgress(80, "Using default locale: en-us"); + console.log(`Localization: No stored locale found, using default ${this.defaultLocale}`); + this.currentLocale = this.defaultLocale; + this.reportProgress(80, `Using default locale: ${this.defaultLocale}`); } } else { - console.log('Localization: Persistence manager not available, using default en-us locale'); - this.reportProgress(80, "Using default locale: en-us"); + console.log(`Localization: Persistence manager not available, using default ${this.defaultLocale} locale`); + this.reportProgress(80, `Using default locale: ${this.defaultLocale}`); } // Dispatch event to notify about loaded locale document.dispatchEvent(new CustomEvent('localization:languageChanged', { detail: { locale: this.currentLocale } })); + document.documentElement.lang = this.currentLocale.replace('_', '-'); this.reportProgress(100, "Localization ready"); return true; @@ -90,14 +90,12 @@ class LocalizationModule extends BaseModule { * @returns {Promise} */ async loadTranslations(locale) { - if (this.translations[locale]) { + const normalizedLocale = this.normalizeLocale(locale); + if (this.translations[normalizedLocale]) { return; // Already loaded } try { - // Normalize locale - const normalizedLocale = locale.toLowerCase(); - // Try to load the exact locale const response = await fetch(`/locales/${normalizedLocale}.json`); @@ -106,7 +104,7 @@ class LocalizationModule extends BaseModule { this.translations[normalizedLocale] = translations; } else { // If exact locale not found, try to load just the language part - const langPart = normalizedLocale.split('-')[0]; + const langPart = normalizedLocale.split('_')[0]; if (langPart !== normalizedLocale) { const langResponse = await fetch(`/locales/${langPart}.json`); if (langResponse.ok) { @@ -128,12 +126,12 @@ class LocalizationModule extends BaseModule { * @param {string} locale - Locale to set * @returns {Promise} - Success status */ - async setLocale(locale) { + async setLocale(locale, options = {}) { if (!locale) return false; try { - // Normalize locale - const normalizedLocale = locale.toLowerCase(); + const normalizedLocale = this.normalizeLocale(locale); + const userInitiated = options.userInitiated !== false; // Load translations if not already loaded if (!this.translations[normalizedLocale]) { @@ -148,12 +146,23 @@ class LocalizationModule extends BaseModule { if (persistenceManager) { persistenceManager.updatePreference('app', 'locale', normalizedLocale); persistenceManager.updatePreference('tts', 'language', normalizedLocale); + if (userInitiated) { + persistenceManager.updatePreference('app', 'localeUserOverride', true); + } } + + document.documentElement.lang = normalizedLocale.replace('_', '-'); // Dispatch locale change event this.dispatchEvent('locale-changed', { locale: normalizedLocale }); + document.dispatchEvent(new CustomEvent('locale:changed', { + detail: { locale: normalizedLocale } + })); + document.dispatchEvent(new CustomEvent('localization:languageChanged', { + detail: { locale: normalizedLocale } + })); return true; } catch (error) { @@ -161,6 +170,21 @@ class LocalizationModule extends BaseModule { return false; } } + + async applyServerLocale(locale) { + const persistenceManager = this.getModule('persistence-manager'); + const userOverride = persistenceManager?.getPreference('app', 'localeUserOverride', false); + if (userOverride) { + return false; + } + return this.setLocale(locale, { userInitiated: false }); + } + + normalizeLocale(locale) { + const normalized = String(locale || this.defaultLocale).trim().replace('-', '_').toLowerCase(); + if (normalized.startsWith('de')) return 'de_DE'; + return 'en_US'; + } /** * Get the current locale @@ -175,7 +199,7 @@ class LocalizationModule extends BaseModule { * @returns {string} - Language code */ getLanguage() { - return this.currentLocale.split('-')[0]; + return this.currentLocale.split('_')[0]; } /** @@ -197,7 +221,7 @@ class LocalizationModule extends BaseModule { if (!locale) return ''; // Normalize locale - const normalizedLocale = locale.toLowerCase(); + const normalizedLocale = this.normalizeLocale(locale); // Try exact match if (this.languageNames[normalizedLocale]) { @@ -205,7 +229,7 @@ class LocalizationModule extends BaseModule { } // Try language part only - const langPart = normalizedLocale.split('-')[0]; + const langPart = normalizedLocale.split('_')[0]; if (this.languageNames[langPart]) { return this.languageNames[langPart]; } diff --git a/public/js/markup-parser-module.js b/public/js/markup-parser-module.js index f3c6a77..81621e9 100644 --- a/public/js/markup-parser-module.js +++ b/public/js/markup-parser-module.js @@ -18,6 +18,8 @@ class MarkupParserModule extends BaseModule { 'parse', 'parseParagraph', 'parseInline', + 'parseImageOptions', + 'parseSfxOptions', 'parseMusicOptions', 'markdownToHtml', 'markdownToPlainText', @@ -38,7 +40,6 @@ class MarkupParserModule extends BaseModule { const text = String(input || '').replace(/\r\n?/g, '\n'); const blocks = []; let paragraphBuffer = []; - let nextParagraphRole = null; const flushParagraph = () => { if (paragraphBuffer.length === 0) return; @@ -48,8 +49,7 @@ class MarkupParserModule extends BaseModule { const paragraph = this.parseParagraph(raw); if (!paragraph.text) return; - const role = nextParagraphRole || 'body'; - nextParagraphRole = null; + const role = 'body'; blocks.push(this.buildParagraphBlock(paragraph, role)); }; @@ -61,65 +61,6 @@ class MarkupParserModule extends BaseModule { return; } - const chapter = trimmed.match(/^::chapter(?:\[(.*?)\]|\s+(.+))$/i); - if (chapter) { - flushParagraph(); - const heading = (chapter[1] || chapter[2] || '').trim(); - if (heading) { - const normalizedHeading = this.normalizeParagraph(heading); - blocks.push({ - type: 'heading', - text: this.markdownToPlainText(normalizedHeading), - layoutText: this.markdownToHtml(normalizedHeading), - role: 'chapter-heading' - }); - } - nextParagraphRole = 'chapter-first'; - return; - } - - const section = trimmed.match(/^::(?:section|textblock)(?:\[(.*?)\]|\s+(.+))?$/i); - if (section) { - flushParagraph(); - const heading = (section[1] || section[2] || '').trim(); - if (heading) { - const normalizedHeading = this.normalizeParagraph(heading); - blocks.push({ - type: 'heading', - text: this.markdownToPlainText(normalizedHeading), - layoutText: this.markdownToHtml(normalizedHeading), - role: 'section-heading' - }); - } - nextParagraphRole = 'textblock-first'; - return; - } - - const image = trimmed.match(/^::image\[(widescreen|portrait)\]\(([^)]+)\)$/i); - if (image) { - flushParagraph(); - blocks.push({ - type: 'image', - size: image[1].toLowerCase(), - filename: image[2].trim(), - url: this.resolveAssetUrl('images', image[2].trim()) - }); - return; - } - - const music = trimmed.match(/^::music(?:\[([^\]]*)\])?\(([^)]+)\)$/i); - if (music) { - flushParagraph(); - const options = this.parseMusicOptions(music[1] || 'crossfade'); - blocks.push({ - type: 'music', - ...options, - filename: music[2].trim(), - url: this.resolveAssetUrl('music', music[2].trim()) - }); - return; - } - paragraphBuffer.push(line); }); @@ -128,6 +69,35 @@ class MarkupParserModule extends BaseModule { return blocks; } + parseImageOptions(optionText) { + const options = { + size: 'landscape', + leadInSeconds: 0 + }; + + String(optionText || 'landscape') + .split(/[,\s]+/) + .map(token => token.trim()) + .filter(Boolean) + .forEach((token, index) => { + const lower = token.toLowerCase(); + const [key, value] = lower.split('='); + + if (['landscape', 'widescreen', 'portrait', 'square'].includes(lower)) { + options.size = lower === 'widescreen' ? 'landscape' : lower; + } else if (['lead', 'lead-in', 'leadins', 'lead-in-seconds', 'delay', 'intro', 'pause', 'wait', 'hold'].includes(key)) { + const seconds = Number(value); + options.leadInSeconds = Number.isFinite(seconds) ? Math.max(0, seconds) : 0; + } else if (/^\d+(\.\d+)?s?$/.test(lower)) { + options.leadInSeconds = Number(lower.replace(/s$/, '')); + } else if (index === 0) { + console.warn(`MarkupParser: Unknown image size "${token}", using landscape`); + } + }); + + return options; + } + parseMusicOptions(optionText) { const options = { mode: 'crossfade', @@ -162,6 +132,45 @@ class MarkupParserModule extends BaseModule { return options; } + parseSfxOptions(optionText) { + const options = { + maxDurationSeconds: 0, + endMode: 'stop', + fadeDurationSeconds: 2 + }; + + String(optionText || '') + .split(/[,\s]+/) + .map(token => token.trim()) + .filter(Boolean) + .forEach(token => { + const lower = token.toLowerCase(); + const [key, value] = lower.split('='); + + if (['fade', 'fadeout', 'fade-out'].includes(lower)) { + options.endMode = 'fade'; + } else if (['stop', 'cut', 'halt'].includes(lower)) { + options.endMode = 'stop'; + } else if (['max', 'duration', 'max-duration', 'limit', 'stop-after', 'fade-after'].includes(key)) { + const seconds = Number(value); + options.maxDurationSeconds = Number.isFinite(seconds) ? Math.max(0, seconds) : 0; + if (key === 'fade-after') options.endMode = 'fade'; + } else if (/^\d+(\.\d+)?s?$/.test(lower)) { + options.maxDurationSeconds = Number(lower.replace(/s$/, '')); + } else if (key === 'mode' && ['fade', 'fadeout', 'fade-out', 'stop', 'cut'].includes(value)) { + options.endMode = value.startsWith('fade') ? 'fade' : 'stop'; + } else if (['fade-duration', 'fade-time', 'fade'].includes(key)) { + const seconds = Number(value); + if (Number.isFinite(seconds)) { + options.fadeDurationSeconds = Math.max(0.1, seconds); + options.endMode = 'fade'; + } + } + }); + + return options; + } + parseParagraph(rawText) { const inline = this.parseInline(this.normalizeParagraph(rawText)); return { @@ -185,35 +194,9 @@ class MarkupParserModule extends BaseModule { } parseInline(text) { - const cueMarkers = []; - let output = ''; - let cursor = 0; - const markerPattern = /\{\{\s*(sfx|music)\s*:\s*(?:(queue|crossfade|cut)\s*:\s*)?([^}]+?)\s*\}\}/gi; - - for (const match of text.matchAll(markerPattern)) { - output += text.slice(cursor, match.index); - const charIndex = output.length; - const wordIndex = this.countWords(output); - const type = match[1].toLowerCase(); - const mode = type === 'music' ? (match[2] || 'crossfade').toLowerCase() : null; - - cueMarkers.push({ - type, - mode, - filename: match[3].trim(), - url: this.resolveAssetUrl(type === 'sfx' ? 'sounds' : 'music', match[3].trim()), - charIndex, - wordIndex - }); - - cursor = match.index + match[0].length; - } - - output += text.slice(cursor); - return { - text: output.replace(/\s{2,}/g, ' ').trim(), - cueMarkers + text: String(text || '').replace(/\s{2,}/g, ' ').trim(), + cueMarkers: [] }; } diff --git a/public/js/module-registry.js b/public/js/module-registry.js index a1abf10..3903408 100644 --- a/public/js/module-registry.js +++ b/public/js/module-registry.js @@ -27,7 +27,7 @@ export class ModuleRegistry { if (dependencies) { this.moduleDependencies.set(module.id, dependencies); - // Also set them on the module itself for backwards compatibility + // Mirror explicit dependencies onto the module instance. if (module.dependencies === undefined) { module.dependencies = [...dependencies]; } diff --git a/public/js/options-ui-module.js b/public/js/options-ui-module.js index 63a562b..d6bf4ef 100644 --- a/public/js/options-ui-module.js +++ b/public/js/options-ui-module.js @@ -46,9 +46,30 @@ class OptionsUIModule extends BaseModule { 'dispatchApiChangeEvent', 'getPreference', 'updatePreference', + 'updateUIText', 'renderProviderStatuses' ]); } + + t(key, params = {}) { + const localization = this.getModule('localization'); + return localization?.translate?.(key, params) || key; + } + + updateUIText() { + if (!this.modal) return; + const wasOpen = this.modal.style.display === 'flex'; + this.modal.remove(); + this.modal = null; + this.elements = {}; + this.createModal(); + this.setupPreferenceBindings(); + this.populateTtsSystems(); + this.populateLanguages(); + this.populateVoices(); + this.renderProviderStatuses(); + if (wasOpen) this.show(); + } /** * Dispatches an API change event @@ -135,7 +156,7 @@ class OptionsUIModule extends BaseModule { header.className = 'modal-header'; const title = document.createElement('h2'); - title.textContent = 'Options'; + title.textContent = this.t('options.title'); header.appendChild(title); const closeButton = document.createElement('span'); @@ -156,7 +177,7 @@ class OptionsUIModule extends BaseModule { appSettingsSection.className = 'options-section'; const appSettingsTitle = document.createElement('h3'); - appSettingsTitle.textContent = 'Application Settings'; + appSettingsTitle.textContent = this.t('options.applicationSettings'); appSettingsSection.appendChild(appSettingsTitle); // Language @@ -164,7 +185,7 @@ class OptionsUIModule extends BaseModule { languageContainer.className = 'option-item'; const languageLabel = document.createElement('label'); - languageLabel.textContent = 'Language:'; + languageLabel.textContent = this.t('options.language') + ':'; languageContainer.appendChild(languageLabel); this.elements.language = createUIElement('select', { @@ -178,7 +199,7 @@ class OptionsUIModule extends BaseModule { speedContainer.className = 'option-item'; const speedLabel = document.createElement('label'); - speedLabel.textContent = 'Speed:'; + speedLabel.textContent = this.t('options.speed') + ':'; speedContainer.appendChild(speedLabel); const speedValue = document.createElement('span'); @@ -210,7 +231,7 @@ class OptionsUIModule extends BaseModule { ttsSection.className = 'options-section'; const ttsTitle = document.createElement('h3'); - ttsTitle.textContent = 'Text-to-Speech'; + ttsTitle.textContent = this.t('options.speech'); ttsSection.appendChild(ttsTitle); // TTS Enable @@ -218,7 +239,7 @@ class OptionsUIModule extends BaseModule { ttsEnableContainer.className = 'option-item'; const ttsEnableLabel = document.createElement('label'); - ttsEnableLabel.textContent = 'Enable TTS:'; + ttsEnableLabel.textContent = this.t('options.enableSpeech') + ':'; ttsEnableContainer.appendChild(ttsEnableLabel); this.elements.ttsEnabled = createUIElement('input', { @@ -233,7 +254,7 @@ class OptionsUIModule extends BaseModule { ttsSystemContainer.className = 'option-item'; const ttsSystemLabel = document.createElement('label'); - ttsSystemLabel.textContent = 'TTS System:'; + ttsSystemLabel.textContent = this.t('options.provider') + ':'; ttsSystemContainer.appendChild(ttsSystemLabel); this.elements.ttsSystem = createUIElement('select', { @@ -252,7 +273,7 @@ class OptionsUIModule extends BaseModule { ttsVoiceContainer.className = 'option-item'; const ttsVoiceLabel = document.createElement('label'); - ttsVoiceLabel.textContent = 'Voice:'; + ttsVoiceLabel.textContent = this.t('options.voice') + ':'; ttsVoiceContainer.appendChild(ttsVoiceLabel); this.elements.ttsVoice = createUIElement('select', { @@ -272,7 +293,7 @@ class OptionsUIModule extends BaseModule { audioSection.className = 'options-section'; const audioTitle = document.createElement('h3'); - audioTitle.textContent = 'Audio'; + audioTitle.textContent = this.t('options.audio'); audioSection.appendChild(audioTitle); // Master Volume @@ -280,7 +301,7 @@ class OptionsUIModule extends BaseModule { masterVolumeContainer.className = 'option-item'; const masterVolumeLabel = document.createElement('label'); - masterVolumeLabel.textContent = 'Master Volume:'; + masterVolumeLabel.textContent = this.t('options.masterVolume') + ':'; masterVolumeContainer.appendChild(masterVolumeLabel); const masterVolumeValue = document.createElement('span'); @@ -310,7 +331,7 @@ class OptionsUIModule extends BaseModule { ttsVolumeContainer.className = 'option-item'; const ttsVolumeLabel = document.createElement('label'); - ttsVolumeLabel.textContent = 'Speech Volume:'; + ttsVolumeLabel.textContent = this.t('options.speechVolume') + ':'; ttsVolumeContainer.appendChild(ttsVolumeLabel); const ttsVolumeValue = document.createElement('span'); @@ -340,7 +361,7 @@ class OptionsUIModule extends BaseModule { musicVolumeContainer.className = 'option-item'; const musicVolumeLabel = document.createElement('label'); - musicVolumeLabel.textContent = 'Music Volume:'; + musicVolumeLabel.textContent = this.t('options.musicVolume') + ':'; musicVolumeContainer.appendChild(musicVolumeLabel); const musicVolumeValue = document.createElement('span'); @@ -370,7 +391,7 @@ class OptionsUIModule extends BaseModule { sfxVolumeContainer.className = 'option-item'; const sfxVolumeLabel = document.createElement('label'); - sfxVolumeLabel.textContent = 'Sound Effects Volume:'; + sfxVolumeLabel.textContent = this.t('options.sfxVolume') + ':'; sfxVolumeContainer.appendChild(sfxVolumeLabel); const sfxVolumeValue = document.createElement('span'); @@ -404,7 +425,7 @@ class OptionsUIModule extends BaseModule { footer.className = 'modal-footer'; const closeModalButton = document.createElement('button'); - closeModalButton.textContent = 'Close'; + closeModalButton.textContent = this.t('options.close'); closeModalButton.onclick = () => this.hide(); footer.appendChild(closeModalButton); @@ -432,7 +453,7 @@ class OptionsUIModule extends BaseModule { elevenLabsSettings.style.display = 'none'; const elevenLabsTitle = document.createElement('h3'); - elevenLabsTitle.textContent = 'ElevenLabs API Settings'; + elevenLabsTitle.textContent = this.t('options.elevenLabsSettings'); elevenLabsSettings.appendChild(elevenLabsTitle); // ElevenLabs API Key @@ -440,7 +461,7 @@ class OptionsUIModule extends BaseModule { elevenLabsApiKeyContainer.className = 'option-item'; const elevenLabsApiKeyLabel = document.createElement('label'); - elevenLabsApiKeyLabel.textContent = 'API Key:'; + elevenLabsApiKeyLabel.textContent = this.t('options.apiKey') + ':'; elevenLabsApiKeyContainer.appendChild(elevenLabsApiKeyLabel); this.elements.elevenLabsApiKey = createUIElement('input', { @@ -455,7 +476,7 @@ class OptionsUIModule extends BaseModule { elevenLabsApiUrlContainer.className = 'option-item'; const elevenLabsApiUrlLabel = document.createElement('label'); - elevenLabsApiUrlLabel.textContent = 'API URL:'; + elevenLabsApiUrlLabel.textContent = this.t('options.apiUrl') + ':'; elevenLabsApiUrlContainer.appendChild(elevenLabsApiUrlLabel); this.elements.elevenLabsApiUrl = createUIElement('input', { @@ -471,7 +492,7 @@ class OptionsUIModule extends BaseModule { openaiSettings.style.display = 'none'; const openaiTitle = document.createElement('h3'); - openaiTitle.textContent = 'OpenAI API Settings'; + openaiTitle.textContent = this.t('options.openAiSettings'); openaiSettings.appendChild(openaiTitle); // OpenAI API Key @@ -479,7 +500,7 @@ class OptionsUIModule extends BaseModule { openaiApiKeyContainer.className = 'option-item'; const openaiApiKeyLabel = document.createElement('label'); - openaiApiKeyLabel.textContent = 'API Key:'; + openaiApiKeyLabel.textContent = this.t('options.apiKey') + ':'; openaiApiKeyContainer.appendChild(openaiApiKeyLabel); this.elements.openaiApiKey = createUIElement('input', { @@ -494,7 +515,7 @@ class OptionsUIModule extends BaseModule { openaiApiUrlContainer.className = 'option-item'; const openaiApiUrlLabel = document.createElement('label'); - openaiApiUrlLabel.textContent = 'API URL:'; + openaiApiUrlLabel.textContent = this.t('options.apiUrl') + ':'; openaiApiUrlContainer.appendChild(openaiApiUrlLabel); this.elements.openaiApiUrl = createUIElement('input', { diff --git a/public/js/persistence-manager-module.js b/public/js/persistence-manager-module.js index 0d62aa7..a178587 100644 --- a/public/js/persistence-manager-module.js +++ b/public/js/persistence-manager-module.js @@ -33,7 +33,7 @@ class PersistenceManagerModule extends BaseModule { enabled: false, preferred_handler: 'none', speed: 1.0, - language: 'en-us', + language: 'en_US', voice: '', 'elevenlabs-tts_api_key': '', 'elevenlabs-tts_api_url': 'https://api.elevenlabs.io/v1', @@ -47,8 +47,10 @@ class PersistenceManagerModule extends BaseModule { sfxVolume: 1.0, }, app: { - locale: 'en-us', + locale: null, + localeUserOverride: false, speed: 1.0, + autoplay: true, } }; @@ -649,7 +651,6 @@ class PersistenceManagerModule extends BaseModule { } } } else { - // Try to parse as JSON for backward compatibility const customTransformer = JSON.parse(element.dataset.prefTransform); if (customTransformer && typeof customTransformer === 'object') { transformer = customTransformer; diff --git a/public/js/sentence-queue-module.js b/public/js/sentence-queue-module.js index 4e02e22..06539f0 100644 --- a/public/js/sentence-queue-module.js +++ b/public/js/sentence-queue-module.js @@ -9,7 +9,7 @@ class SentenceQueueModule extends BaseModule { super('sentence-queue', 'Sentence Queue'); // Dependencies - this.dependencies = ['text-buffer', 'tts-factory', 'paragraph-layout', 'audio-manager']; + this.dependencies = ['text-buffer', 'tts-factory', 'paragraph-layout', 'audio-manager', 'persistence-manager']; // Queue state this.sentenceQueue = []; @@ -18,6 +18,9 @@ class SentenceQueueModule extends BaseModule { // Cache for prefetched sentences this.preparedCache = new Map(); + this.prefetchingCache = new Map(); + this.activeImageWrap = null; + this.autoplay = true; // Bind methods this.bindMethods([ @@ -26,8 +29,18 @@ class SentenceQueueModule extends BaseModule { 'processNextSentence', 'setOnSentenceReady', 'completeSentence', + 'getCacheKey', + 'getPreparedSentence', + 'prefetchAhead', + 'isSpeechItem', + 'getMediaPauseSeconds', + 'readFirstFiniteNumber', + 'waitForSkippableMediaPause', + 'shouldAutoplay', + 'waitForManualContinue', 'prepareSentence', 'prepareLayout', + 'prepareImageLayout', 'extractWords', 'getDropCapText', 'extractDropCapText', @@ -56,6 +69,16 @@ class SentenceQueueModule extends BaseModule { }); this.reportProgress(100, "Sentence queue ready"); + const persistenceManager = this.getModule('persistence-manager'); + if (persistenceManager && typeof persistenceManager.getPreference === 'function') { + this.autoplay = persistenceManager.getPreference('app', 'autoplay', true) !== false; + } + this.addEventListener(document, 'preference-updated', (event) => { + const { category, key, value } = event.detail || {}; + if (category === 'app' && key === 'autoplay') { + this.autoplay = value !== false; + } + }); return true; } catch (error) { console.error("Error initializing Sentence Queue:", error); @@ -106,44 +129,11 @@ class SentenceQueueModule extends BaseModule { const item = this.sentenceQueue[0]; try { - // Check if sentence is already in cache - const cacheKey = `${item.id || ''}:${item.text}`; - let sentence = this.preparedCache.get(cacheKey); + const sentence = await this.getPreparedSentence(item); - if (!sentence) { - // Prepare complete sentence object (TTS + layout in parallel) - sentence = await this.prepareSentence(item); - } else { - console.log('SentenceQueue: Using cached sentence'); - this.preparedCache.delete(cacheKey); - } - - // Prefetch next sentence while current displays - if (this.sentenceQueue.length > 1) { - const nextItem = this.sentenceQueue[1]; - const nextCacheKey = `${nextItem.id || ''}:${nextItem.text}`; - if (!this.preparedCache.has(nextCacheKey)) { - document.dispatchEvent(new CustomEvent('story:process-state', { - detail: { state: 'playing-generating', reason: 'prefetch-start', sentenceId: nextItem.id } - })); - console.log('Process state: playing-generating', { reason: 'prefetch-start', sentenceId: nextItem.id }); - this.prepareSentence(nextItem) - .then(prepared => { - this.preparedCache.set(nextCacheKey, prepared); - console.log('SentenceQueue: Prefetched next sentence'); - document.dispatchEvent(new CustomEvent('story:process-state', { - detail: { state: 'playing-ready', reason: 'prefetch-complete', sentenceId: nextItem.id } - })); - console.log('Process state: playing-ready', { reason: 'prefetch-complete', sentenceId: nextItem.id }); - }) - .catch(err => console.warn('SentenceQueue: Prefetch failed:', err)); - } - } else { - document.dispatchEvent(new CustomEvent('story:process-state', { - detail: { state: 'playing-ready', reason: 'no-prefetch-needed', sentenceId: item.id } - })); - console.log('Process state: playing-ready', { reason: 'no-prefetch-needed', sentenceId: item.id }); - } + // Prefetch far enough ahead that media pauses do not block TTS + // generation for the next spoken paragraph. + this.prefetchAhead(); // Notify display handler with complete sentence if (this.onSentenceReadyCallback) { @@ -153,6 +143,15 @@ class SentenceQueueModule extends BaseModule { }); } + const mediaPauseSeconds = this.getMediaPauseSeconds(sentence); + if (mediaPauseSeconds > 0) { + await this.waitForSkippableMediaPause(mediaPauseSeconds, sentence.kind, sentence.id); + } + + if (sentence.kind === 'paragraph' && !this.shouldAutoplay()) { + await this.waitForManualContinue(sentence.id); + } + // Remove from queue and continue this.sentenceQueue.shift(); if (item.callback) item.callback({ success: true }); @@ -275,12 +274,17 @@ class SentenceQueueModule extends BaseModule { } } + const imageLayout = metadata.type === 'image' + ? await this.prepareImageLayout(metadata) + : null; + return { id, kind: metadata.type, text: text || '', + turnId: metadata.turnId ?? null, status: 'ready', - metadata, + metadata: imageLayout ? { ...metadata, imageLayout } : metadata, tts: { duration: 0, provider: null, audioData: null, play: null, stop: null, enabled: false }, animation: { wordTimings: [], cueTimings: [], totalDuration: 0 }, element: null, @@ -309,6 +313,7 @@ class SentenceQueueModule extends BaseModule { id, kind: metadata.type === 'heading' ? 'heading' : 'paragraph', text, + turnId: metadata.turnId ?? null, paragraphIndex: metadata.paragraphIndex ?? null, isFirstParagraphInChapter: Boolean(metadata.isFirstParagraphInChapter), role: metadata.role || (metadata.type === 'heading' ? 'chapter-heading' : 'body'), @@ -383,10 +388,27 @@ class SentenceQueueModule extends BaseModule { const indentWidth = (isHeading || metadata.isFirstParagraphInChapter || metadata.addTopSpace) ? 0 : lineHeight * 1.5; const layoutText = metadata.layoutText || text; const layoutPlainText = metadata.dropCap ? this.extractDropCapText(layoutText) : layoutText; + const wrap = this.consumeImageWrap(); // Measures are consumed in line order by the line breaker. + const wrappedWidth = wrap ? Math.max(120, containerWidth - wrap.width) : containerWidth; + const imageLeftOffset = wrap && wrap.side !== 'right' ? wrap.width : 0; + const imageRightOffset = wrap && wrap.side === 'right' ? wrap.width : 0; const measures = isHeading ? [containerWidth] + : wrap && metadata.dropCap + ? [ + Math.max(120, wrappedWidth - dropCapWidth), + Math.max(120, wrappedWidth - dropCapWidth), + ...Array(Math.max(0, wrap.lines - dropCapLines)).fill(wrappedWidth), + containerWidth + ] + : wrap + ? [ + Math.max(120, wrappedWidth - indentWidth), + ...Array(Math.max(0, wrap.lines - 1)).fill(wrappedWidth), + containerWidth + ] : metadata.dropCap ? [ Math.max(120, containerWidth - dropCapWidth), @@ -398,8 +420,34 @@ class SentenceQueueModule extends BaseModule { containerWidth, containerWidth ]; + const lineOffsets = isHeading + ? [0] + : wrap && metadata.dropCap + ? [ + imageLeftOffset + dropCapWidth, + imageLeftOffset + dropCapWidth, + ...Array(Math.max(0, wrap.lines - dropCapLines)).fill(imageLeftOffset), + 0 + ] + : wrap + ? [ + imageLeftOffset + indentWidth, + ...Array(Math.max(0, wrap.lines - 1)).fill(imageLeftOffset), + 0 + ] + : metadata.dropCap + ? [ + dropCapWidth, + dropCapWidth, + 0 + ] + : [ + indentWidth, + 0, + 0 + ]; - console.log(`SentenceQueue: Layout calculation - indentWidth: ${indentWidth.toFixed(1)}px, measures: [${measures.map(m => m.toFixed(1)).join(', ')}]`); + console.log(`SentenceQueue: Layout calculation - indentWidth: ${indentWidth.toFixed(1)}px, imageRightOffset: ${imageRightOffset.toFixed(1)}px, measures: [${measures.map(m => m.toFixed(1)).join(', ')}], offsets: [${lineOffsets.map(m => m.toFixed(1)).join(', ')}]`); const layout = paragraphLayout.calculateLayout(layoutPlainText, { measures, @@ -413,13 +461,23 @@ class SentenceQueueModule extends BaseModule { throw new Error('Paragraph layout calculation failed'); } + if (wrap) { + const usedLines = Math.max(0, (layout.breaks?.length || 1) - 1); + const remainingLines = Math.max(0, wrap.lines - usedLines); + this.activeImageWrap = remainingLines > 0 + ? { ...wrap, lines: remainingLines } + : null; + } + return { breaks: layout.breaks, nodes: layout.nodes, processedText: layout.processedText || text, sourceLayoutText: layoutText, measures, + lineOffsets, indentWidth, + imageWrap: wrap, dropCap: Boolean(metadata.dropCap), dropCapText: metadata.dropCap ? this.getDropCapText(layoutText) : '', dropCapLines, @@ -437,6 +495,282 @@ class SentenceQueueModule extends BaseModule { } } + shouldAutoplay() { + const persistenceManager = this.getModule('persistence-manager'); + if (persistenceManager && typeof persistenceManager.getPreference === 'function') { + return persistenceManager.getPreference('app', 'autoplay', this.autoplay) !== false; + } + return this.autoplay !== false; + } + + waitForManualContinue(sentenceId) { + document.documentElement.dataset.skippablePause = 'true'; + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'paused', reason: 'autoplay-disabled', sentenceId } + })); + return new Promise(resolve => { + let resolved = false; + const finish = () => { + if (resolved) return; + resolved = true; + delete document.documentElement.dataset.skippablePause; + document.removeEventListener('ui:command', onCommand); + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: 'manual-continue', sentenceId } + })); + resolve(); + }; + const onCommand = (event) => { + if (event.detail?.type === 'continue') { + finish(); + } + }; + document.addEventListener('ui:command', onCommand); + }); + } + + getCacheKey(item) { + return `${item?.id || ''}:${item?.text || ''}`; + } + + async getPreparedSentence(item) { + const cacheKey = this.getCacheKey(item); + const cached = this.preparedCache.get(cacheKey); + + if (cached) { + console.log('SentenceQueue: Using cached sentence'); + this.preparedCache.delete(cacheKey); + return cached; + } + + const pending = this.prefetchingCache.get(cacheKey); + if (pending) { + console.log('SentenceQueue: Awaiting active prefetch'); + try { + const prepared = await pending; + return prepared || await this.prepareSentence(item); + } finally { + this.prefetchingCache.delete(cacheKey); + this.preparedCache.delete(cacheKey); + } + } + + return this.prepareSentence(item); + } + + prefetchAhead(maxLookahead = 4) { + if (this.sentenceQueue.length <= 1) { + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: 'no-prefetch-needed', sentenceId: this.sentenceQueue[0]?.id } + })); + console.log('Process state: playing-ready', { reason: 'no-prefetch-needed', sentenceId: this.sentenceQueue[0]?.id }); + return; + } + + let started = 0; + let spokenPrepared = 0; + const limit = Math.min(this.sentenceQueue.length, maxLookahead + 1); + + for (let index = 1; index < limit; index += 1) { + const nextItem = this.sentenceQueue[index]; + const nextCacheKey = this.getCacheKey(nextItem); + if (this.preparedCache.has(nextCacheKey) || this.prefetchingCache.has(nextCacheKey)) { + if (this.isSpeechItem(nextItem)) spokenPrepared += 1; + continue; + } + + const state = this.isSpeechItem(nextItem) ? 'playing-generating' : 'playing-ready'; + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state, reason: 'prefetch-start', sentenceId: nextItem.id, queueIndex: index } + })); + console.log(`Process state: ${state}`, { reason: 'prefetch-start', sentenceId: nextItem.id, queueIndex: index }); + + const promise = this.prepareSentence(nextItem) + .then(prepared => { + this.preparedCache.set(nextCacheKey, prepared); + console.log('SentenceQueue: Prefetched queued item', { sentenceId: nextItem.id, queueIndex: index }); + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: 'prefetch-complete', sentenceId: nextItem.id, queueIndex: index } + })); + console.log('Process state: playing-ready', { reason: 'prefetch-complete', sentenceId: nextItem.id, queueIndex: index }); + return prepared; + }) + .catch(err => { + console.warn('SentenceQueue: Prefetch failed:', err); + return null; + }) + .finally(() => { + this.prefetchingCache.delete(nextCacheKey); + }); + + this.prefetchingCache.set(nextCacheKey, promise); + started += 1; + + if (this.isSpeechItem(nextItem)) { + spokenPrepared += 1; + } + + if (spokenPrepared >= 1 && started >= 2) { + break; + } + } + + if (started === 0) { + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: 'prefetch-already-ready', sentenceId: this.sentenceQueue[0]?.id } + })); + console.log('Process state: playing-ready', { reason: 'prefetch-already-ready', sentenceId: this.sentenceQueue[0]?.id }); + } + } + + isSpeechItem(item) { + const type = item?.type || 'paragraph'; + return type === 'paragraph' || type === 'heading' || !['image', 'music'].includes(type); + } + + getMediaPauseSeconds(sentence) { + if (!sentence || !['image', 'music'].includes(sentence.kind)) { + return 0; + } + + const metadata = sentence.metadata || {}; + const configuredPause = this.readFirstFiniteNumber( + metadata.leadInSeconds, + metadata.leadIn, + metadata.pause, + metadata.delay, + 0 + ); + + if (sentence.kind !== 'image') { + return configuredPause; + } + + const revealSeconds = Number(metadata.imageRevealSeconds || metadata.revealSeconds || 0.9); + return Math.max(configuredPause, Number.isFinite(revealSeconds) ? revealSeconds : 0.9); + } + + readFirstFiniteNumber(...values) { + for (const value of values) { + const number = Number(value); + if (Number.isFinite(number)) { + return Math.max(0, number); + } + } + + return 0; + } + + waitForSkippableMediaPause(seconds, kind = 'media', sentenceId = null) { + const duration = Math.max(0, Number(seconds) || 0) * 1000; + if (duration <= 0) return Promise.resolve(false); + + const startedAt = performance.now(); + console.log(`SentenceQueue: Waiting ${seconds}s for ${kind} lead`, { sentenceId }); + document.documentElement.dataset.skippablePause = 'true'; + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: `${kind}-pause-start`, duration, sentenceId } + })); + + return new Promise(resolve => { + let finished = false; + let timeoutId = null; + + const finish = (skipped, source = null) => { + if (finished) return; + finished = true; + clearTimeout(timeoutId); + document.removeEventListener('ui:command', onCommand); + delete document.documentElement.dataset.skippablePause; + const elapsedMs = Math.round(performance.now() - startedAt); + console.log(`SentenceQueue: ${kind} lead ${skipped ? 'skipped' : 'complete'}`, { sentenceId, elapsedMs, source }); + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: `${kind}-pause-${skipped ? 'skipped' : 'complete'}`, duration, elapsedMs, sentenceId } + })); + resolve(skipped); + }; + + const onCommand = (event) => { + if (event.detail?.type === 'continue') { + finish(true, event.detail); + } + }; + + document.addEventListener('ui:command', onCommand); + timeoutId = setTimeout(() => finish(false), duration); + }); + } + + async prepareImageLayout(metadata = {}) { + const storyElement = document.getElementById('story'); + if (!storyElement) { + throw new Error("Story container not found"); + } + + if (document.fonts && document.fonts.ready) { + await document.fonts.ready; + } + + const probe = document.createElement('p'); + probe.style.visibility = 'hidden'; + probe.style.position = 'absolute'; + probe.style.left = '-8000px'; + probe.style.top = '-8000px'; + storyElement.appendChild(probe); + const computedStyle = window.getComputedStyle(probe); + const lineHeight = parseFloat(computedStyle.lineHeight) || 24; + probe.remove(); + + const pageWidth = storyElement.clientWidth; + const size = String(metadata.size || 'landscape').toLowerCase(); + const aspect = size === 'portrait' ? (9 / 16) : size === 'square' ? 1 : (16 / 9); + const imageGap = lineHeight * 0.9; + const maxWidth = size === 'portrait' ? pageWidth * 0.5 : pageWidth; + const naturalHeight = maxWidth / aspect; + const imageLineCount = Math.max(1, Math.floor(naturalHeight / lineHeight)); + const height = imageLineCount * lineHeight; + const width = Math.min(maxWidth, height * aspect); + const verticalMargin = lineHeight / 2; + const lineCount = imageLineCount + 1; + + if (size === 'portrait') { + this.activeImageWrap = { + lines: lineCount, + width: width + imageGap, + imageWidth: width, + gap: imageGap, + height, + lineHeight, + side: metadata.floatSide || 'left' + }; + } + + return { + size, + aspect, + width, + height, + gap: imageGap, + lineCount, + imageLineCount, + lineHeight, + verticalMargin, + floatSide: metadata.floatSide || 'left', + pageWidth + }; + } + + consumeImageWrap() { + if (!this.activeImageWrap || this.activeImageWrap.lines <= 0) { + this.activeImageWrap = null; + return null; + } + + const wrap = { ...this.activeImageWrap }; + this.activeImageWrap = null; + return wrap; + } + /** * Extract words from layout nodes * @param {Array} nodes - Layout nodes from Knuth-Plass algorithm @@ -546,6 +880,7 @@ class SentenceQueueModule extends BaseModule { this.sentenceQueue = []; this.isProcessing = false; this.preparedCache.clear(); + this.activeImageWrap = null; document.dispatchEvent(new CustomEvent('tts:queue-empty', { detail: { reason: 'sentence-queue-cleared' } })); diff --git a/public/js/socket-client-module.js b/public/js/socket-client-module.js index 09b7d24..f0d914b 100644 --- a/public/js/socket-client-module.js +++ b/public/js/socket-client-module.js @@ -9,7 +9,7 @@ class SocketClientModule extends BaseModule { super('socket-client', 'Socket Client'); // Dependencies - this.dependencies = ['text-buffer']; + this.dependencies = ['text-buffer', 'markup-parser']; this.socket = null; this.textBuffer = null; @@ -31,6 +31,7 @@ class SocketClientModule extends BaseModule { 'newGame', 'loadGame', 'saveGame', + 'chooseChoice', 'hasSaveGame', 'getSaveGames', 'isGameRunning', @@ -41,7 +42,21 @@ class SocketClientModule extends BaseModule { 'off', 'emitEvent', 'setupGameEventHandlers', - 'processTextFragment', + 'processTurnResult', + 'processParagraphResult', + 'dispatchTurnTags', + 'isTimedCueTag', + 'cueMarkersFromTags', + 'dispatchChoices', + 'dispatchInputMode', + 'isStructuralTag', + 'blocksFromTags', + 'enqueueStructuredBlock', + 'parseImageTagOptions', + 'parseSfxTagOptions', + 'parseMusicTagOptions', + 'resolveAssetUrl', + 'looksLikeAssetPath', 'attemptReconnect', 'getConnectionStatus', 'loadSocketIO' @@ -166,48 +181,285 @@ class SocketClientModule extends BaseModule { // Special handling for narrative text this.socket.on('narrativeResponse', (data) => { - if (data && data.text && this.textBuffer) { - this.processTextFragment(data.text); - } + this.processTurnResult(data); }); - // Special handling for introduction text - this.socket.on('gameIntroduction', (data) => { - if (data && data.introduction && this.textBuffer) { - this.processTextFragment(data.introduction); - } - - if (data && data.initialRoomDescription && this.textBuffer) { - this.processTextFragment(data.initialRoomDescription); - } + this.socket.on('gameConfig', (data) => { + document.dispatchEvent(new CustomEvent('game:config', { + detail: data + })); }); } - - /** - * Process a text fragment by adding it to the TextBuffer - * @param {string} text - Text fragment to process - */ - processTextFragment(text) { - if (!text) return; - - // Add text to the buffer if available - if (this.textBuffer) { - console.log(`Socket Client: Processing text fragment: "${text.substring(0, 50)}${text.length > 50 ? '...' : ''}"`); + + processTurnResult(data) { + if (!data) return; + + const turnId = Number(data.turnId); + if (!Number.isInteger(turnId) || turnId < 1 || !Array.isArray(data.paragraphs)) { + console.error('Socket Client: Invalid TurnResult received', data); + return; + } + + if (Array.isArray(data.globalTags) && data.globalTags.length > 0) { + document.dispatchEvent(new CustomEvent('story:global-tags', { + detail: data.globalTags + })); + } + + document.dispatchEvent(new CustomEvent('story:turn-start', { + detail: { turnId, turn: data } + })); + + let pendingParagraph = { + role: null, + cueTags: [] + }; + data.paragraphs.forEach((paragraph) => { + pendingParagraph = this.processParagraphResult(paragraph, turnId, pendingParagraph); + }); + + this.dispatchChoices(Array.isArray(data.choices) ? data.choices : []); + this.dispatchInputMode(data.inputMode || (Array.isArray(data.choices) && data.choices.length > 0 ? 'choice' : 'text')); + } + + dispatchTurnTags(tags, paragraph = null) { + if (!Array.isArray(tags)) return; + tags.forEach((tag) => { + if (!tag || !tag.key) return; + document.dispatchEvent(new CustomEvent('story:tag', { + detail: { + ...tag, + paragraph + } + })); + }); + } + + dispatchChoices(choices) { + document.dispatchEvent(new CustomEvent('story:choices', { + detail: choices + })); + } + + dispatchInputMode(inputMode) { + const mode = ['text', 'choice', 'end'].includes(inputMode) ? inputMode : 'text'; + document.dispatchEvent(new CustomEvent('story:input-mode', { + detail: mode + })); + } + + processParagraphResult(paragraph, turnId, pendingParagraph = null) { + const pending = pendingParagraph && typeof pendingParagraph === 'object' + ? pendingParagraph + : { role: pendingParagraph || null, cueTags: [] }; + const tags = Array.isArray(paragraph?.tags) ? paragraph.tags : []; + const { blocks, paragraphRole } = this.blocksFromTags(tags, turnId); + const text = String(paragraph?.text || '').trim(); + const cueTags = tags.filter(tag => this.isTimedCueTag(tag)); + const immediateTags = tags.filter(tag => !this.isStructuralTag(tag) && !this.isTimedCueTag(tag)); + + this.dispatchTurnTags(immediateTags, paragraph); + blocks.forEach(block => this.enqueueStructuredBlock(block)); + + if (!text) { + return { + role: paragraphRole || pending.role || null, + cueTags: [ + ...(Array.isArray(pending.cueTags) ? pending.cueTags : []), + ...cueTags + ] + }; + } + + const role = pending.role || paragraphRole || 'body'; + const cueMarkers = [ + ...(Array.isArray(paragraph.cueMarkers) ? paragraph.cueMarkers : []), + ...this.cueMarkersFromTags([ + ...(Array.isArray(pending.cueTags) ? pending.cueTags : []), + ...cueTags + ]) + ]; + this.enqueueStructuredBlock({ + type: 'paragraph', + text, + layoutText: paragraph.layoutText || text, + cueMarkers, + role, + isFirstParagraphInChapter: role === 'chapter-first' || role === 'textblock-first', + dropCap: role === 'chapter-first', + addTopSpace: role === 'textblock-first', + turnId + }); + + return { role: null, cueTags: [] }; + } + + isStructuralTag(tag) { + const key = String(tag?.key || '').toLowerCase(); + return ['chapter', 'heading', 'section', 'textblock', 'image', 'music'].includes(key); + } + + isTimedCueTag(tag) { + const key = String(tag?.key || '').toLowerCase(); + return ['sfx', 'sound', 'audio'].includes(key); + } + + cueMarkersFromTags(tags) { + if (!Array.isArray(tags)) return []; + + return tags + .filter(tag => this.isTimedCueTag(tag)) + .map(tag => { + const filename = String(tag?.value || tag?.filename || '').trim(); + if (!filename) return null; + const options = this.parseSfxTagOptions(tag?.param || tag?.options || ''); + return { + type: 'sfx', + ...options, + filename, + url: this.resolveAssetUrl('sounds', filename), + wordIndex: 0, + charIndex: 0 + }; + }) + .filter(Boolean); + } + + blocksFromTags(tags, turnId = null) { + const result = { + blocks: [], + paragraphRole: null + }; + + if (!Array.isArray(tags)) return result; + + tags.forEach((tag) => { + const key = String(tag?.key || '').toLowerCase(); + const value = String(tag?.value || '').trim(); + const param = String(tag?.param || tag?.options || '').trim(); + + if ((key === 'chapter' || key === 'heading') && value) { + result.blocks.push({ + type: 'heading', + text: value, + layoutText: value, + role: 'chapter-heading', + turnId + }); + result.paragraphRole = 'chapter-first'; + } else if (key === 'section' || key === 'textblock') { + result.blocks.push({ + type: 'heading', + text: value || '* * *', + layoutText: value || '* * *', + role: 'section-heading', + turnId + }); + result.paragraphRole = 'textblock-first'; + } else if (key === 'image') { + let filename = value; + let optionText = param; + if (this.looksLikeAssetPath(param) && value && !this.looksLikeAssetPath(value)) { + filename = param; + optionText = value; + } + if (!filename) return; + const options = this.parseImageTagOptions(optionText); + const chapterOpening = result.paragraphRole === 'chapter-first'; + result.blocks.push({ + type: 'image', + ...options, + floatSide: chapterOpening && String(options.size || '').toLowerCase() === 'portrait' ? 'right' : 'left', + chapterOpening, + filename, + url: this.resolveAssetUrl('images', filename), + turnId + }); + } else if (key === 'music') { + let filename = value; + let optionText = param; + if (this.looksLikeAssetPath(param) && value && !this.looksLikeAssetPath(value)) { + filename = param; + optionText = value; + } + if (!filename) return; + const options = this.parseMusicTagOptions(optionText); + const leadInSeconds = Number(options.leadInSeconds); + result.blocks.push({ + type: 'music', + ...options, + leadInSeconds: Number.isFinite(leadInSeconds) ? leadInSeconds : 0, + leadIn: Number.isFinite(leadInSeconds) ? leadInSeconds : 0, + pause: Number.isFinite(leadInSeconds) ? leadInSeconds : 0, + filename, + url: this.resolveAssetUrl('music', filename), + turnId + }); + } + }); + + return result; + } + + enqueueStructuredBlock(block) { + if (!block) return; + + if (!this.textBuffer) { + this.textBuffer = this.getModule('text-buffer'); + } + + if (this.textBuffer && typeof this.textBuffer.addBlock === 'function') { + console.log(`Socket Client: Queueing ${block.type} block`); document.dispatchEvent(new CustomEvent('story:process-state', { detail: { state: 'waiting-generating', reason: 'server-response-received' } })); - this.textBuffer.addText(text); - } else { - console.error('Socket Client: Text buffer not available'); - // Attempt to get text buffer again using parent's getModule method - this.textBuffer = this.getModule('text-buffer'); - if (this.textBuffer) { - this.textBuffer.addText(text); - } else { - // Emit a text event as fallback if no text buffer - this.emitEvent('text', text); - } + this.textBuffer.addBlock(block); + return; } + + console.error('Socket Client: Text buffer not available for structured block', block); + } + + parseImageTagOptions(optionText) { + const parser = this.getModule('markup-parser'); + if (parser && typeof parser.parseImageOptions === 'function') { + return parser.parseImageOptions(optionText); + } + return { size: 'landscape', leadInSeconds: 0 }; + } + + parseSfxTagOptions(optionText) { + const parser = this.getModule('markup-parser'); + if (parser && typeof parser.parseSfxOptions === 'function') { + return parser.parseSfxOptions(optionText); + } + return { maxDurationSeconds: 0, endMode: 'stop', fadeDurationSeconds: 2 }; + } + + parseMusicTagOptions(optionText) { + const parser = this.getModule('markup-parser'); + if (parser && typeof parser.parseMusicOptions === 'function') { + return parser.parseMusicOptions(optionText); + } + return { mode: 'crossfade', loop: true, leadInSeconds: 0 }; + } + + resolveAssetUrl(kind, filename) { + const parser = this.getModule('markup-parser'); + if (parser && typeof parser.resolveAssetUrl === 'function') { + return parser.resolveAssetUrl(kind, filename); + } + + const root = kind === 'images' ? '/images/' : kind === 'music' ? '/music/' : '/sounds/'; + const safeName = String(filename || '').replace(/\\/g, '/').replace(/^\/+/, ''); + if (!safeName || safeName.includes('..') || /^[a-z]+:/i.test(safeName)) { + return ''; + } + return root + safeName.split('/').map(encodeURIComponent).join('/'); + } + + looksLikeAssetPath(value) { + return /[./\\]/.test(String(value || '')) || /\.(png|jpe?g|gif|webp|svg|ogg|mp3|wav|m4a|flac)$/i.test(String(value || '')); } /** @@ -329,6 +581,10 @@ class SocketClientModule extends BaseModule { return this.callGameApi('saveGame', [slot]); } + chooseChoice(choiceIndex) { + return this.callGameApi('chooseChoice', [choiceIndex]); + } + hasSaveGame(slot = 1) { return this.callGameApi('hasSaveGame', [slot]); } diff --git a/public/js/text-buffer-module.js b/public/js/text-buffer-module.js index c30e827..ce5d445 100644 --- a/public/js/text-buffer-module.js +++ b/public/js/text-buffer-module.js @@ -21,6 +21,7 @@ class TextBufferModule extends BaseModule { // Bind methods using parent's bindMethods utility this.bindMethods([ 'addText', + 'addBlock', 'splitIntoParagraphs', 'processNextFromQueue', 'processSentences', @@ -135,6 +136,43 @@ class TextBufferModule extends BaseModule { } } + /** + * Add an already parsed render block to the processing queue. + * Engine protocols should prefer this over re-serializing tags into text markup. + * @param {Object} block - Parsed paragraph/media/heading block + */ + addBlock(block) { + if (!block || !block.type) return; + + if (block.type === 'paragraph') { + const paragraphId = block.id || `paragraph-${this.paragraphCounter + 1}`; + this.processingQueue.push({ + ...block, + id: paragraphId, + paragraphIndex: this.paragraphCounter, + textBlockId: this.currentTextBlockId, + text: String(block.text || '').trim(), + layoutText: block.layoutText || block.text || '' + }); + this.paragraphCounter += 1; + } else { + this.processingQueue.push({ + ...block, + id: block.id || `${block.type}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}` + }); + + if (block.type === 'image') { + this.currentTextBlockId += 1; + } + } + + if (!this.isProcessingActive && this.onSentenceReadyCallback) { + this.processNextFromQueue(); + } else { + console.log(`TextBuffer: ${block.type} block queued for processing`); + } + } + /** * Split an incoming narrative fragment into book paragraphs. * Single newlines inside a paragraph are normalized to spaces; blank lines diff --git a/public/js/text-processor-module.js b/public/js/text-processor-module.js index 7ecd729..6aae666 100644 --- a/public/js/text-processor-module.js +++ b/public/js/text-processor-module.js @@ -239,7 +239,7 @@ class TextProcessorModule extends BaseModule { } normalizeHyphenationLocale(locale) { - const normalized = String(locale || 'en-us').toLowerCase(); + const normalized = String(locale || 'en-us').trim().toLowerCase().replace('_', '-'); if (normalized === 'en') return 'en-us'; if (normalized === 'de-de') return 'de'; return normalized; diff --git a/public/js/tts-factory-module.js b/public/js/tts-factory-module.js index 7d0ab10..f34d216 100644 --- a/public/js/tts-factory-module.js +++ b/public/js/tts-factory-module.js @@ -182,12 +182,11 @@ class TTSFactoryModule extends BaseModule { this.reportProgress(100, 'TTS Factory initialized'); console.log(`TTS Factory: Initialization complete, TTS available: ${this.ttsAvailable}`); - // To maintain backward compatibility, we always return true - // since TTS is now optional and the system should function without it + // TTS is optional; the client must continue to function without it. return true; } catch (error) { console.error('TTS Factory: Initialization error:', error); - return true; // Still return true for backward compatibility + return true; } } @@ -655,7 +654,6 @@ class TTSFactoryModule extends BaseModule { detail: { handler: 'none', available: false } })); - // Also dispatch tts:engine:change for compatibility with Options UI document.dispatchEvent(new CustomEvent('tts:engine:change', { detail: { engine: 'none', handler: 'none', available: false } })); @@ -719,7 +717,6 @@ class TTSFactoryModule extends BaseModule { }); document.dispatchEvent(event); - // Also dispatch tts:engine:change for compatibility with Options UI document.dispatchEvent(new CustomEvent('tts:engine:change', { detail: { engine: id, handler: id, available: isReady } })); diff --git a/public/js/ui-controller-module.js b/public/js/ui-controller-module.js index a14f225..57bfa2f 100644 --- a/public/js/ui-controller-module.js +++ b/public/js/ui-controller-module.js @@ -7,7 +7,7 @@ class UIControllerModule extends BaseModule { // Remove 'tts' from direct dependencies to break circular dependency // UI Controller will access TTS through the Game Loop instead - this.dependencies = ['animation-queue', 'ui-display-handler', 'ui-input-handler', 'ui-effects', 'text-buffer', 'socket-client', 'sentence-queue', 'playback-coordinator']; + this.dependencies = ['animation-queue', 'ui-display-handler', 'ui-input-handler', 'ui-effects', 'text-buffer', 'socket-client', 'sentence-queue', 'playback-coordinator', 'persistence-manager']; // References to sub-modules this.displayHandler = null; @@ -47,6 +47,8 @@ class UIControllerModule extends BaseModule { 'syncTopControls', 'getStoredTtsPreference', 'setStoredTtsPreference', + 'getStoredAppPreference', + 'setStoredAppPreference', 'sliderValueFromSpeed', 'speedFromSliderValue', 'initializeTextBuffer', @@ -267,7 +269,8 @@ class UIControllerModule extends BaseModule { } const playbackCoordinator = this.getModule('playback-coordinator'); - if (playbackCoordinator && playbackCoordinator.isPlaying) { + const hasSkippablePause = document.documentElement.dataset.skippablePause === 'true'; + if ((playbackCoordinator && playbackCoordinator.isPlaying) || hasSkippablePause) { this.handleCommand({ type: 'continue', source: 'book-click' }); } @@ -350,6 +353,9 @@ class UIControllerModule extends BaseModule { document.addEventListener('preference-updated', (event) => { const { category, key, value } = event.detail || {}; if (category !== 'tts') { + if (category === 'app' && key === 'autoplay') { + this.syncTopControls(); + } return; } @@ -391,6 +397,7 @@ class UIControllerModule extends BaseModule { bindTopControls() { const speechToggle = document.getElementById('speech'); + const autoplayToggle = document.getElementById('autoplay'); const speedSlider = document.getElementById('speed'); const speedReset = document.getElementById('speed_reset'); @@ -428,6 +435,22 @@ class UIControllerModule extends BaseModule { }); } + if (autoplayToggle && autoplayToggle.dataset.uiControllerBound !== 'true') { + autoplayToggle.dataset.uiControllerBound = 'true'; + autoplayToggle.removeAttribute('disabled'); + autoplayToggle.addEventListener('click', (event) => { + event.preventDefault(); + event.stopPropagation(); + const nextAutoplay = !this.getStoredAppPreference('autoplay', true); + this.setStoredAppPreference('autoplay', nextAutoplay); + console.log(`UIController: Autoplay set to ${nextAutoplay ? 'enabled' : 'disabled'}`); + this.syncTopControls(); + document.dispatchEvent(new CustomEvent('app:autoplay:change', { + detail: { enabled: nextAutoplay, source: 'topbar' } + })); + }); + } + if (speedSlider && speedSlider.dataset.uiControllerBound !== 'true') { speedSlider.dataset.uiControllerBound = 'true'; speedSlider.min = speedSlider.min || '50'; @@ -518,6 +541,48 @@ class UIControllerModule extends BaseModule { console.warn('UIController: Failed to write TTS preference fallback:', error); } } + + getStoredAppPreference(key, defaultValue) { + const persistenceManager = this.getModule('persistence-manager'); + if (persistenceManager && typeof persistenceManager.getPreference === 'function') { + const value = persistenceManager.getPreference('app', key, undefined); + if (typeof value !== 'undefined' && value !== null) { + return value; + } + } + + try { + const raw = localStorage.getItem('ai-interactive-fiction-preferences'); + if (raw) { + const prefs = JSON.parse(raw); + if (prefs && prefs.app && Object.prototype.hasOwnProperty.call(prefs.app, key)) { + return prefs.app[key]; + } + } + } catch (error) { + console.warn('UIController: Failed to read app preference fallback:', error); + } + + return defaultValue; + } + + setStoredAppPreference(key, value) { + const persistenceManager = this.getModule('persistence-manager'); + if (persistenceManager && typeof persistenceManager.updatePreference === 'function') { + persistenceManager.updatePreference('app', key, value); + } + + try { + const storageKey = 'ai-interactive-fiction-preferences'; + const raw = localStorage.getItem(storageKey); + const prefs = raw ? JSON.parse(raw) : {}; + prefs.app = prefs.app || {}; + prefs.app[key] = value; + localStorage.setItem(storageKey, JSON.stringify(prefs)); + } catch (error) { + console.warn('UIController: Failed to write app preference fallback:', error); + } + } async setupMainUI() { // Ensure all UI components exist @@ -583,6 +648,9 @@ class UIControllerModule extends BaseModule { break; case 'continue': { + document.dispatchEvent(new CustomEvent('ui:command', { + detail: { moduleId: this.id, type: 'continue', source: command.source || 'ui-controller-forward' } + })); const playbackCoordinator = this.getModule('playback-coordinator'); if (playbackCoordinator && playbackCoordinator.isPlaying) { playbackCoordinator.fastForward(); @@ -633,6 +701,7 @@ class UIControllerModule extends BaseModule { const loadButton = document.getElementById('reload'); const restartButton = document.getElementById('rewind'); const speechToggle = document.getElementById('speech'); + const autoplayToggle = document.getElementById('autoplay'); // Update save button state if (saveButton && typeof canSave === 'boolean') { @@ -679,6 +748,13 @@ class UIControllerModule extends BaseModule { speechToggle.title = 'Enable speech'; } } + + if (autoplayToggle) { + const autoplay = this.getStoredAppPreference('autoplay', true) !== false; + autoplayToggle.removeAttribute('disabled'); + autoplayToggle.style.fontWeight = autoplay ? 'bold' : 'normal'; + autoplayToggle.style.color = autoplay ? '#000' : '#999'; + } } // Public API methods diff --git a/public/js/ui-display-handler-module.js b/public/js/ui-display-handler-module.js index ca7c56c..a6a1a7f 100644 --- a/public/js/ui-display-handler-module.js +++ b/public/js/ui-display-handler-module.js @@ -9,7 +9,7 @@ class UIDisplayHandlerModule extends BaseModule { super('ui-display-handler', 'UI Display Handler'); // Module dependencies - this.dependencies = ['layout-renderer', 'playback-coordinator']; + this.dependencies = ['layout-renderer', 'playback-coordinator', 'game-config', 'localization']; // DOM elements this.container = null; @@ -31,10 +31,19 @@ class UIDisplayHandlerModule extends BaseModule { // Bind methods using parent's bindMethods utility this.bindMethods([ 'initializeContainers', + 'applyGameConfig', + 'applyTranslations', 'displayText', 'renderSentence', 'handleDeferredMediaBlock', + 'renderImageBlock', + 'calculateImageMetrics', + 'readFirstFiniteNumber', + 'waitForSkippablePause', 'scrollStoryToEnd', + 'animatePageScroll', + 'scrollToTurn', + 'handleStoryScroll', 'rerenderStory', 'clear', 'scheduleRerender', @@ -46,6 +55,10 @@ class UIDisplayHandlerModule extends BaseModule { console.log('UIDisplayHandler: Constructor initialized'); } + + t(key, params = {}) { + return this.localization?.translate?.(key, params) || key; + } async initialize() { try { @@ -61,6 +74,8 @@ class UIDisplayHandlerModule extends BaseModule { // Get references to required modules using parent's getModule method this.layoutRenderer = this.getModule('layout-renderer'); this.playbackCoordinator = this.getModule('playback-coordinator'); + this.gameConfig = this.getModule('game-config'); + this.localization = this.getModule('localization'); this.reportProgress(50, "Initializing display containers"); @@ -73,6 +88,24 @@ class UIDisplayHandlerModule extends BaseModule { this.addEventListener(document, 'book:resized', () => { this.scheduleRerender(); }); + this.addEventListener(document, 'game:config', (event) => { + this.applyGameConfig(event.detail); + }); + this.addEventListener(document, 'localization:languageChanged', () => { + this.applyTranslations(); + }); + this.addEventListener(document, 'story:scroll-to-turn', (event) => { + this.scrollToTurn(event.detail?.turnId); + }); + this.addEventListener(document, 'story:process-state', (event) => { + const state = event.detail?.state || 'ready'; + const remark = document.getElementById('remark_text'); + if (remark) { + remark.textContent = state === 'paused' + ? this.t('title.continueHint') + : this.t('title.fastForwardHint'); + } + }); if (window.ResizeObserver && this.paragraphContainer) { this.storyResizeObserver = new ResizeObserver((entries) => { @@ -196,9 +229,9 @@ class UIDisplayHandlerModule extends BaseModule { const header = document.createElement('div'); header.className = 'header'; header.innerHTML = ` - -

AI Interactive Fiction

-

An open-world text adventure

+ +

+

`; this.pageLeft.appendChild(header); @@ -208,12 +241,13 @@ class UIDisplayHandlerModule extends BaseModule { controls.id = 'controls'; controls.className = 'buttons'; controls.innerHTML = ` - speech - speed* - new game - save - load - options + + + * + + + + `; this.pageLeft.appendChild(controls); @@ -232,7 +266,7 @@ class UIDisplayHandlerModule extends BaseModule { commandInput.id = 'command_input'; commandInput.innerHTML = `
- +
`; @@ -243,8 +277,10 @@ class UIDisplayHandlerModule extends BaseModule { // Create remark const remark = document.createElement('div'); remark.id = 'remark'; - remark.className = 'l10n-remark'; - remark.innerHTML = '*click on page or press spacebar to fast forward text animation'; + remark.innerHTML = ` +
*
+ + `; this.pageLeft.appendChild(remark); bookContainer.appendChild(this.pageLeft); @@ -272,7 +308,6 @@ class UIDisplayHandlerModule extends BaseModule { if (!document.getElementById('start_prompt')) { const startPrompt = document.createElement('div'); startPrompt.id = 'start_prompt'; - startPrompt.textContent = 'Klick on new game or load to start the game'; this.pageRight.appendChild(startPrompt); } @@ -302,6 +337,66 @@ class UIDisplayHandlerModule extends BaseModule { } console.log('UIDisplayHandler: All containers initialized'); + this.applyGameConfig(this.gameConfig?.getConfig?.()); + this.applyTranslations(); + if (this.pageRight && !this.pageRight.dataset.turnScrollBound) { + this.pageRight.dataset.turnScrollBound = 'true'; + this.pageRight.addEventListener('scroll', this.handleStoryScroll, { passive: true }); + } + } + + applyGameConfig(config) { + const metadata = config?.metadata || this.gameConfig?.getMetadata?.() || {}; + const titleElement = document.getElementById('game_title'); + const authorElement = document.getElementById('game_author'); + const subtitleElement = document.getElementById('game_subtitle'); + const legalElement = document.getElementById('game_legal'); + document.getElementById('game_version')?.remove(); + document.getElementById('game_copyright')?.remove(); + + if (titleElement) titleElement.textContent = metadata.title || ''; + if (authorElement) authorElement.textContent = metadata.author ? this.t('title.byAuthor', { author: metadata.author }) : ''; + if (subtitleElement) subtitleElement.textContent = metadata.subtitle || ''; + if (legalElement) { + const items = [ + metadata.version ? this.t('title.version', { version: metadata.version }) : '', + metadata.copyright || '' + ].filter(Boolean); + legalElement.textContent = items.join(' · '); + } + } + + applyTranslations() { + this.localization = this.getModule('localization') || this.localization; + + const setText = (id, key) => { + const element = document.getElementById(id); + if (element) element.textContent = this.t(key); + }; + const setTitle = (id, key) => { + const element = document.getElementById(id); + if (element) element.setAttribute('title', this.t(key)); + }; + + setText('speech', 'topbar.speech'); + setText('autoplay', 'topbar.autoplay'); + setText('speed_label', 'topbar.speed'); + setText('rewind', 'topbar.newGame'); + setText('save', 'topbar.save'); + setText('reload', 'topbar.load'); + setText('options', 'topbar.options'); + setText('remark_text', 'title.fastForwardHint'); + setText('start_prompt', 'title.startPrompt'); + setTitle('speech', 'topbar.speechTitle'); + setTitle('autoplay', 'topbar.autoplayTitle'); + setTitle('rewind', 'topbar.newGameTitle'); + setTitle('save', 'topbar.saveTitle'); + setTitle('reload', 'topbar.loadTitle'); + setTitle('options', 'topbar.optionsTitle'); + + const input = document.getElementById('player_input'); + if (input) input.setAttribute('placeholder', this.t('input.placeholder')); + this.applyGameConfig(this.gameConfig?.getConfig?.()); } /** @@ -327,17 +422,13 @@ class UIDisplayHandlerModule extends BaseModule { /** - * Display text in the UI (backward compatibility) - * Note: Text should flow through SentenceQueue instead - * @param {string} text - Text to display - * @param {Object} options - Display options - * @returns {Promise} - Promise resolving to the displayed paragraph element + * Display a local UI message outside the server turn protocol. + * Story output must flow through structured TurnResult objects instead. */ displayText(text, options = {}) { if (!text) return Promise.resolve(null); - // For backward compatibility, delegate to sentence queue - console.warn('UIDisplayHandler.displayText called directly, text should flow through SentenceQueue'); + console.warn('UIDisplayHandler.displayText called directly; story text should come from TurnResult'); const sentenceQueue = this.getModule('sentence-queue'); if (sentenceQueue) { @@ -369,6 +460,10 @@ class UIDisplayHandlerModule extends BaseModule { sentence.layout, { id: sentence.id } ); + if (sentence.turnId != null) { + paragraphElement.dataset.turnId = String(sentence.turnId); + paragraphElement.classList.add('story-turn-block'); + } // Append to container if (this.paragraphContainer) { @@ -386,6 +481,7 @@ class UIDisplayHandlerModule extends BaseModule { this.renderedItems.push({ type: sentence.kind === 'heading' ? 'heading' : 'paragraph', id: sentence.id, + turnId: sentence.turnId ?? null, text: sentence.text, metadata: { layoutText: sentence.layout?.sourceLayoutText || sentence.text, @@ -427,9 +523,25 @@ class UIDisplayHandlerModule extends BaseModule { this.paragraphContainer.innerHTML = ''; for (const item of this.renderedItems) { + if (item.type === 'image') { + const sentenceQueue = this.getModule('sentence-queue'); + const imageLayout = sentenceQueue && typeof sentenceQueue.prepareImageLayout === 'function' + ? await sentenceQueue.prepareImageLayout(item.metadata || {}) + : null; + this.renderImageBlock({ + ...(item.metadata || {}), + imageLayout: imageLayout || item.metadata?.imageLayout + }, false); + continue; + } + if (item.type === 'heading') { const layout = await sentenceQueue.prepareLayout(item.text, item.metadata || {}); const heading = this.layoutRenderer.renderParagraph(layout, { id: item.id }); + if (item.turnId != null) { + heading.dataset.turnId = String(item.turnId); + heading.classList.add('story-turn-block'); + } heading.querySelectorAll('.word').forEach(word => { word.style.transition = 'none'; word.style.animation = 'none'; @@ -446,6 +558,10 @@ class UIDisplayHandlerModule extends BaseModule { const layout = await sentenceQueue.prepareLayout(item.text, item.metadata || {}); const paragraph = this.layoutRenderer.renderParagraph(layout, { id: item.id }); + if (item.turnId != null) { + paragraph.dataset.turnId = String(item.turnId); + paragraph.classList.add('story-turn-block'); + } paragraph.querySelectorAll('.word').forEach(word => { word.style.transition = 'none'; word.style.animation = 'none'; @@ -468,13 +584,74 @@ class UIDisplayHandlerModule extends BaseModule { } window.requestAnimationFrame(() => { - this.pageRight.scrollTo({ - top: Math.max(0, this.pageRight.scrollHeight - this.pageRight.clientHeight), - behavior: smooth ? 'smooth' : 'auto' - }); + this.animatePageScroll( + Math.max(0, this.pageRight.scrollHeight - this.pageRight.clientHeight), + smooth ? 720 : 0 + ); }); } + animatePageScroll(targetTop, duration = 720) { + if (!this.pageRight) return; + if (!duration) { + this.pageRight.scrollTop = targetTop; + return; + } + + const startTop = this.pageRight.scrollTop; + const delta = targetTop - startTop; + if (Math.abs(delta) < 1) return; + + const startedAt = performance.now(); + const ease = (t) => 1 - Math.pow(1 - t, 3); + const step = (now) => { + const progress = Math.min(1, (now - startedAt) / duration); + this.pageRight.scrollTop = startTop + (delta * ease(progress)); + if (progress < 1) { + requestAnimationFrame(step); + } + }; + requestAnimationFrame(step); + } + + scrollToTurn(turnId) { + if (!this.pageRight || turnId == null) return; + const escapedTurnId = CSS.escape(String(turnId)); + const target = this.paragraphContainer?.querySelector(`[data-turn-id="${escapedTurnId}"]`); + if (!target) return; + this.pageRight.scrollTo({ + top: Math.max(0, target.offsetTop - 12), + behavior: 'smooth' + }); + } + + handleStoryScroll() { + if (!this.pageRight || !this.paragraphContainer) return; + + const blocks = Array.from(this.paragraphContainer.querySelectorAll('[data-turn-id]')); + if (blocks.length === 0) return; + + const viewportMiddle = this.pageRight.scrollTop + (this.pageRight.clientHeight / 2); + let best = null; + let bestDistance = Infinity; + + blocks.forEach((block) => { + const blockMiddle = block.offsetTop + (block.offsetHeight / 2); + const distance = Math.abs(blockMiddle - viewportMiddle); + if (distance < bestDistance) { + bestDistance = distance; + best = block; + } + }); + + if (best?.dataset?.turnId && this.activeTurnId !== best.dataset.turnId) { + this.activeTurnId = best.dataset.turnId; + document.dispatchEvent(new CustomEvent('story:visible-turn', { + detail: { turnId: Number(best.dataset.turnId) } + })); + } + } + async handleDeferredMediaBlock(sentence) { document.dispatchEvent(new CustomEvent('story:media-block', { detail: { @@ -484,12 +661,27 @@ class UIDisplayHandlerModule extends BaseModule { } })); - if (sentence.kind === 'music') { - const leadInSeconds = Number(sentence.metadata?.leadInSeconds || sentence.metadata?.leadIn || 0); - if (leadInSeconds > 0) { - console.log(`UIDisplayHandler: Waiting ${leadInSeconds}s before continuing after music block`); - await new Promise(resolve => setTimeout(resolve, leadInSeconds * 1000)); + if (sentence.kind === 'image') { + const element = this.renderImageBlock(sentence.metadata || {}, true); + this.renderedItems.push({ + type: 'image', + id: sentence.id, + turnId: sentence.turnId ?? null, + text: '', + metadata: sentence.metadata || {} + }); + + this.scrollStoryToEnd(true); + + if (sentence.onComplete) { + sentence.onComplete(); } + + return element; + } + + if (sentence.kind === 'music') { + console.log('UIDisplayHandler: Music block started', sentence.metadata || {}); } if (sentence.onComplete) { @@ -499,7 +691,145 @@ class UIDisplayHandlerModule extends BaseModule { return null; } + readFirstFiniteNumber(...values) { + for (const value of values) { + const number = Number(value); + if (Number.isFinite(number)) { + return Math.max(0, number); + } + } + + return 0; + } + + waitForSkippablePause(seconds, kind = 'media') { + const duration = Math.max(0, Number(seconds) || 0) * 1000; + if (duration <= 0) return Promise.resolve(false); + + document.documentElement.dataset.skippablePause = 'true'; + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: `${kind}-pause-start`, duration } + })); + + return new Promise(resolve => { + let finished = false; + let timeoutId = null; + + const finish = (skipped) => { + if (finished) return; + finished = true; + clearTimeout(timeoutId); + document.removeEventListener('ui:command', onCommand); + delete document.documentElement.dataset.skippablePause; + document.dispatchEvent(new CustomEvent('story:process-state', { + detail: { state: 'playing-ready', reason: `${kind}-pause-${skipped ? 'skipped' : 'complete'}` } + })); + resolve(skipped); + }; + + const onCommand = (event) => { + if (event.detail?.type === 'continue') { + finish(true); + } + }; + + document.addEventListener('ui:command', onCommand); + timeoutId = setTimeout(() => finish(false), duration); + }); + } + + renderImageBlock(metadata = {}, animate = true) { + if (!this.paragraphContainer) return null; + + const metrics = metadata.imageLayout || this.calculateImageMetrics(metadata.size); + const figure = document.createElement('figure'); + figure.className = [ + 'story-image-block', + `story-image-${metrics.size || 'landscape'}`, + metrics.floatSide === 'right' ? 'story-image-float-right' : '', + metrics.floatSide === 'left' ? 'story-image-float-left' : '', + animate ? 'story-image-pending' : 'story-image-visible' + ].filter(Boolean).join(' '); + figure.style.width = `${metrics.width}px`; + figure.style.height = `${metrics.height}px`; + figure.style.marginTop = `${metrics.verticalMargin || 0}px`; + figure.style.marginBottom = `${metrics.verticalMargin || 0}px`; + figure.dataset.animationMs = '900'; + if (metadata.turnId != null) { + figure.dataset.turnId = String(metadata.turnId); + figure.classList.add('story-turn-block'); + } + + const img = document.createElement('img'); + img.src = metadata.url || metadata.filename || ''; + img.alt = metadata.alt || ''; + img.decoding = 'async'; + img.loading = 'eager'; + figure.appendChild(img); + + this.paragraphContainer.appendChild(figure); + + if (animate) { + window.requestAnimationFrame(() => { + figure.classList.remove('story-image-pending'); + figure.classList.add('story-image-visible'); + }); + } else { + figure.classList.remove('story-image-pending'); + figure.classList.add('story-image-visible'); + } + + return figure; + } + + calculateImageMetrics(size = 'landscape') { + const storyElement = document.getElementById('story'); + const pageWidth = storyElement?.clientWidth || 600; + const probe = document.createElement('p'); + probe.style.visibility = 'hidden'; + probe.style.position = 'absolute'; + probe.style.left = '-8000px'; + probe.style.top = '-8000px'; + (storyElement || document.body).appendChild(probe); + const lineHeight = parseFloat(window.getComputedStyle(probe).lineHeight) || 24; + probe.remove(); + + const normalizedSize = String(size || 'landscape').toLowerCase() === 'widescreen' + ? 'landscape' + : String(size || 'landscape').toLowerCase(); + const aspect = normalizedSize === 'portrait' ? (9 / 16) : normalizedSize === 'square' ? 1 : (16 / 9); + const imageGap = lineHeight * 0.9; + const maxWidth = normalizedSize === 'portrait' ? pageWidth * 0.5 : pageWidth; + const naturalHeight = maxWidth / aspect; + const imageLineCount = Math.max(1, Math.floor(naturalHeight / lineHeight)); + const height = imageLineCount * lineHeight; + const width = Math.min(maxWidth, height * aspect); + const verticalMargin = lineHeight / 2; + const lineCount = imageLineCount + 1; + + return { + size: normalizedSize, + aspect, + width, + height, + gap: imageGap, + lineCount, + imageLineCount, + lineHeight, + verticalMargin, + floatSide: 'left', + pageWidth + }; + } + clear() { + if (document.documentElement.dataset.skippablePause === 'true') { + document.dispatchEvent(new CustomEvent('ui:command', { + detail: { moduleId: this.id, type: 'continue', source: 'display-clear' } + })); + delete document.documentElement.dataset.skippablePause; + } + if (this.container) { this.container.innerHTML = ''; this.paragraphContainer = document.createElement('div'); diff --git a/public/js/ui-input-handler-module.js b/public/js/ui-input-handler-module.js index 0fad2cc..9aa507c 100644 --- a/public/js/ui-input-handler-module.js +++ b/public/js/ui-input-handler-module.js @@ -18,6 +18,7 @@ class UIInputHandlerModule extends BaseModule { this.historyIndex = -1; this.commandHistory = []; this.inputBuffer = ''; + this.inputMode = 'text'; // Bind methods using the parent class bindMethods utility this.bindMethods([ @@ -28,11 +29,14 @@ class UIInputHandlerModule extends BaseModule { 'handleKeyboardInput', 'submitCommand', 'addToHistory', + 'bindHistoryToTurn', + 'highlightHistoryTurn', 'formatCommandHistory', 'resetCursorPosition', 'focusInput', 'setProcessState', 'setInputAvailability', + 'setMode', 'clearHistory' ]); @@ -61,6 +65,15 @@ class UIInputHandlerModule extends BaseModule { this.addEventListener(document, 'story:process-state', (event) => { this.setProcessState(event.detail?.state || 'ready', event.detail || {}); }); + this.addEventListener(document, 'story:input-mode', (event) => { + this.setMode(event.detail || 'text'); + }); + this.addEventListener(document, 'story:turn-start', (event) => { + this.bindHistoryToTurn(event.detail?.turnId); + }); + this.addEventListener(document, 'story:visible-turn', (event) => { + this.highlightHistoryTurn(event.detail?.turnId); + }); this.reportProgress(100, 'UI Input Handler ready'); return true; @@ -87,7 +100,7 @@ class UIInputHandlerModule extends BaseModule { return; } - if (event.key === ' ' && this.isPlaybackActive()) { + if (event.key === ' ' && (this.isPlaybackActive() || this.isSkippablePauseActive())) { document.dispatchEvent(new CustomEvent('ui:command', { detail: { type: 'continue', source: 'spacebar' } })); @@ -95,7 +108,7 @@ class UIInputHandlerModule extends BaseModule { if (event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); - if (document.body.dataset.gameRunning !== 'true') { + if (document.body.dataset.gameRunning !== 'true' || this.inputMode !== 'text') { return; } this.submitCommand(); @@ -110,6 +123,9 @@ class UIInputHandlerModule extends BaseModule { if (document.body.dataset.gameRunning !== 'true') { return; } + if (this.inputMode !== 'text') { + return; + } event.preventDefault(); this.focusInput(); const start = this.playerInput.selectionStart ?? this.playerInput.value.length; @@ -176,8 +192,6 @@ class UIInputHandlerModule extends BaseModule { playerInput.id = 'player_input'; playerInput.rows = 1; playerInput.placeholder = 'What will you do?'; - playerInput.setAttribute('autocomplete', 'off'); - playerInput.setAttribute('spellcheck', 'true'); // Fix horizontal scrolling by ensuring the textbox wraps text playerInput.style.overflowX = 'hidden'; @@ -187,6 +201,7 @@ class UIInputHandlerModule extends BaseModule { inputWrapper.appendChild(playerInput); } this.playerInput = playerInput; + this.applyTextInputAttributes(playerInput); // Create the cursor if needed let cursor = document.getElementById('cursor'); @@ -260,7 +275,7 @@ class UIInputHandlerModule extends BaseModule { } setInputAvailability(enabled) { - this.inputEnabled = Boolean(enabled); + this.inputEnabled = Boolean(enabled) && this.inputMode === 'text'; const commandInput = document.getElementById('command_input'); if (commandInput) { commandInput.classList.toggle('fading', !this.inputEnabled); @@ -276,6 +291,31 @@ class UIInputHandlerModule extends BaseModule { } } + applyTextInputAttributes(playerInput) { + if (!playerInput) return; + + const attributes = { + autocomplete: 'off', + autocorrect: 'off', + autocapitalize: 'sentences', + spellcheck: 'true', + 'aria-autocomplete': 'none', + 'data-form-type': 'other', + 'data-1p-ignore': 'true', + 'data-lpignore': 'true', + 'data-bwignore': 'true' + }; + + Object.entries(attributes).forEach(([name, value]) => { + playerInput.setAttribute(name, value); + }); + } + + setMode(mode) { + this.inputMode = ['text', 'choice', 'end'].includes(mode) ? mode : 'text'; + this.setInputAvailability(this.inputMode === 'text'); + } + applyMouseCursor(state) { const root = document.documentElement; if (!root) { @@ -365,6 +405,7 @@ class UIInputHandlerModule extends BaseModule { submitCommand() { if (!this.playerInput || !this.playerInput.value.trim()) return; if (document.body.dataset.gameRunning !== 'true' || !this.inputEnabled) return; + if (this.inputMode !== 'text') return; const command = this.playerInput.value.trim(); console.log(`UIInputHandler: Submitting command: "${command}"`); @@ -420,7 +461,15 @@ class UIInputHandlerModule extends BaseModule { if (this.commandHistoryElement && this.commandHistoryElement.appendChild) { const historyItem = document.createElement('div'); historyItem.className = 'history-item'; + historyItem.dataset.turnId = 'pending'; historyItem.innerHTML = `> ${this.formatCommandHistory(command)}`; + historyItem.addEventListener('click', () => { + const turnId = historyItem.dataset.turnId; + if (!turnId || turnId === 'pending') return; + document.dispatchEvent(new CustomEvent('story:scroll-to-turn', { + detail: { turnId: Number(turnId) } + })); + }); this.commandHistoryElement.appendChild(historyItem); // Limit visible history items @@ -433,6 +482,25 @@ class UIInputHandlerModule extends BaseModule { } } + bindHistoryToTurn(turnId) { + if (!Number.isInteger(Number(turnId))) return; + if (!this.commandHistoryElement) { + this.commandHistoryElement = document.getElementById('command_history'); + } + const pending = this.commandHistoryElement?.querySelector('.history-item[data-turn-id="pending"]'); + if (!pending) return; + pending.dataset.turnId = String(turnId); + pending.classList.remove('history-pending'); + } + + highlightHistoryTurn(turnId) { + if (!this.commandHistoryElement || turnId == null) return; + const id = String(turnId); + this.commandHistoryElement.querySelectorAll('.history-item').forEach((item) => { + item.classList.toggle('active', item.dataset.turnId === id); + }); + } + formatCommandHistory(command) { const parser = this.getModule('markup-parser') || window.MarkupParser; if (parser && typeof parser.markdownToHtml === 'function') { @@ -450,6 +518,10 @@ class UIInputHandlerModule extends BaseModule { return Boolean(playbackCoordinator && playbackCoordinator.isPlaying); } + isSkippablePauseActive() { + return document.documentElement.dataset.skippablePause === 'true'; + } + /** * Resets the cursor position to the start. */ diff --git a/public/locales/de-de.json b/public/locales/de-de.json deleted file mode 100644 index 0967ef4..0000000 --- a/public/locales/de-de.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/public/locales/de_DE.json b/public/locales/de_DE.json new file mode 100644 index 0000000..cdea2a2 --- /dev/null +++ b/public/locales/de_DE.json @@ -0,0 +1,40 @@ +{ + "title.byAuthor": "von {{author}}", + "title.version": "Version {{version}}", + "title.fastForwardHint": "auf die Seite klicken oder Leertaste druecken, um die Textanimation vorzuspulen", + "title.continueHint": "auf die Seite klicken oder Leertaste druecken, um fortzufahren", + "title.startPrompt": "Klicke auf Neues Spiel oder Laden, um das Spiel zu starten", + "topbar.speech": "Sprache", + "topbar.autoplay": "Auto", + "topbar.speed": "Tempo", + "topbar.newGame": "Neues Spiel", + "topbar.save": "Speichern", + "topbar.load": "Laden", + "topbar.options": "Optionen", + "topbar.speechTitle": "Sprachausgabe ein- oder ausschalten", + "topbar.autoplayTitle": "Automatisches Abspielen absatzweise ein- oder ausschalten", + "topbar.newGameTitle": "Neues Spiel starten", + "topbar.saveTitle": "Fortschritt speichern", + "topbar.loadTitle": "Gespeicherten Fortschritt laden", + "topbar.optionsTitle": "Optionen", + "input.placeholder": "Befehl eingeben...", + "options.title": "Optionen", + "options.close": "Schliessen", + "options.applicationSettings": "Anwendung", + "options.language": "Sprache", + "options.speech": "Sprachausgabe", + "options.enableSpeech": "Sprachausgabe aktivieren", + "options.provider": "Anbieter", + "options.voice": "Stimme", + "options.speed": "Tempo", + "options.audio": "Audio", + "options.volume": "Lautstaerke", + "options.masterVolume": "Gesamtlautstaerke", + "options.speechVolume": "Sprachlautstaerke", + "options.musicVolume": "Musiklautstaerke", + "options.sfxVolume": "Effektlautstaerke", + "options.elevenLabsSettings": "ElevenLabs API-Einstellungen", + "options.openAiSettings": "OpenAI API-Einstellungen", + "options.apiKey": "API-Schluessel", + "options.apiUrl": "API-URL" +} diff --git a/public/locales/en-gb.json b/public/locales/en-gb.json deleted file mode 100644 index 0967ef4..0000000 --- a/public/locales/en-gb.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/public/locales/en-us.json b/public/locales/en-us.json deleted file mode 100644 index 0967ef4..0000000 --- a/public/locales/en-us.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/public/locales/en_US.json b/public/locales/en_US.json new file mode 100644 index 0000000..95a6993 --- /dev/null +++ b/public/locales/en_US.json @@ -0,0 +1,40 @@ +{ + "title.byAuthor": "by {{author}}", + "title.version": "Version {{version}}", + "title.fastForwardHint": "click on page or press spacebar to fast forward text animation", + "title.continueHint": "click on page or press spacebar to continue", + "title.startPrompt": "Click on new game or load to start the game", + "topbar.speech": "speech", + "topbar.autoplay": "autoplay", + "topbar.speed": "speed", + "topbar.newGame": "new game", + "topbar.save": "save", + "topbar.load": "load", + "topbar.options": "options", + "topbar.speechTitle": "Toggle text to speech", + "topbar.autoplayTitle": "Toggle paragraph autoplay", + "topbar.newGameTitle": "Start a new game", + "topbar.saveTitle": "Save progress", + "topbar.loadTitle": "Load saved progress", + "topbar.optionsTitle": "Options", + "input.placeholder": "Enter your command...", + "options.title": "Options", + "options.close": "Close", + "options.applicationSettings": "Application Settings", + "options.language": "Language", + "options.speech": "Speech", + "options.enableSpeech": "Enable text to speech", + "options.provider": "Provider", + "options.voice": "Voice", + "options.speed": "Speed", + "options.audio": "Audio", + "options.volume": "Volume", + "options.masterVolume": "Master Volume", + "options.speechVolume": "Speech Volume", + "options.musicVolume": "Music Volume", + "options.sfxVolume": "Sound Effects Volume", + "options.elevenLabsSettings": "ElevenLabs API Settings", + "options.openAiSettings": "OpenAI API Settings", + "options.apiKey": "API Key", + "options.apiUrl": "API URL" +} diff --git a/public/music/README.md b/public/music/README.md index f14ef1f..dfd8aa5 100644 --- a/public/music/README.md +++ b/public/music/README.md @@ -6,13 +6,7 @@ Story music paths resolve relative to this directory. Block music markup: ```text -::music[crossfade, loop, lead=4](track-name.ogg) -``` - -Inline music cue: - -```text -The candles gutter. {{music:cut:danger.ogg}} Something moves upstairs. +#music[track-name.ogg](crossfade, loop, lead=4) ``` Supported modes: diff --git a/public/sounds/README.md b/public/sounds/README.md index a5ffe0f..bc50c8a 100644 --- a/public/sounds/README.md +++ b/public/sounds/README.md @@ -3,13 +3,14 @@ Sound Effects Story sound effect paths resolve relative to this directory. -Use inline sound effect markup inside narrative text: +Use a sound effect story tag: ```text -The old door opens {{sfx:squeaky-door.ogg}} into the dark. +#sfx[squeaky-door.ogg] +The old door opens into the dark. ``` -The marker is removed from displayed text and from TTS input. It is kept as a timed media cue, preloaded by the client, and played when the text animation reaches that cue position. +The server parses the tag into a structured `StoryTag`. The tag is never sent to the client as display text or TTS input. Supported browser-friendly formats are recommended: `.ogg`, `.mp3`, and `.wav`. Keep files small enough for responsive preload. @@ -17,6 +18,9 @@ Sound effect loudness is controlled by the master volume and sound effects volum Document third-party source and license information here or next to the file. -Current test asset: +Current assets: - `squeaky-door.ogg`: Wikimedia Commons, "Squeaky door.ogg", sourced from PDSounds and marked public domain. +- `steam-whistle.ogg`: Wikimedia Commons, "WWS SteamWhistle.ogg" by Work With Sounds / Konrad Gutkowski and Julian Blaschke, Creative Commons Attribution 4.0 International. +- `horse-neigh.ogg`: Wikimedia Commons, "Wiehern.ogg" by Hue, released into the public domain by the author. +- `church-bells.ogg`: Wikimedia Commons, "Churchbells.ogg" by Natalie, sourced from PDSounds and released into the public domain. diff --git a/public/sounds/church-bells.ogg b/public/sounds/church-bells.ogg new file mode 100644 index 0000000..1b1a0e6 Binary files /dev/null and b/public/sounds/church-bells.ogg differ diff --git a/public/sounds/horse-neigh.ogg b/public/sounds/horse-neigh.ogg new file mode 100644 index 0000000..8761f9f Binary files /dev/null and b/public/sounds/horse-neigh.ogg differ diff --git a/public/sounds/steam-whistle.ogg b/public/sounds/steam-whistle.ogg new file mode 100644 index 0000000..1997994 Binary files /dev/null and b/public/sounds/steam-whistle.ogg differ diff --git a/src/config/game-config.ts b/src/config/game-config.ts new file mode 100644 index 0000000..b6deb15 --- /dev/null +++ b/src/config/game-config.ts @@ -0,0 +1,120 @@ +import path from 'path'; +import { existsSync, mkdirSync, readFileSync } from 'fs'; + +export type EngineName = 'yaml' | 'ink' | 'zork' | string; + +export interface GameMetadata { + title: string; + author?: string; + subtitle?: string; + version?: string; + copyright?: string; +} + +export interface GamePaths { + mainGameFile: string; + inkSource?: string; + inkCompiled?: string; + promptDir?: string; + music?: string; + sfx?: string; + images?: string; + [key: string]: string | undefined; +} + +export interface GameEngineConfig { + engine: EngineName; + locale: 'en_US' | 'de_DE' | string; + paths: GamePaths; + metadata: GameMetadata; +} + +const PROJECT_ROOT = path.resolve(__dirname, '../..'); + +function fallbackConfig(engine: EngineName): GameEngineConfig { + return { + engine, + locale: 'en_US', + paths: { + mainGameFile: + engine === 'ink' + ? 'data/ink/story.ink.json' + : engine === 'zork' + ? 'data/z-code/zork1.bin' + : 'data/worlds/example_world.yml', + music: 'public/music', + sfx: 'public/sounds', + images: 'public/images', + }, + metadata: { + title: 'AI Interactive Fiction', + author: 'Generative AI', + subtitle: 'An open-world text adventure', + version: '1.0.0', + copyright: '', + }, + }; +} + +export function projectPath(relativeOrAbsolutePath: string): string { + return path.isAbsolute(relativeOrAbsolutePath) + ? relativeOrAbsolutePath + : path.resolve(PROJECT_ROOT, relativeOrAbsolutePath); +} + +export function loadGameConfig(configPath: string, engine: EngineName): GameEngineConfig { + const absolutePath = projectPath(configPath); + if (!existsSync(absolutePath)) { + console.warn(`[config] Missing ${absolutePath}; using ${engine} defaults.`); + return fallbackConfig(engine); + } + + const parsed = JSON.parse(readFileSync(absolutePath, 'utf8')) as Partial; + const fallback = fallbackConfig(engine); + return { + engine: parsed.engine ?? fallback.engine, + locale: parsed.locale ?? fallback.locale, + paths: { + ...fallback.paths, + ...(parsed.paths ?? {}), + }, + metadata: { + ...fallback.metadata, + ...(parsed.metadata ?? {}), + }, + }; +} + +export function ensureConfiguredAssetDirectories(config: GameEngineConfig): void { + const directories = [ + config.paths.music, + config.paths.sfx, + config.paths.images, + config.paths.inkSource ? path.dirname(config.paths.inkSource) : undefined, + config.paths.inkCompiled ? path.dirname(config.paths.inkCompiled) : undefined, + config.paths.mainGameFile ? path.dirname(config.paths.mainGameFile) : undefined, + config.paths.promptDir, + ]; + + for (const directory of directories) { + if (!directory) continue; + const absolutePath = projectPath(directory); + if (!existsSync(absolutePath)) { + mkdirSync(absolutePath, { recursive: true }); + } + } +} + +export function clientGameConfig(config: GameEngineConfig) { + return { + engine: config.engine, + locale: config.locale, + metadata: config.metadata, + assets: { + music: '/music/', + sfx: '/sounds/', + sounds: '/sounds/', + images: '/images/', + }, + }; +} diff --git a/src/engine/ink-engine.ts b/src/engine/ink-engine.ts new file mode 100644 index 0000000..8e4dd0b --- /dev/null +++ b/src/engine/ink-engine.ts @@ -0,0 +1,176 @@ +import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs'; +import path from 'path'; +import { Story } from 'inkjs'; +import { + ChoiceResult, + StoryTag, + TurnResult, +} from '../interfaces/turn-result'; +import { getTagValue, parseTags } from '../utils/tag-parser'; + +const { Compiler } = require('inkjs/full') as { Compiler: new ( + inkSource: string, + options?: { + sourceFilename?: string; + errorHandler?: (message: string, type: number) => void; + fileHandler?: { + ResolveInkFilename: (filename: string) => string; + LoadInkFileContents: (filename: string) => string; + }; + }, +) => { Compile: () => { ToJson: () => string } | null } }; + +export interface InkCompileResult { + sourcePath: string; + outputPath: string; + warningCount: number; +} + +export function compileInkSource(sourcePath: string, outputPath: string): InkCompileResult { + const resolvedSource = path.resolve(sourcePath); + const resolvedOutput = path.resolve(outputPath); + if (!existsSync(resolvedSource)) { + throw new Error(`Ink source file not found: ${resolvedSource}`); + } + + const warnings: string[] = []; + const errors: string[] = []; + const source = readFileSync(resolvedSource, 'utf8').replace(/^\uFEFF/, ''); + const sourceDir = path.dirname(resolvedSource); + const fileHandler = { + ResolveInkFilename: (filename: string) => + path.isAbsolute(filename) ? filename : path.resolve(sourceDir, filename), + LoadInkFileContents: (filename: string) => + readFileSync(path.isAbsolute(filename) ? filename : path.resolve(sourceDir, filename), 'utf8') + .replace(/^\uFEFF/, ''), + }; + const compiler = new Compiler(source, { + sourceFilename: resolvedSource, + fileHandler, + errorHandler: (message: string, type: number) => { + if (type === 1) { + warnings.push(message); + } else { + errors.push(message); + } + }, + }); + + const story = compiler.Compile(); + if (!story || errors.length > 0) { + throw new Error(`Ink compilation failed:\n${errors.join('\n')}`); + } + + if (warnings.length > 0) { + warnings.forEach((warning) => console.warn(`[ink] ${warning}`)); + } + + mkdirSync(path.dirname(resolvedOutput), { recursive: true }); + writeFileSync(resolvedOutput, story.ToJson(), 'utf8'); + return { + sourcePath: resolvedSource, + outputPath: resolvedOutput, + warningCount: warnings.length, + }; +} + +export class InkEngine { + private story: Story | null = null; + private nextTurnId = 1; + + constructor(private readonly storyPath: string) {} + + isRunning(): boolean { + if (!this.story) return false; + return this.story.canContinue || this.story.currentChoices.length > 0; + } + + newGame(): TurnResult { + this.story = this.loadStory(); + this.nextTurnId = 1; + return this.continueStory(); + } + + chooseChoice(choiceIndex: number): TurnResult { + if (!this.story) { + throw new Error('No active Ink story'); + } + + const choice = this.story.currentChoices.find((item) => item.index === choiceIndex); + if (!choice) { + throw new Error(`Ink choice ${choiceIndex} is not available`); + } + + this.story.ChooseChoiceIndex(choice.index); + return this.continueStory(); + } + + saveGame(): string { + if (!this.story) { + throw new Error('No active Ink story to save'); + } + return this.story.state.toJson(); + } + + loadGame(savedState: string): TurnResult { + this.story = this.loadStory(); + this.story.state.LoadJson(savedState); + return this.continueStory(); + } + + private loadStory(): Story { + const resolvedPath = path.resolve(this.storyPath); + if (!existsSync(resolvedPath)) { + throw new Error(`Ink story file not found: ${resolvedPath}`); + } + + const storyJson = JSON.parse(readFileSync(resolvedPath, 'utf8')); + return new Story(storyJson); + } + + private continueStory(): TurnResult { + if (!this.story) { + throw new Error('No active Ink story'); + } + + const paragraphs: TurnResult['paragraphs'] = []; + const globalTags: StoryTag[] = []; + + while (this.story.canContinue) { + const rawText = this.story.Continue(); + const text = String(rawText || '').trim(); + const tags = parseTags(this.story.currentTags || []); + + tags + .filter((tag) => tag.key === 'title' || tag.key === 'author') + .forEach((tag) => globalTags.push(tag)); + + if (text) { + paragraphs.push({ text, tags }); + } else { + tags.forEach((tag) => globalTags.push(tag)); + } + } + + const choices = this.story.currentChoices.map((choice): ChoiceResult => { + const tags = parseTags(choice.tags || []); + const category = getTagValue(tags, 'action'); + const letter = getTagValue(tags, 'letter'); + return { + index: choice.index, + text: String(choice.text || '').trim(), + tags, + category, + letter, + }; + }); + + return { + turnId: this.nextTurnId++, + paragraphs, + choices, + inputMode: choices.length > 0 ? 'choice' : 'end', + globalTags: globalTags.length > 0 ? globalTags : undefined, + }; + } +} diff --git a/src/engine/zork-llm-engine.ts b/src/engine/zork-llm-engine.ts index ea53420..6538a5b 100644 --- a/src/engine/zork-llm-engine.ts +++ b/src/engine/zork-llm-engine.ts @@ -20,6 +20,10 @@ import * as os from 'os'; import * as yaml from 'js-yaml'; import axios, { AxiosError, AxiosInstance } from 'axios'; import * as dotenv from 'dotenv'; +import { + textToParagraphs, + TurnResult, +} from '../interfaces/turn-result'; dotenv.config(); @@ -91,13 +95,7 @@ export interface ZorkSession { running: boolean; } -/** Subset of the unified TurnResult protocol understood by the client. */ -export interface ZorkTurnResult { - paragraphs: Array<{ text: string; tags: unknown[] }>; - choices: unknown[]; - inputMode: 'text' | 'end'; - gameState?: { statusLine?: string }; -} +export type ZorkTurnResult = TurnResult; interface PromptConfig { system: string; @@ -418,6 +416,7 @@ export class ZorkLlmEngine { private llmCallCounter = 0; private maxRetries: number; private historySize: number; + private nextTurnId = 1; private storyPath: string; private static readonly DEPRECATED_MODEL_REPLACEMENTS: Record = { @@ -425,7 +424,7 @@ export class ZorkLlmEngine { 'openai/gpt-5.4-mini': 'openai/gpt-5.5', }; - constructor() { + constructor(options: { storyPath?: string; promptDir?: string } = {}) { const apiKey = process.env.OPENROUTER_API_KEY; const model = process.env.OPENROUTER_MODEL; if (!apiKey || !model) { @@ -450,10 +449,10 @@ export class ZorkLlmEngine { this.maxRetries = parseInt(process.env.ZORK_MAX_RETRIES ?? '3', 10); this.historySize = parseInt(process.env.ZORK_HISTORY_SIZE ?? '5', 10); this.storyPath = path.resolve( - process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin', + options.storyPath ?? process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin', ); - const promptDir = path.resolve('./data/zork-prompts'); + const promptDir = path.resolve(options.promptDir ?? './data/zork-prompts'); this.prompts = loadPrompts(promptDir); this.llm = axios.create({ @@ -582,6 +581,7 @@ export class ZorkLlmEngine { async newGame(): Promise { // Kill any existing game if (this.zork.isAlive()) this.zork.kill(); + this.nextTurnId = 1; if (!fs.existsSync(this.storyPath)) { throw new Error( @@ -1148,8 +1148,10 @@ export class ZorkLlmEngine { private buildTurnResult(text: string): ZorkTurnResult { const alive = this.zork.isAlive(); if (!alive && this.session) this.session.running = false; + const paragraphs = textToParagraphs(text); return { - paragraphs: [{ text, tags: [] }], + turnId: this.nextTurnId++, + paragraphs, choices: [], inputMode: alive ? 'text' : 'end', gameState: { statusLine: this.session?.currentRoom }, diff --git a/src/index.ts b/src/index.ts index d64ef57..8471a69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,9 +4,10 @@ import * as path from 'path'; import * as dotenv from 'dotenv'; -import { GameRunner } from './cli/game-runner'; -// Import the server module and the startServer function for the web interface -import { startServer } from './server'; +import { GameRunner } from './cli/game-runner'; +// Import the server module and the startServer function for the web interface +import { startServer } from './server'; +import { loadGameConfig, projectPath } from './config/game-config'; // Load environment variables console.log('Loading environment variables...'); @@ -27,8 +28,12 @@ async function main(): Promise { console.log('A modern take on classic text adventures with LLM-powered interactions'); console.log(''); - // Get the world file path from environment variables or use default - const worldFile = process.env.DEFAULT_WORLD_FILE || './data/worlds/example_world.yml'; + // Get the world file path from the YAML engine config, with environment override. + const engineConfig = loadGameConfig( + process.env.YAML_CONFIG_FILE || './config/engines/yaml.json', + 'yaml', + ); + const worldFile = projectPath(process.env.DEFAULT_WORLD_FILE || engineConfig.paths.mainGameFile); console.log(`Using world file: ${worldFile}`); console.log(`OpenRouter API Key: ${process.env.OPENROUTER_API_KEY ? '✓ Found' : '✗ Missing'}`); console.log(`OpenRouter Model: ${process.env.OPENROUTER_MODEL || '✗ Not specified'}`); @@ -58,7 +63,7 @@ async function main(): Promise { // Get port configuration const DEFAULT_PORT = 3000; const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; - const PORT_RANGE = 10; + const PORT_RANGE = 300; // Start the web server with port fallback console.log('Starting web server...'); @@ -80,4 +85,4 @@ console.log('Starting application...'); main().catch(error => { console.error('Unhandled error in main:', error); process.exit(1); -}); \ No newline at end of file +}); diff --git a/src/interfaces/turn-result.ts b/src/interfaces/turn-result.ts new file mode 100644 index 0000000..e2b9146 --- /dev/null +++ b/src/interfaces/turn-result.ts @@ -0,0 +1,71 @@ +/** + * Shared engine-to-client turn protocol. + */ +import { parseTag } from '../utils/tag-parser'; + +export type InputMode = 'text' | 'choice' | 'end'; + +export interface StoryTag { + key: string; + value?: string; + param?: string; +} + +export interface ParagraphResult { + text: string; + tags: StoryTag[]; +} + +export interface ChoiceResult { + index: number; + text: string; + tags: StoryTag[]; + category?: string; + letter?: string; +} + +export interface TurnResult { + turnId: number; + paragraphs: ParagraphResult[]; + choices: ChoiceResult[]; + inputMode: InputMode; + globalTags?: StoryTag[]; + gameState?: { + currentRoomId?: string; + score?: number; + moves?: number; + statusLine?: string; + }; + suggestions?: string[]; +} + +export function textToParagraphs(text: string, tags: StoryTag[] = []): ParagraphResult[] { + return String(text || '') + .replace(/\r\n?/g, '\n') + .split(/\n{2,}/) + .map((paragraph) => paragraph.trim()) + .filter(Boolean) + .map((paragraph) => { + const lines = paragraph.split('\n'); + const paragraphTags: StoryTag[] = [...tags]; + const textLines: string[] = []; + let tagPrefixOpen = true; + + for (const line of lines) { + const trimmed = line.trim(); + const maybeTag = tagPrefixOpen && trimmed.startsWith('#') ? parseTag(trimmed) : null; + + if (maybeTag) { + paragraphTags.push(maybeTag); + } else { + tagPrefixOpen = false; + textLines.push(line); + } + } + + return { + text: textLines.join('\n').trim(), + tags: paragraphTags, + }; + }); +} diff --git a/src/server-ink.ts b/src/server-ink.ts new file mode 100644 index 0000000..4d4ec59 --- /dev/null +++ b/src/server-ink.ts @@ -0,0 +1,282 @@ +/** + * Ink Engine Server + * + * Serves the shared client UI and runs a compiled Ink JSON story through the + * unified TurnResult socket protocol. + */ + +import path from 'path'; +import http from 'http'; +import express from 'express'; +import { Server as SocketIOServer } from 'socket.io'; +import * as dotenv from 'dotenv'; +import { existsSync, mkdirSync, copyFileSync } from 'fs'; +import { compileInkSource, InkEngine } from './engine/ink-engine'; +import { + clientGameConfig, + ensureConfiguredAssetDirectories, + loadGameConfig, + projectPath, +} from './config/game-config'; + +dotenv.config(); + +const app = express(); +const server = http.createServer(app); +const io = new SocketIOServer(server); + +const DEFAULT_PORT = 3003; +const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : DEFAULT_PORT; +const PORT_RANGE = 300; +const engineConfig = loadGameConfig( + process.env.INK_CONFIG_FILE || './config/engines/ink.json', + 'ink', +); + +app.use( + express.static(path.join(__dirname, '../public'), { + etag: false, + lastModified: false, + setHeaders: (res) => { + res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate'); + res.setHeader('Pragma', 'no-cache'); + res.setHeader('Expires', '0'); + }, + }), +); + +app.get('/api/game-config', (_req, res) => { + res.json(clientGameConfig(engineConfig)); +}); + +const sessions = new Map(); +const saveSlots = new Map>(); + +function normalizeSaveSlot(slot: unknown): number { + const n = Number(slot); + return Number.isInteger(n) && n > 0 ? n : 1; +} + +function getStoryPath(): string { + return projectPath( + process.env.INK_STORY_FILE || + engineConfig.paths.inkCompiled || + engineConfig.paths.mainGameFile, + ); +} + +function getSourcePath(): string { + return projectPath(process.env.INK_SOURCE_FILE || engineConfig.paths.inkSource || ''); +} + +function compileConfiguredStory(): void { + const sourcePath = getSourcePath(); + const outputPath = getStoryPath(); + const result = compileInkSource(sourcePath, outputPath); + console.log( + `[ink] Compiled ${result.sourcePath} -> ${result.outputPath}` + + (result.warningCount > 0 ? ` (${result.warningCount} warnings)` : ''), + ); +} + +function getSlots(socketId: string): Map { + let slots = saveSlots.get(socketId); + if (!slots) { + slots = new Map(); + saveSlots.set(socketId, slots); + } + return slots; +} + +function getOrCreateEngine(socketId: string): InkEngine { + let engine = sessions.get(socketId); + if (!engine) { + engine = new InkEngine(getStoryPath()); + sessions.set(socketId, engine); + } + return engine; +} + +async function handleGameApi( + socket: ReturnType & { id: string }, + method: string, + args: unknown[], +): Promise { + const slots = getSlots(socket.id); + + switch (method) { + case 'newGame': + case 'newGame()': { + const engine = new InkEngine(getStoryPath()); + sessions.set(socket.id, engine); + socket.emit('narrativeResponse', engine.newGame()); + return { success: true, result: true, running: true, canLoad: slots.size > 0 }; + } + + case 'chooseChoice': + case 'chooseChoice()': { + const engine = sessions.get(socket.id); + if (!engine?.isRunning()) { + return { success: false, error: 'game_not_running', result: false }; + } + const choiceIndex = Number(args[0]); + if (!Number.isInteger(choiceIndex)) { + return { success: false, error: 'invalid_choice', result: false }; + } + socket.emit('narrativeResponse', engine.chooseChoice(choiceIndex)); + return { success: true, result: true }; + } + + case 'loadGame': + case 'loadGame()': { + const slot = normalizeSaveSlot(args[0]); + if (!slots.has(slot)) { + return { success: false, error: 'missing_save', result: false }; + } + const engine = getOrCreateEngine(socket.id); + socket.emit('narrativeResponse', engine.loadGame(slots.get(slot)!)); + socket.emit('gameLoaded', { slot }); + return { success: true, result: true, running: true, slot }; + } + + case 'saveGame': + case 'saveGame()': { + const engine = sessions.get(socket.id); + if (!engine?.isRunning()) { + return { success: false, error: 'game_not_running', result: false }; + } + const slot = normalizeSaveSlot(args[0]); + slots.set(slot, engine.saveGame()); + socket.emit('gameSaved', { slot }); + return { success: true, result: true, slot }; + } + + case 'hasSaveGame': + case 'hasSaveGame()': { + const slot = normalizeSaveSlot(args[0]); + return { success: true, result: slots.has(slot), slot }; + } + + case 'getSaveGames': + case 'getSaveGames()': + return { success: true, result: Array.from(slots.keys()).sort((a, b) => a - b) }; + + case 'isGameRunning': + case 'isGameRunning()': + return { success: true, result: sessions.get(socket.id)?.isRunning() ?? false }; + + default: + return { success: false, error: `unknown_method:${method}` }; + } +} + +io.on('connection', (socket) => { + console.log(`[ink] Client connected: ${socket.id}`); + socket.emit('gameConfig', clientGameConfig(engineConfig)); + + socket.on( + 'gameApi', + async ( + request: { method?: string; args?: unknown[] }, + respond: (result: object) => void, + ) => { + try { + const result = await handleGameApi( + socket as Parameters[0], + String(request?.method ?? ''), + Array.isArray(request?.args) ? request.args : [], + ); + if (typeof respond === 'function') respond(result); + } catch (error) { + console.error('[ink] gameApi error:', error); + if (typeof respond === 'function') { + respond({ + success: false, + error: error instanceof Error ? error.message : String(error), + }); + } + } + }, + ); + + socket.on('disconnect', () => { + console.log(`[ink] Client disconnected: ${socket.id}`); + sessions.delete(socket.id); + saveSlots.delete(socket.id); + }); +}); + +function ensureDirectories(): void { + const dirs = [ + path.join(__dirname, '../public'), + path.join(__dirname, '../public/js'), + path.join(__dirname, '../public/css'), + path.join(__dirname, '../public/images'), + path.join(__dirname, '../public/music'), + path.join(__dirname, '../public/sounds'), + path.join(__dirname, '../public/fonts'), + ]; + for (const dir of dirs) { + if (!existsSync(dir)) mkdirSync(dir, { recursive: true }); + } + ensureConfiguredAssetDirectories(engineConfig); +} + +function ensureKokoroJs(): void { + const source = path.join(__dirname, '../node_modules/kokoro-js/dist/index.js'); + const destination = path.join(__dirname, '../public/js/kokoro-js.js'); + if (existsSync(source) && !existsSync(destination)) { + copyFileSync(source, destination); + } +} + +export async function startServer(initialPort: number, range: number): Promise { + ensureDirectories(); + try { ensureKokoroJs(); } catch { /* optional */ } + + compileConfiguredStory(); + + if (!existsSync(getStoryPath())) { + console.error(`[ink] Story file missing: ${getStoryPath()}`); + console.error('[ink] Set INK_SOURCE_FILE or configure paths.inkSource in config/engines/ink.json.'); + } + + let port = initialPort; + while (port < initialPort + range) { + try { + await new Promise((resolve, reject) => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { + console.log(`[ink] Ink server running on http://localhost:${port}`); + resolve(); + }); + server.once('error', (error: NodeJS.ErrnoException) => { + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${port} unavailable (${error.code}), trying ${port + 1}...`); + server.close(); + port++; + reject(); + } else { + reject(error); + } + }); + server.listen(port); + }); + return; + } catch { + if (port >= initialPort + range - 1) { + throw new Error(`Failed to start server on ports ${initialPort} to ${initialPort + range - 1}`); + } + } + } +} + +if (require.main === module) { + startServer(PORT, PORT_RANGE).catch((error) => { + console.error('[ink] Failed to start:', error); + process.exit(1); + }); +} + +export { app, server, io }; diff --git a/src/server-zork.ts b/src/server-zork.ts index 8d44454..571a51e 100644 --- a/src/server-zork.ts +++ b/src/server-zork.ts @@ -21,6 +21,12 @@ import { Server as SocketIOServer } from 'socket.io'; import * as dotenv from 'dotenv'; import { existsSync, mkdirSync, copyFileSync } from 'fs'; import { ZorkLlmEngine, ZorkTurnResult } from './engine/zork-llm-engine'; +import { + clientGameConfig, + ensureConfiguredAssetDirectories, + loadGameConfig, + projectPath, +} from './config/game-config'; dotenv.config(); @@ -30,8 +36,12 @@ const io = new SocketIOServer(server); const DEFAULT_PORT = 3002; const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : DEFAULT_PORT; -const PORT_RANGE = 10; +const PORT_RANGE = 300; const DEBUG_ENABLED = /^(1|true|yes|on)$/i.test(process.env.ZORK_DEBUG ?? ''); +const engineConfig = loadGameConfig( + process.env.ZORK_CONFIG_FILE || './config/engines/zork.json', + 'zork', +); function debugLog(message: string, details?: unknown): void { if (!DEBUG_ENABLED) return; @@ -58,23 +68,20 @@ app.use( }), ); +app.get('/api/game-config', (_req, res) => { + res.json(clientGameConfig(engineConfig)); +}); + // One engine instance per connected socket const sessions = new Map(); // Save-game slot maps: socketId → Map const saveSlots = new Map>(); -function toLegacyNarrative(turn: ZorkTurnResult): { - text: string; - gameState: { currentRoomId?: string; statusLine?: string }; -} { - const text = (turn.paragraphs ?? []) - .map((p) => String(p?.text ?? '').trim()) - .filter(Boolean) - .join('\n\n'); - +function toClientTurn(turn: ZorkTurnResult): ZorkTurnResult { return { - text, + ...turn, gameState: { + ...turn.gameState, currentRoomId: turn.gameState?.statusLine, statusLine: turn.gameState?.statusLine, }, @@ -89,7 +96,10 @@ function normalizeSaveSlot(slot: unknown): number { function getOrCreateEngine(socketId: string): ZorkLlmEngine { let engine = sessions.get(socketId); if (!engine) { - engine = new ZorkLlmEngine(); + engine = new ZorkLlmEngine({ + storyPath: projectPath(process.env.ZORK_STORY_FILE || engineConfig.paths.mainGameFile), + promptDir: projectPath(engineConfig.paths.promptDir || 'data/zork-prompts'), + }); sessions.set(socketId, engine); } return engine; @@ -119,7 +129,7 @@ async function handleGameApi( case 'newGame()': { const engine = getOrCreateEngine(socket.id); const turn = await engine.newGame(); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); return { success: true, result: true, @@ -136,7 +146,7 @@ async function handleGameApi( } const engine = getOrCreateEngine(socket.id); const turn = await engine.loadGame(slots.get(slot)!); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); socket.emit('gameLoaded', { slot }); return { success: true, result: true, running: true, slot }; } @@ -180,10 +190,8 @@ async function handleGameApi( } function checkRuntimeConfiguration(): void { - const storyPath = path.resolve( - process.env.ZORK_STORY_FILE ?? './data/z-code/zork1.bin', - ); - const promptDir = path.resolve('./data/zork-prompts'); + const storyPath = projectPath(process.env.ZORK_STORY_FILE ?? engineConfig.paths.mainGameFile); + const promptDir = projectPath(engineConfig.paths.promptDir || 'data/zork-prompts'); const promptFiles = [ 'character-generation.yml', 'text-rewriter.yml', @@ -223,6 +231,7 @@ function checkRuntimeConfiguration(): void { io.on('connection', (socket) => { console.log(`[zork] Client connected: ${socket.id}`); + socket.emit('gameConfig', clientGameConfig(engineConfig)); socket.on( 'gameApi', @@ -272,7 +281,7 @@ io.on('connection', (socket) => { paragraphs: turn.paragraphs.length, statusLine: turn.gameState?.statusLine, }); - socket.emit('narrativeResponse', toLegacyNarrative(turn)); + socket.emit('narrativeResponse', toClientTurn(turn)); } catch (error) { console.error('[zork] playerCommand error:', error); socket.emit('error', { @@ -309,6 +318,7 @@ function ensureDirectories(): void { for (const dir of dirs) { if (!existsSync(dir)) mkdirSync(dir, { recursive: true }); } + ensureConfiguredAssetDirectories(engineConfig); } function ensureKokoroJs(): void { @@ -326,15 +336,17 @@ async function startServer(initialPort: number, range: number): Promise { while (port < initialPort + range) { try { await new Promise((resolve, reject) => { - server.listen(port, () => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { console.log( `[zork] Zork Narrator server running on http://localhost:${port}`, ); resolve(); }); - server.on('error', (err: NodeJS.ErrnoException) => { - if (err.code === 'EADDRINUSE') { - console.log(`Port ${port} in use, trying ${port + 1}…`); + server.once('error', (err: NodeJS.ErrnoException) => { + if (err.code === 'EADDRINUSE' || err.code === 'EACCES') { + console.log(`Port ${port} unavailable (${err.code}), trying ${port + 1}...`); server.close(); port++; reject(); @@ -342,6 +354,7 @@ async function startServer(initialPort: number, range: number): Promise { reject(err); } }); + server.listen(port); }); return; } catch { diff --git a/src/server.ts b/src/server.ts index 42cfeb5..bcead76 100644 --- a/src/server.ts +++ b/src/server.ts @@ -7,9 +7,19 @@ import path from 'path'; import express from 'express'; import http from 'http'; import { Server as SocketIOServer } from 'socket.io'; -import * as dotenv from 'dotenv'; -import { GameRunner } from './cli/game-runner'; -import { existsSync, mkdirSync, copyFileSync } from 'fs'; +import * as dotenv from 'dotenv'; +import { GameRunner } from './cli/game-runner'; +import { existsSync, mkdirSync, copyFileSync } from 'fs'; +import { + textToParagraphs, + TurnResult, +} from './interfaces/turn-result'; +import { + clientGameConfig, + ensureConfiguredAssetDirectories, + loadGameConfig, + projectPath, +} from './config/game-config'; // Load environment variables dotenv.config(); @@ -21,8 +31,12 @@ const io = new SocketIOServer(server); // Get port from environment variables or use default const DEFAULT_PORT = 3001; -const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; -const PORT_RANGE = 10; // Try up to 10 ports starting from the default +const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; +const PORT_RANGE = 300; // Try enough ports to skip OS-excluded ranges. +const engineConfig = loadGameConfig( + process.env.YAML_CONFIG_FILE || './config/engines/yaml.json', + 'yaml', +); // Serve static files from the public directory. During local development the // browser must not keep stale ES modules, otherwise UI fixes appear to do @@ -36,9 +50,37 @@ app.use(express.static(path.join(__dirname, '../public'), { res.setHeader('Expires', '0'); } })); + +app.get('/api/game-config', (_req, res) => { + res.json(clientGameConfig(engineConfig)); +}); // Set up game sessions const gameSessions = new Map(); +const nextTurnIds = new Map(); + +function nextTurnId(socketId: string): number { + const current = nextTurnIds.get(socketId) || 1; + nextTurnIds.set(socketId, current + 1); + return current; +} + +function createTextTurn( + socketId: string, + text: string, + gameState: TurnResult['gameState'] = {}, + suggestions?: string[], +): TurnResult { + const paragraphs = textToParagraphs(text); + return { + turnId: nextTurnId(socketId), + paragraphs, + choices: [], + inputMode: 'text', + gameState, + suggestions, + }; +} function normalizeSaveSlot(slot: unknown): number { const value = Number(slot); @@ -46,17 +88,26 @@ function normalizeSaveSlot(slot: unknown): number { } async function startDemoGameForSocket(socket: any): Promise { + nextTurnIds.set(socket.id, 1); const gameRunner = new GameRunner(); - const worldFile = process.env.DEFAULT_WORLD_FILE || './data/worlds/example_world.yml'; + const worldFile = projectPath(process.env.DEFAULT_WORLD_FILE || engineConfig.paths.mainGameFile); await gameRunner.initialize(worldFile); gameSessions.set(socket.id, gameRunner); const gameState = gameRunner.getGameState(); - socket.emit('gameIntroduction', { - introduction: gameState.world.introduction, - initialRoomDescription: gameRunner.getCurrentRoomDescription(), - currentRoomId: gameState.currentRoomId + const paragraphs = [ + ...textToParagraphs(gameState.world.introduction), + ...textToParagraphs(gameRunner.getCurrentRoomDescription()), + ]; + socket.emit('narrativeResponse', { + turnId: nextTurnId(socket.id), + paragraphs, + choices: [], + inputMode: 'text', + gameState: { + currentRoomId: gameState.currentRoomId, + }, }); return gameRunner; @@ -115,8 +166,9 @@ async function handleGameApi(socket: any, method: string, args: unknown[] = []) } // Handle socket connections -io.on('connection', (socket) => { +io.on('connection', (socket) => { console.log(`New client connected: ${socket.id}`); + socket.emit('gameConfig', clientGameConfig(engineConfig)); socket.data.saveGames = new Map(); @@ -159,13 +211,9 @@ io.on('connection', (socket) => { // During typography and animation work, mirror the command back through // the real socket path so the UI pipeline can be tested end to end. - socket.emit('narrativeResponse', { - text: command, - gameState: { - currentRoomId: gameRunner.getGameState().currentRoomId - }, - suggestions: gameRunner.getSuggestions() - }); + socket.emit('narrativeResponse', createTextTurn(socket.id, command, { + currentRoomId: gameRunner.getGameState().currentRoomId + }, gameRunner.getSuggestions())); } catch (error) { console.error('Error processing command:', error); @@ -222,15 +270,16 @@ io.on('connection', (socket) => { console.log(`Client disconnected: ${socket.id}`); // Clean up game session - if (gameSessions.has(socket.id)) { - gameSessions.delete(socket.id); - } - }); -}); + if (gameSessions.has(socket.id)) { + gameSessions.delete(socket.id); + } + nextTurnIds.delete(socket.id); + }); +}); // Ensure required asset folders exist function ensureDirectories() { - const dirs = [ + const dirs = [ path.join(__dirname, '../public'), path.join(__dirname, '../public/js'), path.join(__dirname, '../public/css'), @@ -240,12 +289,13 @@ function ensureDirectories() { path.join(__dirname, '../public/fonts') ]; - for (const dir of dirs) { + for (const dir of dirs) { if (!existsSync(dir)) { mkdirSync(dir, { recursive: true }); } - } -} + } + ensureConfiguredAssetDirectories(engineConfig); +} // Copy kokoro-js library from node_modules if not already present function ensureKokoroJs() { @@ -276,27 +326,29 @@ export async function startServer(initialPort: number, range: number): Promise((resolve, reject) => { - server.listen(currentPort, () => { - console.log(`AI Interactive Fiction web server running on http://localhost:${currentPort}`); - resolve(); - }); - - server.on('error', (error: NodeJS.ErrnoException) => { + // Try to start the server on the current port + await new Promise((resolve, reject) => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { + console.log(`AI Interactive Fiction web server running on http://localhost:${currentPort}`); + resolve(); + }); + server.once('error', (error: NodeJS.ErrnoException) => { // If port is in use, try next port - if (error.code === 'EADDRINUSE') { - console.log(`Port ${currentPort} is in use, trying next port...`); + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${currentPort} is unavailable (${error.code}), trying next port...`); server.close(); currentPort++; reject(); } else { // For other errors, log and reject console.error('Server error:', error); - reject(error); - } - }); - }); + reject(error); + } + }); + server.listen(currentPort); + }); // If we reach here, server started successfully return; diff --git a/src/test-server.ts b/src/test-server.ts index d642677..b92b938 100644 --- a/src/test-server.ts +++ b/src/test-server.ts @@ -9,6 +9,7 @@ import http from 'http'; import { Server as SocketIOServer } from 'socket.io'; import * as dotenv from 'dotenv'; import { existsSync, mkdirSync, copyFileSync } from 'fs'; +import { textToParagraphs } from './interfaces/turn-result'; // Load environment variables dotenv.config(); @@ -21,7 +22,7 @@ const io = new SocketIOServer(server); // Get port from environment variables or use default const DEFAULT_PORT = 3001; const PORT = process.env.PORT ? parseInt(process.env.PORT) : DEFAULT_PORT; -const PORT_RANGE = 10; // Try up to 10 ports starting from the default +const PORT_RANGE = 300; // Try enough ports to skip OS-excluded ranges. // Serve static files from the public directory. Keep browser modules uncached // during local development so fixes are visible without a hard cache clear. @@ -47,15 +48,24 @@ io.on('connection', (socket) => { console.log(`New client connected: ${socket.id}`); let currentParagraphIndex = 0; let gameRunning = false; + let nextTurnId = 1; const saveGames = new Set(); const startDemoGame = () => { gameRunning = true; + nextTurnId = 1; currentParagraphIndex = 0; - socket.emit('gameIntroduction', { - introduction: "::chapter[Interactive Fiction Test]\n\nWelcome to the Interactive Fiction Test. This is a simplified version that sends predefined paragraphs instead of using an LLM.", - initialRoomDescription: TEST_PARAGRAPHS[0], - currentRoomId: "test-room" + socket.emit('narrativeResponse', { + turnId: nextTurnId++, + paragraphs: [ + ...textToParagraphs("#chapter[Interactive Fiction Test]\n\nWelcome to the Interactive Fiction Test. This is a simplified version that sends predefined paragraphs instead of using an LLM."), + ...textToParagraphs(TEST_PARAGRAPHS[0]), + ], + choices: [], + inputMode: 'text', + gameState: { + currentRoomId: 'test-room', + }, }); }; @@ -145,7 +155,10 @@ io.on('connection', (socket) => { // Send narrative response to client socket.emit('narrativeResponse', { - text: data.command, + turnId: nextTurnId++, + paragraphs: textToParagraphs(String(data.command || '')), + choices: [], + inputMode: 'text', gameState: { currentRoomId: "test-room" }, @@ -214,16 +227,17 @@ async function startServer(initialPort: number, range: number): Promise { // Try to start the server on the current port await new Promise((resolve, reject) => { - server.listen(currentPort, () => { + server.removeAllListeners('error'); + server.removeAllListeners('listening'); + server.once('listening', () => { console.log(`AI Interactive Fiction TEST SERVER running on http://localhost:${currentPort}`); console.log('This server is sending predefined test paragraphs instead of using an LLM'); resolve(); }); - - server.on('error', (error: NodeJS.ErrnoException) => { + server.once('error', (error: NodeJS.ErrnoException) => { // If port is in use, try next port - if (error.code === 'EADDRINUSE') { - console.log(`Port ${currentPort} is in use, trying next port...`); + if (error.code === 'EADDRINUSE' || error.code === 'EACCES') { + console.log(`Port ${currentPort} is unavailable (${error.code}), trying next port...`); server.close(); currentPort++; reject(); @@ -233,6 +247,7 @@ async function startServer(initialPort: number, range: number): Promise { reject(error); } }); + server.listen(currentPort); }); // If we reach here, server started successfully diff --git a/src/utils/tag-parser.ts b/src/utils/tag-parser.ts new file mode 100644 index 0000000..70c5149 --- /dev/null +++ b/src/utils/tag-parser.ts @@ -0,0 +1,45 @@ +import type { StoryTag } from '../interfaces/turn-result'; + +const LEGACY_TAG_ALIASES: Record = { + audio: 'sfx', + audioloop: 'music', + separator: 'section', +}; + +function normalizeKey(key: string): string { + const normalized = key.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, '-'); + return LEGACY_TAG_ALIASES[normalized] || normalized; +} + +export function parseTag(raw: string): StoryTag | null { + const text = String(raw || '').trim().replace(/^#\s*/, ''); + if (!text) return null; + + const bracketMatch = text.match(/^([A-Za-z][\w-]*)(?:\[([^\]]*)\])?(?:\(([^)]*)\))?$/); + if (bracketMatch) { + const tag: StoryTag = { key: normalizeKey(bracketMatch[1]) }; + if (typeof bracketMatch[2] !== 'undefined') tag.value = bracketMatch[2].trim(); + if (typeof bracketMatch[3] !== 'undefined') tag.param = bracketMatch[3].trim(); + return tag; + } + + const bareMatch = text.match(/^[A-Za-z][\w-]*$/); + if (bareMatch) { + return { key: normalizeKey(text) }; + } + + return null; +} + +export function parseTags(rawTags: unknown[] | undefined): StoryTag[] { + if (!Array.isArray(rawTags)) return []; + + return rawTags + .map((raw) => parseTag(String(raw ?? ''))) + .filter((tag): tag is StoryTag => Boolean(tag)); +} + +export function getTagValue(tags: StoryTag[], key: string): string | undefined { + const normalizedKey = normalizeKey(key); + return tags.find((tag) => tag.key === normalizedKey)?.value; +}