From: Ian Jackson Date: Tue, 13 Apr 2021 20:15:22 +0000 (+0100) Subject: js: Break out inner function is_already() X-Git-Tag: otter-0.5.0~92 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7e5a23860a791620a9e0b81bb618bc89d2e45db5;p=otter.git js: Break out inner function is_already() Signed-off-by: Ian Jackson --- diff --git a/templates/script.ts b/templates/script.ts index b52d5d75..c426235d 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -880,6 +880,14 @@ function mouse_find_predicate( break; } let piece = uelem.dataset.piece!; + + function is_already() { + if (note_already != null) { + already_count++; + note_already[piece] = true; + } + } + let p = pieces[piece]; if (p.pinned && !wresting) continue; if (p.held && p.held != us && !wresting) continue; @@ -893,10 +901,7 @@ function mouse_find_predicate( if (p.held != us) continue; // skip ones we don't have } else { // user is going to be selecting if (p.held == us) { - if (note_already != null) { - already_count++; - note_already[piece] = true; - } + is_already(); continue; // skip ones we have already } if (held == null) held = p.held; // wrestish