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 leptos::*;
|
||||||
use lib::*;
|
use lib::*;
|
||||||
use serde_json::to_string;
|
use serde_json::to_string;
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn PlayingView() -> impl IntoView {
|
pub fn PlayingView() -> impl IntoView {
|
||||||
|
@ -13,7 +13,8 @@ pub fn PlayingView() -> impl IntoView {
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
let (selected_cards, set_selected_cards) = create_signal::<Vec<WhiteCardMeta>>(vec![]);
|
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 (card_clicked, set_card_clicked) = create_signal::<String>(String::new());
|
||||||
let (submitted, set_submitted) = create_signal(false);
|
let (submitted, set_submitted) = create_signal(false);
|
||||||
let (player_hand, set_player_hand) =
|
let (player_hand, set_player_hand) =
|
||||||
|
@ -85,9 +86,15 @@ pub fn PlayingView() -> impl IntoView {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
set_submitted_cards.update_untracked(|cards| {
|
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);
|
websocket.send(&msg);
|
||||||
set_selected_cards.update_untracked(|list| {
|
set_selected_cards.update_untracked(|list| {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub struct PlayerMoveRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// White Card Meta
|
/// White Card Meta
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct WhiteCardMeta {
|
pub struct WhiteCardMeta {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
pub text: String,
|
pub text: String,
|
||||||
|
|
Loading…
Add table
Reference in a new issue