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
+175 -5
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
@@ -9,12 +10,177 @@ import 'package:lumen/ui/board.dart';
import 'package:lumen/ui/paper.dart';
void main() {
testWidgets(
'object illustrations remain hidden until their own pattern is solved',
(tester) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
final game = Game(book, Progress.memory({'story_access_level': 11}));
game.showStory(0);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
void expectHidden() {
for (final level in book.levels) {
expect(
find.image(AssetImage(level.illustrationAsset!)),
findsNothing,
);
}
expect(find.byType(PixelPicture), findsNothing);
}
for (var i = 0; i < 12; i++) {
game.reveal(i, readAhead: true);
await tester.pumpAndSettle();
expectHidden();
expect(game.solved, 0);
}
for (final index in [5, 6, 9, 12, 15]) {
game.showStory(index);
await tester.pumpAndSettle();
expectHidden();
}
game.showStory(book.pageFor(1, StoryPageType.puzzle));
final solution = List<int>.of(game.puzzle!.solution);
for (var c = 0; c < solution.length; c++) {
while (game.cells[c] != (solution[c] == 1 ? 1 : 2)) {
game.mark(c);
}
}
await tester.pumpAndSettle();
expect(
find.image(AssetImage(book.levels[1].illustrationAsset!)),
findsOneWidget,
);
game.showStory(5);
await tester.pumpAndSettle();
expectHidden();
game.reveal(2, readAhead: true);
await tester.pumpAndSettle();
expectHidden();
expect(game.solved, 1);
final restarted = Game(book, Progress.memory(game.progress.snapshot));
await restarted.restore();
expect(restarted.recovered(1), true);
expect(restarted.recovered(2), false);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
},
);
testWidgets('completed saves never put discovery art on earlier leaves', (
tester,
) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
final game = Game(
book,
Progress.memory({
for (var i = 0; i < 12; i++) 'done_story_v1_$i': true,
'notebook_handle_seen': true,
}),
);
game.showStory(0);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
for (var i = 0; i < book.pages.length; i++) {
game.showStory(i);
await tester.pumpAndSettle();
final page = book.pages[i];
for (var object = 0; object < 12; object++) {
expect(
find.image(AssetImage(book.levels[object].illustrationAsset!)),
page.type == StoryPageType.memory && page.campaignIndex == object
? findsOneWidget
: findsNothing,
reason: '${page.id} must not reveal object $object before its puzzle',
);
}
expect(find.byType(PixelPicture), findsNothing);
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox());
});
testWidgets('all cottage leaves turn, offer hints and fit larger text', (
tester,
) async {
addTearDown(tester.view.reset);
await tester.runAsync(() async {
final font = FontLoader('MaraHand')
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
await font.load();
});
final book = (await tester.runAsync(Book.load))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final g = Game(book, Progress.memory());
g.showStory(0);
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: MediaQueryData(
size: size,
textScaler: const TextScaler.linear(1.5),
),
child: Notebook(game: g, adsEnabled: false),
),
),
);
await tester.pumpAndSettle();
for (var i = 0; i < book.pages.length; i++) {
expect(g.storyIndex, i);
final page = book.pages[i];
if (page.type == StoryPageType.puzzle) {
final before = List<int>.of(g.cells);
final hint = find.text('Hint · free');
await tester.ensureVisible(hint);
await tester.pumpAndSettle();
await tester.tap(hint);
await tester.pumpAndSettle();
expect(g.cells, isNot(before), reason: page.id);
await tester.tap(find.text('Keep going'));
await tester.pumpAndSettle();
}
final next = find.text(
i == book.pages.length - 1 ? 'Across the tide →' : 'Next leaf →',
);
expect(next.hitTestable(), findsOneWidget, reason: page.id);
await tester.tap(next);
await tester.pumpAndSettle();
if (page.type == StoryPageType.puzzle) {
await tester.tap(find.text('Read ahead'));
await tester.pumpAndSettle();
}
expect(g.solved, 0);
expect(tester.takeException(), isNull, reason: page.id);
}
expect(g.screen, Screen.briefing);
expect(g.campaignIndex, 4);
g.contents(0);
await tester.pumpAndSettle();
expect(find.text('I · The keeper’s cottage'), findsOneWidget);
expect(find.text('2 · Something to carry the flame'), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
await tester.pumpAndSettle();
}
});
testWidgets('campaign discoveries use bundled art with a pixel fallback', (
tester,
) async {
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
final g = Game(book, Progress.memory({'story_access_level': 11}));
final g = Game(
book,
Progress.memory({
'story_access_level': 11,
for (var i = 0; i < 12; i++) 'done_story_v1_$i': true,
}),
);
expect(book.levels.every((l) => l.illustrationAsset != null), true);
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
@@ -40,12 +206,16 @@ void main() {
expect(find.byType(PixelPicture), findsNothing);
await tester.ensureVisible(art);
await tester.pumpAndSettle();
expect(tester.getSize(art).height, 190);
expect(tester.getSize(art).height, index < 4 ? 155 : 190);
} else {
expect(find.byType(PixelPicture), findsOneWidget);
}
final next = find.text(
index == 11 ? 'Return to the notebook' : 'Turn the page →',
index < 4
? 'Next leaf →'
: index == 11
? 'Return to the notebook'
: 'Turn the page →',
);
await tester.ensureVisible(next);
await tester.pumpAndSettle();
@@ -84,7 +254,7 @@ void main() {
'clues': original.clues,
'areas': original.areas,
});
final game = Game(book, Progress.memory());
final game = Game(book, Progress.memory({'done_story_v1_0': true}));
game.reveal(0, readAhead: true);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
@@ -280,7 +450,7 @@ void main() {
greaterThan(lastCell.right),
);
expect(find.text('Hint · free'), findsOneWidget);
expect(find.text('Back to notebook'), findsOneWidget);
expect(find.text('Next leaf →'), findsOneWidget);
expect(tester.takeException(), isNull);
// The opening notebook's puzzle leaf uses the same two columns, with the