add more game stats
This commit is contained in:
parent
e473114bec
commit
4734227da0
4 changed files with 21 additions and 3 deletions
|
@ -18,6 +18,9 @@ pub fn Game() -> impl IntoView {
|
||||||
let (game_host, set_game_host) = create_signal("".to_string());
|
let (game_host, set_game_host) = create_signal("".to_string());
|
||||||
let (game_players, set_game_players) = create_signal(vec![]);
|
let (game_players, set_game_players) = create_signal(vec![]);
|
||||||
let (game_czar, set_game_czar) = create_signal("".to_string());
|
let (game_czar, set_game_czar) = create_signal("".to_string());
|
||||||
|
let (game_white_count, set_game_white_count) = create_signal(0usize);
|
||||||
|
let (game_black_count, set_game_black_count) = create_signal(0usize);
|
||||||
|
let (game_white_discard_count, set_game_white_discard_count) = create_signal(0usize);
|
||||||
let (game_black, set_game_black) = create_signal(("".to_string(), 0u8));
|
let (game_black, set_game_black) = create_signal(("".to_string(), 0u8));
|
||||||
let (selected_cards_ordered, set_selected_cards_ordered) = create_signal::<Vec<String>>(vec![]);
|
let (selected_cards_ordered, set_selected_cards_ordered) = create_signal::<Vec<String>>(vec![]);
|
||||||
let (player_hand, set_player_hand) = create_signal::<Vec<String>>(vec![]);
|
let (player_hand, set_player_hand) = create_signal::<Vec<String>>(vec![]);
|
||||||
|
@ -40,6 +43,9 @@ pub fn Game() -> impl IntoView {
|
||||||
set_player_white.update(|hand| {
|
set_player_white.update(|hand| {
|
||||||
hand.clear();
|
hand.clear();
|
||||||
});
|
});
|
||||||
|
set_game_white_count(0usize);
|
||||||
|
set_game_black_count(0usize);
|
||||||
|
set_game_white_discard_count(0usize);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,6 +105,9 @@ pub fn Game() -> impl IntoView {
|
||||||
set_game_players(game.players.clone());
|
set_game_players(game.players.clone());
|
||||||
set_game_czar(game.czar.clone());
|
set_game_czar(game.czar.clone());
|
||||||
set_game_black(game.black.clone());
|
set_game_black(game.black.clone());
|
||||||
|
set_game_white_count(game.white_count.clone());
|
||||||
|
set_game_black_count(game.black_count.clone());
|
||||||
|
set_game_white_discard_count(game.white_discard_count.clone());
|
||||||
|
|
||||||
// Load hand
|
// Load hand
|
||||||
for card in game.white {
|
for card in game.white {
|
||||||
|
@ -176,6 +185,9 @@ pub fn Game() -> impl IntoView {
|
||||||
<p>Name: {move || game_name()}</p>
|
<p>Name: {move || game_name()}</p>
|
||||||
<p>Host: {move || game_host()}</p>
|
<p>Host: {move || game_host()}</p>
|
||||||
<p>Czar: {move || game_czar()}</p>
|
<p>Czar: {move || game_czar()}</p>
|
||||||
|
<p>White Deck: {move || game_white_count().to_string()}</p>
|
||||||
|
<p>White Discard: {move || game_white_discard_count().to_string()}</p>
|
||||||
|
<p>Black Deck: {move || game_black_count().to_string()}</p>
|
||||||
</span>
|
</span>
|
||||||
<span class="absolute top-0 right-0">
|
<span class="absolute top-0 right-0">
|
||||||
<p>Players:</p>
|
<p>Players:</p>
|
||||||
|
|
|
@ -57,6 +57,9 @@ pub struct GameStateMeta {
|
||||||
pub black: (String, u8),
|
pub black: (String, u8),
|
||||||
pub white: Vec<WhiteCardMeta>,
|
pub white: Vec<WhiteCardMeta>,
|
||||||
pub packs: Vec<u8>,
|
pub packs: Vec<u8>,
|
||||||
|
pub white_count: usize,
|
||||||
|
pub black_count: usize,
|
||||||
|
pub white_discard_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Game browser meta
|
/// Game browser meta
|
||||||
|
|
|
@ -73,11 +73,11 @@ pub struct Game {
|
||||||
/// Judge pile that contains cards
|
/// Judge pile that contains cards
|
||||||
judge_pile: HashMap<String, Arc<CardWhiteWithID>>,
|
judge_pile: HashMap<String, Arc<CardWhiteWithID>>,
|
||||||
/// White draw pile
|
/// White draw pile
|
||||||
white: Vec<Arc<CardWhiteWithID>>,
|
pub white: Vec<Arc<CardWhiteWithID>>,
|
||||||
/// White discard pile
|
/// White discard pile
|
||||||
white_discard: Vec<Arc<CardWhiteWithID>>,
|
pub white_discard: Vec<Arc<CardWhiteWithID>>,
|
||||||
/// Black draw pile
|
/// Black draw pile
|
||||||
black: Vec<Arc<CardBlackWithID>>,
|
pub black: Vec<Arc<CardBlackWithID>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Game {
|
impl Game {
|
||||||
|
|
|
@ -249,6 +249,9 @@ impl GameHandler {
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
packs: this_game.read().unwrap().packs.clone(),
|
packs: this_game.read().unwrap().packs.clone(),
|
||||||
|
white_count: this_game.read().unwrap().white.len(),
|
||||||
|
black_count: this_game.read().unwrap().black.len(),
|
||||||
|
white_discard_count: this_game.read().unwrap().white_discard.len(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send user's update
|
// Send user's update
|
||||||
|
|
Loading…
Add table
Reference in a new issue