chiark / gitweb /
hidden: make describe take ShowUnocculted
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Mar 2021 11:45:44 +0000 (11:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Mar 2021 12:21:43 +0000 (12:21 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/otterlib.rs
src/gamestate.rs
src/hand.rs
src/hidden.rs
src/pcrender.rs
src/pieces.rs
src/shapelib.rs

index 674bd6dbe5dcc70f0cc51640446252a4606fa75b..47868add56c70bedcd8a1219c928cf0a38278bae 100644 (file)
@@ -134,7 +134,7 @@ fn preview(items: Vec<ItemForOutput>) {
     println!(r#"<th align="left"><kbd>{}</kbd></th>"#,
              Html::from_txt(&spec.item).0);
     println!(r#"<th align="left">{}</th>"#,
-             p.describe_html(&GPiece::dummy())?.0);
+             p.describe_html(&GPiece::dummy(), unocc_ok)?.0);
     let only1 = s.face_cols(unocc_ok) == 1;
 
     for facecol in 0..(if only1 { 1 } else { max_facecols }) {
index 3c84bccb1c88d8f5f123f673c1e10a549711d0c5..b53139b748c2b16c0241c4cd92376085ffd74c57 100644 (file)
@@ -147,7 +147,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static {
   fn svg_piece(&self, f: &mut Html, gpc: &GPiece,
                id: VisiblePieceId, y: ShowUnocculted) -> Result<(),IE>;
 
-  fn describe_html(&self, gpc: &GPiece) -> Result<Html,IE>;
+  fn describe_html(&self, gpc: &GPiece, y: ShowUnocculted) -> Result<Html,IE>;
 
   fn delete_hook(&self, _p: &GPiece, _gs: &mut GameState)
                  -> ExecuteGameChangeUpdates { 
index c3b0e74a53d00cdff9845471d2e37d213ce7463e..122b5142f28dfe26d261303d73c9970ef78c95d0 100644 (file)
@@ -101,7 +101,7 @@ impl PieceTrait for Hand {
   }
 
   #[throws(IE)]
-  fn describe_html(&self, gpc: &GPiece) -> Html {
+  fn describe_html(&self, gpc: &GPiece, _: ShowUnocculted) -> Html {
     let xdata = gpc.xdata.get()?;
     self.describe_html_inner(xdata)
   }
index 94a0f3698613ceeebbb26c31299768db22a0e9be..c7b27e59aedfda41cb24d7e52899a3a387601b7f 100644 (file)
@@ -282,7 +282,7 @@ fn recalculate_occultation_general<
   gpieces: &mut GPieces,
   goccults: &mut GameOccults,
   ipieces: &IPieces,
-  _ioccults: &IOccults,
+  ioccults: &IOccults,
   to_permute: &mut ToPermute,
   piece: PieceId,
   // if no change, we return ret_vanilla(log_visible)
@@ -429,7 +429,9 @@ fn recalculate_occultation_general<
       let bad = || internal_error_bydebug(&("missing", opiece, h.occid));
       let oipc = ipieces.get(opiece).ok_or_else(bad)?;
       let ogpc = gpieces.get(opiece).ok_or_else(bad)?;
-      Ok::<_,IE>(oipc.p.describe_html(ogpc)?)
+      let ounocc = ogpc.fully_visible_to_everyone()
+        .ok_or_else(||internal_error_bydebug(&(occulteds, &ogpc)))?;
+      Ok::<_,IE>(oipc.p.describe_html(ogpc, ounocc)?)
     };
 
     let most_obscure = most_obscure.unwrap_or(&OccK::Visible); // no players!
@@ -441,15 +443,16 @@ fn recalculate_occultation_general<
                      show)
       );
 
-    let log = match most_obscure {
-      OccK::Visible => {
+    let log = match most_obscure.map_displaced(|_|((),())).pri_occulted() {
+      Some(PriOG::Visible(_y)) => {
         log_visible
       }
-      OccK::Scrambled | OccK::Displaced{..} => {
-        let show = ipc.p.describe_html(gpc)?;
+      Some(prioc@ PriOG::Occulted) |
+      Some(prioc@ PriOG::Displaced(..)) => {
+        let show = prioc.describe(ioccults, gpc, ipc);
         call_log_callback(Some(&show))?
       },
-      OccK::Invisible => {
+      None => {
         call_log_callback(None)?
       },
     };
index 6e2293ff7b654099d2c17963ceeae68deae3d56e..401854426ca1dd85ed5e9e8440ec285e64becfd6 100644 (file)
@@ -78,7 +78,7 @@ impl<P,Z> PriOccultedGeneral<P,Z> {
   pub fn describe_fallible(&self, ioccults: &IOccults,
                            gpc: &GPiece, ipc: &IPiece) -> Html {
     match self.instead(ioccults, ipc)? {
-      Left(_y) => ipc.p.describe_html(gpc)?,
+      Left(y) => ipc.p.describe_html(gpc, y)?,
       Right(i) => i.describe_html()?,
     }
   }
index fc1cceaa8e8eb78ea1cd5bb4360106cdac1a74ba..d0a387caaadc07b219c7f5f8a2dc5b1c93e4082c 100644 (file)
@@ -134,7 +134,7 @@ impl PieceTrait for SimpleShape {
     self.svg_piece_raw(f, gpc.face, &mut |_|Ok(()))?;
   }
   #[throws(IE)]
-  fn describe_html(&self, gpc: &GPiece) -> Html {
+  fn describe_html(&self, gpc: &GPiece, _: ShowUnocculted) -> Html {
     Html(if_chain! {
       if let face = gpc.face;
       if let Some(colour) = self.colours.get(face);
index 3297528fe83afc7bb29fe61bfcc4f61c54d30044..b836952add8306e71c30c28e014e2b9ff178d8b1 100644 (file)
@@ -224,7 +224,7 @@ impl PieceTrait for Item {
     
   }
   #[throws(IE)]
-  fn describe_html(&self, gpc: &GPiece) -> Html {
+  fn describe_html(&self, gpc: &GPiece, _: ShowUnocculted) -> Html {
     self.descs[ self.faces[gpc.face].desc ].clone()
   }
 
@@ -344,6 +344,7 @@ impl Contents {
     let pat = glob::Pattern::new(pat).map_err(|pe| ME::BadGlob {
       pat: pat.to_string(), msg: pe.msg.to_string() })?;
     let mut out = vec![];
+    let unocc_ok = ShowUnocculted::new_visible();
     for (k,v) in &self.items {
       if !pat.matches(&k) { continue }
       let loaded = match self.load1(v, &k) {
@@ -355,7 +356,7 @@ impl Contents {
       let ier = ItemEnquiryData {
         itemname: k.clone(),
         f0bbox,
-        f0desc: loaded.p.describe_html(&GPiece::dummy())?,
+        f0desc: loaded.p.describe_html(&GPiece::dummy(), unocc_ok)?,
       };
       out.push(ier);
     }