mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 14:03:09 +02:00
🍪
This commit is contained in:
parent
7ed905f76b
commit
dd78ac089c
2 changed files with 25 additions and 1 deletions
|
@ -31,6 +31,8 @@ let prevCookies = $ref(0);
|
||||||
|
|
||||||
function onClick(ev: MouseEvent) {
|
function onClick(ev: MouseEvent) {
|
||||||
saveData.value!.cookies++;
|
saveData.value!.cookies++;
|
||||||
|
saveData.value!.totalCookies++;
|
||||||
|
saveData.value!.totalHandmadeCookies++;
|
||||||
saveData.value!.clicked++;
|
saveData.value!.clicked++;
|
||||||
|
|
||||||
const x = ev.clientX;
|
const x = ev.clientX;
|
||||||
|
|
|
@ -4,7 +4,11 @@ import * as os from '@/os';
|
||||||
type SaveData = {
|
type SaveData = {
|
||||||
gameVersion: number;
|
gameVersion: number;
|
||||||
cookies: number;
|
cookies: number;
|
||||||
|
totalCookies: number;
|
||||||
|
totalHandmadeCookies: number;
|
||||||
clicked: number;
|
clicked: number;
|
||||||
|
achievements: any[];
|
||||||
|
facilities: any[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const saveData = ref<SaveData>();
|
export const saveData = ref<SaveData>();
|
||||||
|
@ -21,15 +25,33 @@ export async function load() {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'NO_SUCH_KEY') {
|
if (err.code === 'NO_SUCH_KEY') {
|
||||||
saveData.value = {
|
saveData.value = {
|
||||||
gameVersion: 1,
|
gameVersion: 2,
|
||||||
cookies: 0,
|
cookies: 0,
|
||||||
|
totalCookies: 0,
|
||||||
|
totalHandmadeCookies: 0,
|
||||||
clicked: 0,
|
clicked: 0,
|
||||||
|
achievements: [],
|
||||||
|
facilities: [],
|
||||||
};
|
};
|
||||||
save();
|
save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw err;
|
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() {
|
export async function save() {
|
||||||
|
|
Loading…
Reference in a new issue