# Story game

Implemented beside Millionaire in the shared modern game modal. Czech label: **Příběh**. First published in addon **2.1.64**; final settings-caption correction is in **2.1.65** (skin **1.3.52**). Specification, decisions and exact verification evidence: [Story plan](../plan/story-game/000-index.md), [handoff](../plan/story-game/110-progress-and-handoff.md).

## Player behavior

The existing film/series/episode launch opens one title card with Millionaire / Story selection. The last explicit eligible choice is remembered. Persons and mixed topics remain Millionaire-only; fallback does not erase the Story preference.

Story follows the selected work's actual plot in presentation order. Each concise narrator scene asks what happens next, with four A–D choices. Wrong answers reveal the canonical event and cost one of three lives; the plot still continues identically. The third error ends the attempt, including on the final question. With a life remaining, answering the final question completes the story and reveals its ending.

Difficulty is independent of Millionaire: Easy 10, Medium 15, Hard 20 questions. Each covers the entire selected story in five equal groups of 2/3/4 scenes. Chapters show progress and grant no lives/saves. Results are immediate and Continue is manual; there are no lifelines, countdowns or autoplay.

Every existing Millionaire demo now has a Story counterpart: 29 titles and 87 fixed authored packs, including all eight Harry Potter movies. Movies and three closed series cover the complete work; eight episodic series use clearly marked S01E01. Existing Matrix, first Harry Potter and all other original JSON remain unchanged. Scope/verification: [initial demo catalog](../plan/story-game/140-demo-catalog.md), [Harry Potter expansion](../plan/story-game/150-harry-potter-demos.md). Unknown or incomplete offline fixtures never generate paid Story content. These expansions remain local and unpublished.

## Implementation map

| Owner | Responsibility |
|---|---|
| `wcs/games/millionaire/{__init__,subject}.py` | Existing canonical launches and selected-work metadata |
| `wcs/games/DialogMilionarGame.py` | Shared modern shell, selection/settings/focus and adapter disposal |
| `wcs/games/story/content.py` | One schema/limits, strict full-pack validator and demo loader |
| `resources/demo/story/<id>/*.json`, `scopes.json` | Fixed 10/15/20 packs for all 29 IDs; one Story-only episode scope overlay |
| `wcs/games/story/engine.py` | Pure answer/life/progress/terminal rules |
| `wcs/games/story/{adapter,view}.py` | Attempt worker/voice/intents and pure Story properties |
| `wcs/games/story/{prompts,ai}.py` | Czech narrator prompt, one fresh inference and local letter shuffle |
| Existing modern generator + `scripts/game_dialog/story_screens.py` | Shared textures/geometry/primitives, one generated XML |
| Existing provider clients and `wcs/ai/response_json.py` | Shared transport/JSON/accounting; optional call budget/privacy |
| Existing `TtsVoice` / `SilentVoice` | Shared voice settings/providers and owned cancellation |

Story owns `WCS.Story.*`; the shell owns common `WCS.Game.*`. Correct-answer/reveal fields are empty before evaluation; ending is present only after a win. Mode switch, native closure and replay retire workers/voice and release the pack.

## Content and AI

Each explicit Start/replay/retry prepares a complete validated pack once using the selected provider/model, JSON mode and tools off. The output ceiling is 16000 tokens; OpenAI/Anthropic high/xhigh/max receive 32000 and a 300 s request timeout for Story only. Existing client/global defaults are unchanged. Invalid/unavailable/failed generation shows Retry/Back and costs no life. Answering and continuing are entirely local. There is no automatic repair inference, pack history, cache, saved attempt or previous content in the next request.

Limits are centralized in `content.py`: setup 220, question 140, option 30, reveal 240, ending/reason 220 characters. Exact title/year/episode identity and all requested scenes/chapter groups are validated. Knowledge-only generation cannot independently guarantee factual accuracy; optional online grounding is deferred.

Preferences and ordinary call metadata are retained; generated packs/prompts/responses are excluded from default diagnostics. Demo transcripts/screenshots contain authored content only. Standa accepted the demo and authorized real Luna/Sonnet tests on 2026-10-13. Explicit `story-review --capture-content` diagnostic files never feed later gameplay; real voice remains untested.

## Verification and commands

```bash
python3 tests/test_story_game.py
python3 tests/test_story_demo_catalog.py
python3 tests/test_story_transport.py
python3 tests/test_story_review.py
python3 scripts/game_harness/game.py open --demo matrix --mode story
python3 scripts/game_harness/game.py run --demo matrix --mode story --difficulty medium --mistakes 2,8
```

The existing harness also supports authorized Kodi runs with `--live --input click --shots`. Actual pack counts/lives are asserted, and the original live difficulty is restored. Millionaire golden/property fixtures remain unchanged; new selector fields have separate coverage. Run test scripts separately because existing fake-module setups can interfere under combined discovery.

Actual 10/15/20-question Kodi flows and terminal cases passed, with targeted Millionaire regression, and Standa confirmed his test. Published package assets were checked at deployment. Current local prompt/budget/harness optimization is newer than published 2.1.65. Real comparison results, factual failures and practical costs/latency are in [AI experiments](../plan/story-game/130-ai-experiments.md); a structural PASS is not a factual certification.

The completed comparison recommends **Sol 6.1 / medium** for the Story trial. Three further fresh Matrix packs (10/15/20) passed structural/manual checks with documented narrative compression; the initial Sol sample and repeated Luna/Sonnet defects remain recorded. Existing global model/effort settings were not changed. No knowledge-only sample establishes guaranteed accuracy for every selected work.
