diff --git a/server/schema/game-config.json b/server/schema/game-config.json index c6e1ac6..62e5d9a 100644 --- a/server/schema/game-config.json +++ b/server/schema/game-config.json @@ -84,6 +84,10 @@ "face_down": { "default": false, "type": "boolean" + }, + "visible": { + "default": true, + "type": "boolean" } }, "additionalProperties": true diff --git a/server/src/games/config.rs b/server/src/games/config.rs index 38a8b1e..1c1d298 100644 --- a/server/src/games/config.rs +++ b/server/src/games/config.rs @@ -36,10 +36,14 @@ pub struct Pile { pub cards: Vec, #[serde(default)] pub face_down: bool, + #[serde(default = "default_visible")] + pub visible: bool, #[serde(flatten)] pub other: HashMap, } +fn default_visible() -> bool {true} + impl Config { pub fn load + std::fmt::Debug>(file: P) -> Self { let s: Config = serde_json::from_reader(std::fs::File::open(&file).unwrap()) diff --git a/server/src/games/run/types.rs b/server/src/games/run/types.rs index 9ffda68..4d22b77 100644 --- a/server/src/games/run/types.rs +++ b/server/src/games/run/types.rs @@ -172,6 +172,7 @@ impl Debug for Card { pub struct RunningPile { pub cards: Vec, pub face_down: bool, + pub visible: bool, #[serde(flatten)] pub other: HashMap, } @@ -183,6 +184,7 @@ impl RunningPile { cards: p.cards.into_iter().map(|kind| {let other = available_cards.get(&kind).unwrap().other.clone(); Card {kind, uuid: Uuid::new_v4(), other}}).collect(), other: p.other, face_down: p.face_down, + visible: p.visible } } } @@ -195,6 +197,7 @@ impl RunningPile { rhai::serde::from_dynamic(map.get("cards").ok_or("Pile doesn't have property cards")?)?; let face_down: bool = rhai::serde::from_dynamic(map.get("face_down").ok_or("Pile doesn't have property face_down")?)?; + let visible: bool = rhai::serde::from_dynamic(map.get("visible").ok_or("Pile doesn't have property visible")?)?; let other_fallible: Vec>> = map.into_iter() @@ -210,6 +213,6 @@ impl RunningPile { other.insert(k, v); } - Ok(Self { cards, other, face_down }) + Ok(Self { cards, other, face_down, visible }) } } diff --git a/server/src/server/game.rs b/server/src/server/game.rs index 9be6621..7753ec0 100644 --- a/server/src/server/game.rs +++ b/server/src/server/game.rs @@ -54,6 +54,7 @@ pub(super) async fn get_status(data: &mut ServiceData) -> Result { }) .collect(), face_down: v.face_down, + visible: v.visible }, ) }) @@ -80,6 +81,7 @@ pub(super) async fn get_status(data: &mut ServiceData) -> Result { }) .collect(), face_down: v.face_down, + visible: v.visible }, ) }) diff --git a/server/src/server/protos/game.rs b/server/src/server/protos/game.rs index c80a2f4..4232b3f 100644 --- a/server/src/server/protos/game.rs +++ b/server/src/server/protos/game.rs @@ -91,6 +91,8 @@ pub mod game_status { pub cards: ::prost::alloc::vec::Vec, #[prost(bool, tag="2")] pub face_down: bool, + #[prost(bool, tag="3")] + pub visible: bool, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct Piles {