diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-09-22 09:15:09 -0400 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-09-22 09:15:09 -0400 |
commit | 030b45c000210b153b5ef224ddcaa668de763638 (patch) | |
tree | dfeb3d8c6ee803c41b96b2dd3f6da0fbe38614b2 /webapp/src/components | |
parent | d66f16ae60190eebe711f7f2fb931513d711cd32 (diff) |
Add component for current trick
Diffstat (limited to 'webapp/src/components')
-rw-r--r-- | webapp/src/components/card.rs | 1 | ||||
-rw-r--r-- | webapp/src/components/game.rs | 15 | ||||
-rw-r--r-- | webapp/src/components/trick_in_play.rs | 23 |
3 files changed, 37 insertions, 2 deletions
diff --git a/webapp/src/components/card.rs b/webapp/src/components/card.rs index 5401899..d5aee36 100644 --- a/webapp/src/components/card.rs +++ b/webapp/src/components/card.rs @@ -24,5 +24,6 @@ pub fn ccard(props: &CardProps) -> Html { #[derive(PartialEq, Properties, Clone)] pub struct CardProps { pub card: card::Card, + #[prop_or_default] pub onclick: Callback<card::Card>, } diff --git a/webapp/src/components/game.rs b/webapp/src/components/game.rs index e893691..accdd33 100644 --- a/webapp/src/components/game.rs +++ b/webapp/src/components/game.rs @@ -2,7 +2,7 @@ use crate::bridge_engine::{self, Contract, Player, PlayingDeal, PlayingDealResul use crate::card; use crate::card::Deal; use crate::card::Suit; -use crate::components::{Bidding, Hand, ShowBid}; +use crate::components::{Bidding, Hand, ShowBid, TrickInPlay}; use log::{error, info}; use yew::prelude::*; @@ -108,7 +108,18 @@ pub fn game() -> Html { <Bidding {on_contract} dealer={dealer.clone()} /> } } - GameState::Play { .. } => html! { <p>{ "Time to play" }</p> }, + GameState::Play { + playing_deal, + contract, + bidding, + } => { + html! { + <> + <p>{ "Time to play" }</p> + <TrickInPlay in_progress={ playing_deal.trick_in_play().clone() } /> + </> + } + }, GameState::PassedOut { .. } => html! { <p>{ "Everyone passed" }</p> }, }; diff --git a/webapp/src/components/trick_in_play.rs b/webapp/src/components/trick_in_play.rs new file mode 100644 index 0000000..086a422 --- /dev/null +++ b/webapp/src/components/trick_in_play.rs @@ -0,0 +1,23 @@ +use yew::prelude::*; +use crate::bridge_engine::PlayTurn; +use crate::components::Card; + +#[function_component(TrickInPlay)] +pub fn trick_in_play(props: &TrickInPlayProps) -> Html { + let cards = props.in_progress.cards_played().iter().map(|card| { + html! { + <Card card={ card.clone() } /> + } + }); +html! { + <> + <p>{ format!("Leader: {:?}", props.in_progress.leader()) }</p> + { for cards } + </> +} +} + +#[derive(PartialEq, Properties, Clone)] +pub struct TrickInPlayProps { + pub in_progress: PlayTurn, +} |