From: Ian Jackson Date: Fri, 26 Feb 2021 22:31:02 +0000 (+0000) Subject: apitest: Get positions of pieces X-Git-Tag: otter-0.4.0~346 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=affe0803f614fc8b51249bd805d9630192f9a115;p=otter.git apitest: Get positions of pieces Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 053f060d..62a470be 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -130,6 +130,7 @@ impl Ctx { #[derive(Debug,Clone)] struct PieceInfo { id: String, + pos: Pos, info: I, } @@ -143,10 +144,15 @@ impl Session { let puse = puse.value(); let puse = puse.as_element().ok_or(Loop::Continue)?; let attr = puse.attr("data-info").ok_or(Loop::Break)?; + let pos = Pos::from_iter(["x","y"].iter().map(|attr|{ + puse + .attr(attr).unwrap() + .parse().unwrap() + })).unwrap(); let id = puse.id.as_ref().unwrap(); let id = id.strip_prefix("use").unwrap().to_string(); let info = serde_json::from_str(attr).unwrap(); - Loop::ok(PieceInfo { id, info }) + Loop::ok(PieceInfo { id, pos, info }) }) .collect() }