Files
logic-puzzle/README.md
T
2026-10-31 04:08:16 +01:00

93 lines
7.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Lumen — The Last Light (Flutter 2.0)
An illustrated island notebook about grandmother Mara, her grandchild, and restoring a lighthouse. The active app is now written in **Dart and Flutter**, with a thin Android Kotlin entry point. All puzzle generation, deductions, story navigation, progress, audio controls and advertising behavior live in `lib/`.
Android is the tested target. iOS project scaffolding and test AdMob configuration are included, but iOS has not been built or tested on this Linux workstation. It still needs Apple signing, device testing, store icons and platform release configuration.
## Play
- Six opening notebook leaves: a dedication, illustrated cottage entry, match puzzle, memory, folded note and inspectable lantern.
- Margin swipes and corner arrows turn leaves. Grid gestures never turn pages. Navigation stays fixed; overflow scrolling supports smaller screens and larger text.
- A saved ribbon bookmark, opened note, inspected repair, viewed pages and current reading place.
- Twelve 7×7 picture puzzles across three chapters, with overlapping-area deductions on entries 3–12. Later chapters retain their earlier briefing/puzzle/reveal structure until the roadmap expands them.
- Deterministic daily grids and generated Easy, Medium and Hard 5×5 practice. The grades measure deduction-chain depth, not expert-level difficulty. Every board has a unique solution and needs no guessing.
- Undo, one free explained hint per puzzle, then optional rewarded hints. Later hints require the AdMob reward callback. An unavailable ad never blocks the board.
- Local daily streaks, independent difficulty levels and exactly-once puzzle completion awards.
- AdMob/UMP consent, optional rewarded hints, practice interstitials after every fourth completion and one-time campaign chapter transitions. No ads interrupt opening notebook leaves or recorded readings.
Progress starts fresh in Flutter, as requested. Old Java `lumen.xml` saves are **not imported or read**. Flutter keeps its own local preferences through `shared_preferences`; no account or game backend is required. Uninstalling loses local progress, and the daily date follows the device calendar.
## Artwork and readings
All app-created text uses the bundled Dancing Script handwriting font, including grid clues and menus. Original watercolour harbour, cloth cover, cottage, lantern and single-page art remain bundled for offline use. Native text sits directly on the page’s blank writing area. Art prompts and provenance are in [assets/artwork](assets/artwork/README.md); the font’s OFL license ships in the app’s open-source licenses.
Five fixed, pre-rendered synthetic British-English readings ship as lossless FLAC assets, with PCM16 WAV masters for review. `just_audio` plays bundled files; there is no Android reader, runtime synthesis or audio download. Controls support play, pause, resume at the same position, stop, replay, speed and passage highlighting. Leaving a page or backgrounding the app stops playback. See [narration provenance](assets/narration/README.md).
## Build and run
Tested with Flutter 3.47.5 / Dart 3.13.4, JDK 21 and Android SDK 36. Flutter uses the standard `android/` platform project; the former root Gradle project is archived in `legacy/android/` and is not compiled into the Flutter app.
```sh
flutter pub get
flutter analyze
flutter test
flutter run --flavor prod -d YOUR_ANDROID_DEVICE
```
Use `JAVA_HOME=/path/to/jdk-21` if your default JDK is incompatible with Gradle. Use `flutter doctor -v` to inspect your setup.
```sh
# Separate QA package: com.lumen.daily.qa
flutter build apk --debug --flavor qa
# Optimized development APK for the connected arm64 tablet
flutter build apk --release --flavor prod --target-platform android-arm64
```
The normal application ID remains `com.lumen.daily`; version 2.0.0 uses build number 9. The review APK is `artifacts/lumen-flutter-2.0-arm64.apk`. Build outputs, screenshots, local SDK paths, IDE state and private signing keys are ignored by Git. `pubspec.lock` is tracked for reproducible package resolution.
The development release build currently uses the Android debug signing key so it can update the installed prototype. **Configure your private upload key before publishing.** No production signing material is included.
## Verification
```sh
flutter analyze
flutter test
python3 scripts/check_narration_assets.py
# Launch/playback/restart smoke test after installing the normal APK
python3 scripts/check_flutter_install.py --serial YOUR_ANDROID_DEVICE
# Real tablet integration, isolated from the normal app
flutter drive --driver test_driver/integration_test.dart \
--target integration_test/notebook_test.dart --flavor qa \
--dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE
```
The nine unit/widget tests cover 40 Java reference boards (including signed 64-bit seeds), 300 graded generated boards, solver counts against 300 exhaustive small systems, all twelve campaign solutions, streaks, fresh progress, read-ahead, completion awards, gesture isolation, landscape and larger text. Reference parity protects the port’s rules; it is not used to migrate saves.
The physical-device integration test uses a disposable in-memory game plus an isolated QA disk round-trip. It plays all five real FLAC files, checks pause/resume, explores the six leaves, verifies bookmarks/discoveries, solves match and lantern puzzles and checks exactly-once awards. Screenshots are saved in `artifacts/flutter-check/`. The release smoke script exercises the actual play/pause/resume UI and restores the last page after process restart, without injecting puzzle fixtures. The release build includes a targeted R8 keep rule for the database constructor used reflectively by AdMob’s WorkManager dependency. Advertising is disabled for the automated story tests; real UMP startup is checked separately in the normal build. Reward delivery, cancellation and ad no-fill still need manual release testing with your final AdMob configuration.
## Source map
| Location | Responsibility |
| --- | --- |
| `lib/main.dart` | Handwritten home, notebook, campaign, dialogs and lifecycle |
| `lib/domain/puzzle.dart` | Seeded generation, uniqueness, constraint deductions, hints and difficulty |
| `lib/domain/book.dart` | Stable story records and campaign asset loading |
| `lib/domain/game.dart` | Routing, marks, undo, progress, streaks and completion |
| `lib/ui/` | Page layout, margin gestures, native grid semantics and illustrated keepsakes |
| `lib/services/` | Local storage, bundled playback and consent-gated AdMob |
| `assets/campaign.json` | Authored twelve-picture campaign |
| `assets/narration/scripts.json` | Canonical spoken diary text |
| `assets/audio/` | Runtime FLAC files and passage timing manifest |
| `legacy/` | Archived Java version 1.7, excluded from Flutter builds |
## Before publishing
Create your production Android AdMob app and ad units, configure Privacy & messaging, supply a public privacy policy and support contact, complete Play disclosures and ratings, and configure an upload key outside Git. The SDK still uses Google test IDs by default.
For Android, supply the app ID using Gradle property `ADMOB_APP_ID`. Rewarded/interstitial unit IDs use Dart compile-time defines `ADMOB_REWARDED_ID` and `ADMOB_INTERSTITIAL_ID`. iOS needs its own app ID in `ios/Runner/Info.plist` and iOS-specific ad unit IDs. Verify consent refusal/revocation, reward completion/cancellation, offline/no-fill behavior, lifecycle interruptions, accessibility and release signing on physical devices before submitting an AAB.
See [ROADMAP.md](ROADMAP.md) for the proposed 30–40-leaf campaign, page variety and further exploration ideas.