From: Ian Jackson Date: Thu, 25 Mar 2021 18:46:41 +0000 (+0000) Subject: piece aliases: Define the new aliases, according to the game spec X-Git-Tag: otter-0.5.0~402 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b94fec83d23b30d16d938ebd67ec376b4235a770;p=otter.git piece aliases: Define the new aliases, according to the game spec Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 0d36043c..304456d4 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -667,6 +667,7 @@ mod reset_game { table_size, pieces, table_colour, + pcaliases, } = read_spec(&ma, &args.game_file)?; let mut insns = vec![]; @@ -695,6 +696,10 @@ mod reset_game { insns.push(MgmtGameInstruction::DeletePieceAlias(p)); } + for (alias, target) in pcaliases.into_iter() { + insns.push(MGI::DefinePieceAlias{ alias, target }); + } + if let Some(table_size) = table_size { insns.push(MGI::SetTableSize(table_size)); } diff --git a/src/spec.rs b/src/spec.rs index 41a1b528..7da64d57 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -163,6 +163,7 @@ pub struct GameSpec { pub table_size: Option, pub pieces: Vec, pub table_colour: Option, + #[serde(default)] pub pcaliases: HashMap>, } #[derive(Debug, Serialize, Deserialize)]