chiark / gitweb /
script: break out piece_moveable
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 6 Jul 2021 00:39:05 +0000 (01:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 6 Jul 2021 00:39:43 +0000 (01:39 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index e0a779d8c5430e894951c9114f2a4e59e9e2d584..d7dde081acf22402053a84cb9a9ae2e4ed531af5 100644 (file)
@@ -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;