From f5e63b9b899644cd8135855dcd49ff6bdebb14fc Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 23 Jul 2026 18:43:29 +0200 Subject: [PATCH] Adds more balancing fields --- Cargo.toml | 2 +- crates/monsters/src/monster_analysis.rs | 56 +++++++++++++++++++++++-- crates/monsters/src/monster_render.rs | 2 +- crates/monsters/src/monster_structs.rs | 12 ++++-- helper_config.toml | 2 +- ravenous_databases | 2 +- 6 files changed, 65 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index efd0cd8..169995c 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.13" +version = "0.3.14" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/monsters/src/monster_analysis.rs b/crates/monsters/src/monster_analysis.rs index 83656ed..26c46c2 100644 --- a/crates/monsters/src/monster_analysis.rs +++ b/crates/monsters/src/monster_analysis.rs @@ -1,13 +1,13 @@ //! Monster export module +#![allow(dead_code)] use crate::{ Config, Connection, MonsterConfig, monster_database::{fetch_all_creature_data, fetch_all_player_data}, monster_render::ToRow, - monster_structs::PlayerBalancing, + monster_structs::{MonsterFullAttack, PlayerBalancing}, }; -use comfy_table::presets::UTF8_FULL; -use comfy_table::*; +use comfy_table::{presets, *}; use more_fields::FieldsAsSlice; /// Shows balancing information for monsters and players. @@ -22,7 +22,8 @@ pub fn show_balancing_data( let mut table = Table::new(); table - .load_preset(UTF8_FULL) + .load_preset(presets::UTF8_FULL_CONDENSED) + .apply_modifier(modifiers::UTF8_ROUND_CORNERS) .set_content_arrangement(ContentArrangement::Dynamic) .set_width(120) .set_header( @@ -41,3 +42,50 @@ pub fn show_balancing_data( println!("{table}"); Ok(()) } + +impl PlayerBalancing { + // /// Estimate what an attack does to a player + // pub fn estimate_attack(&self, atk: MonsterAttack) {} + + /// Apply an attack to a player, returns the damage done but "healing" afterwards + pub fn apply_attack(&mut self, atk: &MonsterAttack) -> DamageDone { + let _ = atk; + self.health -= 1; + DamageDone { + armor: 0, + health: 0, + category: DamageCategory::Low, + } + } +} + +pub struct MonsterAttack<'a> { + base_attack: &'a MonsterFullAttack, + damage: Vec, + successes: usize, + armor_break: usize, + action_cost: usize, +} + +pub struct DamageDone { + armor: i64, + health: i64, + category: DamageCategory, +} + +pub enum DamageCategory { + /// No lasting damage + None, + /// Chip damage + Low, + /// Average, under half + Moderate, + /// High, above half + High, + /// Near death 90% + NearDeath, + /// Kill, above > 100% + Kill, + /// Complete overkill > 200% + Overkill, +} diff --git a/crates/monsters/src/monster_render.rs b/crates/monsters/src/monster_render.rs index 44c82c4..461f7d3 100644 --- a/crates/monsters/src/monster_render.rs +++ b/crates/monsters/src/monster_render.rs @@ -18,7 +18,7 @@ impl ToRow for PlayerBalancing { self.profile_hse.to_cell(), self.profile_stance.to_cell(), Cell::new(format!("{:?}", self.damage_per_s)), - Cell::new(format!("{:?}", self.successes)), + Cell::new(format!("{:?}", self.successes_off)), Cell::new(format!("{:?}", self.protection)), Cell::new(format!("{:?}", self.strength)), Cell::new(format!("{:?}", self.integrity)), diff --git a/crates/monsters/src/monster_structs.rs b/crates/monsters/src/monster_structs.rs index f008401..3c18127 100644 --- a/crates/monsters/src/monster_structs.rs +++ b/crates/monsters/src/monster_structs.rs @@ -199,6 +199,9 @@ pub struct MonsterSingleAttack { /// Fatigue cost for activating the ability. #[INTEGER] pub cost_fatigue: Option, + /// Armor_break of the ability. + #[INTEGER] + pub armor_break: Option, /// Action‑point cost (used in systems where actions and fatigue are separate). #[INTEGER] pub cost_action: Option, @@ -417,7 +420,7 @@ pub struct CreatureBalancing { time_to_armorbreak: i64, #[INTEGER] /// (GOAL) Avg. turns to kill a single target. - time_to_kill_avg: i64, + time_to_first_kill: i64, #[INTEGER] /// (FIXED) Size of a single monster group (usually one). monster_groupsize: i64, @@ -441,8 +444,11 @@ pub struct PlayerBalancing { /// Damage dealt per success. pub damage_per_s: f64, #[INTEGER] - /// Number of successes per round. - pub successes: i64, + /// Number of offensive successes per round. + pub successes_off: i64, + #[INTEGER] + /// Number of deffensive successes per round. + pub successes_def: i64, #[INTEGER] /// Amount of protection (e.g., armor) the player has. pub protection: i64, diff --git a/helper_config.toml b/helper_config.toml index dd8d083..8df5d8c 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -276,7 +276,7 @@ master_part = ''' {{#each phase as | attack_group |}} \hline {{#each attack_group.attacklist}} -\SetCell{bg={{{../color}}}} & {{{name}}} & {{{attack_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} {{{success}}}& {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\ +\SetCell{bg={{{../color}}}} & {{{name}}} & {{{attack_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} {{{success}}}& {{#if armor_break}} {{{armor_break}}}\arbreakk{} {{/if}} {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\ {{/each}} {{#if description_final}}\SetCell{bg={{{color}}}} & \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\ {{/if}} \hline diff --git a/ravenous_databases b/ravenous_databases index f52776f..01dbdc1 160000 --- a/ravenous_databases +++ b/ravenous_databases @@ -1 +1 @@ -Subproject commit f52776f917aeaf0e29944351d05f76efb0ecb2f6 +Subproject commit 01dbdc14a30d63a555aa5848619f941585934fd3 -- 2.45.1