summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-12-23 13:05:54 -0500
committerKjetil Orbekk <kj@orbekk.com>2022-12-23 13:05:54 -0500
commit82c447fbfe12ee76dbbdaa36b0de1343d3a91795 (patch)
tree6726496043db35b11561cc43fd9b95e0411a10ae
parent89489b0cf0a6cf81dd29426fdf0eeb5aee9231de (diff)
Fix propagation of the previous trick
-rw-r--r--protocol/src/bridge_engine.rs7
-rw-r--r--protocol/src/simple_bots.rs1
-rw-r--r--webapp/src/components/table.rs4
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<Vec<Card>>,
pub declarer_tricks: u8,
pub hand: Vec<Card>,
- pub previous_trick: Trick,
+ pub previous_trick: Option<Trick>,
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(
</div>
<div class="previous-trick">
<p>{"Last trick"}</p>
- <TrickInPlay trick={playing.previous_trick.clone()}/>
+ if let Some(previous_trick) = &playing.previous_trick {
+ <TrickInPlay trick={previous_trick.clone()}/>
+ }
</div>
</div>
</div>