From 103a92b48639058cedb663083177f3899c59f3e6 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:51:51 -0400 Subject: [PATCH] create_game bandaid --- client/src/components/create_game.rs | 54 ++++++++++++++++++---------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/client/src/components/create_game.rs b/client/src/components/create_game.rs index 684a172..0818023 100644 --- a/client/src/components/create_game.rs +++ b/client/src/components/create_game.rs @@ -10,20 +10,38 @@ use std::collections::BTreeSet; pub fn CreateGame() -> impl IntoView { // Websocket stuff let websocket = expect_context::(); - let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open; - let tx = websocket.clone(); let (websocket_send, set_websocket_send) = create_signal("".to_string()); + + let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open; + + let tx = websocket.clone(); create_effect(move |_| { - tx.send(&websocket_send()); + if websocket_send() != "".to_string() { + tx.send(&websocket_send()); + } }); // New game stuff let card_packs = expect_context::>(); - let new_game_name_ref = create_node_ref::(); + let (show_packs, set_show_packs) = create_signal(false); - let show_packs_button = move |_| set_show_packs(!show_packs()); let (selected_packs, set_selected_packs) = create_signal::>(BTreeSet::new()); - let new_game = move |_| { + + create_effect(move |_| { + set_selected_packs + .update(|set| set.extend(card_packs().official_meta.iter().map(|pack| pack.pack))); + }); + + create_effect(move |_| { + set_selected_packs + .update(|set| set.extend(card_packs().unofficial_meta.iter().map(|pack| pack.pack))); + }); + + let new_game_name_ref = create_node_ref::(); + + let toggle_show_packs = move |_| set_show_packs(!show_packs()); + + let request_new_game = move |_| { if let Some(input) = new_game_name_ref.get() { if input.value() == *"" { logging::log!("New game name is empty!"); @@ -46,7 +64,7 @@ pub fn CreateGame() -> impl IntoView {
Disconnected.

}>
-
+

Create Game

impl IntoView { />

Packs

- + // +

"All 205 card packs are enabled by default"

+ - - - "click custom at least once for the new game button to work. there are worse problems right now (sorry (kinda))"