diff --git a/client/src/components/game.rs b/client/src/components/game.rs index dbab2e5..aa0c948 100644 --- a/client/src/components/game.rs +++ b/client/src/components/game.rs @@ -25,6 +25,7 @@ pub fn Game() -> impl IntoView { let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open; let game_meta = expect_context::>>(); let judge_round = expect_context::>>(); + let user_update = expect_context::>>(); // Signals // let (selected_cards, set_selected_cards) = create_signal::>(vec![]); @@ -52,6 +53,22 @@ pub fn Game() -> impl IntoView { }); }); + // Determine judging + create_effect(move |_| { + user_update.with(move |user_meta| { + if let Some(user_meta) = user_meta { + if let Some(game_meta) = game_meta() { + logging::log!("{} {}", user_meta.username, game_meta.czar); + if user_meta.username == game_meta.czar { + set_judging(true); + } else { + set_judging(false); + } + } + } + }) + }); + // On Incoming Judge // create_effect(move |_| { // Clear selected cards @@ -59,7 +76,6 @@ pub fn Game() -> impl IntoView { set_selected_cards.update(|list| { list.clear(); }); - set_judging(true); } }); @@ -92,7 +108,6 @@ pub fn Game() -> impl IntoView { .unwrap(); set_websocket_send(msg); - set_judging(false); set_selected_cards.update(|list| { list.clear(); }); @@ -196,31 +211,42 @@ pub fn Game() -> impl IntoView { - - - - - } - } - /> - +

+ "You are the czar this round. Cards will appear here once all players have submitted their cards." +

} } - /> + > + + + + + } + } + /> + + } + } + /> + // Playing view //