From f6458b62e733de11e3665c83bcde4fd4051d7842 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Oct 2025 00:13:56 +0200 Subject: Book pages from recipe groups --- server/data/src/lib.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'server/data/src/lib.rs') diff --git a/server/data/src/lib.rs b/server/data/src/lib.rs index 822d6997..fa078643 100644 --- a/server/data/src/lib.rs +++ b/server/data/src/lib.rs @@ -31,7 +31,7 @@ use hurrycurry_protocol::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::{BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, BTreeSet, HashMap, HashSet}, sync::RwLock, time::Duration, }; @@ -52,14 +52,16 @@ pub enum RecipeDeclAction { #[rustfmt::skip] #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RecipeDecl { - #[serde(default)] tile: Option, + tile: Option, #[serde(default)] inputs: Vec, #[serde(default)] outputs: Vec, #[serde(default)] action: RecipeDeclAction, #[serde(default)] warn: bool, - #[serde(default)] revert_duration: Option, - #[serde(default)] duration: Option, - #[serde(default)] points: Option, + revert_duration: Option, + duration: Option, + points: Option, + group: Option, + #[serde(default)] group_hidden: bool, } #[rustfmt::skip] @@ -114,7 +116,8 @@ pub struct Serverdata { pub default_timer: Option, pub book: Book, pub flags: ServerdataFlags, - pub entity_decls: Vec + pub entity_decls: Vec, + pub recipe_groups: BTreeMap>, } #[rustfmt::skip] @@ -133,6 +136,7 @@ fn build_data( let mut recipes = Vec::new(); let mut entities = Vec::new(); let mut raw_demands = Vec::new(); + let mut recipe_groups = BTreeMap::>::new(); for mut r in recipes_in { #[cfg(feature = "fast_recipes")] @@ -149,6 +153,11 @@ fn build_data( let mut inputs = r.inputs.into_iter().map(|i| reg.register_item(i)); let mut outputs = r.outputs.into_iter().map(|o| reg.register_item(o)); let tile = r.tile.map(|t| reg.register_tile(t)); + if let Some(g) = r.group { + if !r.group_hidden { + recipe_groups.entry(g).or_default().extend(inputs.clone()); + } + } match r.action { RecipeDeclAction::Never => {} RecipeDeclAction::Passive => recipes.push(Recipe::Passive { @@ -327,6 +336,7 @@ fn build_data( book: Book::default(), score_baseline: map_in.score_baseline, entity_decls: entities, + recipe_groups, }, )) } -- cgit v1.2.3-70-g09d2