Compare commits

..

1 Commits

Author SHA1 Message Date
Dandaedre d79ddf6255
Bad multithread tentative 2026-07-28 23:21:56 +02:00
16 changed files with 154 additions and 91 deletions

4
.gitmodules vendored
View File

@ -1,4 +1,4 @@
[submodule "ravenous_databases"]
path = ravenous_databases
url = git@git.dandaedre.com:Ravenous/ravenous_databases.git
# url = https://proxy.dandaedre.com/gitea/Ravenous/ravenous_databases.git
# url = git@git.dandaedre.com:Ravenous/ravenous_databases.git
url = https://proxy.dandaedre.com/gitea/Ravenous/ravenous_databases.git

View File

@ -6,7 +6,7 @@ resolver = "3"
# edition = "2024"
# license = "MIT OR Apache-2.0"
[workspace.package]
version = "0.3.34"
version = "0.3.26"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -128,6 +128,9 @@ pub struct MonsterMarkup {
/// Master part of monsters
pub master_part: String,
/// The list of all includes
pub meta_import: String,
}
#[derive(Deserialize)]

View File

@ -62,7 +62,7 @@ pub fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
Some(MakeTargets::Clean) => make_clean(args),
None => {
let file = make_file(args);
launch_subprocess(args, file).context("Launching PdfLatex")?;
launch_subprocess(args, file).unwrap();
}
}
Ok(())

View File

