1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-25 15:46:39 +09:00
This commit is contained in:
syuilo 2023-01-08 20:30:19 +09:00
parent 5d13e2744f
commit 7ed905f76b

View File

@ -1,6 +1,7 @@
<template>
<div>
<div v-if="game.ready" :class="$style.game">
<div :class="$style.cps" class="">{{ number(cps) }}cps</div>
<div :class="$style.count" class=""><i class="ti ti-cookie" style="font-size: 70%;"></i> {{ number(cookies) }}</div>
<button v-click-anime class="_button" :class="$style.button" @click="onClick">
<img src="/client-assets/cookie.png" :class="$style.img">
@ -25,6 +26,8 @@ defineProps<{
const saveData = game.saveData;
const cookies = computed(() => saveData.value?.cookies);
let cps = $ref(0);
let prevCookies = $ref(0);
function onClick(ev: MouseEvent) {
saveData.value!.cookies++;
@ -35,6 +38,15 @@ function onClick(ev: MouseEvent) {
os.popup(MkPlusOneEffect, { x, y }, {}, 'end');
}
useInterval(() => {
const diff = saveData.value!.cookies - prevCookies;
cps = diff;
prevCookies = saveData.value!.cookies;
}, 1000, {
immediate: false,
afterMounted: true,
});
useInterval(game.save, 1000 * 5, {
immediate: false,
afterMounted: true,
@ -42,6 +54,7 @@ useInterval(game.save, 1000 * 5, {
onMounted(async () => {
await game.load();
prevCookies = saveData.value!.cookies;
});
onUnmounted(() => {
@ -55,6 +68,13 @@ onUnmounted(() => {
text-align: center;
}
.cps {
position: absolute;
top: 12px;
left: 12px;
opacity: 0.5;
}
.count {
font-size: 1.3em;
margin-bottom: 6px;