summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-08-29 13:36:23 +0200
committermetamuffin <metamuffin@disroot.org>2024-08-29 16:47:50 +0200
commit1cefa37b1cce8dd6add0d10086395365777b7b99 (patch)
treee2117e395fab28385d91087781ab3a3b865453a3
parentf483afdc85f10934828dcacfa1636cd1934bfa8b (diff)
downloadhurrycurry-1cefa37b1cce8dd6add0d10086395365777b7b99.tar
hurrycurry-1cefa37b1cce8dd6add0d10086395365777b7b99.tar.bz2
hurrycurry-1cefa37b1cce8dd6add0d10086395365777b7b99.tar.zst
constistent struct naming in data
-rw-r--r--server/src/data/mod.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/server/src/data/mod.rs b/server/src/data/mod.rs
index 28a4a60f..dd916a93 100644
--- a/server/src/data/mod.rs
+++ b/server/src/data/mod.rs
@@ -38,7 +38,7 @@ use tokio::fs::read_to_string;
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default)]
#[serde(rename_all = "snake_case")]
-pub enum Action {
+pub enum RecipeDeclAction {
#[default]
Never,
Passive,
@@ -56,7 +56,7 @@ pub struct RecipeDecl {
#[serde(default)]
outputs: Vec<String>,
#[serde(default)]
- action: Action,
+ action: RecipeDeclAction,
#[serde(default)]
warn: bool,
#[serde(default)]
@@ -68,7 +68,7 @@ pub struct RecipeDecl {
}
#[derive(Debug, Clone, Deserialize)]
-pub struct InitialMap {
+pub struct MapDecl {
map: Vec<String>,
tiles: HashMap<char, String>,
#[serde(default)]
@@ -159,7 +159,7 @@ pub fn build_data(
maps: &HashMap<String, MapMetadata>,
spec: String,
map_name: String,
- map_in: InitialMap,
+ map_in: MapDecl,
recipes_in: Vec<RecipeDecl>,
) -> Result<(Gamedata, Serverdata, Entities)> {
let reg = ItemTileRegistry::default();
@@ -173,8 +173,8 @@ pub fn build_data(
let mut outputs = r.outputs.into_iter().map(|o| reg.register_item(o));
let tile = r.tile.map(|t| reg.register_tile(t));
match r.action {
- Action::Never => {}
- Action::Passive => recipes.push(Recipe::Passive {
+ RecipeDeclAction::Never => {}
+ RecipeDeclAction::Passive => recipes.push(Recipe::Passive {
duration: r.duration.ok_or(anyhow!("duration for passive missing"))?,
warn: r.warn,
tile,
@@ -184,7 +184,7 @@ pub fn build_data(
.ok_or(anyhow!("passive recipe without input"))?,
output: outputs.next(),
}),
- Action::Active => recipes.push(Recipe::Active {
+ RecipeDeclAction::Active => recipes.push(Recipe::Active {
duration: r.duration.ok_or(anyhow!("duration for active missing"))?,
tile,
input: inputs
@@ -192,7 +192,7 @@ pub fn build_data(
.ok_or(anyhow!("active recipe without input"))?,
outputs: [outputs.next(), outputs.next()],
}),
- Action::Instant => {
+ RecipeDeclAction::Instant => {
recipes.push(Recipe::Instant {
points: r.points.take().unwrap_or(0),
tile,
@@ -200,7 +200,7 @@ pub fn build_data(
outputs: [outputs.next(), outputs.next()],
});
}
- Action::Demand => raw_demands.push((
+ RecipeDeclAction::Demand => raw_demands.push((
inputs.next().ok_or(anyhow!("demand needs inputs"))?,
outputs.next(),
r.duration.unwrap_or(10.),
@@ -211,16 +211,6 @@ pub fn build_data(
assert_eq!(r.points, None, "points specified where not possible")
}
- // TODO
- // for d in demands_in {
- // demands.push(Demand {
- // from: reg.register_item(d.from),
- // to: d.to.map(|to| reg.register_item(to)),
- // duration: d.duration,
- // points: d.points,
- // })
- // }
-
let mut chef_spawn = Vec2::new(0., 0.);
let mut customer_spawn = Vec2::new(0., 0.);
let mut initial_map = HashMap::new();