From 32ff0ef11550b7fdad51537ad421cfb3606617ac Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 25 Feb 2025 23:23:31 +0100 Subject: [PATCH] Adds a better sort (still miles from real custom cli) --- weaponry/databases/weapons.db | Bin 28672 -> 28672 bytes weaponry/examples/usage_scenario.rs | 2 +- .../equipement_advanced_repr.rs | 52 ++++++++++++++---- .../src/weaponry_structs/equipement_fields.rs | 6 +- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/weaponry/databases/weapons.db b/weaponry/databases/weapons.db index e1924d36cf44cba642d2cc9b13c86e237650d0ec..6b5528b07512de047d84d29509c2d1205d2ff241 100644 GIT binary patch delta 1023 zcmZva%TE(Q9LGB|EuDcvZM0x1uw{{m2~`#ZN@4`sDoB7DNfgpFWNimpQ`%2dLyl+goiR z+qUKMgRgHAFGlA#kn^Rpzv+F`Vw1J;Rb#~Q%TaRNbfAWJ4Qma(^*`#j>oxYBl~^0y zrHl4M`(t}|-G{n)+oA25t;hP!x`v*ku;tLQVO7XSk|pi<6ONU3&3SvW~Qex33oMU=Ql z_(GBWow55!WJ7QFpWg7;L_D}7CR%&;KTi!~L4wVQiPm86EYbR;JQWVk8hQ2j8jZ=P zF{)Tv6bg$mnJ67b$mx_@#qFYQO6QV#jt8^Fcsj+6yop6$usLKM3Sd*6OQv`_kyjK#3^%o9flZ9Q6dEC&=E0c1Pk z%S;O=?9E@DqQ$ju@yo&AJVjdsRq-rmhk*vAKwFS62;vNs$&JkSxUES&Umygs@=sx{ wPpec_&{uhFQ%nKm&ca~X2($%rddjnK5ayuAt=RS|<<2$rF6U7&#^{_tBaBMu(TXSV_sTC^x^T zSSfmPx92kEOkMfO6H+B7i#YjDKI*)QF>kV?uoR>Gr>R6P_%rZINUv%;US&PXheEB9n ill6tDF_#O4Feb=_K^U*(av_Xp`5Xx2w7%)000jV3RCn(H diff --git a/weaponry/examples/usage_scenario.rs b/weaponry/examples/usage_scenario.rs index 7644c7e..42a3a5e 100644 --- a/weaponry/examples/usage_scenario.rs +++ b/weaponry/examples/usage_scenario.rs @@ -124,7 +124,7 @@ fn cmd_to_filter(og_entry: &str) -> Result for AdvancedStats { ) .map(|f| *f) .unwrap_or_default(), - avg_damage_single_huge_hit: BestDamageScenarios::from_action_constraints( + avg_damage_2a_huge_hit: BestDamageScenarios::from_action_constraints( value, Actions(2), Attacks(2), - Dices(8), + Dices(10), Precision(9), ) .map(|f| *f) @@ -290,7 +290,7 @@ macro_rules! sort_by { #[macro_export] /// A simple macro to sort the inner advanced field by a specific field // TODO[6] find a way to not have to import the refinedequipement -macro_rules! sort_by_cat_then { +macro_rules! sort_by_weapon_then { ($field:ident) => { |a, b| match a.inner.id[0].cmp(&b.inner.id[0]) { std::cmp::Ordering::Equal => a.advanced.$field.total_cmp(&b.advanced.$field), @@ -298,3 +298,35 @@ macro_rules! sort_by_cat_then { } }; } + +#[macro_export] +/// Sort by size first, then by the given field +macro_rules! sort_by_cat_then { + ($field:ident) => { + |a, b| { + if let (Some(c), Some(d)) = ( + a.inner.category_size.as_ref(), + b.inner.category_size.as_ref(), + ) { + match c.cmp(d) { + std::cmp::Ordering::Equal => a.advanced.$field.total_cmp(&b.advanced.$field), + ord => ord, + } + } else { + a.advanced.$field.total_cmp(&b.advanced.$field) + } + } + }; +} + +#[macro_export] +/// A simple macro to sort the inner advanced field by a specific field +// TODO[6] find a way to not have to import the refinedequipement +macro_rules! sort_by_size_then { + ($field:ident) => { + |a, b| match a.inner.category_size.cmp(&b.inner.category_size) { + std::cmp::Ordering::Equal => a.advanced.$field.total_cmp(&b.advanced.$field), + ord => ord, + } + }; +} diff --git a/weaponry/src/weaponry_structs/equipement_fields.rs b/weaponry/src/weaponry_structs/equipement_fields.rs index 84679d9..4f436ac 100644 --- a/weaponry/src/weaponry_structs/equipement_fields.rs +++ b/weaponry/src/weaponry_structs/equipement_fields.rs @@ -266,8 +266,10 @@ impl EquipementTargets { // TODO[!] : This part is initialized by the natures subtable and might be better of being a new column in the database /// The Base Size of the weapon, used to infer the final category of the weapon #[allow(clippy::missing_docs_in_private_items, missing_docs)] -#[derive(Clone, Debug, Display, Deserialize, Serialize, strum::EnumString)] -#[cfg_attr(test, derive(PartialEq))] +#[derive( + Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Display, Deserialize, Serialize, strum::EnumString, +)] +// #[cfg_attr(test, derive(PartialEq))] pub enum WeaponBaseSize { Light, Medium,