fix game swap card mismatch
This commit is contained in:
parent
11a694bbac
commit
c71e17ff91
1 changed files with 15 additions and 5 deletions
|
@ -26,6 +26,21 @@ pub fn Game() -> impl IntoView {
|
||||||
|
|
||||||
create_effect(move |_| {
|
create_effect(move |_| {
|
||||||
if let Some(game) = game_meta() {
|
if let Some(game) = game_meta() {
|
||||||
|
// Clear in case of (re-)joining game
|
||||||
|
set_card_clicked.update(|list| {
|
||||||
|
list.clear();
|
||||||
|
});
|
||||||
|
set_selected_cards_ordered.update(|list| {
|
||||||
|
list.clear();
|
||||||
|
});
|
||||||
|
set_player_hand.update(|list| {
|
||||||
|
list.clear();
|
||||||
|
});
|
||||||
|
set_player_white.update(|list| {
|
||||||
|
list.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load meta
|
||||||
set_game_id(game.uuid.clone());
|
set_game_id(game.uuid.clone());
|
||||||
set_game_name(game.name.clone());
|
set_game_name(game.name.clone());
|
||||||
set_game_host(game.host.clone());
|
set_game_host(game.host.clone());
|
||||||
|
@ -34,16 +49,11 @@ pub fn Game() -> impl IntoView {
|
||||||
set_game_black(game.black.clone());
|
set_game_black(game.black.clone());
|
||||||
set_game_white(game.white.clone());
|
set_game_white(game.white.clone());
|
||||||
|
|
||||||
// Primitive reset when joining new game
|
|
||||||
set_player_hand(vec![]);
|
|
||||||
set_selected_cards_ordered(vec![]);
|
|
||||||
|
|
||||||
// Load hand
|
// Load hand
|
||||||
for card in game.white {
|
for card in game.white {
|
||||||
set_player_white.update(|hand| {
|
set_player_white.update(|hand| {
|
||||||
hand.insert(card.uuid.clone(), card.clone());
|
hand.insert(card.uuid.clone(), card.clone());
|
||||||
});
|
});
|
||||||
|
|
||||||
set_player_hand.update(|hand| {
|
set_player_hand.update(|hand| {
|
||||||
hand.push(card.uuid.clone());
|
hand.push(card.uuid.clone());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue