This commit is contained in:
syuilo 2024-01-09 20:15:03 +09:00
parent eda727c487
commit 4918923635
2 changed files with 19 additions and 3 deletions

View file

@ -148,7 +148,7 @@ 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 @click="retry">Retry</MkButton> <MkButton @click="surrender">Retry</MkButton>
</div> </div>
</div> </div>
</div> </div>
@ -468,8 +468,8 @@ function hold() {
game.hold(); game.hold();
} }
function retry() { function surrender() {
game.gameOver(); game.surrender();
} }
function restart() { function restart() {

View file

@ -28,6 +28,9 @@ type Log = {
} | { } | {
frame: number; frame: number;
operation: 'hold'; operation: 'hold';
} | {
frame: number;
operation: 'surrender';
}; };
export class DropAndFusionGame extends EventEmitter<{ export class DropAndFusionGame extends EventEmitter<{
@ -274,6 +277,15 @@ export class DropAndFusionGame extends EventEmitter<{
} }
} }
public surrender() {
this.logs.push({
frame: this.frame,
operation: 'surrender',
});
this.gameOver();
}
public gameOver() { public gameOver() {
this.isGameOver = true; this.isGameOver = true;
if (this.tickRaf) window.cancelAnimationFrame(this.tickRaf); if (this.tickRaf) window.cancelAnimationFrame(this.tickRaf);
@ -393,6 +405,10 @@ export class DropAndFusionGame extends EventEmitter<{
this.hold(); this.hold();
break; break;
} }
case 'surrender': {
this.surrender();
break;
}
default: default:
break; break;
} }