Complete cottage notebook with narration and discovery-only artwork

This commit is contained in:
Hadrian Burkhardt
2026-11-01 00:18:34 +01:00
parent 36fbbce6ef
commit 6bd14a9e20
90 changed files with 2394 additions and 221 deletions
+33 -21
View File
@@ -31,7 +31,7 @@ lib/
├── main.dart LumenApp, Notebook, all screen builders, dialogs, routing
├── domain/
│ ├── puzzle.dart Puzzle, JavaRandom, LogicSolver, Difficulty, Region, Hint
│ ├── book.dart Book, CampaignLevel, StoryPage — loads authored content
│ ├── book.dart Book, CampaignLevel, StoryPage/StoryPageType — loads authored content
│ └── game.dart Game (ChangeNotifier), Screen/Mode, puzzle session, awards
├── services/
│ ├── progress.dart Progress — typed façade over SharedPreferencesAsync
@@ -43,16 +43,17 @@ lib/
assets/
├── campaign.json premise + 12 authored levels (chapter/title/object/before/after/picture/clues/areas; optional illustrationAsset)
├── notebook.json sixteen stable cottage leaf records (type, speaker, campaignIndex, text source)
├── narration/scripts.json canonical diary text, one record per recorded page
├── narration/manifest.json source masters and checksums for narration
├── audio/narration_manifest.json runtime tracks: file, duration, cue timings
├── audio/*.wav five bundled PCM16 readings (APK runtime assets)
├── audio/*.wav 28 bundled PCM16 recordings (APK runtime assets)
├── audio/*.flac archival lossless exports (not declared in pubspec)
├── artwork/*.png watercolours, vignettes and the notebook page
└── fonts/DancingScript.ttf bundled as family MaraHand; OFL.txt ships with licences
test/puzzle_test.dart 8 domain tests (Java parity, generation, solver, awards, restore)
test/widget_test.dart 6 widget tests (page gestures, scrolling, landscape layout)
test/puzzle_test.dart 11 domain tests (Java parity, generation, solver, awards, restore)
test/widget_test.dart 9 widget tests (page gestures, scrolling, landscape layout)
test/fixtures/java_boards.json 40 reference boards from the Java 1.7 version
integration_test/notebook_test.dart one on-device end-to-end test (QA flavour only)
scripts/ narration verification, install smoke check, narration rendering
@@ -86,6 +87,7 @@ flowchart TD
game --> progress
book --> puzzle
book --> campaign[("assets/campaign.json")]
book --> notebook[("assets/notebook.json")]
book --> scripts[("assets/narration/scripts.json")]
narrator --> manifest[("assets/audio/narration_manifest.json")]
narrator --> wav[("assets/audio/*.wav")]
@@ -129,11 +131,11 @@ stateDiagram-v2
[*] --> home
home --> story: openNotebook / showStory
home --> game: startDaily or startPractice
story --> story: turn within 0..5
story --> story: turn within sixteen cottage leaves
story --> contents: Contents
story --> home: Close book
story --> briefing: leaf 6 lantern link
contents --> story: opening leaf or bookmark
contents --> story: cottage entry, memory or bookmark
contents --> briefing: accessible campaign entry
contents --> reveal: recovered campaign entry
contents --> home: Close the notebook
@@ -153,8 +155,8 @@ stateDiagram-v2
| Screen | Builder in `_NotebookState` | Leaf key | Content | `onTurn` |
| --- | --- | --- | --- | --- |
| `home` | `home()` | none (own `Scaffold` body) | Harbour art, notebook cover, daily ritual, difficulty, rules, privacy, licences | none |
| `story` | `story()` | `story-<index>` | Six opening leaves: dedication, cottage, match puzzle, memory, folded note, lantern | `turn()` |
| `contents` | `contents()` | `contents` | Dedication, opening-leaf links, ribbon bookmark, twelve campaign entries with access state, premise | none |
| `story` | `story()` | `story-<index>` | Sixteen cottage leaves: dedication, four entry/puzzle/memory beats, note, inspection, closing | `turn()` |
| `contents` | `contents()` | `contents-<chapter>` | Four chapter entries, ribbon bookmark, reading resume and optional cottage scraps; chapter navigation | none |
| `briefing` | `briefing()` | `briefing-<i>` | Chapter, title, `before` passage, "Restore the pattern →" | `turnCampaign()` |
| `game` | `game()` | `game-<key>` | Puzzle heading, area totals, square board, hint/undo, actions | `turnCampaign()` in campaign mode only |
| `reveal` | `reveal()` | `reveal-<i>` | Object name, watercolour (or `PixelPicture` fallback), `after` passage, ending text on level 12 | `turnCampaign()` |
@@ -165,16 +167,17 @@ stateDiagram-v2
| --- | --- |
| `home()` | `Screen.home`; cancels pending board generation |
| `openNotebook()` | `showStory(index of notebook_last_page, else 0)` |
| `showStory(i)` | Clamp `i` to 0–5, `mode = campaign`, `campaignIndex = 0`; on `i == 2` load `book.levels[0]` under key `story_v1_0` unless already loaded; persist last page and `viewed_<pageId>`; `Screen.story` |
| `contents()` | `Screen.contents` |
| `briefing(i)` | Clamp to `accessible`, `Screen.briefing` |
| `reveal(i, {readAhead})` | Redirect to `briefing(i)` unless recovered, or read-ahead is allowed for an accessible level; otherwise `Screen.reveal` |
| `startCampaign(i)` | No-op if `i > accessible`; recovered levels go to `reveal`; else load `book.levels[i]` under `story_v1_<i>` and open `Screen.game` |
| `showStory(i)` | Clamp `i` to available pages; set campaign mode and the record’s campaign index; on a puzzle leaf load its `story_v1_<index>` unless already loaded; persist last page and `viewed_<pageId>`; `Screen.story` |
| `contents([chapter])` | One chapter’s four entries; persist `notebook_contents_chapter`; default to current campaign chapter |
| `leaveCottage()` | Open Chapter II for reading without awarding unfinished cottage puzzles |
| `briefing(i)` | Clamp to `accessible`; cottage entry leaf or later `Screen.briefing` |
| `reveal(i, {readAhead})` | Redirect to `briefing(i)` unless recovered, or read-ahead is allowed for an accessible level; otherwise the cottage memory leaf or later `Screen.reveal` |
| `startCampaign(i)` | No-op if `i > accessible`; recovered levels go to `reveal`; else load `book.levels[i]` under `story_v1_<i>` and open the cottage puzzle leaf or later `Screen.game` |
| `startDaily(day)` | Load `Puzzle.seeded(epochDay(date) * 7919)` under `d<YYYY-MM-DD>`; `Screen.game` |
| `startPractice([level])` | Generate 5×5 board off the UI isolate with `compute(generatePractice)`; key `v2_<DIFFICULTY>_<level>`; `Screen.game` |
| `mark(i)` / `undo()` / `area(i)` | Cycle a cell 0→1→2→0, restore the previous snapshot, select an A/B/C area |
| `applyHint()` | Return one explained `Hint` and apply it (prefers detecting a conflicting earlier mark) |
| `check()` | Award completion exactly once; campaign solve advances to story leaf 3 or the reveal; classic levels advance; daily updates the streak |
| `check()` | Award completion exactly once; cottage solves advance to the matching memory record; later solves advance to the reveal; classic levels advance; daily updates the streak |
| `restore()` | Re-open the saved screen (`flutter_screen`), including read-ahead reveals and unfinished campaign/classic boards |
### `main.dart` internal map
@@ -265,10 +268,11 @@ All writes go through `Progress.set` (memory is updated synchronously, disk is w
| Key | Type | Written by | Purpose |
| --- | --- | --- | --- |
| `notebook_last_page` | page id | `Game.showStory` | Resume the last opening leaf |
| `notebook_last_page` | page id | `Game.showStory` | Resume the last cottage leaf |
| `notebook_contents_chapter` | int 0–2 | `Game.contents` | Restored chapter contents leaf |
| `notebook_manual_bookmark` | page id | `bookmark()` | "Return to my ribbon bookmark" in Contents |
| `notebook_note_open` | bool | folded-note leaf | Note unfolded/folded state |
| `notebook_handle_seen` | bool | `inspect()` | Lantern handle discovered |
| `notebook_handle_seen` | bool | `inspect()` | Repair margin note read; never reveals pre-puzzle artwork |
| `notebook_read_ahead` | bool | `turn()` | Written when leaving the unsolved story puzzle; currently no reader |
| `viewed_<pageId>` | bool | `Game.showStory` | Written per visited leaf; currently no reader |
@@ -286,7 +290,7 @@ All writes go through `Progress.set` (memory is updated synchronously, disk is w
| `lastDaily` | int (epoch day) | daily completion | Streak bookkeeping |
| `streak` | int | daily completion | Consecutive daily completions |
| `campaignUnlocked` | int 0–11 | campaign completion | Furthest solved campaign level |
| `story_access_level` | int 0–11 | `nextCampaign`, leaf 6 link | Furthest readable campaign level (independent of awards) |
| `story_access_level` | int 0–11 | `nextCampaign`, `leaveCottage` | Furthest readable campaign level; effective access is at least 3 for cottage exploration, independent of awards |
| `storyAd_<index>` | bool | `nextCampaign` | At most one interstitial per fourth campaign step |
| `recording_speed` | double | speed dialog | `0.85`, `1.0` or `1.15` |
@@ -299,14 +303,21 @@ Board key formats (`<key>`):
## Content and assets
- `assets/campaign.json`: `{ premise, levels: [{ chapter, title, object, before, after, picture, clues, areas, illustrationAsset? }] }`. `picture` is 49 characters of `0`/`1` (7×7, row-major). `clues` is a comma-separated list of forced-given indices. `areas` is `top,left,height,width` rectangles separated by `;` (labels A, B, C… in order).
- `assets/narration/scripts.json`: canonical diary text, one record per recorded page (`pageId`, `text`). `Book.load()` matches the six fixed page ids and titles; a missing script yields empty text.
- `assets/notebook.json`: sixteen ordered records with stable `id`, `type`, `title`, optional `campaignIndex`, `speaker`, `illustrationAsset` and `textSource` (`recording`, `before`, `after`) or inline `text`. `Book.pageFor()` finds a campaign entry/puzzle/memory. Preserve the first six IDs when extending the chapter.
- Cottage `briefing`, `startCampaign` and `reveal` route to the entry, puzzle or memory leaf for levels 0–3. This migrates older saved routes while retaining marks, hint keys and completion awards. Chapters II/III use the existing screens.
- `assets/narration/scripts.json`: canonical diary text, one record per recorded page (`pageId`, `text`). `Book.load()` resolves `recording` text by stable page ID; a missing script yields empty text.
- `assets/narration/manifest.json`: source masters, text hashes, WAV/FLAC hashes and cues — the provenance record.
- `assets/audio/narration_manifest.json`: runtime `{ tracks: { pageId: { file, durationMs, cues: [{ startMs, endMs, text }] } } }`. `Narrator` plays `assets/audio/<file>`.
- Five recordings exist: `cottage.dedication`, `cottage.window`, `cottage.match.memory`, `cottage.folded.note`, `cottage.lantern.sketch`. The match-puzzle leaf has no recording.
- Five Mara recordings exist: `cottage.dedication`, `cottage.window`, `cottage.match.memory`, `cottage.folded.note`, `cottage.lantern.sketch`. The match-puzzle leaf has no recording.
- Twenty-three narrator tracks use `bm_george`: seven cottage prose leaves and `campaign.<4..11>.before/after`. `scripts.json` records speaker/voice/speed; the renderer accepts `--speaker Narrator` to preserve Mara’s original takes. The asset checker validates narrator scripts against notebook/campaign text.
- `audio()` uses the story ID or `campaign.<index>.before/after`, with a visible speaker label. Never show a recording control for an ID without a bundled track.
- `discoveryArt()` returns only a text placeholder until `Game.recovered(index)` is true. This gates both watercolours and pixel fallbacks; entry, inspection and closing leaves never call it, regardless of completed progress. The helper also rejects calls outside a memory/reveal screen. The repair note uses a text action rather than a picture hotspot; completed saves must not re-enable artwork on earlier leaves. Contextual cottage/background art is separate from the discovery images.
- The `check` Android flavor (`com.lumen.daily.check`) isolates device automation from the user’s installed QA app and progress.
- WAV is the runtime format because FLAC advanced its clock without an audio track on the API 26 Huawei tablet used for testing. FLAC files remain as archives but are not listed in `pubspec.yaml`, so they are not bundled.
- Artwork: `mara-single-page-v2.png` (page), `home-harbour-v2.png`, `home-notebook-cover-v2.png`, `cottage-vignette-v1.png`, `lantern-vignette-v1.png`, `harbour-bell-vignette-v1.png`, plus `match`, `brass-key`, `compass`, `little-boat`, `anchor`, `stone-bridge`, `missing-gear`, `beacon-lens`, `lighthouse` and `home` (each `<name>-vignette-v1.png`); prompts and provenance live beside each file.
- Campaign reveals use optional `CampaignLevel.illustrationAsset` paths from campaign JSON. All twelve discoveries have watercolours; absent or unloadable image assets fall back to `PixelPicture`. The opening match memory shares the first campaign illustration through `discoveryArt()`. No puzzle identity or progress keys change.
- Font: `assets/fonts/DancingScript.ttf` registered as `MaraHand`; `assets/fonts/OFL.txt` is registered with `LicenseRegistry` in `main()`.
- `android/app/src/qa/AndroidManifest.xml` opts the isolated QA package into external installation (`preferExternal`); the production manifest keeps its existing installation policy. Android/OEM support still determines whether an SD-card install is accepted. The review Huawei reports `sm has-adoptable=false` and rejects new ASEC installs; use a compact release build installed internally there.
- `pubspec.yaml` lists every bundled asset explicitly (no directory globs), so new assets must be added there.
### Audio flow
@@ -332,6 +343,7 @@ Board key formats (`<key>`):
| `test/puzzle_test.dart` | 40 Java reference boards (signed 64-bit seeds), 300 graded boards, solver counts vs. exhaustive search, campaign uniqueness/no-guess, streaks, fresh progress, read-ahead, daily awards and practice levels |
| `test/widget_test.dart` | Page swipes vs. grid drags, swipes over text/blank paper, vertical scrolling and cancelled drags, small/landscape/1.5× text, landscape two-column puzzle leaf, illustrated campaign reveals and pixel fallback at 1.5× text |
| `integration_test/notebook_test.dart` | On-device QA flow: six leaves, real WAV playback and pause/resume, bookmarks/discoveries, match and lantern solves, exactly-once awards, QA disk round-trip, screenshots |
| `integration_test/cottage_test.dart` | All sixteen leaves, larger-text portrait/landscape, bookmarks, legacy-key marks, all four awards, all 23 narrator tracks and isolated test persistence; eight screenshots |
| `integration_test/discovery_art_test.dart` | QA tablet screenshots of all twelve discoveries and the opening match memory, portrait/landscape at 1.5× text; checks reachable controls and unchanged awards |
| `scripts/check_narration_assets.py` | Script text ↔ manifest ↔ WAV masters checksums |
| `scripts/check_flutter_install.py` | Read-only installed-app smoke check and screenshots |
@@ -386,7 +398,7 @@ Each run checks four discoveries in both orientations at 1.5× text, including n
| Goal | Touch | Also |
| --- | --- | --- |
| Edit campaign content or pictures | `assets/campaign.json` | Re-run `flutter test` (uniqueness/no-guess campaign tests) and `scripts/check_narration_assets.py` only if text changes |
| Add or reorder opening leaves | `_NotebookState.story()` switch, `Book` page ids/titles, `assets/narration/scripts.json` | Add a WAV + manifests + `pubspec.yaml` if narrated; update integration test |
| Add or reorder cottage leaves | `assets/notebook.json`, `StoryPageType` builders, `Book.pageFor()`, narration scripts if recorded | Add a WAV + manifests + `pubspec.yaml` if narrated; update integration test |
| Add a screen | `Screen` enum, `Game._route`/navigation method, `_NotebookState.build` switch, new builder | Back-button behaviour in `back()` and `PopScope` |
| Change puzzle rules, hints or grading | `lib/domain/puzzle.dart` (`Constraint`, `LogicSolver`, `Puzzle`) | `test/puzzle_test.dart`, `Game.applyHint`, board semantics |
| Change marks, undo, hints or awards | `lib/domain/game.dart` (`mark`, `undo`, `applyHint`, `check`) | `_NotebookState.hint()`, `puzzleNotes()`, widget tests |
@@ -403,7 +415,7 @@ Each run checks four discoveries in both orientations at 1.5× text, including n
- **`pumpAndSettle` can struggle with the full app.** Prefer a bounded `pump()` loop when mounting `LumenApp`; the audio streams keep notifying and may prevent settling.
- **`Game.restore()` must be awaited before `runApp`.** Otherwise the app opens on `home` and ignores the saved screen.
- **Story page 3 is index 2.** Solving the opening match puzzle awards the first campaign entry (`story_v1_0`) and jumps to story page 4 (`showStory(3)`), skipping the campaign reveal.
- **`showStory()` resets `mode` to campaign and `campaignIndex` to 0.** Daily and classic starts set their own mode afterwards; keep that order.
- **`showStory()` sets campaign mode and the page record’s campaign index (0 if absent).** Daily and classic starts set their own mode afterwards; keep that order.
- **`startPractice` discards stale results** with `_request`. Do not remove that guard when refactoring.
- **Hints are applied immediately.** `Game.applyHint()` writes a mark and pushes an undo snapshot; the free/ad gate lives in `_NotebookState.hint()` via `hint_<key>`, not in the domain.
- **Read-ahead never bypasses access.** `reveal(i, readAhead: true)` still redirects when `i > accessible`.