diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 |
commit | 58f4ab0b26948bec13ba853c90298271e472169f (patch) | |
tree | 9fa6e4443addf067310ff9ba868ec72b9e237637 /server/src/data.rs | |
parent | b0042dce860406431f2e486112b14987c665f6a8 (diff) | |
download | hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.bz2 hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.zst |
implement points
Diffstat (limited to 'server/src/data.rs')
-rw-r--r-- | server/src/data.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/server/src/data.rs b/server/src/data.rs index 763a67bc..46f7ed28 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -56,6 +56,8 @@ pub struct RecipeDecl { revert_duration: Option<f32>, #[serde(default)] duration: Option<f32>, + #[serde(default)] + points: Option<i64>, } #[derive(Debug, Clone, Deserialize)] @@ -72,15 +74,17 @@ pub struct InitialMap { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DemandDecl { from: String, - to: String, + to: Option<String>, duration: f32, + points: i64, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Demand { pub from: ItemIndex, - pub to: ItemIndex, + pub to: Option<ItemIndex>, pub duration: f32, + pub points: i64, } #[derive(Debug, Clone, Serialize, Deserialize, Default)] @@ -161,7 +165,7 @@ impl Gamedata { let mut recipes = Vec::new(); let mut demands = Vec::new(); - for r in recipes_in { + for mut r in recipes_in { let r2 = r.clone(); let mut inputs = r .inputs @@ -190,21 +194,24 @@ impl Gamedata { }), Action::Instant => { recipes.push(Recipe::Instant { + points: r.points.take().unwrap_or(0), tile, inputs: [inputs.next(), inputs.next()], outputs: [outputs.next(), outputs.next()], }); } } - assert_eq!(inputs.next(), None, "{r2:?}"); - assert_eq!(outputs.next(), None, "{r2:?}"); + assert_eq!(inputs.next(), None, "{r2:?} inputs left over"); + assert_eq!(outputs.next(), None, "{r2:?} outputs left over"); + assert_eq!(r.points, None, "points specified where not possible") } for d in demands_in { demands.push(Demand { from: ItemIndex(register(&item_names, d.from)), - to: ItemIndex(register(&item_names, d.to)), + to: d.to.map(|to| ItemIndex(register(&item_names, to))), duration: d.duration, + points: d.points, }) } |