insns.push(MGI::DefinePieceAlias{ alias, target });
}
- if let Some(table_size) = table_size {
- insns.push(MGI::SetTableSize(table_size));
- }
- if let Some(table_colour) = table_colour {
- insns.push(MGI::SetTableColour(table_colour));
- }
+ insns.push(MGI::SetTableSize(table_size));
+ insns.push(MGI::SetTableColour(table_colour));
for pspec in pieces.into_iter() {
insns.push(MGI::AddPieces(pspec));
pub struct Timestamp(pub u64); /* time_t */
pub const DEFAULT_TABLE_SIZE: Pos = PosC::new( 400, 200 );
+pub const DEFAULT_TABLE_COLOUR: &str = "green";
// ---------- general data types ----------
#[derive(Debug,Serialize,Deserialize)]
pub struct GameSpec {
- pub table_size: Option<Pos>,
+ #[serde(default="imp::def_table_size")] pub table_size: Pos,
pub pieces: Vec<PiecesSpec>,
- pub table_colour: Option<ColourSpec>,
+ #[serde(default="imp::def_table_colour")] pub table_colour: ColourSpec,
#[serde(default)] pub pcaliases: HashMap<String, Box<dyn PieceSpec>>,
}
type AS = AccountScope;
type TPS = TablePlayerSpec;
+ pub fn def_table_size() -> Pos {
+ DEFAULT_TABLE_SIZE
+ }
+ pub fn def_table_colour() -> ColourSpec {
+ ColourSpec(DEFAULT_TABLE_COLOUR.into())
+ }
+
impl Default for piece_specs::PieceLabelPlace {
fn default() -> Self { Self::BottomLeft }
}
Ok::<_,AE>(())
};
- let table_size = self.spec.table_size
- .ok_or(anyhow!("table size missing from spec"))?;
+ let table_size = self.spec.table_size;
let exp_end = {
let mut w = su.w(&self.alice)?;