From: Ian Jackson Date: Tue, 16 Mar 2021 11:45:44 +0000 (+0000) Subject: hidden: make describe take ShowUnocculted X-Git-Tag: otter-0.4.0~16 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=82c677facb0b96b2b0e92b7e9b302eca51493471;p=otter.git hidden: make describe take ShowUnocculted Signed-off-by: Ian Jackson --- diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 674bd6db..47868add 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -134,7 +134,7 @@ fn preview(items: Vec) { println!(r#"{}"#, Html::from_txt(&spec.item).0); println!(r#"{}"#, - 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 }) { diff --git a/src/gamestate.rs b/src/gamestate.rs index 3c84bccb..b53139b7 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -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; + fn describe_html(&self, gpc: &GPiece, y: ShowUnocculted) -> Result; fn delete_hook(&self, _p: &GPiece, _gs: &mut GameState) -> ExecuteGameChangeUpdates { diff --git a/src/hand.rs b/src/hand.rs index c3b0e74a..122b5142 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -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) } diff --git a/src/hidden.rs b/src/hidden.rs index 94a0f369..c7b27e59 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -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)? }, }; diff --git a/src/pcrender.rs b/src/pcrender.rs index 6e2293ff..40185442 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -78,7 +78,7 @@ impl PriOccultedGeneral { 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()?, } } diff --git a/src/pieces.rs b/src/pieces.rs index fc1cceaa..d0a387ca 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -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); diff --git a/src/shapelib.rs b/src/shapelib.rs index 3297528f..b836952a 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -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); }