Adds more info to damage to creature

This commit is contained in:
Dandaedre 2026-07-27 16:25:59 +02:00
parent d58ddc9349
commit 55960bffbd
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
2 changed files with 125 additions and 67 deletions

View File

@ -2,12 +2,13 @@ use crate::{
monster_analysis::{
DefenseMode, attack_analysis,
helpers::{binomial_dice_distribution, how_much_with_succeses},
monster_analysis_structs,
monster_analysis_structs::{self, Showcase},
},
monster_render::ToTable,
monster_structs::{CreatureBodyPart, FullMonster, PlayerBalancing, ProfileHSE, ProfileStance},
};
use config::monsters::BalanceArgs;
use indexmap::IndexMap;
use more_fields::FieldsAsSlice;
use std::collections::HashMap;
@ -17,56 +18,81 @@ pub(crate) fn display_player_attacks(
profiles: &HashMap<ProfileStance, PlayerBalancing>,
mode: DefenseMode,
) {
let _ = args;
let _ = mode;
let r = &creature
let r = report_from_profile(args, creature, profiles);
println!("{}", r.to_table());
}
fn report_from_profile(
args: &BalanceArgs,
creature: &FullMonster,
profiles: &HashMap<ProfileStance, PlayerBalancing>,
) -> Vec<DefenseReport> {
creature
.body_parts
.body_parts
.iter()
.map(|body_part| {
let ratio = creature.balancing.monster_groupsize / creature.balancing.player_groupsize;
let damage_done_p1 =
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.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);
let time_to_armorbreak =
ratio * (body_part.integrity_p1.unwrap() as f64 / damage_done_p1.ab_t);
let time_to_kill_through = ratio
* (body_part.life_points_p1.unwrap() as f64
/ (damage_done_p1.damage_through - creature.stats.strength as f64).max(0.)
+ body_part.life_points_p2.unwrap_or(0) as f64
/ (damage_done_p2.damage_through - creature.stats.strength as f64).max(0.));
DefenseReport {
id: creature.balancing.creature_id,
name: creature.name.clone(),
part_name: body_part.body_part_name.clone(),
profile_hse: creature.balancing.profile_hse.clone(),
time_to_p2,
time_to_p2_target: creature.balancing.time_to_p2,
time_to_armorbreak,
time_to_player_kill: creature.balancing.time_to_player_kill,
monster_groupsize: creature.balancing.monster_groupsize,
player_groupsize: creature.balancing.player_groupsize,
time_to_kill,
time_to_kill_target: creature.balancing.time_to_kill,
damage_per_turn_p1: damage_done_p1.hp_t,
damage_per_turn_p2: damage_done_p2.hp_t,
health_p1: body_part.life_points_p1.unwrap(),
health_p2: body_part.life_points_p2.unwrap_or(0),
time_to_armorbreak_target: creature.balancing.time_to_armorbreak,
armor_break_per_turn: damage_done_p1.ab_t,
integrity_p1: body_part.integrity_p1.unwrap(),
damage_through_p1: damage_done_p1.damage_through,
damage_through_p2: damage_done_p2.damage_through,
time_to_kill_through,
.flat_map(|body_part| {
match args.show_extra {
true => vec![
(ProfileStance::Neutral, Showcase::Display),
(ProfileStance::Defensive, Showcase::Balancing),
(ProfileStance::Offensive, Showcase::Balancing),
],
false => vec![(ProfileStance::Neutral, Showcase::Display)],
}
.into_iter()
.map(|(p, show)| damage_report_on_part(creature, &profiles[&p], body_part, show))
.collect::<Vec<DefenseReport>>()
})
.collect::<Vec<DefenseReport>>();
println!("{}", r.to_table());
.collect::<Vec<DefenseReport>>()
}
fn damage_report_on_part(
creature: &FullMonster,
profile: &PlayerBalancing,
body_part: &CreatureBodyPart,
display: Showcase,
) -> DefenseReport {
let ratio = creature.balancing.monster_groupsize / creature.balancing.player_groupsize;
let damage_done_p1 = damage_done_to_part(body_part, profile, Phases::P1);
let damage_done_p2 = damage_done_to_part(body_part, profile, Phases::P2);
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);
let time_to_armorbreak = ratio * (body_part.integrity_p1.unwrap() as f64 / damage_done_p1.ab_t);
let time_to_kill_through = ratio
* (body_part.life_points_p1.unwrap() as f64
/ (damage_done_p1.damage_through - creature.stats.strength as f64).max(0.)
+ body_part.life_points_p2.unwrap_or(0) as f64
/ (damage_done_p2.damage_through - creature.stats.strength as f64).max(0.));
DefenseReport {
id: creature.balancing.creature_id,
name: creature.name.clone(),
part_name: body_part.body_part_name.clone(),
profile_hse: creature.balancing.profile_hse.clone(),
time_to_p2,
time_to_p2_target: creature.balancing.time_to_p2,
time_to_armorbreak,
time_to_player_kill: creature.balancing.time_to_player_kill,
monster_groupsize: creature.balancing.monster_groupsize,
player_groupsize: creature.balancing.player_groupsize,
time_to_kill,
time_to_kill_target: creature.balancing.time_to_kill,
damage_per_turn_p1: damage_done_p1.hp_t,
damage_per_turn_p2: damage_done_p2.hp_t,
health_p1: body_part.life_points_p1.unwrap(),
health_p2: body_part.life_points_p2.unwrap_or(0),
time_to_armorbreak_target: creature.balancing.time_to_armorbreak,
armor_break_per_turn: damage_done_p1.ab_t,
integrity_p1: body_part.integrity_p1.unwrap(),
damage_through_p1: damage_done_p1.damage_through,
damage_through_p2: damage_done_p2.damage_through,
time_to_kill_through,
target_stance: profile.profile_stance,
showcase: display,
}
}
pub fn resist_physical(part: &CreatureBodyPart, mode: DefenseMode) -> i64 {
@ -199,9 +225,12 @@ pub struct DefenseReport {
pub name: String,
/// The part of the monster’s body that is currently active
pub part_name: String,
/// (Fixed) HSE profile of the monster.
/// (Fixed) HSE profile of the hunter.
#[SKIP(name = "Profile")]
pub profile_hse: ProfileHSE,
/// (Fixed) Stance of the player.
#[SKIP(name = "Stance")]
pub target_stance: ProfileStance,
/// (Actual) Armor‑breaking damage per turn.
/// This is the rate at which the monster’s armor is degraded during combat.
#[INTEGER(name = "AbPT P1")]
@ -266,6 +295,9 @@ pub struct DefenseReport {
/// (Actual) Time to kill through armor
#[INTEGER(name = "P1 ⇝ P2 ⇝ 🕇")]
pub time_to_kill_through: f64,
/// (Misc) Display name or target of balancing
#[SKIP]
pub showcase: Showcase,
}
pub(crate) fn display_monster_attacks(

View File

@ -100,7 +100,7 @@ impl ToRow for DamageReport {
fn to_row(&self) -> Row {
vec![
match self.showcase {
Showcase::Balancing => shorten_string(&self.name, 24).to_cell().fg(Color::Green),
Showcase::Balancing => shorten_string(&self.name, 22).to_cell().fg(Color::Green),
Showcase::Display => self.stance.to_string().to_cell().fg(Color::DarkGrey),
},
dim_if_not!(
@ -248,27 +248,53 @@ impl ToRow for DefenseReport {
fn to_row(&self) -> comfy_table::Row {
let row: Vec<Cell> = vec![
// format!("{:?}", self.id).to_cell(),
helpers::shorten_string(&self.part_name.to_string(), 18).to_cell(),
format!("{:.1?}/{}", self.armor_break_per_turn, self.integrity_p1)
match self.showcase {
Showcase::Display => {
helpers::shorten_string(&self.part_name.to_string(), 18).to_cell()
}
Showcase::Balancing => self.target_stance.to_cell().fg(Color::DarkGrey),
},
dim_if_not!(
self,
format!("{:.1?}/{}", self.armor_break_per_turn, self.integrity_p1)
.to_cell()
.fg(Color::DarkGrey)
),
dim_if_not!(
self,
compare_vals("t", self.time_to_armorbreak, self.time_to_armorbreak_target)
),
dim_if_not!(
self,
format!("{:.1?}/{}", self.damage_per_turn_p1, self.health_p1)
.to_cell()
.fg(Color::DarkGrey)
),
dim_if_not!(
self,
compare_vals("t", self.time_to_p2, self.time_to_p2_target)
),
dim_if_not!(
self,
format!("{:.1?}/{}", self.damage_per_turn_p2, self.health_p2)
.to_cell()
.fg(Color::DarkGrey)
),
dim_if_not!(
self,
compare_vals("t", self.time_to_kill, self.time_to_kill_target)
),
dim_if_not!(
self,
format!(
"[{:.0} & {:.0}] ⇝ {}",
self.damage_through_p1,
self.damage_per_turn_p2,
fmt_target(self.time_to_kill_through)
)
.to_cell()
.fg(Color::DarkGrey),
compare_vals("t", self.time_to_armorbreak, self.time_to_armorbreak_target),
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),
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),
format!(
"[{:.0} & {:.0}] ⇝ {}",
self.damage_through_p1,
self.damage_per_turn_p2,
fmt_target(self.time_to_kill_through)
)
.to_cell()
.fg(Color::DarkGrey),
.fg(Color::DarkGrey)
),
];
row.into()
}