chiark / gitweb /
script: Break out pinned_log_message
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jun 2022 19:16:51 +0000 (20:16 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jun 2022 19:59:49 +0000 (20:59 +0100)
We're going to reuse this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index 8760224d15f5912c446996f34f1fc315ef958864..2de8a0bd82ed0961fc306f2f4c41b1a0bf03a77f 100644 (file)
@@ -303,6 +303,9 @@ function piece_moveable(p: PieceInfo) {
 function treat_as_pinned(p: { pinned: boolean }): boolean {
   return p.pinned && !wresting;
 }
+function pinned_log_message(p: PieceInfo) {
+  add_log_message('That piece ('+p.desc+') is pinned to the table.');
+}
 
 // ----- key handling -----
 
@@ -1215,8 +1218,7 @@ function drag_mousedown(e : MouseEvent, shifted: boolean) {
       ungrab_all_except(note_already);
     }
     if (treat_as_pinned(c)) {
-      let p = pieces[c.clicked[0]!]!;
-      add_log_message('That piece ('+p.desc+') is pinned to the table.');
+      pinned_log_message(pieces[c.clicked[0]!]!);
       return;
     }
     grab_clicked(clicked, !wresting, multigrab);