Skip to content
Snippets Groups Projects
Commit 87ffc672 authored by syuilo's avatar syuilo
Browse files

enhance(drop-and-fusion): yenモードで生涯で稼いだ額を記録するように

parent 5672ead9
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.frameInner">
<div>SCORE: <b><MkNumber :value="score"/>{{ gameMode === 'yen' ? '円' : 'pt' }}</b></div>
<div>HIGH SCORE: <b v-if="highScore"><MkNumber :value="highScore"/>{{ gameMode === 'yen' ? '円' : 'pt' }}</b><b v-else>-</b></div>
<div v-if="gameMode === 'yen'">TOTAL EARNINGS: <b v-if="yenTotal"><MkNumber :value="yenTotal"/></b><b v-else>-</b></div>
</div>
</div>
<div :class="[$style.frame]" style="margin-left: auto;">
......@@ -609,6 +610,7 @@ const dropReady = ref(true);
const isGameOver = ref(false);
const gameLoaded = ref(false);
const highScore = ref<number | null>(null);
const yenTotal = ref<number | null>(null);
const showConfig = ref(false);
const replaying = ref(false);
const replayPlaybackRate = ref(1);
......@@ -1071,6 +1073,15 @@ function attachGameEvents() {
logs: DropAndFusionGame.serializeLogs(logs),
});
if (props.gameMode === 'yen') {
yenTotal.value = (yenTotal.value ?? 0) + score.value;
misskeyApi('i/registry/set', {
scope: ['dropAndFusionGame'],
key: 'yenTotal',
value: yenTotal.value,
});
}
if (score.value > (highScore.value ?? 0)) {
highScore.value = score.value;
......@@ -1135,6 +1146,25 @@ onMounted(async () => {
highScore.value = null;
}
if (props.gameMode === 'yen') {
try {
yenTotal.value = await misskeyApi('i/registry/get', {
scope: ['dropAndFusionGame'],
key: 'yenTotal',
});
} catch (err) {
if (err.code === 'NO_SUCH_KEY') {
// nop
} else {
os.alert({
type: 'error',
text: i18n.ts.cannotLoad,
});
return;
}
}
}
await start();
const bgmBuffer = await sound.loadAudio('/client-assets/drop-and-fusion/bgm_1.mp3');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment