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,31 +211,42 @@ pub fn Game() -> impl IntoView {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<For
|
<Show
|
||||||
each=move || judge_round().unwrap().cards_to_judge
|
when=move || { judge_round().is_some() }
|
||||||
key=move |_| 69
|
fallback=move || {
|
||||||
children=move |group| {
|
|
||||||
view! {
|
view! {
|
||||||
<div class="m-2 inline-flex flex-wrap justify-center">
|
<p>
|
||||||
<For
|
"You are the czar this round. Cards will appear here once all players have submitted their cards."
|
||||||
each=move || group.clone()
|
</p>
|
||||||
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>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/>
|
>
|
||||||
|
<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>
|
</Show>
|
||||||
|
|
||||||
// Playing view //
|
// Playing view //
|
||||||
|
|
Loading…
Add table
Reference in a new issue