From 3d211b711a3b63d5a647d5de83efbc1abe070fa1 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 22 Jul 2026 00:23:53 +0200 Subject: [PATCH] Adds some weaapon balancing cleanup and \half support --- Cargo.toml | 2 +- crates/weaponry/src/error.rs | 6 ++++++ crates/weaponry/src/export_tex.rs | 11 +++++------ .../equipement_advanced_repr.rs | 19 ++++++++++++++++++- .../equipement_impl_basics.rs | 1 - ravenous_databases | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 98135cd..6769bcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "3" # edition = "2024" # license = "MIT OR Apache-2.0" [workspace.package] -version = "0.3.11" +version = "0.3.12" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/weaponry/src/error.rs b/crates/weaponry/src/error.rs index 7a19384..a1048f6 100644 --- a/crates/weaponry/src/error.rs +++ b/crates/weaponry/src/error.rs @@ -58,6 +58,12 @@ pub enum FatalEquipementError { pub enum WeaponGenerationError { #[error("An unexpected error occured")] Unexpected, + + #[error("An error was encountered while generating equipement")] + FatalEquipementError(#[from] FatalEquipementError), + + #[error("An error occured while writing the file")] + IOError(#[from] std::io::Error), } // #[derive(Error, Debug)] diff --git a/crates/weaponry/src/export_tex.rs b/crates/weaponry/src/export_tex.rs index 63272f3..6fdaa59 100644 --- a/crates/weaponry/src/export_tex.rs +++ b/crates/weaponry/src/export_tex.rs @@ -37,18 +37,17 @@ pub fn export_weapons(args: &WeaponConfig, config: &Config) -> Result<(), Weapon materials: None, nature: Some(()), //(!args.no_natures).then_some(()), finishing: None, //args.finishing.then_some(()), - }) - .unwrap(); + })?; // let filter = Box::new(|_: &RefinedEquipement| true); - let refined_list = scenarios.generate_refined_recipes().unwrap(); + let refined_list = scenarios.generate_refined_recipes()?; // .inner_filter(filter); - let tex = refined_list.to_tex(config).unwrap(); + let tex = refined_list.to_tex(config)?; let name = format!("{}/gen-forge-table.tex", args.export); println!("Writing to file {name}"); - let mut f = fs::File::create(name).unwrap(); - writeln!(f, "{}", tex).unwrap(); + let mut f = fs::File::create(name)?; + writeln!(f, "{}", tex)?; Ok(()) } diff --git a/crates/weaponry/src/weaponry_structs/equipement_advanced_repr.rs b/crates/weaponry/src/weaponry_structs/equipement_advanced_repr.rs index fbd2763..fae9911 100644 --- a/crates/weaponry/src/weaponry_structs/equipement_advanced_repr.rs +++ b/crates/weaponry/src/weaponry_structs/equipement_advanced_repr.rs @@ -75,6 +75,20 @@ pub struct ExportableEquipement { pub needs_break: bool, } +/// Put half numbers +fn halves(f: f32) -> String { + let base = f.floor(); + let extra = f - base; + if !(-0.1..=0.1).contains(&extra) { + if base == 0. { + "\\half{}".to_string() + } else { + format!("{base:0}\\half{{}}") + } + } else { + format!("{base}") + } +} impl From<&RefinedEquipement> for ExportableEquipement { fn from(value: &RefinedEquipement) -> Self { let mut special = Vec::new(); @@ -108,6 +122,9 @@ impl From<&RefinedEquipement> for ExportableEquipement { value.inner.precision )); } + if value.inner.agility_bonus != 0. { + special.push(format!(r"Ag {}", halves(value.inner.agility_bonus))); + } Self { name: value.advanced.display_name.clone(), maniement: value.inner.get_maniement(), @@ -120,7 +137,7 @@ impl From<&RefinedEquipement> for ExportableEquipement { torque_one_handed: value.inner.torque_one_handed, torque_two_handed: value.inner.torque_two_handed, modes: value.inner.get_modes(), - esquive: value.inner.dodge.to_string(), + esquive: halves(value.inner.dodge), parrade: value.inner.parry.to_string(), vitesse: value.inner.speed.to_string(), discretion: value.inner.stealth.to_string(), diff --git a/crates/weaponry/src/weaponry_structs/equipement_impl_basics.rs b/crates/weaponry/src/weaponry_structs/equipement_impl_basics.rs index 8f0cc0f..9daaa7f 100644 --- a/crates/weaponry/src/weaponry_structs/equipement_impl_basics.rs +++ b/crates/weaponry/src/weaponry_structs/equipement_impl_basics.rs @@ -87,7 +87,6 @@ impl Display for InnerEquipementStats { self.difficulty, self.tier, self.category_base - .clone() .map_or_else(|| "ΓΈ".to_string(), |v| v.to_string()), self.category_size .clone() diff --git a/ravenous_databases b/ravenous_databases index 1493491..f52776f 160000 --- a/ravenous_databases +++ b/ravenous_databases @@ -1 +1 @@ -Subproject commit 14934910a40cd5fdee09f9ef7df75e1e4d0f2288 +Subproject commit f52776f917aeaf0e29944351d05f76efb0ecb2f6