From db68b143458819b616440d9b31034e1690db672e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 6 Jul 2021 01:39:05 +0100 Subject: [PATCH] script: break out piece_moveable Signed-off-by: Ian Jackson --- templates/script.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/script.ts b/templates/script.ts index e0a779d8..d7dde081 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -269,6 +269,10 @@ function piece_element(base: string, piece: PieceId): SVGGraphicsElement | null return svg_element(base+piece); } +function piece_moveable(p: PieceInfo) { + return p.moveable == 'Yes' || p.moveable == 'IfWresting' && wresting; +} + // ----- key handling ----- function recompute_keybindings() { @@ -937,8 +941,7 @@ function mouse_find_predicate( let p = pieces[piece]; if (p.pinned && !wresting) continue; if (p.held && p.held != us && !wresting) continue; - if (i > 0 - && !(p.moveable == 'Yes' || p.moveable == 'IfWresting' && wresting)) + if (i > 0 && !piece_moveable(p)) continue; if (!predicate(p)) { continue; -- 2.30.2