Skip to content
Snippets Groups Projects
Commit 8578dacf authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

fix: handle complete misses and foe absence #fe

parent 7b417baf
No related branches found
No related tags found
No related merge requests found
......@@ -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;
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment