chiark / gitweb /
Pass face to InertPieceTrait::describe_html
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 10:40:56 +0000 (11:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 10:40:56 +0000 (11:40 +0100)
This ought to have been part of
  Extend InertPieceTrait to support multiple faces

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/pcrender.rs
src/pieces.rs
src/shapelib.rs
src/updates.rs

index 9dc9d8ff443be4a3cf085fafd36b5db4bd89d7d5..6887274b4f1cbef85ffe53918f4f56a89fe43c57 100644 (file)
@@ -244,7 +244,7 @@ pub trait InertPieceTrait: PieceBaseTrait {
   /// face used is always default, regardless of nfaces.
   fn svg(&self, f: &mut Html, id: VisiblePieceId, face: FaceId,
          xdata: &PieceXDataState /* use with care! */) -> Result<(),IE>;
-  fn describe_html(&self) -> Result<Html,IE>;
+  fn describe_html(&self, face: FaceId) -> Result<Html,IE>;
 }
 
 #[derive(Debug)]
index 6dbcb80a9285ac2acea183a4c4e89ba17c5ad48c..f5e81a36575bd6188687a70c3dadc724a648eed3 100644 (file)
@@ -76,7 +76,7 @@ impl<P,Z> PriOccultedGeneral<P,Z> {
                            gpc: &GPiece, ipc: &IPiece) -> Html {
     match self.instead(ioccults, ipc)? {
       Left(y) => ipc.show(y).describe_html(gpc, goccults)?,
-      Right(i) => i.describe_html()?,
+      Right(i) => i.describe_html(default())?,
     }
   }
 }
index 14194eeb38437f84d6fdc3818241b40e44dae762..f6e5f867eb3c6cfcd162151ac505fa39238c116d 100644 (file)
@@ -160,7 +160,7 @@ impl InertPieceTrait for SimpleShape {
   }
 
   #[throws(IE)]
-  fn describe_html(&self) -> Html {
+  fn describe_html(&self, _: FaceId) -> Html {
     hformat!("a {}", self.desc)
   }
 }
index a42422780309e5a38a9efd8be588070c7eec23d2..7a85c1f478467c4f974cce6eff8ddfd8ca94a142 100644 (file)
@@ -239,7 +239,7 @@ impl InertPieceTrait for ItemInertForOcculted {
     self.xform.write_svgd(f, &self.svgd)?;
   }
   #[throws(IE)]
-  fn describe_html(&self) -> Html { self.desc.clone() }
+  fn describe_html(&self, _: FaceId) -> Html { self.desc.clone() }
 }
 
 #[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)]
@@ -361,7 +361,7 @@ impl Item {
       if let Some(face) = self.faces.get(face) {
         face.desc
       } else if let Some(back) = &self.back {
-        return back.describe_html()?;
+        return back.describe_html(default())?;
       } else {
         self.faces[0].desc
       }
@@ -402,7 +402,7 @@ impl InertPieceTrait for Item {
     self.svg_face(f, face, id, xdata)?;
   }
   #[throws(IE)]
-  fn describe_html(&self) -> Html {
+  fn describe_html(&self, _: FaceId) -> Html {
     self.describe_face(default())?
   }
 }
index a9d87f3be284f86837d2fb4070c4baf048289ffb..1587cd7372813dbcadbd973ce5d8bc89cd29723e 100644 (file)
@@ -301,7 +301,7 @@ pub fn log_did_to_piece_whoby(ioccults: &IOccults, goccults: &GameOccults,
   let desc = (||{
     Ok::<_,IE>(match ipc.show_or_instead(ioccults, y)? {
       Left(y) => ipc.show(y).describe_html(gpc, goccults)?,
-      Right(instead) => instead.describe_html()?,
+      Right(instead) => instead.describe_html(default())?,
     })
   })().unwrap_or_else(|e|{
     error!("failed to format during logging: {:?}", e);