From fd12c693a7eb92213569c699d228f3c595ab94d5 Mon Sep 17 00:00:00 2001
From: Paolo Brasolin <paolo.brasolin@eurac.edu>
Date: Thu, 24 Mar 2022 10:56:44 +0100
Subject: [PATCH] fix: #fe drop foe/clue on failure

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

diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts
index 828fdc2..1a212eb 100644
--- a/frontend/src/js/fight_scene.ts
+++ b/frontend/src/js/fight_scene.ts
@@ -213,6 +213,10 @@ export default class FightScene extends Phaser.Scene {
     return result;
   }
 
+  popFoe(foe) {
+    this.foes.splice(this.foes.indexOf(foe), 1);
+  }
+
   submitTranscription(inputStatus: InputStatus) {
     const { score, match } = this.findMatchingFoe(inputStatus.final);
     // TODO: visual near misses based on score
@@ -223,7 +227,7 @@ export default class FightScene extends Phaser.Scene {
       this.showMissMessage();
       new Spear(this, this.player, undefined);
     } else {
-      this.foes.splice(this.foes.indexOf(match), 1);
+      this.popFoe(match);
       match.handleSuccess();
       this.showHitMessage();
       new Spear(this, this.player, match.critter);
diff --git a/frontend/src/js/foe.ts b/frontend/src/js/foe.ts
index c588a63..764ca57 100644
--- a/frontend/src/js/foe.ts
+++ b/frontend/src/js/foe.ts
@@ -41,6 +41,8 @@ class Foe {
       this.critter,
       () => {
         this.scene.physics.world.removeCollider(overlap);
+        this.scene.popFoe(this);
+        this.clue.delete();
         this.critter.escape();
       },
     );
-- 
GitLab