From 22452073063b9211aa2aa38a1b1e2cf2e44cf133 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 22 Dec 2022 13:31:24 -0500 Subject: Delete outdated `game` component --- webapp/src/components.rs | 2 - webapp/src/components/game.rs | 135 ------------------------------------------ webapp/src/main.rs | 6 +- webapp/src/routing.rs | 2 - 4 files changed, 1 insertion(+), 144 deletions(-) delete mode 100644 webapp/src/components/game.rs (limited to 'webapp/src') diff --git a/webapp/src/components.rs b/webapp/src/components.rs index aa3636f..d4b03ee 100644 --- a/webapp/src/components.rs +++ b/webapp/src/components.rs @@ -6,7 +6,6 @@ mod bidding_box; mod bidding_table; mod card; mod error_info; -mod game; mod hand; mod show_bid; mod table; @@ -19,7 +18,6 @@ pub use self::bidding_box::*; pub use self::bidding_table::*; pub use self::card::*; pub use self::error_info::*; -pub use self::game::*; pub use self::hand::*; pub use self::show_bid::*; pub use self::table::*; diff --git a/webapp/src/components/game.rs b/webapp/src/components/game.rs deleted file mode 100644 index c590357..0000000 --- a/webapp/src/components/game.rs +++ /dev/null @@ -1,135 +0,0 @@ -use crate::components::{Bidding, Hand, ShowBid, TrickInPlay, TricksPlayed}; -use log::{error, info}; -use protocol::bridge_engine::{ - BiddingState, DealInPlay, DealInPlayResult, GameState, PlayState, Player, -}; -use rand::random; -use yew::prelude::*; - -fn init_state() -> GameState { - GameState::new(random(), Player::East) -} - -#[function_component(Game)] -pub fn game() -> Html { - let state = use_state(|| init_state()); - - let shuffle = { - let state = state.clone(); - Callback::from(move |_| { - state.set(init_state()); - }) - }; - - let on_card_clicked = { - let state = state.clone(); - Callback::from(move |card| { - if let GameState::Play(PlayState { - dealer, - playing_deal, - contract, - bidding, - deal, - .. - }) = (*state).clone() - { - info!("Card clicked: {}", card); - match playing_deal.play(card) { - Err(err) => error!("Could not play card: {:?}", err), - Ok(DealInPlayResult::InProgress(playing_deal)) => { - state.set(GameState::Play(PlayState { - dealer, - playing_deal, - contract, - bidding, - deal, - })) - } - Ok(DealInPlayResult::PlayFinished(_tricks)) => todo!(), - }; - } - }) - }; - - let center = match &*state { - GameState::Bidding(BiddingState { - dealer, - deal, - bidding, - }) => { - let on_contract = { - let state = state.clone(); - let dealer = dealer.clone(); - let deal = deal.clone(); - Callback::from(move |(contract, bidding)| { - state.set(match contract { - Some(contract) => GameState::Play(PlayState { - dealer, - deal: deal.clone(), - playing_deal: DealInPlay::new(dealer, deal.clone()), - contract, - bidding, - }), - None => GameState::PassedOut { - dealer: dealer, - deal: deal.clone(), - bidding: bidding, - }, - }); - }) - }; - html! { - - } - } - GameState::Play(PlayState { - deal, - dealer, - playing_deal, - contract: _, - bidding: _, - }) => { - html! { - <> - - - - } - } - GameState::PassedOut { .. } => html! {

{ "Everyone passed" }

}, - }; - - html! { - <> - -
- { center } -
-
- -
-
- -
-
- -
-
- -
- - } -} diff --git a/webapp/src/main.rs b/webapp/src/main.rs index f99dfe0..73531d5 100644 --- a/webapp/src/main.rs +++ b/webapp/src/main.rs @@ -4,7 +4,7 @@ use yew::prelude::*; use yew_router::prelude::*; pub mod components; pub mod utils; -use components::{AppContextProvider, ErrorInfo, Game, OnlineTable}; +use components::{AppContextProvider, ErrorInfo, OnlineTable}; extern crate wee_alloc; pub mod routing; use crate::{components::use_app_context, routing::Route}; @@ -60,7 +60,6 @@ fn home() -> Html { html! {
  • { user }
  • -
  • to={Route::Playground}>{ "Playground" }>
} @@ -79,9 +78,6 @@ fn header() -> Html { fn switch(routes: &Route) -> Html { let main = match routes { Route::Home => html! { }, - Route::Playground => html! { -
- }, Route::Table { id } => html! { }, diff --git a/webapp/src/routing.rs b/webapp/src/routing.rs index e451791..57d4af0 100644 --- a/webapp/src/routing.rs +++ b/webapp/src/routing.rs @@ -5,8 +5,6 @@ use uuid::Uuid; pub enum Route { #[at("/")] Home, - #[at("/playground")] - Playground, #[at("/table/:id")] Table { id: Uuid }, } -- cgit v1.2.3