From 8578dacf12702b0b4d4bbb85b25dfad5b63c6959 Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Thu, 10 Mar 2022 10:35:24 +0100 Subject: [PATCH] fix: handle complete misses and foe absence #fe --- frontend/src/js/fight_scene.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/js/fight_scene.js b/frontend/src/js/fight_scene.js index b85e412..ada1a70 100644 --- a/frontend/src/js/fight_scene.js +++ b/frontend/src/js/fight_scene.js @@ -326,15 +326,17 @@ function shootSpear(enemy, hit, scene = fightScene) { } function submitTranscription(transcription) { - // TODO: guess the enemy if any + if (window.onscreenEnemies.length < 1) return; + let similarity = 0; let match = null; + window.onscreenEnemies.forEach((foe) => { const s = levenshtein( transcription.toLowerCase(), foe.word.ocr_transcript.toLowerCase(), ).similarity; - if (s <= similarity) return; + if (s < similarity) return; similarity = s; match = foe; }); -- GitLab