From ba8e6c09f367d07816432f359da4ff0ca37c75f1 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 30 Jul 2026 04:04:03 +0200 Subject: [PATCH] Balancing & some display features --- crates/monsters/src/monster_analysis.rs | 6 ++-- .../src/monster_analysis/attack_analysis.rs | 4 +-- .../src/monster_analysis/defense_analysis.rs | 9 +++--- crates/monsters/src/monster_database.rs | 2 +- crates/monsters/src/monster_render.rs | 32 ++++++++++++++----- crates/monsters/src/monster_structs.rs | 1 + ravenous_databases | 2 +- 7 files changed, 37 insertions(+), 19 deletions(-) diff --git a/crates/monsters/src/monster_analysis.rs b/crates/monsters/src/monster_analysis.rs index 01e98d2..5e05bd7 100644 --- a/crates/monsters/src/monster_analysis.rs +++ b/crates/monsters/src/monster_analysis.rs @@ -3,6 +3,7 @@ use comfy_table::modifiers; use config::monsters::BalanceArgs; +use indexmap::IndexMap; use crate::{ Config, Connection, @@ -12,9 +13,8 @@ use crate::{ monster_structs::{PlayerBalancing, ProfileStance}, }; pub mod attack_analysis; -pub mod helpers; -use std::collections::HashMap; pub mod defense_analysis; +pub mod helpers; pub mod monster_analysis_structs; /// Shows balancing information for monsters and players. @@ -53,7 +53,7 @@ pub fn show_balancing_data( .filter(|v| &v.profile_hse == player_level) .collect::>(); - let profiles: HashMap = available_profiles + let profiles: IndexMap = available_profiles .into_iter() .map(|profile| (profile.profile_stance, profile)) .collect(); diff --git a/crates/monsters/src/monster_analysis/attack_analysis.rs b/crates/monsters/src/monster_analysis/attack_analysis.rs index cb4743a..f45feeb 100644 --- a/crates/monsters/src/monster_analysis/attack_analysis.rs +++ b/crates/monsters/src/monster_analysis/attack_analysis.rs @@ -8,15 +8,15 @@ use crate::{ monster_structs::{PlayerBalancing, ProfileStance}, }; use config::monsters::BalanceArgs; +use indexmap::IndexMap; use more_fields::FieldsAsSlice; use std::cmp::max; -use std::collections::HashMap; /// Returns the Balancing profile, and eventually the other profiles as well pub fn all_attacks( args: &BalanceArgs, attack: &monster_analysis_structs::MonsterBalancingAttack, - victims: &HashMap, + victims: &IndexMap, mode: DefenseMode, ) -> Vec { let mut balancing = vec![ diff --git a/crates/monsters/src/monster_analysis/defense_analysis.rs b/crates/monsters/src/monster_analysis/defense_analysis.rs index 94ec054..58a3943 100644 --- a/crates/monsters/src/monster_analysis/defense_analysis.rs +++ b/crates/monsters/src/monster_analysis/defense_analysis.rs @@ -8,13 +8,14 @@ use crate::{ monster_structs::{CreatureBodyPart, FullMonster, PlayerBalancing, ProfileHSE, ProfileStance}, }; use config::monsters::BalanceArgs; +use indexmap::IndexMap; use more_fields::FieldsAsSlice; -use std::{collections::HashMap, ops::AddAssign}; +use std::ops::AddAssign; pub(crate) fn display_player_attacks( args: &BalanceArgs, creature: &FullMonster, - profiles: &HashMap, + profiles: &IndexMap, mode: DefenseMode, ) { let _ = mode; @@ -25,7 +26,7 @@ pub(crate) fn display_player_attacks( fn report_from_profile( args: &BalanceArgs, creature: &FullMonster, - profiles: &HashMap, + profiles: &IndexMap, ) -> Vec { creature .body_parts @@ -405,7 +406,7 @@ pub struct DefenseReport { pub(crate) fn display_monster_attacks( args: &BalanceArgs, creature: FullMonster, - profiles: &HashMap, + profiles: &IndexMap, mode: DefenseMode, ) { let attacks: Vec = creature.into(); diff --git a/crates/monsters/src/monster_database.rs b/crates/monsters/src/monster_database.rs index 0b0ba77..e890020 100644 --- a/crates/monsters/src/monster_database.rs +++ b/crates/monsters/src/monster_database.rs @@ -34,7 +34,7 @@ pub(crate) fn fetch_all_creature_data( filter: Option<&str>, ) -> Result, anyhow::Error> { let list_creatures = - generic_deserialize::(connection, "creature", filter, Some("id"))?; + generic_deserialize::(connection, "creature", filter, Some("sort_id"))?; let mut finished_creatures = Vec::new(); for creature in list_creatures.iter() { // println!("Working on {}@{}", creature.id, creature.name); diff --git a/crates/monsters/src/monster_render.rs b/crates/monsters/src/monster_render.rs index a84f5b0..fd1983e 100644 --- a/crates/monsters/src/monster_render.rs +++ b/crates/monsters/src/monster_render.rs @@ -96,6 +96,17 @@ macro_rules! dim_if_not { } }}; } +macro_rules! attr_if_not { + ($self:ident, $content:expr, $attribute:expr) => {{ + match $self.showcase { + Showcase::Display => $content + // .add_attribute(Attribute::Dim) + .add_attribute($attribute), + // .fg(Color::DarkGrey) + Showcase::Balancing => $content, + } + }}; +} impl ToRow for DamageReport { fn to_row(&self) -> Row { vec![ @@ -111,12 +122,16 @@ impl ToRow for DamageReport { ) .to_cell() ), - format!("{}", self.fatigue,) - .to_cell() - .add_attribute(match self.fatigue == 0 { - true => Attribute::Hidden, - false => Attribute::NoHidden, - }), + attr_if_not!( + self, + format!("{}", self.fatigue,) + .to_cell() + .add_attribute(match self.fatigue == 0 { + true => Attribute::Hidden, + false => Attribute::NoHidden, + }), + Attribute::Hidden + ), dim_if_not!( self, format!("{:.1} [>{:.1}]", self.successes_left, self.threshold) @@ -143,7 +158,7 @@ impl ToRow for DamageReport { }, ) ), - dim_if_not!(self, self.damage_expected.to_cell()), + attr_if_not!(self, self.damage_expected.to_cell(), Attribute::Hidden), dim_if_not!( self, format!("{:.1}/{:.1}", self.armor_loss, self.player_integrity) @@ -160,7 +175,7 @@ impl ToRow for DamageReport { }, ) ), - dim_if_not!(self, self.armor_expected.to_cell()), + attr_if_not!(self, self.armor_expected.to_cell(), Attribute::Hidden), ] .into() } @@ -240,6 +255,7 @@ impl ToCell for ProfileStance { ProfileStance::Defensive => Into::::into(format!("{self:?}")).fg(Color::Blue), ProfileStance::Offensive => Into::::into(format!("{self:?}")).fg(Color::Red), ProfileStance::Neutral => Into::::into(format!("{self:?}")).fg(Color::Yellow), + ProfileStance::NoDefense => Into::::into(format!("{self:?}")).fg(Color::DarkRed), } } } diff --git a/crates/monsters/src/monster_structs.rs b/crates/monsters/src/monster_structs.rs index 4e66698..0d60aba 100644 --- a/crates/monsters/src/monster_structs.rs +++ b/crates/monsters/src/monster_structs.rs @@ -498,6 +498,7 @@ pub struct PlayerBalancing { pub enum ProfileStance { Defensive, Offensive, + NoDefense, #[default] Neutral, } diff --git a/ravenous_databases b/ravenous_databases index 100d805..d259078 160000 --- a/ravenous_databases +++ b/ravenous_databases @@ -1 +1 @@ -Subproject commit 100d805aa2741d86d8fefa2d4916ff398a1a9fcc +Subproject commit d259078b51caee4ddfc9e1f0f44a82451a82ea18 -- 2.45.1