@ -3,7 +3,6 @@
use comfy_table::modifiers;
use config::monsters::BalanceArgs;
use indexmap::IndexMap;
use crate::{
Config, Connection,
@ -13,8 +12,9 @@ use crate::{
monster_structs::{PlayerBalancing, ProfileStance},
};
pub mod attack_analysis;
pub mod defense_analysis;
pub mod helpers;
use std::collections::HashMap;
pub mod defense_analysis;
pub mod monster_analysis_structs;
/// Shows balancing information for monsters and players.
@ -53,7 +53,7 @@ pub fn show_balancing_data(
.filter(|v| &v.profile_hse == player_level)
.collect::<Vec<PlayerBalancing>>();
let profiles: IndexMap<ProfileStance, PlayerBalancing> = available_profiles
let profiles: HashMap<ProfileStance, PlayerBalancing> = available_profiles
.into_iter()
.map(|profile| (profile.profile_stance, profile))
.collect();

View File

@ -8,15 +8,15 @@ use crate::{
monster_structs::{PlayerBalancing, ProfileStance},
};
use config::monsters::BalanceArgs;
use indexmap::IndexMap;
use more_fields::FieldsAsSlice;
use std::cmp::max;
use std::collections::HashMap;
/// Returns the Balancing profile, and eventually the other profiles as well
pub fn all_attacks(
args: &BalanceArgs,
attack: &monster_analysis_structs::MonsterBalancingAttack,
victims: &IndexMap<ProfileStance, PlayerBalancing>,
victims: &HashMap<ProfileStance, PlayerBalancing>,
mode: DefenseMode,
) -> Vec<DamageReport> {
let mut balancing = vec![
@ -72,14 +72,9 @@ pub fn attack_player(
})
.sum::<f64>();
let damage_incoming = avg_damage_incomming;
let mut damage_tanked =
(damage_incoming - (victim.protection + victim.strength) as f64).max(0.0);
let mut armor_loss =
let damage_tanked = (damage_incoming - (victim.protection + victim.strength) as f64).max(0.0);
let armor_loss =
(damage_incoming - victim.protection as f64).clamp(0.0, attack.armor_break as f64);
if avg_successes_left > 0. {
armor_loss += attack.antimaterial as f64;
damage_tanked += attack.armor_pierce.min(victim.protection) as f64;
}
let report = DamageReport {
damage_incoming,
damage_tanked,

View File

@ -8,14 +8,13 @@ use crate::{
monster_structs::{CreatureBodyPart, FullMonster, PlayerBalancing, ProfileHSE, ProfileStance},
};
use config::monsters::BalanceArgs;
use indexmap::IndexMap;
use more_fields::FieldsAsSlice;
use std::ops::AddAssign;
use std::{collections::HashMap, ops::AddAssign};
pub(crate) fn display_player_attacks(
args: &BalanceArgs,
creature: &FullMonster,
profiles: &IndexMap<ProfileStance, PlayerBalancing>,
profiles: &HashMap<ProfileStance, PlayerBalancing>,
mode: DefenseMode,
) {
let _ = mode;
@ -26,7 +25,7 @@ pub(crate) fn display_player_attacks(
fn report_from_profile(
args: &BalanceArgs,
creature: &FullMonster,
profiles: &IndexMap<ProfileStance, PlayerBalancing>,
profiles: &HashMap<ProfileStance, PlayerBalancing>,
) -> Vec<DefenseReport> {
creature
.body_parts
@ -406,7 +405,7 @@ pub struct DefenseReport {
pub(crate) fn display_monster_attacks(
args: &BalanceArgs,
creature: FullMonster,
profiles: &IndexMap<ProfileStance, PlayerBalancing>,
profiles: &HashMap<ProfileStance, PlayerBalancing>,
mode: DefenseMode,
) {
let attacks: Vec<monster_analysis_structs::MonsterBalancingAttack> = creature.into();

View File

@ -29,8 +29,6 @@ impl From<FullMonster> for Vec<MonsterBalancingAttack> {
target_damage: sub_attack.target_damage_category.into(),
target_ab: sub_attack.target_ab_category.into(),
target_stance: sub_attack.target_stance.into(),
antimaterial: from_opt_i64(sub_attack.antimaterial.as_ref()),
armor_pierce: from_opt_i64(sub_attack.armor_pierce.as_ref()),
}
})
.filter(|sub| !sub.damage.is_empty())
@ -78,10 +76,6 @@ pub struct MonsterBalancingAttack {
pub target_ab: ArmorBreakCategory,
#[TEXT(name = "stance_t")]
pub target_stance: ProfileStance,
#[SKIP(name = "AM")]
pub antimaterial: i64,
#[SKIP(name = "AP")]
pub armor_pierce: i64,
}
pub struct DamageDone {

View File

@ -34,7 +34,7 @@ pub(crate) fn fetch_all_creature_data(
filter: Option<&str>,
) -> Result<Vec<FullMonster>, anyhow::Error> {
let list_creatures =
generic_deserialize::<CreatureData>(connection, "creature", filter, Some("sort_id"))?;
generic_deserialize::<CreatureData>(connection, "creature", filter, Some("id"))?;
let mut finished_creatures = Vec::new();
for creature in list_creatures.iter() {
// println!("Working on {}@{}", creature.id, creature.name);

View File

@ -29,18 +29,13 @@ macro_rules! template_load {
}
handlebars_helper!(plus: |x:i64 ,y:Option<i64>| x+y.unwrap_or(0));
handlebars_helper!(threshold_bonus: |threshold:i64, size:i64| {
let mal = (threshold-6-size).min(-2);
let bon = threshold-mal-6;
format!("{:+}{:+}",mal,bon)
});
fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
let mut templates = Handlebars::new();
template_load!(templates, &config.monster, common_part);
template_load!(templates, &config.monster, master_part);
template_load!(templates, &config.monster, meta_import);
templates.register_helper("plus", Box::new(plus));
templates.register_helper("threshold_bonus", Box::new(threshold_bonus));
Ok(templates)
}
@ -53,31 +48,66 @@ pub fn generate_monsters_tex(
let all_monsters = fetch_all_creature_data(&connection, config, args.filter.filter.as_deref())?;
let templates = load_templates(config)?;
println!("Processing");
let mut m_out = String::new();
let mut p_out = String::new();
let mut player_files: Vec<String> = Vec::new();
let mut master_files: Vec<String> = Vec::new();
for creature in &all_monsters {
let mut m_out = String::new();
let mut p_out = String::new();
if !creature.data.show_to_master.is_none_or(|v| v == 0) {
println!(" > {}", creature.name);
};
println!(" > MASTER : Processing {}", creature.name);
master_files.push(format!("./Bestiaire/master_{}.tex", creature.id));
}
if !creature.data.show_to_players.is_none_or(|v| v == 0) {
println!(" > PLAYER : Processing {}", creature.name);
player_files.push(format!("./Bestiaire/player_{}.tex", creature.id));
// player_files.push(format!("./{}/player_{}", args.destination, creature.id));
}
write!(p_out, "{}", templates.render("common_part", &creature)?)?;
if args.master || args.all {
write!(m_out, "{}", templates.render("common_part", &creature)?)?;
write!(m_out, "{}", templates.render("master_part", &creature)?)?;
}
if args.player || args.all {
println!(" > PLAYER : Writing creature {}", creature.name);
let path = format!("./{}/player_{}.tex", args.destination, creature.id);
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
write!(f, "{}", p_out).context(format!("Writing {}", path))?;
}
if args.master || args.all {
println!(" > MASTER : Writing creature {}", creature.name);
let path = format!("./{}/master_{}.tex", args.destination, creature.id);
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
write!(f, "{}", m_out).context(format!("Writing {}", path))?;
}
}
if args.player || args.all {
println!("Generating Player Bestiaire");
println!("Writing Player Bestiaire");
let path = format!("./{}/player_bestiaire.tex", args.destination);
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
write!(f, "{}", p_out).context(format!("Writing {}", path))?;
write!(
f,
"{}",
templates
.render("meta_import", &master_files)
.context("Processing meta import")?
)
.context(format!("Writing {}", path))?;
}
if args.master || args.all {
println!("Generating Master Bestiaire");
println!("Writing Master Bestiaire");
let path = format!("./{}/master_bestiaire.tex", args.destination);
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
write!(f, "{}", m_out).context(format!("Writing {}", path))?;
write!(
f,
"{}",
templates
.render("meta_import", &master_files)
.context("Processing meta import")?
)
.context(format!("Writing {}", path))?;
}
Ok(())
}

View File

@ -96,28 +96,11 @@ macro_rules! dim_if_not {
}
}};
}
macro_rules! attr_if_not {
($self:ident, $content:expr, $attribute:expr) => {{
match $self.showcase {
Showcase::Display => $content
// .add_attribute(Attribute::Dim)
.add_attribute($attribute),
// .fg(Color::DarkGrey)
Showcase::Balancing => $content,
}
}};
}
impl ToRow for DamageReport {
fn to_row(&self) -> Row {
vec![
match self.showcase {
Showcase::Balancing => format!(
"[{}]{}",
self.stance.to_string().chars().nth(0).unwrap_or(' '),
shorten_string(&self.name, 15)
)
.to_cell()
.fg(Color::Green),
Showcase::Balancing => shorten_string(&self.name, 20).to_cell().fg(Color::Green),
Showcase::Display => self.stance.to_string().to_cell().fg(Color::DarkGrey),
},
dim_if_not!(
@ -128,16 +111,12 @@ impl ToRow for DamageReport {
)
.to_cell()
),
attr_if_not!(
self,
format!("{}", self.fatigue,)
.to_cell()
.add_attribute(match self.fatigue == 0 {
true => Attribute::Hidden,
false => Attribute::NoHidden,
}),
Attribute::Hidden
),
format!("{}", self.fatigue,)
.to_cell()
.add_attribute(match self.fatigue == 0 {
true => Attribute::Hidden,
false => Attribute::NoHidden,
}),
dim_if_not!(
self,
format!("{:.1} [>{:.1}]", self.successes_left, self.threshold)
@ -164,7 +143,7 @@ impl ToRow for DamageReport {
},
)
),
attr_if_not!(self, self.damage_expected.to_cell(), Attribute::Hidden),
dim_if_not!(self, self.damage_expected.to_cell()),
dim_if_not!(
self,
format!("{:.1}/{:.1}", self.armor_loss, self.player_integrity)
@ -181,7 +160,7 @@ impl ToRow for DamageReport {
},
)
),
attr_if_not!(self, self.armor_expected.to_cell(), Attribute::Hidden),
dim_if_not!(self, self.armor_expected.to_cell()),
]
.into()
}
@ -261,7 +240,6 @@ impl ToCell for ProfileStance {
ProfileStance::Defensive => Into::<Cell>::into(format!("{self:?}")).fg(Color::Blue),
ProfileStance::Offensive => Into::<Cell>::into(format!("{self:?}")).fg(Color::Red),
ProfileStance::Neutral => Into::<Cell>::into(format!("{self:?}")).fg(Color::Yellow),
ProfileStance::NoDefense => Into::<Cell>::into(format!("{self:?}")).fg(Color::DarkRed),
}
}
}

View File

@ -203,12 +203,6 @@ pub struct MonsterSingleAttack {
/// Armor_break of the ability.
#[INTEGER]
pub armor_break: Option<i64>,
/// armor_pierce of the ability.
#[INTEGER]
pub armor_pierce: Option<i64>,
/// antimaterial of the ability.
#[INTEGER]
pub antimaterial: Option<i64>,
/// Action‑point cost (used in systems where actions and fatigue are separate).
#[INTEGER]
pub cost_action: Option<String>,
@ -301,6 +295,77 @@ pub struct GroupedResists {
inner: IndexMap<String, Vec<Option<String>>>,
}
// / Counts how many items in `list` have a **Some** value for the given `field`.
// /
// / # Example
// / ```
// / let pierced = count_present!(part_list, piercing);
// / ```
// macro_rules! count_present {
// ($list:expr, $field:ident) => {
// // We keep everything inside its own block so that it behaves like a single expression.
// let $field = $list
// .body_parts
// .iter()
// .filter(|v| v.$field.is_some())
// .count();
// };
// }
// impl GroupedResists {
// pub fn from_list_body_parts(part_list: CreatureListBodyParts) -> Self {
// let mut inner: IndexMap<String, Vec<Option<String>>> = IndexMap::new();
// count_present!(part_list, slash);
// count_present!(part_list, blunt);
// count_present!(part_list, piercing);
// count_present!(part_list, celestial);
// count_present!(part_list, fire);
// count_present!(part_list, magma);
// count_present!(part_list, earth);
// count_present!(part_list, wood);
// count_present!(part_list, abyssal);
// count_present!(part_list, wind);
// count_present!(part_list, water);
// count_present!(part_list, ice);
// count_present!(part_list, thunder);
// if slash > 0 {
// for part in part_list.body_parts {
// let key = &part.body_part_name;
// if let Some(values) = inner.get_mut(key) {
// let value = part_list.get(key).to_owned();
// values.push(value);
// }
// println!("{}", part.body_part_name);
// println!("{}", slash);
// }
// }
// // for elt in &[
// // "slash",
// // "blunt",
// // "piercing",
// // "celestial",
// // "fire",
// // "magma",
// // "earth",
// // "wood",
// // "abyssal",
// // "wind",
// // "water",
// // "ice",
// // "thunder",
// // ] {}
// // if slash > 0 { // inner.insert(
// // "slash".to_string(),
// // part_list
// // .body_parts
// // .iter()
// // .map(|v| v.slash.clone())
// // .collect(),
// // );
// // }
// Self { inner }
// }
// }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
/// All creature stats used in combat calculations.
pub struct CreatureStats {
@ -335,8 +400,6 @@ pub struct CreatureStats {
#[INTEGER]
pub resistance_transcendentale: i64,
#[INTEGER]
pub size_bonus_to_hit: i64,
#[INTEGER]
pub mvt_walk: i64,
#[INTEGER]
pub mvt_trot: i64,
@ -435,7 +498,6 @@ pub struct PlayerBalancing {
pub enum ProfileStance {
Defensive,
Offensive,
NoDefense,
#[default]
Neutral,
}

View File

@ -71,7 +71,6 @@ pub struct ExportableEquipement {
pub vitesse: String,
pub discretion: String,
pub difficulty: String,
pub cost: String,
pub special: String,
pub needs_break: bool,
}
@ -146,7 +145,6 @@ impl From<&RefinedEquipement> for ExportableEquipement {
category: value.inner.category_base,
special: special.join(", "),
needs_break: false,
cost: value.inner.cost.to_string(),
}
}
}

View File

@ -149,7 +149,6 @@ end_empty = ""
[monster]
common_part = '''
{{#with data}}
\section{ {{{~name~}}} }
\begin{tblr}{
vspan=even, hspan=minimal,
colspec={X[-1] X[-1]},
@ -169,7 +168,7 @@ Nom & {{{name}}} \\
{{/if}}{{#if default_human_reaction}}Réaction à l'homme & \SetCell{font=\footnotesize} {{{default_human_reaction}}} \\
{{/if}}{{#if variants}}Variantes & \SetCell{font=\footnotesize} {{{variants}}}\\
{{/if}}{{#if size}}Taille & \SetCell{font=\footnotesize} {{{size}}}\\
{{/if}}{{#if traces}}Traces & \SetCell{font=\footnotesize} {{{traces}}}\\
{{/if}}{{#if traces}}Traces de pas & \SetCell{font=\footnotesize} {{{traces}}}\\
{{/if}}{{#if habits}}Mœurs & \SetCell{font=\footnotesize} {{{habits}}} \\
{{/if}}\end{tblr}
\vfill
@ -211,7 +210,7 @@ master_part = '''
\hline
{{#with stats as |s|}}
{{#each ../body_parts.body_parts}}
\SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{threshold_p1}}} ${\tiny ({{{threshold_bonus threshold_p1 ../../stats/size_bonus_to_hit~}}}) } & ${{{plus s.strength protection_p1}}}[{{{protection_p1}}}]$ & \SetCell{r,f}\tiny ${{{integrity_p1}}} $ & \SetCell{r,f}\tiny ${{{life_points_p1}}} $ & ${{{threshold_p2}}} ${\tiny ({{{threshold_bonus threshold_p1 ../../stats/size_bonus_to_hit~}}}) } & ${{{plus s.strength protection_p1}}}[{{{protection_p1}}}]$ & \SetCell{r,f}\tiny ${{{integrity_p2}}} $ & \SetCell{r,f}\tiny ${{{life_points_p2}}} $\\
\SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{threshold_p1}}} $ & ${{{plus s.strength protection_p1}}}[{{{protection_p1}}}]$ & \SetCell{r,f}\tiny ${{{integrity_p1}}} $ & \SetCell{r,f}\tiny ${{{life_points_p1}}} $ & ${{{threshold_p2}}} $ & ${{{plus s.strength protection_p1}}}[{{{protection_p1}}}]$ & \SetCell{r,f}\tiny ${{{integrity_p2}}} $ & \SetCell{r,f}\tiny ${{{life_points_p2}}} $\\
{{/each}}
{{/with}}
{{#if data.annotations_master}}
@ -277,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}}} & {{#if armor_break}} {{{armor_break}}}\arbreakk{} {{/if}}{{#if armor_pierce}} {{{armor_pierce}}}\arpierce{} {{/if}}{{#if antimaterial}} {{{antimaterial}}}\antimateriel{} {{/if}} {{{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
@ -302,6 +301,11 @@ Plan de combat {{#if intent_graph}}& Graphique d'intentions{{/if}} \\
\pagebreak
{{/with}}
'''
meta_import = '''
{{#each this}}
\include{ {{{~this~}}} }
{{/each}}
'''
color_table='''
ATK: ravred
MVT: ravblu
@ -349,10 +353,10 @@ template='''
rowhead = 1,
}
\hline
{Forme} & {Maniement} & {\damagew} & + & {R.Max} & \arbreakk & \protection & \integrite & $\mathbb{T}$2 & $\mathbb{T}$1 & {Modes} & {Esq.} & {Par.} & {Vit.} & {Disc.} & {Spécial} & {\aLvl} & {\aCst} \\
{Forme} & {Maniement} & {\damagew} & + & {R.Max} & \arbreakk & \protection & \integrite & $\mathbb{T}$2 & $\mathbb{T}$1 & {Modes} & {Esq.} & {Par.} & {Vit.} & {Disc.} & {Spécial} & {Diff.} \\
\hline
{{#each this}}
{{name}} & {{maniement}} & {{damage_base}} & {{damage_per}} & {{rmax}} & {{arbreak}} & {{protection}} & {{integrity}} & {{torque_two_handed}} & {{torque_one_handed}} & $\mathbf{ {{{~modes~}}} }$ & {{esquive}} & {{parrade}} & {{vitesse}} & {{discretion}} & {{{special}}} & \ddlvl{ {{~difficulty~}} } & \ddlvl{ {{~cost~}} } \\
{{name}} & {{maniement}} & {{damage_base}} & {{damage_per}} & {{rmax}} & {{arbreak}} & {{protection}} & {{integrity}} & {{torque_two_handed}} & {{torque_one_handed}} & $\mathbf{ {{{~modes~}}} }$ & {{esquive}} & {{parrade}} & {{vitesse}} & {{discretion}} & {{{special}}} & \ddlvl{ {{~difficulty~}} } \\
{{#if needs_break}}
\hline
\hline

View File

@ -1 +1 @@
Subproject commit c5af8a89ccb47b4a4bd57412a13bec90809fc61a
Subproject commit 44fa85167e2e10d08f2488a61fb3945495a64265