chiark / gitweb /
Add special field to SpecLoaded
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 10:12:56 +0000 (11:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 12:17:31 +0000 (13:17 +0100)
This is currently empty.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/clock.rs
src/currency.rs
src/deck.rs
src/dice.rs
src/gamestate.rs
src/global.rs
src/hand.rs
src/pieces.rs
src/shapelib.rs

index 77468fbfd7aa6236f7142152db782fc1c479fbda..f826c6ae4212a53bbbb5e284c1d8d5a74c320483 100644 (file)
@@ -1110,7 +1110,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
           last_released: default(),
           rotateable: true,
         };
-        let SpecLoaded { p, occultable } =
+        let SpecLoaded { p, occultable, special } =
           info.load(piece_i as usize, &mut gpc, ig, SpecDepth::zero())?;
         if p.nfaces() <= face.into() {
           throw!(SpecError::FaceNotFound);
@@ -1127,7 +1127,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
             ilks.load_lilk(lilk, data)
           });
           ig.ipieces.as_mut(modperm).insert(piece, IPiece {
-            p, occilk,
+            p, occilk, special,
           });
           updates.push((piece, PieceUpdateOp::Insert(())));
         })(); // <- no ?, infallible (to avoid leaking ilk)
index 2b1eb47f2e4b00ce9273f517abcf7f79231a09d5..16fbfbdcb49d6a00f8e4c96ed8dbd9ef93e0687b 100644 (file)
@@ -417,6 +417,7 @@ impl PieceSpec for Spec {
     SpecLoaded {
       p: Box::new(clock),
       occultable: None,
+      special: default(),
     }
   }
 }
index 04dc23a0f2320bfa8329be687e3a3c6df5e3df6f..29e632bfc067566f40df823d8c2a517fcd68c9cc 100644 (file)
@@ -69,7 +69,8 @@ impl PieceSpec for Spec {
       itemname, qty, min_unit,
     };
 
-    SpecLoaded { p: Box::new(bnote) as _, occultable: None }
+    SpecLoaded { p: Box::new(bnote) as _, occultable: None,
+                 special: default() }
   }
 }
 
index e31de48e30a7198b6817902fd4e677361429dd7e..004bc88101eae016ff32bfa8b7d6b1584fca2200 100644 (file)
@@ -71,6 +71,7 @@ impl PieceSpec for piece_specs::Deck {
     SpecLoaded {
       p,
       occultable: None,
+      special: default(),
     }
   }
 }
index 6c72dcc5ae609bfd23b38de6fc7b16fee9c55f7b..1701b52c4e92ceaa07ee30d694d458f386bb175b 100644 (file)
@@ -224,6 +224,7 @@ impl PieceSpec for Spec {
     SpecLoaded {
       p: Box::new(die) as _,
       occultable,
+      special: default(),
     }
   }
 }
index aa1a55a61b9358dc5faaa2202f4996a765b3db85..85b7e011961c0030be70efc66466dce4753d7596 100644 (file)
@@ -283,6 +283,7 @@ pub struct ApiPieceOpArgs<'a> {
 pub struct SpecLoaded {
   pub p: Box<dyn PieceTrait>,
   pub occultable: PieceSpecLoadedOccultable,
+  pub special: PieceSpecialProperties,
 }
 #[derive(Debug)]
 pub struct SpecLoadedInert {
@@ -293,6 +294,14 @@ pub struct SpecLoadedInert {
 pub type PieceSpecLoadedOccultable =
   Option<(LOccultIlk, Arc<dyn InertPieceTrait>)>;
 
+/// Special handling instructions for this piece
+///
+/// These remain constant after the piece has been loaded,
+/// so they are mostly "can/do we do this thing".
+#[derive(Debug,Clone,Default,Serialize,Deserialize)]
+pub struct PieceSpecialProperties {
+}
+
 #[typetag::serde(tag="type")]
 pub trait PieceSpec: Debug + Sync + Send + 'static {
   #[throws(SpecError)]
index 18cccd6dfd534f93623eb68f8a859c5a69ccf0ec..2a8a2ab71cd395fa1c3fd2fcce207f7b996a67d2 100644 (file)
@@ -80,6 +80,7 @@ pub struct IPlayer { // usual variable: ipl
 pub struct IPiece {
   pub p: IPieceTraitObj,
   pub occilk: Option<IOccultIlk>,
+  #[serde(default)] pub special: PieceSpecialProperties,
 }
 deref_to_field!{IPiece, IPieceTraitObj, p}
 
index 5ed96ae0d0f89f41875646bfadd768739902c5d4..eb4461cbf0b1b03cc86dcff6c415e4d91cdc100f 100644 (file)
@@ -111,6 +111,7 @@ impl piece_specs::OwnedCommon {
     SpecLoaded {
       p,
       occultable: None,
+      special: default(),
     }
   }
 }
index b353037a9ff026ef25d800c817c8c38b13e6f2c5..cf52fb5efda0da8faa08129613c5fb2bed9a6d46 100644 (file)
@@ -358,6 +358,7 @@ macro_rules! impl_PieceSpec_for_SimplePieceSpec { { $ty:ty } => {
       SpecLoaded {
         p: Box::new(self.load_raw()?.0),
         occultable: None,
+        special: default(),
       }
     }
 
index 3eee455c9ebb4802a49172449f7e309387a84969..98df20547655b07fb0cbfcc764982a2ec6f59cbb 100644 (file)
@@ -493,6 +493,7 @@ impl From<ItemSpecLoaded> for SpecLoaded {
     SpecLoaded {
       p,
       occultable,
+      special: default(),
     }
   }
 }