diff --git a/frontend/src/js/fight_scene.js b/frontend/src/js/fight_scene.js index b85e4127238073c7058b1121f96a0e90a7cffe0e..ada1a70588e13862f26306920692ccc88150c179 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; });