better judging flow
This commit is contained in:
parent
781357512b
commit
d1054ed672
1 changed files with 50 additions and 24 deletions
|
@ -25,6 +25,7 @@ pub fn Game() -> impl IntoView {
|
||||||
let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open;
|
let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open;
|
||||||
let game_meta = expect_context::<ReadSignal<Option<GameStateMeta>>>();
|
let game_meta = expect_context::<ReadSignal<Option<GameStateMeta>>>();
|
||||||
let judge_round = expect_context::<ReadSignal<Option<JudgeRound>>>();
|
let judge_round = expect_context::<ReadSignal<Option<JudgeRound>>>();
|
||||||
|
let user_update = expect_context::<ReadSignal<Option<UserUpdate>>>();
|
||||||
|
|
||||||
// Signals //
|
// Signals //
|
||||||
let (selected_cards, set_selected_cards) = create_signal::<Vec<WhiteCardMeta>>(vec![]);
|
let (selected_cards, set_selected_cards) = create_signal::<Vec<WhiteCardMeta>>(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 //
|
// On Incoming Judge //
|
||||||
create_effect(move |_| {
|
create_effect(move |_| {
|
||||||
// Clear selected cards
|
// Clear selected cards
|
||||||
|
@ -59,7 +76,6 @@ pub fn Game() -> impl IntoView {
|
||||||
set_selected_cards.update(|list| {
|
set_selected_cards.update(|list| {
|
||||||
list.clear();
|
list.clear();
|
||||||
});
|
});
|
||||||
set_judging(true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +108,6 @@ pub fn Game() -> impl IntoView {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
set_websocket_send(msg);
|
set_websocket_send(msg);
|
||||||
set_judging(false);
|
|
||||||
set_selected_cards.update(|list| {
|
set_selected_cards.update(|list| {
|
||||||
list.clear();
|
list.clear();
|
||||||
});
|
});
|
||||||
|
@ -196,6 +211,16 @@ pub fn Game() -> impl IntoView {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Show
|
||||||
|
when=move || { judge_round().is_some() }
|
||||||
|
fallback=move || {
|
||||||
|
view! {
|
||||||
|
<p>
|
||||||
|
"You are the czar this round. Cards will appear here once all players have submitted their cards."
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
<For
|
<For
|
||||||
each=move || judge_round().unwrap().cards_to_judge
|
each=move || judge_round().unwrap().cards_to_judge
|
||||||
key=move |_| 69
|
key=move |_| 69
|
||||||
|
@ -222,6 +247,7 @@ pub fn Game() -> impl IntoView {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
|
</Show>
|
||||||
|
|
||||||
// Playing view //
|
// Playing view //
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue