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

This commit is contained in:
syuilo 2024-01-12 21:01:38 +09:00
parent 5672ead957
commit 87ffc672dd
1 changed files with 30 additions and 0 deletions

View File

@ -110,6 +110,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.frameInner"> <div :class="$style.frameInner">
<div>SCORE: <b><MkNumber :value="score"/>{{ gameMode === 'yen' ? '円' : 'pt' }}</b></div> <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>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> </div>
<div :class="[$style.frame]" style="margin-left: auto;"> <div :class="[$style.frame]" style="margin-left: auto;">
@ -609,6 +610,7 @@ const dropReady = ref(true);
const isGameOver = ref(false); const isGameOver = ref(false);
const gameLoaded = ref(false); const gameLoaded = ref(false);
const highScore = ref<number | null>(null); const highScore = ref<number | null>(null);
const yenTotal = ref<number | null>(null);
const showConfig = ref(false); const showConfig = ref(false);
const replaying = ref(false); const replaying = ref(false);
const replayPlaybackRate = ref(1); const replayPlaybackRate = ref(1);
@ -1071,6 +1073,15 @@ function attachGameEvents() {
logs: DropAndFusionGame.serializeLogs(logs), 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)) { if (score.value > (highScore.value ?? 0)) {
highScore.value = score.value; highScore.value = score.value;
@ -1135,6 +1146,25 @@ onMounted(async () => {
highScore.value = null; 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(); await start();
const bgmBuffer = await sound.loadAudio('/client-assets/drop-and-fusion/bgm_1.mp3'); const bgmBuffer = await sound.loadAudio('/client-assets/drop-and-fusion/bgm_1.mp3');