From: Ian Jackson Date: Thu, 19 May 2022 23:22:59 +0000 (+0100) Subject: currency: Occult the left-behind value too X-Git-Tag: otter-1.1.0~42 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=beb02864f9740b363b22cadcd1831d174dc89386;p=otter.git currency: Occult the left-behind value too By plumbing Value more, rather than raw Qty. Signed-off-by: Ian Jackson --- diff --git a/src/currency.rs b/src/currency.rs index 31c41934..2b4c71b3 100644 --- a/src/currency.rs +++ b/src/currency.rs @@ -45,7 +45,7 @@ pub struct Banknote { label_options: TextOptions, } -#[derive(Debug,Serialize,Deserialize)] +#[derive(Debug,Clone,Serialize,Deserialize)] pub struct Value { qty: Qty, } @@ -162,9 +162,10 @@ impl PieceTrait for Banknote { let tgpc_value: &mut Value = tgpc.xdata.get_mut_exp()?; let remaining = tgpc_value.qty.checked_sub(take) .ok_or(Ia::CurrencyShortfall)?; + let remaining = Value { qty: remaining }; tgpc_value.qty = take; - ngpc.xdata_init(Value { qty: remaining })?; + ngpc.xdata_init(remaining.clone())?; tgpc.held = Some(player); ngpc.held = None; @@ -175,7 +176,8 @@ impl PieceTrait for Banknote { "{} took {}, leaving {}{}", gpl.nick.to_html(), self_unocc.describe(tgpc.face, &tgpc_value.html(show_to_all))?, - remaining, ¤cy, + remaining.html(show_to_all), + ¤cy, )}]; let update = PieceUpdateOp::ModifyQuiet(());