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

@ -28,6 +28,9 @@ type Log = {
} | {
frame: number;
operation: 'hold';
} | {
frame: number;
operation: 'surrender';
};
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() {
this.isGameOver = true;
if (this.tickRaf) window.cancelAnimationFrame(this.tickRaf);
@ -393,6 +405,10 @@ export class DropAndFusionGame extends EventEmitter<{
this.hold();
break;
}
case 'surrender': {
this.surrender();
break;
}
default:
break;
}