From: Ian Jackson Date: Tue, 6 Jul 2021 00:39:05 +0000 (+0100) Subject: script: break out piece_moveable X-Git-Tag: otter-0.7.2~251 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=db68b143458819b616440d9b31034e1690db672e;p=otter.git script: break out piece_moveable Signed-off-by: Ian Jackson --- 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;