From 229d58ca88547f8afbc268f0e94c817b7f7daf0e Mon Sep 17 00:00:00 2001
From: Paolo Brasolin <paolo.brasolin@eurac.edu>
Date: Mon, 11 Apr 2022 18:39:47 +0200
Subject: [PATCH] fix: #fe reset typewriter on game over

---
 frontend/src/js/fight_scene.ts | 1 +
 frontend/src/js/typewriter.ts  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts
index 24ed26a..38c6741 100644
--- a/frontend/src/js/fight_scene.ts
+++ b/frontend/src/js/fight_scene.ts
@@ -357,6 +357,7 @@ export default class FightScene extends Phaser.Scene {
     this.foes.forEach((foe) => foe.destroy());
     this.sound.play("sfx_game_over");
     this.typewriter.setActive(false);
+    this.typewriter.resetInputStatus();
     this.scene.start("game_over", { music: this.music });
   }
 
diff --git a/frontend/src/js/typewriter.ts b/frontend/src/js/typewriter.ts
index 6af7b06..dd97bb6 100644
--- a/frontend/src/js/typewriter.ts
+++ b/frontend/src/js/typewriter.ts
@@ -199,7 +199,6 @@ class Typewriter {
     if (this.inputStatus.began_at_gmtm === null)
       this.inputStatus.began_at_gmtm = this.getGameTime();
     if (key === Key.Enter) {
-      this.keyboard.clearInput();
       this.inputStatus.typed += "\n";
       this.inputStatus.ended_at = new Date();
       this.inputStatus.ended_at_gmtm = this.getGameTime();
@@ -222,6 +221,7 @@ class Typewriter {
   }
 
   resetInputStatus() {
+    this.keyboard.clearInput();
     this.inputStatus = {
       began_at: null,
       ended_at: null,
-- 
GitLab