Open Lumen on a responsive bookshelf and land pending story work
- Start the app on a shelf of every installed book instead of the last book's home. Cards show the cover, translated metadata, available languages, restored patterns and either "Continue reading" or a way in. - Keep each book's saved route: the shelf is never written to flutter_screen, so choosing a book resumes its own leaf. - Lay the shelf out responsively: dense single-column cards on phones, a two-column grid from 720 logical pixels, a centred 860 px column on tablets and a chevron that exists in the bundled handwriting font. - Keep Settings reachable from the shelf and let the home page's story library button open the shelf instead of a dialog. - Add tool/shelf_screenshots_test.dart, which renders the shelf at phone and tablet metrics, checks that every card and Settings stay reachable without overflow, and writes artifacts/library/shelf-*.png. - Commit the pending Midnight Invitation package (campaign, notebook, narration and artwork), cast drama and ambience tooling, region selection, phone/tablet integration coverage and related docs. flutter analyze is clean and all 74 widget/domain tests pass.
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lumen/domain/book.dart';
|
||||
import 'package:lumen/domain/game.dart';
|
||||
import 'package:lumen/domain/library.dart';
|
||||
import 'package:lumen/domain/puzzle.dart';
|
||||
import 'package:lumen/domain/thinking.dart';
|
||||
import 'package:lumen/services/progress.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
late StoryLibrary library;
|
||||
late Book book;
|
||||
setUpAll(() async {
|
||||
library = await StoryLibrary.load();
|
||||
book = await library.open('midnight-invitation');
|
||||
});
|
||||
|
||||
test('Halloween is a complete three-chapter English story with an opening and ending', () {
|
||||
expect(book.language, 'en');
|
||||
expect(book.title, 'The Midnight Invitation');
|
||||
expect(book.levels.length, 12);
|
||||
expect(book.pages.length, 38);
|
||||
expect(book.chapters.length, 3);
|
||||
expect(book.chapterLevels(0), [0, 1, 2, 3]);
|
||||
expect(book.chapterLevels(1), [4, 5, 6, 7]);
|
||||
expect(book.chapterLevels(2), [8, 9, 10, 11]);
|
||||
expect(book.pages.first.type, StoryPageType.dedication);
|
||||
expect(book.pages.last.type, StoryPageType.closing);
|
||||
expect(book.pages.last.text, contains('The end.'));
|
||||
expect(book.continueAt, isNull);
|
||||
expect(
|
||||
book.pages
|
||||
.where((p) => p.type != StoryPageType.puzzle)
|
||||
.fold<int>(0, (n, p) => n + p.text.split(RegExp(r'\s+')).length),
|
||||
greaterThan(3000),
|
||||
);
|
||||
});
|
||||
|
||||
test('all twelve authored silhouettes are unique and solvable by visible clues without guessing', () {
|
||||
expect(book.levels.map((l) => l.picture.join()).toSet().length, 12);
|
||||
for (var i = 0; i < book.levels.length; i++) {
|
||||
final level = book.levels[i], p = level.puzzle();
|
||||
expect(p.countSolutions(), 1, reason: level.id);
|
||||
final solver = LogicSolver(49, p.constraints);
|
||||
expect(solver.analyze(p.initial).cells, p.solution, reason: level.id);
|
||||
final reasoning = ThinkingAnalyzer(
|
||||
49,
|
||||
p.constraints,
|
||||
).analyze(p.initial, maxLookahead: 0);
|
||||
expect(reasoning.status, ThinkingStatus.solved, reason: level.id);
|
||||
expect(reasoning.assumptionSteps, 0, reason: level.id);
|
||||
expect(reasoning.rounds.length, inInclusiveRange(4, 8));
|
||||
if (i < 2) {
|
||||
expect(p.regions, isEmpty);
|
||||
expect(solver.analyze(p.initial, useAreas: false).solved, true);
|
||||
} else {
|
||||
expect(p.regions.length, i < 4 ? 2 : 3);
|
||||
expect(solver.analyze(p.initial, useAreas: false).solved, false);
|
||||
expect(reasoning.comparisonSteps, greaterThanOrEqualTo(2));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('all prose has matching English narration and every discovery has an original image', () async {
|
||||
final scripts = (jsonDecode(
|
||||
await rootBundle.loadString(
|
||||
'assets/stories/midnight-invitation/narration/scripts.json',
|
||||
),
|
||||
) as List).map((s) => MapEntry(s['pageId'] as String, s)).toList();
|
||||
final byId = Map.fromEntries(scripts);
|
||||
expect(book.tracks.length, 26);
|
||||
for (final page in book.pages) {
|
||||
if (page.type == StoryPageType.puzzle) {
|
||||
expect(book.tracks.containsKey(page.id), false);
|
||||
continue;
|
||||
}
|
||||
final track = book.tracks[page.id];
|
||||
expect(track['text'], page.text, reason: page.id);
|
||||
expect(byId[page.id]['text'], page.text);
|
||||
expect(track['speaker'], 'Elias');
|
||||
expect(track['production'], 'diary-drama-v2');
|
||||
expect(
|
||||
(track['cues'] as List)
|
||||
.map((c) => c['text'])
|
||||
.join(track['cueJoin'] ?? '\n\n'),
|
||||
page.text,
|
||||
);
|
||||
final roles = (track['cues'] as List).map((c) => c['speaker']).toSet();
|
||||
expect(roles, contains('Elias'));
|
||||
if (page.id == 'midnight.feather.memory' ||
|
||||
page.id == 'midnight.candle.entry') {
|
||||
expect(roles, contains('Iris'));
|
||||
expect(track['events'], isNotEmpty);
|
||||
}
|
||||
final bytes = await rootBundle.load(track['asset']);
|
||||
expect(
|
||||
ascii.decode(bytes.buffer.asUint8List(bytes.offsetInBytes, 4)),
|
||||
'RIFF',
|
||||
);
|
||||
}
|
||||
final illustrations = {
|
||||
book.coverAsset!,
|
||||
book.paperAsset!,
|
||||
...book.levels.map((l) => l.illustrationAsset!),
|
||||
};
|
||||
expect(illustrations.length, 14);
|
||||
for (final asset in illustrations) {
|
||||
final data = await rootBundle.load(asset);
|
||||
expect(data.getUint32(0), 0x89504e47, reason: asset);
|
||||
}
|
||||
});
|
||||
|
||||
test('all discoveries award once, survive read-ahead and restore independently of other books', () async {
|
||||
final store = Progress.memory();
|
||||
final g = Game(book, store, library: library);
|
||||
g.openNotebook();
|
||||
expect(g.storyPage.id, 'midnight.opening');
|
||||
for (var i = 0; i < 12; i++) {
|
||||
g.showStory(book.pageFor(i, StoryPageType.entry));
|
||||
g.startCampaign(i);
|
||||
final p = g.puzzle!;
|
||||
final open = p.given.indexOf(false);
|
||||
g.mark(open);
|
||||
final marks = List<int>.of(g.cells);
|
||||
g.showStory(book.pageFor(i, StoryPageType.memory));
|
||||
expect(g.recovered(i), false);
|
||||
g.startCampaign(i);
|
||||
expect(g.cells, marks);
|
||||
for (var c = 0; c < g.cells.length; c++) {
|
||||
while (g.cells[c] != (p.solution[c] == 1 ? 1 : 2)) {
|
||||
g.mark(c);
|
||||
}
|
||||
}
|
||||
expect(g.storyPage.type, StoryPageType.memory);
|
||||
expect(g.recoveredCount, i + 1);
|
||||
expect(g.solved, i + 1);
|
||||
g.startCampaign(i);
|
||||
g.check();
|
||||
expect(g.solved, i + 1);
|
||||
}
|
||||
g.showStory(book.pages.length - 1);
|
||||
await g.progress.set('notebook_manual_bookmark', g.storyPage.id);
|
||||
final restarted = Game(book, Progress.memory(store.snapshot));
|
||||
await restarted.restore();
|
||||
expect(restarted.storyPage.id, 'midnight.ending');
|
||||
expect(restarted.recoveredCount, 12);
|
||||
await g.selectStory('mara-island');
|
||||
expect(g.recoveredCount, 0);
|
||||
expect(g.progress.text('notebook_manual_bookmark'), isEmpty);
|
||||
await g.selectStory('midnight-invitation');
|
||||
expect(g.storyPage.id, 'midnight.ending');
|
||||
expect(g.recoveredCount, 12);
|
||||
g.leaveCottage();
|
||||
expect(g.screen, Screen.contents);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user