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! {
|
view! {
|
||||||
<Show when=move || { game_meta().is_some() }>
|
<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">
|
<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="p-4">{game_meta().unwrap().black.unwrap().text}</p>
|
||||||
<p class="absolute right-4 bottom-4">Pick: {game_meta().unwrap().black.1}</p>
|
<p class="absolute right-4 bottom-4">
|
||||||
|
Pick: {game_meta().unwrap().black.unwrap().pick}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,14 @@ pub fn PlayingView() -> impl IntoView {
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if card_clicked() != "".to_string()
|
if card_clicked() != "".to_string()
|
||||||
&& !submitted()
|
&& !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
|
if let Some(clicked_card) = player_hand
|
||||||
.get_untracked()
|
.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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,10 +91,21 @@ pub struct GameMeta {
|
||||||
pub white_discard_count: u32,
|
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
|
/// Game state meta
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Message, Serialize, Deserialize)]
|
||||||
pub struct GameStateMeta {
|
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>,
|
pub white: Vec<WhiteCardMeta>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,10 +251,10 @@ impl GameHandler {
|
||||||
for player in this_game.players.values() {
|
for player in this_game.players.values() {
|
||||||
// Create update for user's game view
|
// Create update for user's game view
|
||||||
let meta = GameStateMeta {
|
let meta = GameStateMeta {
|
||||||
black: (
|
black: Some(BlackCardMeta {
|
||||||
this_game.current_black.text.clone(),
|
text: this_game.current_black.text.clone(),
|
||||||
this_game.current_black.pick,
|
pick: this_game.current_black.pick.try_into().unwrap(),
|
||||||
),
|
}),
|
||||||
white: player
|
white: player
|
||||||
.white
|
.white
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -282,10 +282,10 @@ impl GameHandler {
|
||||||
if let Some(player) = this_game.players.get(&user_id) {
|
if let Some(player) = this_game.players.get(&user_id) {
|
||||||
// Create update for user's game view
|
// Create update for user's game view
|
||||||
let meta = GameStateMeta {
|
let meta = GameStateMeta {
|
||||||
black: (
|
black: Some(BlackCardMeta {
|
||||||
this_game.current_black.text.clone(),
|
text: this_game.current_black.text.clone(),
|
||||||
this_game.current_black.pick,
|
pick: this_game.current_black.pick.try_into().unwrap(),
|
||||||
),
|
}),
|
||||||
white: player
|
white: player
|
||||||
.white
|
.white
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Add table
Reference in a new issue