feat: chapter select system, multi-chapter support, scene manager refactor, and docs update
This commit is contained in:
@@ -12,13 +12,19 @@ interface SaveRecord {
|
||||
thumbnail?: string
|
||||
}
|
||||
|
||||
interface UnlockRecord {
|
||||
chapterId: string
|
||||
}
|
||||
|
||||
class SaveDB extends Dexie {
|
||||
saves!: Table<SaveRecord, number>
|
||||
unlocks!: Table<UnlockRecord, string>
|
||||
|
||||
constructor() {
|
||||
super('MovieGameSaves')
|
||||
this.version(2).stores({
|
||||
this.version(3).stores({
|
||||
saves: '++id, slot',
|
||||
unlocks: 'chapterId',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -73,4 +79,21 @@ export class SaveSystem {
|
||||
async delete(slot: number): Promise<void> {
|
||||
await db.saves.where('slot').equals(slot).delete()
|
||||
}
|
||||
|
||||
async unlockChapter(chapterId: string) {
|
||||
const exists = await db.unlocks.get(chapterId)
|
||||
if (!exists) {
|
||||
await db.unlocks.put({ chapterId })
|
||||
}
|
||||
}
|
||||
|
||||
async isChapterUnlocked(chapterId: string): Promise<boolean> {
|
||||
const record = await db.unlocks.get(chapterId)
|
||||
return !!record
|
||||
}
|
||||
|
||||
async getUnlockedChapters(): Promise<string[]> {
|
||||
const records = await db.unlocks.toArray()
|
||||
return records.map((r) => r.chapterId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user