Adds more balancing fields #134

Merged
Dandaedre merged 1 commits from database_monsters into main 2026-07-23 18:44:42 +02:00
6 changed files with 65 additions and 11 deletions

View File

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

View File

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

View File

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

View File

@ -199,6 +199,9 @@ pub struct MonsterSingleAttack {
/// Fatigue cost for activating the ability.
#[INTEGER]
pub cost_fatigue: Option<String>,
/// Armor_break of the ability.
#[INTEGER]
pub armor_break: Option<i64>,
/// Action‑point cost (used in systems where actions and fatigue are separate).
#[INTEGER]
pub cost_action: Option<String>,
@ -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,

View File

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

@ -1 +1 @@
Subproject commit f52776f917aeaf0e29944351d05f76efb0ecb2f6
Subproject commit 01dbdc14a30d63a555aa5848619f941585934fd3