From 0b2df958d4c49fc979efa9da192f292806538079 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 18 Apr 2022 16:23:47 +0100 Subject: [PATCH] currency: Abolish min_unit We can instead just rely on the players to Not Do That, or to tell each other off. It's easy to recover from, too: just move money until the amounts are right. This also avoids any question of what to do if people try to combine banknotes with the same currency but different min_qty. (GCD?) Suggested-by: Gareth Taylor Signed-off-by: Ian Jackson --- src/currency.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/currency.rs b/src/currency.rs index a26e4236..9ad96dfd 100644 --- a/src/currency.rs +++ b/src/currency.rs @@ -24,18 +24,14 @@ pub struct Spec { image: Box, qty: Qty, currency: String, - #[serde(default="default_min_unit")] min_unit: Qty, } -fn default_min_unit() -> Qty { 1 } - #[derive(Debug,Serialize,Deserialize)] pub struct Banknote { itemname: String, image: Arc, qty: Qty, currency: String, - min_unit: Qty, } #[typetag::serde(name="Currency")] @@ -45,7 +41,7 @@ impl PieceSpec for Spec { -> SpecLoaded { gpc.rotateable = false; - let Spec { ref image, ref currency, qty, min_unit } = *self; + let Spec { ref image, ref currency, qty } = *self; let SpecLoadedInert { p: image, occultable:_ } = image.load_inert(ig, depth)?; @@ -59,14 +55,10 @@ impl PieceSpec for Spec { }); } - if (qty % min_unit) != 0 { - throw!(SpecError::CurrencyQtyNotMultipleOfUnit) - } - let bnote = Banknote { image: image.into(), currency: currency.clone(), - itemname, qty, min_unit, + itemname, qty, }; let special = PieceSpecialProperties { -- 2.30.2