From 9ae9471ccde8e089434a23e3f657b6c579a8e2dc Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 25 Jul 2026 22:30:39 +0200 Subject: [PATCH] Updates rendering --- Cargo.toml | 2 +- crates/config/src/monsters.rs | 4 +++ crates/monsters/src/monster_analysis.rs | 3 ++- .../src/monster_analysis/attack_analysis.rs | 4 +-- .../src/monster_analysis/defense_analysis.rs | 26 +++++++++---------- .../monster_analysis_structs.rs | 7 +++-- crates/monsters/src/monster_export.rs | 2 +- crates/monsters/src/monster_render.rs | 21 ++++++++------- crates/monsters/src/monster_structs.rs | 3 +++ ravenous_databases | 2 +- 10 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9b1de3e..63a6051 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "3" # edition = "2024" # license = "MIT OR Apache-2.0" [workspace.package] -version = "0.3.17" +version = "0.3.18" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/config/src/monsters.rs b/crates/config/src/monsters.rs index 845e4cf..e4bf2e2 100644 --- a/crates/config/src/monsters.rs +++ b/crates/config/src/monsters.rs @@ -102,6 +102,10 @@ pub struct BalanceArgs { #[arg(long, default_value_t = false)] pub show_extra: bool, + /// Show even the balanced numbers + #[arg(long, default_value_t = false)] + pub show_balanced: bool, + /// Show detailed profiles for each monster #[arg(long, default_value_t = false)] pub show_profiles: bool, diff --git a/crates/monsters/src/monster_analysis.rs b/crates/monsters/src/monster_analysis.rs index 117deee..e40c26c 100644 --- a/crates/monsters/src/monster_analysis.rs +++ b/crates/monsters/src/monster_analysis.rs @@ -5,7 +5,7 @@ use comfy_table::modifiers; use config::monsters::BalanceArgs; use crate::{ - Config, Connection, MonsterConfig, + Config, Connection, monster_analysis::monster_analysis_structs::DefenseMode, monster_database::{fetch_all_creature_data, fetch_all_player_data}, monster_render::ToCell, @@ -35,6 +35,7 @@ pub fn show_balancing_data( .apply_modifier(modifiers::UTF8_ROUND_CORNERS) .set_content_arrangement(comfy_table::ContentArrangement::Dynamic); table.add_row(vec![ + creature.id.to_cell(), match creature.balancing.monster_groupsize { 0 | 1 => creature.name.clone(), n => format!("{} x {}", creature.name, n), diff --git a/crates/monsters/src/monster_analysis/attack_analysis.rs b/crates/monsters/src/monster_analysis/attack_analysis.rs index a6fad7e..b05fba6 100644 --- a/crates/monsters/src/monster_analysis/attack_analysis.rs +++ b/crates/monsters/src/monster_analysis/attack_analysis.rs @@ -28,8 +28,8 @@ pub fn all_attacks( ) .unwrap(), ]; - // Filter - if balancing[0].damage_category == attack.target_damage + if !args.show_balanced + && balancing[0].damage_category == attack.target_damage && balancing[0].armor_category == attack.target_ab { return Vec::new(); diff --git a/crates/monsters/src/monster_analysis/defense_analysis.rs b/crates/monsters/src/monster_analysis/defense_analysis.rs index 6d439dc..9e5ef25 100644 --- a/crates/monsters/src/monster_analysis/defense_analysis.rs +++ b/crates/monsters/src/monster_analysis/defense_analysis.rs @@ -30,7 +30,7 @@ pub(crate) fn display_player_attacks( damage_done_to_part(body_part, &profiles[&ProfileStance::Neutral], Phases::P1); let damage_done_p2 = damage_done_to_part(body_part, &profiles[&ProfileStance::Neutral], Phases::P2); - let time_to_p2 = ratio * body_part.integrity_p1.unwrap() as f64 / damage_done_p1.ab_t; + let time_to_p2 = ratio * body_part.life_points_p1.unwrap() as f64 / damage_done_p1.hp_t; let time_to_kill = ratio * (body_part.life_points_p1.unwrap() as f64 / damage_done_p1.hp_t + body_part.life_points_p2.unwrap_or(0) as f64 / damage_done_p2.hp_t); @@ -91,9 +91,9 @@ pub(crate) fn damage_done_to_part( threshold, profile.successes_off - profile.successes_off / 2, ); - let ab_a = (damage_a - protection as f64).max(0.); - let ab_b1 = (damage_b1 - protection as f64).max(0.); - let ab_b2 = (damage_b2 - protection as f64).max(0.); + let ab_a = (damage_a - protection as f64).clamp(0., profile.armor_break as f64); + let ab_b1 = (damage_b1 - protection as f64).clamp(0., profile.armor_break as f64); + let ab_b2 = (damage_b2 - protection as f64).clamp(0., profile.armor_break as f64); let hp_t = damage_a.max(damage_b1 + damage_b2); let ab_t = ab_a.max(ab_b1 + ab_b2); @@ -141,7 +141,7 @@ pub(crate) fn damage_with_profile(damage_profile: &[i64], threshold: i64, dices: #[derive(Debug, FieldsAsSlice)] pub struct DefenseReport { /// Unique identifier for the monster definition. - #[INTEGER] + #[SKIP] pub id: i64, /// Display name of the monster (human‑readable). #[SKIP] @@ -151,6 +151,14 @@ pub struct DefenseReport { /// (Fixed) HSE profile of the monster. #[SKIP(name = "Profile")] pub profile_hse: ProfileHSE, + /// (Actual) Armor‑breaking damage per turn. + /// This is the rate at which the monster’s armor is degraded during combat. + #[INTEGER(name = "AbPT P1")] + pub armor_break_per_turn: f64, + /// (Actual) Turns until this monster’s armor breaks, i.e. the point + /// at which it stops being able to mitigate incoming damage. + #[INTEGER(name = "TT AB")] + pub time_to_armorbreak: f64, /// Damage per turn while in phase 1. /// Used when the monster changes behaviour between phases. #[INTEGER(name = "DPT P1")] @@ -174,14 +182,6 @@ pub struct DefenseReport { /// If actual `time_to_kill` is larger, you may need to adjust attack power or strategy. #[SKIP] pub time_to_kill_target: i64, - /// (Actual) Armor‑breaking damage per turn. - /// This is the rate at which the monster’s armor is degraded during combat. - #[INTEGER(name = "AbPT P1")] - pub armor_break_per_turn: f64, - /// (Actual) Turns until this monster’s armor breaks, i.e. the point - /// at which it stops being able to mitigate incoming damage. - #[INTEGER(name = "TT AB")] - pub time_to_armorbreak: f64, /// (Goal) Desired turns until the monster’s armor breaks. /// A lower value indicates a more aggressive strategy. #[SKIP(name = "ttAB")] diff --git a/crates/monsters/src/monster_analysis/monster_analysis_structs.rs b/crates/monsters/src/monster_analysis/monster_analysis_structs.rs index a2c9171..540b8c8 100644 --- a/crates/monsters/src/monster_analysis/monster_analysis_structs.rs +++ b/crates/monsters/src/monster_analysis/monster_analysis_structs.rs @@ -111,6 +111,8 @@ pub enum ArmorBreakCategory { None, /// Chip damage Chip, + /// Moderate + Moderate, /// High, above half High, /// Full destruction @@ -136,8 +138,9 @@ impl ArmorBreakCategory { match value { ..0.01 => ArmorBreakCategory::None, 0.01..0.3 => ArmorBreakCategory::Chip, - 0.3..0.7 => ArmorBreakCategory::High, - 0.7..1.2 => ArmorBreakCategory::FullBreak, + 0.3..0.5 => ArmorBreakCategory::Moderate, + 0.5..0.9 => ArmorBreakCategory::High, + 0.8..1.2 => ArmorBreakCategory::FullBreak, 1.2.. => ArmorBreakCategory::Overkill, _ => ArmorBreakCategory::None, } diff --git a/crates/monsters/src/monster_export.rs b/crates/monsters/src/monster_export.rs index f24ac07..3cd94b2 100644 --- a/crates/monsters/src/monster_export.rs +++ b/crates/monsters/src/monster_export.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result}; use cli_parser::Config; -use config::monsters::{ExportArgs, MonsterConfig}; +use config::monsters::ExportArgs; use handlebars::{Handlebars, handlebars_helper}; use indexmap::IndexMap; use rusqlite::Connection; diff --git a/crates/monsters/src/monster_render.rs b/crates/monsters/src/monster_render.rs index 3f0e1ed..936e5c4 100644 --- a/crates/monsters/src/monster_render.rs +++ b/crates/monsters/src/monster_render.rs @@ -188,7 +188,8 @@ impl ToColor for ArmorBreakCategory { fn get_color(&self) -> Color { match self { ArmorBreakCategory::None => Color::DarkGrey, - ArmorBreakCategory::Chip => Color::Blue, + ArmorBreakCategory::Chip => Color::Green, + ArmorBreakCategory::Moderate => Color::Blue, ArmorBreakCategory::High => Color::Yellow, ArmorBreakCategory::FullBreak => Color::Red, ArmorBreakCategory::Overkill => Color::DarkRed, @@ -237,16 +238,8 @@ impl ToCell for ProfileStance { impl ToRow for DefenseReport { fn to_row(&self) -> comfy_table::Row { let row: Vec = vec![ - format!("{:?}", self.id).to_cell(), + // format!("{:?}", self.id).to_cell(), helpers::shorten_string(&self.part_name.to_string(), 18).to_cell(), - format!("{:.1?}/{}", self.damage_per_turn_p1, self.health_p1) - .to_cell() - .fg(Color::DarkGrey), - compare_vals("t", self.time_to_p2, self.time_to_p2_target as f64), - format!("{:.1?}/{}", self.damage_per_turn_p2, self.health_p2) - .to_cell() - .fg(Color::DarkGrey), - compare_vals("t", self.time_to_kill, self.time_to_kill_target as f64), format!("{:.1?}/{}", self.armor_break_per_turn, self.integrity_p1) .to_cell() .fg(Color::DarkGrey), @@ -255,6 +248,14 @@ impl ToRow for DefenseReport { self.time_to_armorbreak, self.time_to_armorbreak_target as f64, ), + format!("{:.1?}/{}", self.damage_per_turn_p1, self.health_p1) + .to_cell() + .fg(Color::DarkGrey), + compare_vals("t", self.time_to_p2, self.time_to_p2_target as f64), + format!("{:.1?}/{}", self.damage_per_turn_p2, self.health_p2) + .to_cell() + .fg(Color::DarkGrey), + compare_vals("t", self.time_to_kill, self.time_to_kill_target as f64), ]; row.into() } diff --git a/crates/monsters/src/monster_structs.rs b/crates/monsters/src/monster_structs.rs index 565762f..b14d694 100644 --- a/crates/monsters/src/monster_structs.rs +++ b/crates/monsters/src/monster_structs.rs @@ -481,6 +481,9 @@ pub struct PlayerBalancing { #[INTEGER] /// Current deffensive specialty. pub specialty_def: i64, + #[INTEGER] + /// Current armor_break. + pub armor_break: i64, } #[derive( diff --git a/ravenous_databases b/ravenous_databases index cd34aa2..430114d 160000 --- a/ravenous_databases +++ b/ravenous_databases @@ -1 +1 @@ -Subproject commit cd34aa21d07d0bf0bcda0f88e12279b791546a20 +Subproject commit 430114d8e51fc3c85a0e9e2718f62e8ab8848f98 -- 2.45.1