From: Ian Jackson Date: Mon, 18 Apr 2022 15:23:47 +0000 (+0100) Subject: currency: Abolish min_unit X-Git-Tag: otter-1.1.0~470 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0b2df958d4c49fc979efa9da192f292806538079;p=otter.git 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 --- 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 {