chiark / gitweb /
currency: Abolish min_unit
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 15:23:47 +0000 (16:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 15:31:05 +0000 (16:31 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/currency.rs

index a26e4236ab1c0bcb6c1502e0f183df385f459d1f..9ad96dfda5bbe9e87bed6c162fa6686ff8e181b4 100644 (file)
@@ -24,18 +24,14 @@ pub struct Spec {
   image: Box<dyn PieceSpec>,
   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<dyn InertPieceTrait>,
   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 {