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.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/server/src/data.rs b/server/src/data.rs
index 3526d786..e467fefa 100644
--- a/server/src/data.rs
+++ b/server/src/data.rs
@@ -31,22 +31,34 @@ pub struct InitialMap {
tiles: HashMap<String, String>,
}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct DemandDecl {
+ from: String,
+ to: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Demand {
+ pub from: usize,
+ pub to: usize,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Gamedata {
pub recipes: Vec<Recipe>,
+ pub demands: Vec<Demand>,
pub item_names: Vec<String>,
pub tile_names: Vec<String>,
#[serde(skip)]
pub initial_map: HashMap<IVec2, TileIndex>,
pub chef_spawn: Vec2,
pub customer_spawn: Vec2,
- pub demands: Vec<usize>,
}
pub fn build_gamedata(
recipes_in: Vec<RecipeDecl>,
map_in: InitialMap,
- demands_in: Vec<String>,
+ demands_in: Vec<DemandDecl>,
) -> Gamedata {
let item_names = RwLock::new(Vec::new());
let tile_names = RwLock::new(Vec::new());
@@ -85,7 +97,10 @@ pub fn build_gamedata(
}
for d in demands_in {
- demands.push(register(&item_names, d))
+ demands.push(Demand {
+ from: register(&item_names, d.from),
+ to: register(&item_names, d.to),
+ })
}
let mut chef_spawn = Vec2::new(0., 0.);