Cleanup
This commit is contained in:
parent
fadd82ff3b
commit
3b94b71782
|
|
@ -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
|
||||
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 23%"><title>test-coverage: 23%</title><linearGradient id="bms-446d4cb5ae0bdc86" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-446d4cb5ae0bdc86"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-446d4cb5ae0bdc86)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#e05d44"/><rect width="122" height="18" fill="url(#bms-446d4cb5ae0bdc86)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">23%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">23%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 23%"><title>test-coverage: 23%</title><linearGradient id="bms-53a22d886a16ba1d" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-53a22d886a16ba1d"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-53a22d886a16ba1d)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#97ca00"/><rect width="122" height="18" fill="url(#bms-53a22d886a16ba1d)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">23%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">23%</text></g></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
// }
|
||||
// }
|
||||
|
|
@ -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<T> Debug for FilterFunction<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Filter:{}", std::any::type_name::<Self>())
|
||||
}
|
||||
}
|
||||
impl<T> Default for FilterFunction<T> {
|
||||
fn default() -> Self {
|
||||
FilterFunction(Box::new(Rc::new(|_, _| true)))
|
||||
}
|
||||
}
|
||||
impl<T> PartialEq for FilterFunction<T> {
|
||||
#[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::<Equipement>::default());
|
||||
let r = FilterFunction::<Equipement>::new(&|_, _| false) == FilterFunction::default();
|
||||
assert!(r);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<T> Debug for FilterFunction<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Filter:{}", std::any::type_name::<Self>())
|
||||
}
|
||||
}
|
||||
impl<T> Default for FilterFunction<T> {
|
||||
fn default() -> Self {
|
||||
FilterFunction(Box::new(Rc::new(|_, _| true)))
|
||||
}
|
||||
}
|
||||
impl<T> PartialEq for FilterFunction<T> {
|
||||
#[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::<Equipement>::default());
|
||||
let r = FilterFunction::<Equipement>::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::<i8>, None::<i8>), None);
|
||||
assert_eq!(first_correct_option!(Some(3), None::<i8>), Some(3));
|
||||
assert_eq!(first_correct_option!(None::<i8>, 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::<i8>), Some(3));
|
||||
assert_eq!(add_two_options!(None::<i8>, Some(4)), Some(4));
|
||||
|
||||
let a = vec![1, 2];
|
||||
let b = vec![3];
|
||||
|
||||
assert_eq!(add_to_vec!(a, b), vec![1, 2, 3]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ impl ToCSV for RefinedEquipementList {
|
|||
}
|
||||
}
|
||||
|
||||
// impl To
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
// use super::*;
|
||||
|
|
|
|||
|
|
@ -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::<i8>, None::<i8>), None);
|
||||
assert_eq!(first_correct_option!(Some(3), None::<i8>), Some(3));
|
||||
assert_eq!(first_correct_option!(None::<i8>, 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::<i8>), Some(3));
|
||||
assert_eq!(add_two_options!(None::<i8>, Some(4)), Some(4));
|
||||
|
||||
let a = vec![1, 2];
|
||||
let b = vec![3];
|
||||
|
||||
assert_eq!(add_to_vec!(a, b), vec![1, 2, 3]);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<usize> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn find_points_of_interest(representation: &Self::InterestElementList) -> Self {
|
||||
let _ = representation;
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue