No known key found for this signature in database
GPG Key ID: FD81DE6D75E20917
5 changed files with
16 additions and
1 deletions
-
server/schema/game-config.json
-
server/src/games/config.rs
-
server/src/games/run/types.rs
-
server/src/server/game.rs
-
server/src/server/protos/game.rs
|
|
|
@ -84,6 +84,10 @@ |
|
|
|
"face_down": { |
|
|
|
"default": false, |
|
|
|
"type": "boolean" |
|
|
|
}, |
|
|
|
"visible": { |
|
|
|
"default": true, |
|
|
|
"type": "boolean" |
|
|
|
} |
|
|
|
}, |
|
|
|
"additionalProperties": true |
|
|
|
|
|
|
|
@ -36,10 +36,14 @@ pub struct Pile { |
|
|
|
pub cards: Vec<String>, |
|
|
|
#[serde(default)] |
|
|
|
pub face_down: bool, |
|
|
|
#[serde(default = "default_visible")] |
|
|
|
pub visible: bool, |
|
|
|
#[serde(flatten)] |
|
|
|
pub other: HashMap<String, serde_json::Value>, |
|
|
|
} |
|
|
|
|
|
|
|
fn default_visible() -> bool {true} |
|
|
|
|
|
|
|
impl Config { |
|
|
|
pub fn load<P: AsRef<std::path::Path> + std::fmt::Debug>(file: P) -> Self { |
|
|
|
let s: Config = serde_json::from_reader(std::fs::File::open(&file).unwrap()) |
|
|
|
|
|
|
|
@ -172,6 +172,7 @@ impl Debug for Card { |
|
|
|
pub struct RunningPile { |
|
|
|
pub cards: Vec<Card>, |
|
|
|
pub face_down: bool, |
|
|
|
pub visible: bool, |
|
|
|
#[serde(flatten)] |
|
|
|
pub other: HashMap<String, serde_json::Value>, |
|
|
|
} |
|
|
|
@ -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<Result<(String, serde_json::Value), Box<rhai::EvalAltResult>>> = |
|
|
|
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 }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -54,6 +54,7 @@ pub(super) async fn get_status(data: &mut ServiceData) -> Result<GameStatus> { |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
face_down: v.face_down, |
|
|
|
visible: v.visible |
|
|
|
}, |
|
|
|
) |
|
|
|
}) |
|
|
|
@ -80,6 +81,7 @@ pub(super) async fn get_status(data: &mut ServiceData) -> Result<GameStatus> { |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
face_down: v.face_down, |
|
|
|
visible: v.visible |
|
|
|
}, |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
|
@ -91,6 +91,8 @@ pub mod game_status { |
|
|
|
pub cards: ::prost::alloc::vec::Vec<Card>, |
|
|
|
#[prost(bool, tag="2")] |
|
|
|
pub face_down: bool, |
|
|
|
#[prost(bool, tag="3")] |
|
|
|
pub visible: bool, |
|
|
|
} |
|
|
|
#[derive(Clone, PartialEq, ::prost::Message)] |
|
|
|
pub struct Piles { |
|
|
|
|