wtf
This commit is contained in:
parent
59214e4d12
commit
66b3a51b8d
4 changed files with 42 additions and 14 deletions
|
@ -7,8 +7,10 @@ pub fn BlackCard() -> impl IntoView {
|
|||
view! {
|
||||
<Show when=move || { game_meta().is_some() }>
|
||||
<div class="relative m-2 w-36 h-56 shrink-0 text-white bg-black rounded-lg shadow-black shadow-md">
|
||||
<p class="p-4">{game_meta().unwrap().black.0}</p>
|
||||
<p class="absolute right-4 bottom-4">Pick: {game_meta().unwrap().black.1}</p>
|
||||
<p class="p-4">{game_meta().unwrap().black.unwrap().text}</p>
|
||||
<p class="absolute right-4 bottom-4">
|
||||
Pick: {game_meta().unwrap().black.unwrap().pick}
|
||||
</p>
|
||||
</div>
|
||||
</Show>
|
||||
}
|
||||
|
|
|
@ -48,7 +48,14 @@ pub fn PlayingView() -> impl IntoView {
|
|||
Effect::new(move |_| {
|
||||
if card_clicked() != "".to_string()
|
||||
&& !submitted()
|
||||
&& submitted_cards().len() < game_state().unwrap().black.1.into()
|
||||
&& submitted_cards().len()
|
||||
< game_state()
|
||||
.unwrap()
|
||||
.black
|
||||
.unwrap()
|
||||
.pick
|
||||
.try_into()
|
||||
.unwrap()
|
||||
{
|
||||
if let Some(clicked_card) = player_hand
|
||||
.get_untracked()
|
||||
|
@ -86,7 +93,15 @@ pub fn PlayingView() -> impl IntoView {
|
|||
}
|
||||
});
|
||||
|
||||
if submitted_cards().len() < game_state().unwrap().black.1.into() {
|
||||
if submitted_cards().len()
|
||||
< game_state()
|
||||
.unwrap()
|
||||
.black
|
||||
.unwrap()
|
||||
.pick
|
||||
.try_into()
|
||||
.unwrap()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,10 +91,21 @@ pub struct GameMeta {
|
|||
pub white_discard_count: u32,
|
||||
}
|
||||
|
||||
/// Black card meta
|
||||
#[derive(Clone, Message, Serialize, Deserialize)]
|
||||
pub struct BlackCardMeta {
|
||||
#[prost(string, tag = "1")]
|
||||
pub text: String,
|
||||
#[prost(uint32, tag = "2")]
|
||||
pub pick: u32,
|
||||
}
|
||||
|
||||
/// Game state meta
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Message, Serialize, Deserialize)]
|
||||
pub struct GameStateMeta {
|
||||
pub black: (String, u8),
|
||||
#[prost(message, tag = "1")]
|
||||
pub black: Option<BlackCardMeta>, // this has to be an option or prost gets cranky
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub white: Vec<WhiteCardMeta>,
|
||||
}
|
||||
|
||||
|
|
|
@ -251,10 +251,10 @@ impl GameHandler {
|
|||
for player in this_game.players.values() {
|
||||
// Create update for user's game view
|
||||
let meta = GameStateMeta {
|
||||
black: (
|
||||
this_game.current_black.text.clone(),
|
||||
this_game.current_black.pick,
|
||||
),
|
||||
black: Some(BlackCardMeta {
|
||||
text: this_game.current_black.text.clone(),
|
||||
pick: this_game.current_black.pick.try_into().unwrap(),
|
||||
}),
|
||||
white: player
|
||||
.white
|
||||
.iter()
|
||||
|
@ -282,10 +282,10 @@ impl GameHandler {
|
|||
if let Some(player) = this_game.players.get(&user_id) {
|
||||
// Create update for user's game view
|
||||
let meta = GameStateMeta {
|
||||
black: (
|
||||
this_game.current_black.text.clone(),
|
||||
this_game.current_black.pick,
|
||||
),
|
||||
black: Some(BlackCardMeta {
|
||||
text: this_game.current_black.text.clone(),
|
||||
pick: this_game.current_black.pick.try_into().unwrap(),
|
||||
}),
|
||||
white: player
|
||||
.white
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Reference in a new issue