chiark / gitweb /
Updatess: Handle Unpredictable updates and UI operations
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Feb 2021 18:20:47 +0000 (18:20 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Feb 2021 00:15:34 +0000 (00:15 +0000)
This was not implemented.

We need hand claim/unclaim to work this way.

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

index 9e49fed36c82b048ac585bc30dd8904157d29856..b5ccd816c2186f656cb8bc468c785954983e8e93 100644 (file)
@@ -385,14 +385,14 @@ impl Piece for Hand {
         def_key: 'C',
         opname: "deactivate".to_owned(),
         desc: Html::lit("Deactivate hand"),
-        wrc: WRC::UpdateSvg,
+        wrc: WRC::Unpredictable,
       }}
       else { UoDescription {
         kind: UoKind:: Piece,
         def_key: 'C',
         opname: "claim".to_owned(),
         desc: Html::lit("Claim this as your hand"),
-        wrc: WRC::UpdateSvg,
+        wrc: WRC::Unpredictable,
       }}
     })
   }
index 5cdd9b2a001f368966df7bbcc6cf65a89b72bb2c..cfad75fd1234219722e6f30c83ce9ad851c52064 100644 (file)
@@ -381,14 +381,12 @@ function some_keydown(e: KeyboardEvent) {
   if (!(uo.kind == 'Global' || uo.kind == 'GlobalExtra' || uo.kind == 'Piece'))
     throw 'bad kind '+uo.kind;
 
-  if (uo.wrc == 'UpdateSvg' || uo.wrc == 'Predictable') {
-    for (var piece of uo.targets!) {
-      let p = pieces[piece]!;
-      api_piece(api, 'k', piece, p, { opname: uo.opname, wrc: uo.wrc });
-      if (uo.wrc == 'UpdateSvg') {
-       p.cseq_updatesvg = p.cseq;
-       redisplay_ancillaries(piece,p);
-      }
+  for (var piece of uo.targets!) {
+    let p = pieces[piece]!;
+    api_piece(api, 'k', piece, p, { opname: uo.opname, wrc: uo.wrc });
+    if (uo.wrc == 'UpdateSvg') {
+      p.cseq_updatesvg = p.cseq;
+      redisplay_ancillaries(piece,p);
     }
   }
 }
@@ -1190,6 +1188,13 @@ messages.Recorded = <MessageHandler>function
   }
 }
 
+messages.RecordedUnpredictable = <MessageHandler>function
+(j: { piece: PieceId, cseq: ClientSeq, ns: PreparedPieceState } ) {
+  let piece = j.piece;
+  let p = pieces[piece]!;
+  piece_modify(piece, p, j.ns, false);
+}
+
 messages.Error = <MessageHandler>function
 (m: any) {
   console.log('ERROR UPDATE ', m);