diff --git a/weaponry/src/interfaces.rs b/weaponry/src/interfaces.rs index c54f718..2252354 100644 --- a/weaponry/src/interfaces.rs +++ b/weaponry/src/interfaces.rs @@ -9,10 +9,16 @@ use std::rc::Rc; /// This element can be converted to tex -pub trait ToTex {} +pub trait ToTex { + /// Export the object to a Tex string + fn to_tex() -> String; +} -/// Specify this element can be made from parts (Unsure, maybe a way to ensure Add is presend ?) -pub trait FromParts {} +/// This element can be converted to a csv for further analysis +pub trait ToAnalysis { + /// Convert this object into a csv + fn to_csv() -> String; +} /// Trait implemented for the final collection of a recipe, allowing it to be combined with parts /// diff --git a/weaponry/src/weaponry_structs/equipement_impl_math.rs b/weaponry/src/weaponry_structs/equipement_impl_math.rs index 7951a98..1f7c501 100644 --- a/weaponry/src/weaponry_structs/equipement_impl_math.rs +++ b/weaponry/src/weaponry_structs/equipement_impl_math.rs @@ -15,6 +15,21 @@ macro_rules! add_to_vec { }}; } +/// Adds either of the vectors or merge them +macro_rules! add_two_options { + ($self: expr, $rhs: expr) => {{ + match ($self.clone(), $rhs.clone()) { + (None, None) => None, + (None, Some(a)) => Some(a), + (Some(a), None) => Some(a), + (Some(mut a), Some(mut b)) => { + a.0.append(&mut b.0); + Some(a) + } + } + }}; +} + impl std::ops::Add for &InnerStats { type Output = InnerStats; @@ -34,17 +49,7 @@ impl std::ops::Add for &InnerStats { armor_break: self.armor_break + rhs.armor_break, armor_pierce: self.armor_pierce + rhs.armor_pierce, antimaterial: self.antimaterial + rhs.antimaterial, - damage_type: { - match (self.damage_type.clone(), rhs.damage_type.clone()) { - (None, None) => None, - (None, Some(a)) => Some(a), - (Some(a), None) => Some(a), - (Some(mut a), Some(mut b)) => { - a.0.append(&mut b.0); - Some(a) - } - } - }, + damage_type: add_two_options!(self.damage_type, rhs.damage_type), protection: self.protection + rhs.protection, integrity: self.integrity + rhs.integrity, torque_two_handed: self.torque_two_handed + rhs.torque_two_handed, diff --git a/weaponry/src/weaponry_structs/equipement_tools.rs b/weaponry/src/weaponry_structs/equipement_tools.rs new file mode 100644 index 0000000..1099749 --- /dev/null +++ b/weaponry/src/weaponry_structs/equipement_tools.rs @@ -0,0 +1,15 @@ +// Workspace: weaponry +// File: weaponry/src/weaponry_structs/equipement_tools.rs +//! Tools user facing, implement all that a end user would need +//! + +#![allow(dead_code)] + +/// Tooling utility +fn load_database() {} + +/// Export the data generated to tex +fn export_to_tex() {} + +/// Export the data generated to csv +fn export_to_csv() {} diff --git a/weaponry/src/weaponry_structs/mod.rs b/weaponry/src/weaponry_structs/mod.rs index 9bcb277..6e3dd86 100644 --- a/weaponry/src/weaponry_structs/mod.rs +++ b/weaponry/src/weaponry_structs/mod.rs @@ -23,6 +23,7 @@ mod equipement_impl_io; mod equipement_impl_logic; mod equipement_impl_math; pub mod equipement_structs; +pub mod equipement_tools; // Republishes the most used symbols // All generic structs