chiark / gitweb /
Make Hand be rectangles only
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Feb 2021 00:50:43 +0000 (00:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Feb 2021 11:51:14 +0000 (11:51 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hand.rs
src/spec.rs

index 77384f8ab1bf06df39fbce50d8717d687d96793b..da4038f4394ea4f9f879c4e28ca8417d20c9b50b 100644 (file)
@@ -16,7 +16,7 @@ struct MagicOwner {
 
 #[derive(Debug,Serialize,Deserialize)]
 struct Hand {
-  shape: GenericSimpleShape<(), OutlineRepr>,
+  shape: GenericSimpleShape<(), shapelib::Rectangle>,
 }
 
 #[derive(Debug,Clone,Default,Serialize,Deserialize)]
@@ -49,9 +49,13 @@ impl PieceSpec for piece_specs::Hand {
       edges: self.edge.iter().cloned().collect(),
       edge_width: self.edge_width,
     };
+    let shape = match self.shape {
+      OutlineRepr::Rectangle(r) => r,
+      _ => throw!(SpecError::UnsupportedShape),
+    };
     let shape = GenericSimpleShape::new(
       (),
-      self.shape.clone(),
+      shape,
       "magic-hand",
       &common)?;
     Box::new(Hand {
index 59933764b191259b9d511bffd7a86ee936f30c96..c8d0e8ebbc3a7b8bf9970c59e82a30fabf533848 100644 (file)
@@ -82,8 +82,7 @@ pub enum SpecError {
   ZeroFaces,
   InconsistentFacesEdgecoloursCount,
   SpecifiedWidthOfNoEdges,
-  ItemnameSpecifiedWhereForbidden,
-  MultifacetedMagic,
+  UnsupportedShape,
 }
 display_as_debug!{SpecError}