From 5b68985e5da31ab8b185734248a2498f8af20e1b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 5 Jul 2021 20:55:54 +0100 Subject: [PATCH] hand: Show count of items occulted Signed-off-by: Ian Jackson --- src/hand.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/hand.rs b/src/hand.rs index 9a574158..c7f1e70c 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -155,25 +155,34 @@ impl PieceTrait for Hand { gs: &GameState, _vpid: VisiblePieceId) { let owned = if_chain!{ if let Some(xdata) = gpc.xdata.get::()?; + if let count = gpc.occult.active_total_ppieces(&gs.occults)?; if let Some(owned) = &xdata.owner; - then { Some(owned) } + then { Some((owned, count)) } else { None } }; self.shape.svg_piece_raw(f, gpc.face, &mut |f: &mut Html| { - if let Some(owned) = owned { + if let Some((owned,_)) = owned { hwrite!(f, r##" stroke-dasharray="{}" "##, &owned.dasharray)?; } Ok(()) })?; if_chain! { - if let Some(owned) = owned; + if let Some((owned, count)) = owned; if let Some(gpl) = gs.players.get(owned.player); if let Some(label) = &self.label; then { label.svg(f, &self.shape.outline, - self.shape.edges.get(0), - &gpl.nick.to_html())? + self.shape.edges.get(0), + &if let Some(count) = count { + hformat!(r#"{} {}"#, + monospace_font(5), + count, + &gpl.nick) + } else { + hformat!("??? {}", + &gpl.nick) + })? } } } @@ -330,4 +339,8 @@ impl PieceTrait for Hand { ops: PUOs::Simple(PUO::Modify(())), }, xupdates.into_unprepared(None)) } + + fn occultation_notify_hook(&self, piece: PieceId) -> UnpreparedUpdates { + occultation_notify_update_image(piece) + } } -- 2.30.2