aboutsummaryrefslogtreecommitdiff
path: root/server/src/data.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/data.rs')
-rw-r--r--server/src/data.rs19
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,
})
}