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
+56 -30
View File
@@ -38,9 +38,31 @@ class CampaignLevel {
}
}
enum StoryPageType {
dedication,
entry,
puzzle,
memory,
note,
inspection,
closing,
}
class StoryPage {
const StoryPage(this.id, this.title, this.text);
const StoryPage(
this.id,
this.title,
this.text, {
this.type = StoryPageType.entry,
this.campaignIndex,
this.speaker = '',
this.illustrationAsset,
});
final String id, title, text;
final StoryPageType type;
final int? campaignIndex;
final String speaker;
final String? illustrationAsset;
}
class Book {
@@ -49,6 +71,9 @@ class Book {
final List<CampaignLevel> levels;
final List<StoryPage> pages;
final Map<String, dynamic> tracks;
int pageFor(int campaignIndex, StoryPageType type) => pages.indexWhere(
(p) => p.campaignIndex == campaignIndex && p.type == type,
);
static Future<Book> load() async {
final campaign = jsonDecode(
await rootBundle.loadString('assets/campaign.json'),
@@ -63,37 +88,38 @@ class Book {
),
)['tracks']
as Map<String, dynamic>;
const ids = [
'cottage.dedication',
'cottage.window',
'cottage.match.puzzle',
'cottage.match.memory',
'cottage.folded.note',
'cottage.lantern.sketch',
];
const titles = [
'For you, when you are ready',
'By the cottage window',
'A spark in the drawer',
'One small light',
'A note I nearly forgot',
'The handle, carefully mended',
];
final levels = (campaign['levels'] as List)
.map((e) => CampaignLevel(e))
.toList();
final notebook = jsonDecode(
await rootBundle.loadString('assets/notebook.json'),
) as Map<String, dynamic>;
return Book(
campaign['premise'],
(campaign['levels'] as List).map((e) => CampaignLevel(e)).toList(),
List.generate(
6,
(i) => StoryPage(
ids[i],
titles[i],
scripts
.where((s) => s['pageId'] == ids[i])
.map((s) => s['text'] as String)
.firstOrNull ??
'',
),
),
levels,
(notebook['pages'] as List).map((record) {
final index = record['campaignIndex'] as int?;
final text = switch (record['textSource']) {
'before' => levels[index!].before,
'after' => levels[index!].after,
'recording' =>
scripts
.where((s) => s['pageId'] == record['id'])
.map((s) => s['text'] as String)
.firstOrNull ??
'',
_ => record['text'] as String? ?? '',
};
return StoryPage(
record['id'],
record['title'],
text,
type: StoryPageType.values.byName(record['type']),
campaignIndex: index,
speaker: record['speaker'] as String? ?? '',
illustrationAsset: record['illustrationAsset'] as String?,
);
}).toList(),
tracks,
);
}