From 527e5a39127914e3541c5d60c3469cfaa523d7ca Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Feb 2021 18:20:47 +0000 Subject: [PATCH] Updatess: Handle Unpredictable updates and UI operations This was not implemented. We need hand claim/unclaim to work this way. Signed-off-by: Ian Jackson --- src/pieces.rs | 4 ++-- templates/script.ts | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pieces.rs b/src/pieces.rs index 9e49fed3..b5ccd816 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -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, }} }) } diff --git a/templates/script.ts b/templates/script.ts index 5cdd9b2a..cfad75fd 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -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 = function } } +messages.RecordedUnpredictable = 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 = function (m: any) { console.log('ERROR UPDATE ', m); -- 2.30.2