diff --git a/.run_status.toml b/.run_status.toml
new file mode 100644
index 0000000..d94ea54
--- /dev/null
+++ b/.run_status.toml
@@ -0,0 +1,8 @@
+[last_run_clean]
+run_status = "Success"
+lines_parsed = 133
+coverage = 23.38
+
+[last_run_clean.run_duration]
+secs = 66
+nanos = 917039211
diff --git a/badges/coverage.svg b/badges/coverage.svg
index c78d807..b1210c9 100644
--- a/badges/coverage.svg
+++ b/badges/coverage.svg
@@ -1 +1 @@
-
+
diff --git a/weaponry/.run_status.toml b/weaponry/.run_status.toml
new file mode 100644
index 0000000..4ac0f3f
--- /dev/null
+++ b/weaponry/.run_status.toml
@@ -0,0 +1,8 @@
+[last_run_clean]
+run_status = "Success"
+lines_parsed = 57
+coverage = 60.03
+
+[last_run_clean.run_duration]
+secs = 19
+nanos = 961545465
diff --git a/weaponry/src/lib.rs b/weaponry/src/lib.rs
index e035bd5..840bc6c 100644
--- a/weaponry/src/lib.rs
+++ b/weaponry/src/lib.rs
@@ -11,7 +11,6 @@ mod database;
pub mod error;
pub mod export;
pub mod interfaces;
-mod strategy;
pub mod weaponry_structs;
/// Signals the function running is unfinished
diff --git a/weaponry/src/strategy.rs b/weaponry/src/strategy.rs
deleted file mode 100644
index a19727f..0000000
--- a/weaponry/src/strategy.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Workspace: weaponry
-// File: weaponry/src/strategy.rs
-//! All different algorythms and strategies to create a weapon
-//!
-//! These strategies can lock a parameter to allow a more fine tuned balancing
-//! or balancing specifically one parameter (balancing materials, balencing finishes etc..)
-//! These strategies must take into account the level of the fighter (hence his precision) and of the craftsman (hence a difficulty diminution)
-//!
-// #![allow(dead_code)]
-
-// /// Generation strategy, how to generate all the data, instead of a full permutation
-// pub enum EquipementStrategy {
-// /// Full permutation, generate all possible outcomes
-// GenerateAll,
-// /// Generate all the named equipements
-// GenerateNamed,
-// /// Do not add finishing touches
-// NoFinishes,
-// }
-
-// /// Which material to select
-// pub enum MaterialsStrategy {
-// /// Add all materials to the mix
-// AllMaterials,
-// /// Add only tier one material
-// OnlyTier1,
-// /// Add only easy materials
-// OnlyEasy,
-// /// Add only cheap materials
-// OnlyCheap,
-// /// Add only one material
-// OnlyOne,
-// }
-
-// /// Filter to apply after the generation
-// pub enum EquipementFilter {
-// /// Don't filter anything
-// All,
-// /// Filter all outliers
-// Outiliers,
-// /// Filter in all the named
-// Named,
-// }
-
-// #[cfg(test)]
-// mod test {
-// // use super::*;
-
-// #[test]
-// fn test_naive_generator() {
-// // let t = naive_generation(vec![1, 2, 3], vec![5, 6, 7]);
-// // assert_eq!(t.len(), 3 * 3);
-// }
-// }
diff --git a/weaponry/src/weaponry_structs/equipement_impl_advanced.rs b/weaponry/src/weaponry_structs/equipement_impl_advanced.rs
deleted file mode 100644
index 6fa4647..0000000
--- a/weaponry/src/weaponry_structs/equipement_impl_advanced.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Workspace: weaponry
-// File: weaponry/src/weaponry_structs/equipement_impl_advanced.rs
-//! Advanced implementation, reserved for traits and impls that are implemented only once on the main equipement and it's helper
-//!
-//! These impls are here to either prettify output, or allow for smoother implementation of other traits and inner workings
-
-use crate::interfaces::FilterFunction;
-use std::{fmt::Debug, rc::Rc};
-
-impl Debug for FilterFunction {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "Filter:{}", std::any::type_name::())
- }
-}
-impl Default for FilterFunction {
- fn default() -> Self {
- FilterFunction(Box::new(Rc::new(|_, _| true)))
- }
-}
-impl PartialEq for FilterFunction {
- #[coverage(off)] // INCORRECT: Error with line report
- fn eq(&self, _other: &Self) -> bool {
- true
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::{interfaces::FilterFunction, weaponry_structs::Equipement};
-
- #[test]
- fn test_filter_weapons() {
- let _ = format!("{:?}", FilterFunction::::default());
- let r = FilterFunction::::new(&|_, _| false) == FilterFunction::default();
- assert!(r);
- }
-}
diff --git a/weaponry/src/weaponry_structs/equipement_impl_basics.rs b/weaponry/src/weaponry_structs/equipement_impl_basics.rs
index f7ec799..01f4383 100644
--- a/weaponry/src/weaponry_structs/equipement_impl_basics.rs
+++ b/weaponry/src/weaponry_structs/equipement_impl_basics.rs
@@ -8,17 +8,20 @@
//! Implementations to transform all Specialized equipement into a generic Equipement
//! A specific implementation could be preferable, but this simplicity might allow for easier developpement
-use comfy_table::{Table, modifiers::UTF8_ROUND_CORNERS};
-use std::fmt::Display;
-
+use super::equipement_structs::InnerEquipementStats;
use crate::interfaces::{FilterFunction, Reportable};
+use crate::weaponry_structs::{SpecialField, WeaponBaseShape};
+use comfy_table::{Table, modifiers::UTF8_ROUND_CORNERS};
+use std::{
+ fmt::{Debug, Display},
+ rc::Rc,
+};
use super::{
Equipement, InitialEquipementList,
equipement_advanced_repr::RefinedEquipementList,
equipement_structs::{
- EqFinishing, EqMaterial, EqNature, EqShape, InnerEquipementStats,
- filter_id_unique_and_right_category,
+ EqFinishing, EqMaterial, EqNature, EqShape, filter_id_unique_and_right_category,
},
};
@@ -176,10 +179,116 @@ impl Reportable for RefinedEquipementList {
}
}
+impl Debug for FilterFunction {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "Filter:{}", std::any::type_name::())
+ }
+}
+impl Default for FilterFunction {
+ fn default() -> Self {
+ FilterFunction(Box::new(Rc::new(|_, _| true)))
+ }
+}
+impl PartialEq for FilterFunction {
+ #[coverage(off)] // INCORRECT: Error with line report
+ fn eq(&self, _other: &Self) -> bool {
+ true
+ }
+}
+
+/// Add a new vector to a clone of a inner field
+macro_rules! add_to_vec {
+ ($self: expr, $rhs: expr) => {{
+ let mut new = $self.clone();
+ new.append(&mut $rhs.clone());
+ new
+ }};
+}
+
+/// Adds either of the vectors or merge them
+macro_rules! add_two_options {
+ ($self: expr, $rhs: expr) => {{
+ match ($self.as_ref(), $rhs.as_ref()) {
+ (None, None) => None,
+ (None, Some(a)) => Some(a.clone()),
+ (Some(a), None) => Some(a.clone()),
+ (Some(a), Some(b)) => Some(a.clone() + b.clone()),
+ }
+ }};
+}
+
+/// Clones the first option that has some data
+macro_rules! first_correct_option {
+ ($self:expr, $rhs:expr) => {
+ match ($self.as_ref(), $rhs.as_ref()) {
+ (Some(a), _) => Some(a.clone()),
+ (_, Some(b)) => Some(b.clone()),
+ _ => None,
+ }
+ };
+}
+
+impl std::ops::Add for &InnerEquipementStats {
+ type Output = InnerEquipementStats;
+
+ fn add(self, rhs: Self) -> Self::Output {
+ InnerEquipementStats {
+ id: add_to_vec!(self.id, rhs.id),
+ name: add_to_vec!(self.name, rhs.name),
+ rarity: self.rarity + rhs.rarity,
+ cost: self.cost + rhs.cost,
+ difficulty: self.difficulty + rhs.difficulty,
+ tier: self.tier + rhs.tier,
+ damage: self.damage + rhs.damage,
+ p_damage: self.p_damage + rhs.p_damage,
+ precision: self.precision + rhs.precision,
+ rmax: self.rmax + rhs.rmax,
+ armor_break: self.armor_break + rhs.armor_break,
+ armor_pierce: {
+ if self.armor_pierce > 0
+ || matches!(self.category_base, Some(WeaponBaseShape::Ranged))
+ {
+ self.armor_pierce + rhs.armor_pierce
+ } else {
+ 0
+ }
+ },
+ antimaterial: self.antimaterial + rhs.antimaterial,
+ damage_type: add_two_options!(self.damage_type, rhs.damage_type),
+ protection: self.protection + rhs.protection,
+ integrity: self.integrity + rhs.integrity,
+ torque_two_handed: add_two_options!(self.torque_two_handed, rhs.torque_two_handed),
+ torque_one_handed: add_two_options!(self.torque_one_handed, rhs.torque_one_handed),
+ dodge: self.dodge + rhs.dodge,
+ parry: self.parry + rhs.parry,
+ speed: self.speed + rhs.speed,
+ stealth: self.stealth + rhs.stealth,
+ special: self.special.clone() + rhs.special.clone(), // Can be further optimized
+ action_cost: self.action_cost + rhs.action_cost,
+ reload_cost: self.reload_cost.or(rhs.reload_cost),
+ range: self.range + rhs.range,
+ agility_bonus: self.agility_bonus + rhs.agility_bonus,
+ category_base: first_correct_option!(self.category_base, rhs.category_base),
+ category_size: first_correct_option!(self.category_size, rhs.category_size),
+ target_category: first_correct_option!(self.target_category, rhs.target_category),
+ }
+ }
+}
+
+impl std::ops::Add for SpecialField {
+ type Output = Self;
+
+ fn add(self, rhs: Self) -> Self::Output {
+ let mut c = self.clone();
+ c.append(&mut rhs.clone());
+ c
+ }
+}
+
#[cfg(test)]
mod test {
use crate::{
- interfaces::{RecipeCollection, Reportable},
+ interfaces::{FilterFunction, RecipeCollection, Reportable},
weaponry_structs::{
Equipement, InitialEquipementList,
equipement_advanced_repr::RefinedEquipementList,
@@ -187,6 +296,12 @@ mod test {
},
};
+ #[test]
+ fn test_filter_weapons() {
+ let _ = format!("{:?}", FilterFunction::::default());
+ let r = FilterFunction::::new(&|_, _| false) == FilterFunction::default();
+ assert!(r);
+ }
#[allow(dead_code)]
/// A manually implemented hashmap of all values
#[doc(hidden)]
@@ -238,4 +353,21 @@ mod test {
println!("{}", feqlist.get_report(None));
println!("{}", eqlist.get_report(None));
}
+
+ #[test]
+ fn test_macros() {
+ assert_eq!(first_correct_option!(None::, None::), None);
+ assert_eq!(first_correct_option!(Some(3), None::), Some(3));
+ assert_eq!(first_correct_option!(None::, Some(4)), Some(4));
+ assert_eq!(first_correct_option!(Some(1), Some(3)), Some(1));
+
+ assert_eq!(add_two_options!(Some(1), Some(3)), Some(4));
+ assert_eq!(add_two_options!(Some(3), None::), Some(3));
+ assert_eq!(add_two_options!(None::, Some(4)), Some(4));
+
+ let a = vec![1, 2];
+ let b = vec![3];
+
+ assert_eq!(add_to_vec!(a, b), vec![1, 2, 3]);
+ }
}
diff --git a/weaponry/src/weaponry_structs/equipement_impl_io.rs b/weaponry/src/weaponry_structs/equipement_impl_io.rs
index 9c12248..4db5645 100644
--- a/weaponry/src/weaponry_structs/equipement_impl_io.rs
+++ b/weaponry/src/weaponry_structs/equipement_impl_io.rs
@@ -16,6 +16,8 @@ impl ToCSV for RefinedEquipementList {
}
}
+// impl To
+
#[cfg(test)]
mod test {
// use super::*;
diff --git a/weaponry/src/weaponry_structs/equipement_impl_math.rs b/weaponry/src/weaponry_structs/equipement_impl_math.rs
deleted file mode 100644
index 32ad6f3..0000000
--- a/weaponry/src/weaponry_structs/equipement_impl_math.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-// Workspace: weaponry
-// File: weaponry/src/weaponry_structs/equipement_math.rs
-//! Implements base math for each field
-//!
-
-use super::equipement_structs::InnerEquipementStats;
-use crate::weaponry_structs::{SpecialField, WeaponBaseShape};
-
-/// Add a new vector to a clone of a inner field
-macro_rules! add_to_vec {
- ($self: expr, $rhs: expr) => {{
- let mut new = $self.clone();
- new.append(&mut $rhs.clone());
- new
- }};
-}
-
-/// Adds either of the vectors or merge them
-macro_rules! add_two_options {
- ($self: expr, $rhs: expr) => {{
- match ($self.as_ref(), $rhs.as_ref()) {
- (None, None) => None,
- (None, Some(a)) => Some(a.clone()),
- (Some(a), None) => Some(a.clone()),
- (Some(a), Some(b)) => Some(a.clone() + b.clone()),
- }
- }};
-}
-
-/// Clones the first option that has some data
-macro_rules! first_correct_option {
- ($self:expr, $rhs:expr) => {
- match ($self.as_ref(), $rhs.as_ref()) {
- (Some(a), _) => Some(a.clone()),
- (_, Some(b)) => Some(b.clone()),
- _ => None,
- }
- };
-}
-
-impl std::ops::Add for &InnerEquipementStats {
- type Output = InnerEquipementStats;
-
- fn add(self, rhs: Self) -> Self::Output {
- InnerEquipementStats {
- id: add_to_vec!(self.id, rhs.id),
- name: add_to_vec!(self.name, rhs.name),
- rarity: self.rarity + rhs.rarity,
- cost: self.cost + rhs.cost,
- difficulty: self.difficulty + rhs.difficulty,
- tier: self.tier + rhs.tier,
- damage: self.damage + rhs.damage,
- p_damage: self.p_damage + rhs.p_damage,
- precision: self.precision + rhs.precision,
- rmax: self.rmax + rhs.rmax,
- armor_break: self.armor_break + rhs.armor_break,
- armor_pierce: {
- if self.armor_pierce > 0
- || matches!(self.category_base, Some(WeaponBaseShape::Ranged))
- {
- self.armor_pierce + rhs.armor_pierce
- } else {
- 0
- }
- },
- antimaterial: self.antimaterial + rhs.antimaterial,
- damage_type: add_two_options!(self.damage_type, rhs.damage_type),
- protection: self.protection + rhs.protection,
- integrity: self.integrity + rhs.integrity,
- torque_two_handed: add_two_options!(self.torque_two_handed, rhs.torque_two_handed),
- torque_one_handed: add_two_options!(self.torque_one_handed, rhs.torque_one_handed),
- dodge: self.dodge + rhs.dodge,
- parry: self.parry + rhs.parry,
- speed: self.speed + rhs.speed,
- stealth: self.stealth + rhs.stealth,
- special: self.special.clone() + rhs.special.clone(), // Can be further optimized
- action_cost: self.action_cost + rhs.action_cost,
- reload_cost: self.reload_cost.or(rhs.reload_cost),
- range: self.range + rhs.range,
- agility_bonus: self.agility_bonus + rhs.agility_bonus,
- category_base: first_correct_option!(self.category_base, rhs.category_base),
- category_size: first_correct_option!(self.category_size, rhs.category_size),
- target_category: first_correct_option!(self.target_category, rhs.target_category),
- }
- }
-}
-
-impl std::ops::Add for SpecialField {
- type Output = Self;
-
- fn add(self, rhs: Self) -> Self::Output {
- let mut c = self.clone();
- c.append(&mut rhs.clone());
- c
- }
-}
-
-#[cfg(test)]
-mod test {
- #[test]
- fn test_macros() {
- assert_eq!(first_correct_option!(None::, None::), None);
- assert_eq!(first_correct_option!(Some(3), None::), Some(3));
- assert_eq!(first_correct_option!(None::, Some(4)), Some(4));
- assert_eq!(first_correct_option!(Some(1), Some(3)), Some(1));
-
- assert_eq!(add_two_options!(Some(1), Some(3)), Some(4));
- assert_eq!(add_two_options!(Some(3), None::), Some(3));
- assert_eq!(add_two_options!(None::, Some(4)), Some(4));
-
- let a = vec![1, 2];
- let b = vec![3];
-
- assert_eq!(add_to_vec!(a, b), vec![1, 2, 3]);
- }
-}
diff --git a/weaponry/src/weaponry_structs/equipement_views.rs b/weaponry/src/weaponry_structs/equipement_views.rs
deleted file mode 100644
index a5c4ec4..0000000
--- a/weaponry/src/weaponry_structs/equipement_views.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Workspace: weaponry
-// File: weaponry/src/weaponry_structs/equipement_views.rs
-//! Implement the view trait to allow for a list of "Points of Interest" to be created
-//! This list is imperative to allow several criterias to be looked up one after the other to gather as many points of data as possible
-//!
-//! It is mandatory that these points of interest link back to the original data by index and not by reference, to allow this operation to be thread safe
-// TODO[3]: Consider deletion of this module and the associated view table
-
-#![allow(dead_code)]
-
-use crate::interfaces::ViewTable;
-
-use super::equipement_advanced_repr::RefinedEquipementList;
-
-/// A rather full view of an equipement, this multi field allow for a great amount of different operations but incurrs a rather hefty calculation price
-struct EquipementFullView {}
-
-impl ViewTable for EquipementFullView {
- type InterestElementList = RefinedEquipementList;
-
- fn index_of_interest_points(&self) -> Vec {
- todo!()
- }
-
- fn find_points_of_interest(representation: &Self::InterestElementList) -> Self {
- let _ = representation;
- todo!()
- }
-}
diff --git a/weaponry/src/weaponry_structs/mod.rs b/weaponry/src/weaponry_structs/mod.rs
index d03f50d..c35a0a7 100644
--- a/weaponry/src/weaponry_structs/mod.rs
+++ b/weaponry/src/weaponry_structs/mod.rs
@@ -18,16 +18,13 @@
mod equipement_advanced_repr;
mod equipement_advanced_tools;
mod equipement_fields;
-mod equipement_impl_advanced;
mod equipement_impl_basics;
pub mod equipement_impl_database;
mod equipement_impl_io;
mod equipement_impl_logic;
-mod equipement_impl_math;
pub mod equipement_scenario;
pub mod equipement_structs;
pub mod equipement_thin_types;
-mod equipement_views;
// Republishes the most used symbols
// All generic structs