diff --git a/packages/frontend/src/components/MkClickerGame.vue b/packages/frontend/src/components/MkClickerGame.vue index 6d0b2236b..03736ac5e 100644 --- a/packages/frontend/src/components/MkClickerGame.vue +++ b/packages/frontend/src/components/MkClickerGame.vue @@ -31,6 +31,8 @@ let prevCookies = $ref(0); function onClick(ev: MouseEvent) { saveData.value!.cookies++; + saveData.value!.totalCookies++; + saveData.value!.totalHandmadeCookies++; saveData.value!.clicked++; const x = ev.clientX; diff --git a/packages/frontend/src/scripts/clicker-game.ts b/packages/frontend/src/scripts/clicker-game.ts index 77206cc8e..d3b0f9d1e 100644 --- a/packages/frontend/src/scripts/clicker-game.ts +++ b/packages/frontend/src/scripts/clicker-game.ts @@ -4,7 +4,11 @@ import * as os from '@/os'; type SaveData = { gameVersion: number; cookies: number; + totalCookies: number; + totalHandmadeCookies: number; clicked: number; + achievements: any[]; + facilities: any[]; }; export const saveData = ref(); @@ -21,15 +25,33 @@ export async function load() { } catch (err) { if (err.code === 'NO_SUCH_KEY') { saveData.value = { - gameVersion: 1, + gameVersion: 2, cookies: 0, + totalCookies: 0, + totalHandmadeCookies: 0, clicked: 0, + achievements: [], + facilities: [], }; save(); return; } throw err; } + + // migration + if (saveData.value.gameVersion === 1) { + saveData.value = { + gameVersion: 2, + cookies: saveData.value.cookies, + totalCookies: saveData.value.cookies, + totalHandmadeCookies: saveData.value.cookies, + clicked: saveData.value.clicked, + achievements: [], + facilities: [], + }; + save(); + } } export async function save() {