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 game_meta = expect_context::<ReadSignal<Option<GameStateMeta>>>();
|
||||
let judge_round = expect_context::<ReadSignal<Option<JudgeRound>>>();
|
||||
let user_update = expect_context::<ReadSignal<Option<UserUpdate>>>();
|
||||
|
||||
// Signals //
|
||||
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 //
|
||||
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 {
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<For
|
||||
each=move || judge_round().unwrap().cards_to_judge
|
||||
key=move |_| 69
|
||||
children=move |group| {
|
||||
<Show
|
||||
when=move || { judge_round().is_some() }
|
||||
fallback=move || {
|
||||
view! {
|
||||
<div class="m-2 inline-flex flex-wrap justify-center">
|
||||
<For
|
||||
each=move || group.clone()
|
||||
key=move |card| card.uuid.clone()
|
||||
children=move |card| {
|
||||
view! {
|
||||
// Hide cards from hand view when they exist as selected
|
||||
<Show when={
|
||||
let waste_of_memory = card.clone();
|
||||
move || { !selected_cards().contains(&waste_of_memory) }
|
||||
}>
|
||||
<WhiteCard card_data=card.clone() />
|
||||
</Show>
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<p>
|
||||
"You are the czar this round. Cards will appear here once all players have submitted their cards."
|
||||
</p>
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<For
|
||||
each=move || judge_round().unwrap().cards_to_judge
|
||||
key=move |_| 69
|
||||
children=move |group| {
|
||||
view! {
|
||||
<div class="m-2 inline-flex flex-wrap justify-center">
|
||||
<For
|
||||
each=move || group.clone()
|
||||
key=move |card| card.uuid.clone()
|
||||
children=move |card| {
|
||||
view! {
|
||||
// Hide cards from hand view when they exist as selected
|
||||
<Show when={
|
||||
let waste_of_memory = card.clone();
|
||||
move || { !selected_cards().contains(&waste_of_memory) }
|
||||
}>
|
||||
<WhiteCard card_data=card.clone() />
|
||||
</Show>
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
/>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
// Playing view //
|
||||
|
|
Loading…
Add table
Reference in a new issue