From: Ian Jackson Date: Wed, 24 Mar 2021 18:24:40 +0000 (+0000) Subject: deck: Refactor, ready for counting instead, fix current_face X-Git-Tag: otter-0.5.0~449 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=430640c009cdcf02137f8168acd64fb42ab2ee48;p=otter.git deck: Refactor, ready for counting instead, fix current_face Signed-off-by: Ian Jackson --- diff --git a/src/deck.rs b/src/deck.rs index e0b171c0..8ac3370a 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -68,8 +68,11 @@ impl Deck { if gpc.occult.is_active() { Enabled } else { Disabled } } - fn current_face(&self, gpc: &GPiece) -> FaceId { - (gpc.occult.is_active() as RawFaceId).into() + fn current_face(&self, gpc: &GPiece, goccults: &GameOccults) -> FaceId { + RawFaceId::from(match self.state(gpc, goccults) { + Disabled => 0, + Enabled => 1, + }).into() } } @@ -79,7 +82,7 @@ impl PieceTrait for Deck { #[throws(IE)] fn svg_piece(&self, f: &mut Html, gpc: &GPiece, gs: &GameState, _vpid: VisiblePieceId) { - let face = self.current_face(gpc); + let face = self.current_face(gpc, &gs.occults); self.shape.svg_piece_raw(f, face, &mut |_|Ok::<_,IE>(()))?; if_chain! { if let Some(label) = &self.label;