From 82c447fbfe12ee76dbbdaa36b0de1343d3a91795 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 23 Dec 2022 13:05:54 -0500 Subject: Fix propagation of the previous trick --- protocol/src/bridge_engine.rs | 7 ++----- protocol/src/simple_bots.rs | 1 + webapp/src/components/table.rs | 4 +++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protocol/src/bridge_engine.rs b/protocol/src/bridge_engine.rs index b069e18..ee43437 100644 --- a/protocol/src/bridge_engine.rs +++ b/protocol/src/bridge_engine.rs @@ -841,7 +841,7 @@ pub struct PlayStatePlayerView { pub dummy: Option>, pub declarer_tricks: u8, pub hand: Vec, - pub previous_trick: Trick, + pub previous_trick: Option, pub current_trick: TurnInPlay, } @@ -870,10 +870,7 @@ impl PlayStatePlayerView { hand: player_position .get_cards(&play_state.playing_deal.deal) .clone(), - previous_trick: Trick { - leader: random(), - cards_played: vec![], - }, + previous_trick: play_state.playing_deal.tricks_played.last().cloned(), current_trick: play_state.playing_deal.in_progress.clone(), } } diff --git a/protocol/src/simple_bots.rs b/protocol/src/simple_bots.rs index 8965254..8612e64 100644 --- a/protocol/src/simple_bots.rs +++ b/protocol/src/simple_bots.rs @@ -69,6 +69,7 @@ mod tests { PlayStatePlayerView::from_play_state(&play_state, Player::South); assert!(!play_state.playing_deal.is_dummy_visible()); assert!(south_state.dummy.is_none()); + assert!(south_state.previous_trick.is_none()); let card1 = (RandomPlayingBot {}).play(&south_state).await; info!("South state: {south_state:#?}"); diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index 6ccb9d1..e1ec1a1 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -187,7 +187,9 @@ pub fn playing_view(

{"Last trick"}

- + if let Some(previous_trick) = &playing.previous_trick { + + }
-- cgit v1.2.3