diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-29 14:44:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-29 14:44:14 +0200 |
commit | 7df4af963c93e3bfc92f9e42b9e946186c1f89d2 (patch) | |
tree | 39c2f854f99d1b14947527a88977311618b34095 | |
parent | cfb256390ef7367d272d8e17e38719d5104a62fc (diff) | |
download | hurrycurry-7df4af963c93e3bfc92f9e42b9e946186c1f89d2.tar hurrycurry-7df4af963c93e3bfc92f9e42b9e946186c1f89d2.tar.bz2 hurrycurry-7df4af963c93e3bfc92f9e42b9e946186c1f89d2.tar.zst |
change maps again and change spec order
-rw-r--r-- | data/maps/big.yaml | 16 | ||||
-rw-r--r-- | data/maps/small.yaml | 32 | ||||
-rw-r--r-- | server/src/bin/graph.rs | 2 | ||||
-rw-r--r-- | server/src/data.rs | 21 | ||||
-rw-r--r-- | server/src/state.rs | 6 |
5 files changed, 37 insertions, 40 deletions
diff --git a/data/maps/big.yaml b/data/maps/big.yaml index 2ac5d2e0..88a1726c 100644 --- a/data/maps/big.yaml +++ b/data/maps/big.yaml @@ -17,14 +17,14 @@ map: - "*''''*'''*'''''*'''*'''*'''*''*'" - "'''*''''*'*'**'''*''**''**''*'''" - "''██▒██▒██▒███▒███▒████▒██▒███*'" - - "''█ctc.ctc.ctc.ctc.ctc█p....s█**" - - "''█.....c.............█p....s█''" - - "'*▒c...c...████www██dd█p.⌷.⌷⌷█*'" - - "*'█tc.ctc..█⌷.C...ff..d..⌷..L█''" - - "''▒c...c...█⌷.C.....~.d..⌷..R█'*" - - "*'█c.......w..⌷⌷⌷⌷⌷⌷⌷⌷█⌷.⌷..T█*'" - - "'*▒tc......w..........d..⌷..F█''" - - "''█c.....ct█⌷S⌷S⌷S⌷⌷oo█⌷⌷⌷..X█*'" + - "''█ctc.ctc.ctc.ctc.ctc█s....p█**" + - "''█.....c.............█s.~..⌷█''" + - "'*▒c...c...████www██dd█⌷⌷.⌷.⌷█*'" + - "*'█tc.ctc..█⌷.....CC..d...⌷.L█''" + - "''▒c...c...w..⌷⌷......d...⌷.R█'*" + - "*'█c.......w..⌷⌷⌷⌷⌷⌷⌷⌷█ff.⌷.T█*'" + - "'*▒tc......w..........d...⌷.F█''" + - "''█c.....ct█⌷SSS⌷f⌷oo⌷█⌷⌷...X█*'" - "*'████dd██████████▒███████▒███'*" - "'''*''__''''''''''''''''''''''*'" - "*'''*'__________________________" diff --git a/data/maps/small.yaml b/data/maps/small.yaml index ed2f7545..768793a3 100644 --- a/data/maps/small.yaml +++ b/data/maps/small.yaml @@ -14,22 +14,22 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # map: - - "*''''*'''*'''''*'''*'''*''" - - "'''*''''*'*'**'''*''**'''*" - - "''████▒████▒████▒████▒██*'" - - "''█ctc.ctc.ctc.ctc.ctc.█**" - - "''▒.....c..............█''" - - "'*█c...c...████www██dd██*'" - - "*'█tc.ctc..█sCC...f⌷..L█''" - - "''▒c...c...█.........~R█'*" - - "*'█c.......█⌷⌷pp⌷⌷⌷⌷..T█*'" - - "'*█tc......█..........F█'*" - - "''█c.....ct█⌷oo⌷⌷⌷SSS⌷X█*'" - - "*'████dd██████▒█████▒███*'" - - "'*''''__'''''''''''''''''*" - - "*'*'''____________________" - - "'''*''___________________!" - - "'*''''''''''''''''''''''''" + - "*''''*'''*'''''*''*'''*''" + - "'''*''''*'*'**'''''**'''*" + - "''████▒████▒████▒███▒██*'" + - "''█ctc.ctc.ctc.ctc.ctc█**" + - "''▒.....c.............█''" + - "'*█c...c...████ww██dd██*'" + - "*'█tc.ctc..█sCC..f⌷..L█''" + - "''▒c...c...w....~....R█'*" + - "*'█c.......w.⌷⌷⌷⌷⌷⌷..T█*'" + - "'*█tc......w.........F█'*" + - "''█c.....ct█⌷⌷oo⌷SSS⌷X█''" + - "*'████dd██████▒████▒███*'" + - "'*''''__''''''''''''''''*" + - "*'*'''___________________" + - "'''*''__________________!" + - "'*'''''''''''''''''''''''" tiles: "⌷": counter diff --git a/server/src/bin/graph.rs b/server/src/bin/graph.rs index 817352c1..deae2034 100644 --- a/server/src/bin/graph.rs +++ b/server/src/bin/graph.rs @@ -32,7 +32,7 @@ fn main() -> Result<()> { .nth(1) .ok_or(anyhow!("first arg should be recipe set name"))?; - let data = index.generate(format!("default-small-{rn}"))?; + let data = index.generate(format!("small-default-{rn}"))?; for i in 0..data.item_names.len() { println!("i{i} [label=\"{}\"]", data.item_name(ItemIndex(i))) diff --git a/server/src/data.rs b/server/src/data.rs index 6b0442ce..763a67bc 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -122,42 +122,39 @@ impl DataIndex { } pub fn generate(&self, spec: String) -> anyhow::Result<Gamedata> { - let [demands, map, recipes] = spec - .split("-") - .collect::<Vec<_>>() - .try_into() - .map_err(|_| anyhow!("data specification malformed"))?; + let (map, rest) = spec.split_once("-").unwrap_or((spec.as_str(), "default")); + let (demands, recipes) = rest.split_once("-").unwrap_or((rest, "default")); - if !self.demands.contains(demands) { - bail!("unknown demands: {demands:?}"); - } if !self.maps.contains(map) { bail!("unknown map: {map:?}"); } + if !self.demands.contains(demands) { + bail!("unknown demands: {demands:?}"); + } if !self.recipes.contains(recipes) { bail!("unknown recipes: {recipes:?}"); } - let demands_path = data_dir().join(format!("demands/{demands}.yaml")); let map_path = data_dir().join(format!("maps/{map}.yaml")); + let demands_path = data_dir().join(format!("demands/{demands}.yaml")); let recipes_path = data_dir().join(format!("recipes/{recipes}.yaml")); + let map_in = serde_yaml::from_reader(File::open(map_path).context("opening map failed")?)?; let demands_in = serde_yaml::from_reader(File::open(demands_path).context("opening demands failed")?)?; - let map_in = serde_yaml::from_reader(File::open(map_path).context("opening map failed")?)?; let recipes_in = serde_yaml::from_reader( File::open(recipes_path).context("opening recipes failed. are they generated yet?")?, )?; - Ok(Gamedata::build(recipes_in, map_in, demands_in)?) + Ok(Gamedata::build(map_in, demands_in, recipes_in)?) } } impl Gamedata { pub fn build( - recipes_in: Vec<RecipeDecl>, map_in: InitialMap, demands_in: Vec<DemandDecl>, + recipes_in: Vec<RecipeDecl>, ) -> Result<Self> { let item_names = RwLock::new(Vec::new()); let tile_names = RwLock::new(Vec::new()); diff --git a/server/src/state.rs b/server/src/state.rs index 08d8516a..ae3388b6 100644 --- a/server/src/state.rs +++ b/server/src/state.rs @@ -18,7 +18,7 @@ pub struct State { #[clap(multicall = true)] enum Command { Start { - #[arg(default_value = "default-small-default")] + #[arg(default_value = "small-default-default")] spec: String, }, End, @@ -30,7 +30,7 @@ impl State { index.reload()?; let mut game = Game::new(); - game.load(index.generate("none-lobby-none".to_string())?); + game.load(index.generate("lobby-none-none".to_string())?); Ok(Self { game, index, tx }) } @@ -69,7 +69,7 @@ impl State { } Command::End => { self.game - .load(self.index.generate("none-lobby-none".to_string())?); + .load(self.index.generate("lobby-none-none".to_string())?); } } Ok(()) |