fix(drop-and-fusion): バブルゲームのリトライボタンでリトライができない問題を修正 (MisskeyIO#350)

This commit is contained in:
まっちゃとーにゅ 2024-01-10 07:41:27 +09:00 committed by GitHub
commit 38469c2b87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -153,7 +153,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
<div :class="$style.frame"> <div :class="$style.frame">
<div :class="$style.frameInner"> <div :class="$style.frameInner">
<MkButton danger @click="surrender">Retry</MkButton> <MkButton v-if="!isGameOver && !replaying" full danger @click="surrender">Surrender</MkButton>
<MkButton v-else full @click="retry">Retry</MkButton>
</div> </div>
</div> </div>
</div> </div>
@ -483,15 +484,22 @@ async function surrender() {
game.surrender(); game.surrender();
} }
async function retry() {
end();
await start();
}
function end() { function end() {
game.dispose(); game.dispose();
isGameOver.value = false; isGameOver.value = false;
replaying.value = false;
currentPick.value = null; currentPick.value = null;
dropReady.value = true; dropReady.value = true;
stock.value = []; stock.value = [];
score.value = 0; score.value = 0;
combo.value = 0; combo.value = 0;
comboPrev.value = 0; comboPrev.value = 0;
maxCombo.value = 0;
bgmNodes?.soundSource.stop(); bgmNodes?.soundSource.stop();
gameStarted.value = false; gameStarted.value = false;
} }

View file

@ -500,12 +500,13 @@ export class DropAndFusionGame extends EventEmitter<{
}); });
this.emit('changeStock', this.stock); this.emit('changeStock', this.stock);
const x = Math.min(this.gameWidth - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), Math.round(_x))); const inputX = Math.round(_x);
const x = Math.min(this.gameWidth - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), inputX));
const body = this.createBody(head.mono, x, 50 + head.mono.size / 2); const body = this.createBody(head.mono, x, 50 + head.mono.size / 2);
this.logs.push({ this.logs.push({
frame: this.frame, frame: this.frame,
operation: 'drop', operation: 'drop',
x, x: inputX,
}); });
Matter.Composite.add(this.engine.world, body); Matter.Composite.add(this.engine.world, body);
this.activeBodyIds.push(body.id); this.activeBodyIds.push(body.id);