fix game lockup when submitting > 0 but < required number of cards
This commit is contained in:
parent
21477d09f8
commit
5e65765be1
2 changed files with 11 additions and 4 deletions
|
@ -3,7 +3,7 @@ use crate::components::websocket::WebSocketContext;
|
|||
use leptos::*;
|
||||
use lib::*;
|
||||
use serde_json::to_string;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[component]
|
||||
pub fn PlayingView() -> impl IntoView {
|
||||
|
@ -13,7 +13,8 @@ pub fn PlayingView() -> impl IntoView {
|
|||
|
||||
// Signals
|
||||
let (selected_cards, set_selected_cards) = create_signal::<Vec<WhiteCardMeta>>(vec![]);
|
||||
let (submitted_cards, set_submitted_cards) = create_signal::<Vec<WhiteCardMeta>>(vec![]);
|
||||
let (submitted_cards, set_submitted_cards) =
|
||||
create_signal::<HashSet<WhiteCardMeta>>(HashSet::new());
|
||||
let (card_clicked, set_card_clicked) = create_signal::<String>(String::new());
|
||||
let (submitted, set_submitted) = create_signal(false);
|
||||
let (player_hand, set_player_hand) =
|
||||
|
@ -85,9 +86,15 @@ pub fn PlayingView() -> impl IntoView {
|
|||
.unwrap();
|
||||
|
||||
set_submitted_cards.update_untracked(|cards| {
|
||||
cards.extend(selected_cards.get_untracked());
|
||||
for card in selected_cards.get_untracked() {
|
||||
cards.insert(card);
|
||||
}
|
||||
});
|
||||
|
||||
if submitted_cards().len() < game_meta().unwrap().black.1.into() {
|
||||
return;
|
||||
}
|
||||
|
||||
websocket.send(&msg);
|
||||
set_selected_cards.update_untracked(|list| {
|
||||
list.clear();
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct PlayerMoveRequest {
|
|||
}
|
||||
|
||||
/// White Card Meta
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WhiteCardMeta {
|
||||
pub uuid: String,
|
||||
pub text: String,
|
||||
|
|
Loading…
Add table
Reference in a new issue