Updates rendering #143

Merged
Dandaedre merged 1 commits from database_monsters into main 2026-07-25 22:32:13 +02:00
10 changed files with 43 additions and 31 deletions

View File

@ -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

View File

@ -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,

View File

@ -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),

View File

@ -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();

View File

@ -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")]

View File

@ -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,
}

View File

@ -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;

View File

@ -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<Cell> = 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()
}

View File

@ -481,6 +481,9 @@ pub struct PlayerBalancing {
#[INTEGER]
/// Current deffensive specialty.
pub specialty_def: i64,
#[INTEGER]
/// Current armor_break.
pub armor_break: i64,
}
#[derive(

@ -1 +1 @@
Subproject commit cd34aa21d07d0bf0bcda0f88e12279b791546a20
Subproject commit 430114d8e51fc3c85a0e9e2718f62e8ab8848f98