Fixes generation #105

Merged
Dandaedre merged 1 commits from fix-gen into main 2026-07-18 17:38:50 +02:00
6 changed files with 67 additions and 38 deletions

View File

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

View File

@ -238,7 +238,7 @@ pub(super) enum LineType {
NoGlossary,
#[regex(
r"/usr/share/texlive/texmf-dist/fonts/type1/public/fontawesome5[^\n]+",
r" ?\)?<?/usr/share/texlive/texmf-dist/fonts/type1/public/fontawesome5[^\n]+",
allow_greedy = true
)]
/// The fontawesome package has loaded it's fonts

View File

@ -95,7 +95,19 @@ pub fn generate_monsters_tex(
if args.master || args.all {
write!(master_out, "{}", &config.monster.body_parts_intro)?;
for part in creature.body_parts.body_parts.iter() {
write!(master_out, "{}", templates.render("body_parts_row", part)?)?;
let mut fixed_part = part.clone();
fixed_part.protection_p1 = fixed_part
.protection_p1
.map(|v| v + creature.stats.strength);
fixed_part.protection_p2 = fixed_part
.protection_p2
.map(|v| v + creature.stats.strength);
// println!("{:#?}", templates.render("body_parts_row", &fixed_part)?);
write!(
master_out,
"{}",
templates.render("body_parts_row", &fixed_part)?
)?;
}
write!(
master_out,
@ -105,7 +117,7 @@ pub fn generate_monsters_tex(
// TODO: Maybe add modularity and not print empty resists
write!(master_out, "{}", &config.monster.resists_intro)?;
for part in creature.body_parts.body_parts.iter() {
write!(master_out, "{}", templates.render("resists_row", part)?)?;
write!(master_out, "{}", templates.render("resists_row", &part)?)?;
}
write!(master_out, "{}", &config.monster.resists_end)?;
write!(
@ -139,13 +151,16 @@ pub fn generate_monsters_tex(
}
if args.player || args.all {
println!("Generating Player Bestiaire");
let mut f = File::create(format!("./{}/player_bestiaire.tex", args.destination))?;
write!(f, "{}", player_out)?;
let path = format!("./{}/player_bestiaire.tex", args.destination);
let mut f = File::create(&path).context(format!("Opening file {}", &path))?;
write!(f, "{}", player_out).context(format!("Writing {}", &path))?;
}
if args.master || args.all {
println!("Generating Master Bestiaire");
let mut f = File::create(format!("./{}/master_bestiaire.tex", args.destination))?;
write!(f, "{}", master_out)?;
let path = format!("./{}/master_bestiaire.tex", args.destination);
let mut f = File::create(&path).context(format!("Opening file {}", &path))?;
write!(f, "{}", master_out).context(format!("Writing {}", &path))?;
}
Ok(())
}
@ -182,7 +197,12 @@ impl MonsterAllAttacks {
attacklist: atk.iter().map(|&v| v.clone()).collect(),
// color: atk.first().unwrap().attack_type.clone(),
size: atk.len() + 1,
description: atk.first().unwrap().effects.clone(),
description: atk
.first()
.unwrap()
.description_all
.clone()
.unwrap_or_default(),
};
phases.get_mut(&phase_name).unwrap().push(group_attack);
} else {
@ -193,7 +213,7 @@ impl MonsterAllAttacks {
.push(MonsterFullAttack {
attacklist: vec![single_atk.clone()],
size: 2,
description: single_atk.effects.clone(),
description: single_atk.description_all.clone().unwrap_or_default(),
});
}
};

View File

@ -66,6 +66,9 @@ pub struct CreatureData {
/// Wether a dismorphism exists
#[TEXT]
pub dysmorphism: String,
/// Monster size
#[TEXT]
pub size: Option<String>,
/// Generic color describing the creature
#[TEXT]
pub colors: String,
@ -188,6 +191,9 @@ pub struct MonsterSingleAttack {
/// The string format is up‑to‑you – many people store JSON or a custom DSL here.
#[TEXT]
pub effects: String,
/// The description of the whole attack
#[TEXT]
pub description_all: Option<String>,
/// Minimum parry rating required to avoid the ability’s effect.
#[INTEGER]
pub threshold_parry: Option<i64>,
@ -196,7 +202,7 @@ pub struct MonsterSingleAttack {
pub threshold_dodge: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default, FieldsAsSlice)]
/// All different body parts and their different resists
pub struct CreatureBodyPart {
#[INTEGER]

View File

@ -154,19 +154,20 @@ intro = '''\begin{tblr}{
cell{1}{1}={c=2}{c},
}
\includegraphics[height=5cm]{ {{image}} } & \\
\includegraphics[height=5cm]{ {{{image}}} } & \\
& \\
Nom & {{name}} \\
Dénomination & {{denomination}} \\
Calamité & {{calamity}} \\
Niveau de danger (HSE) & {{danger_level}} \\
Nom & {{{name}}} \\
Dénomination & {{{denomination}}} \\
Calamité & {{{calamity}}} \\
Niveau de danger (HSE) & {{{danger_level}}} \\
& \\
Habitat & \SetCell{font=\footnotesize} {{habitat}} \\
Dysmorphisme & \SetCell{font=\footnotesize} {{dysmorphism}} \\
Couleurs & \SetCell{font=\footnotesize} {{colors}} \\
Réaction à l'homme & \SetCell{font=\footnotesize} {{default_human_reaction}} \\
Variantes & \SetCell{font=\footnotesize} {{variants}}\\
Mœurs & \SetCell{font=\footnotesize} {{habits}} \\
Habitat & \SetCell{font=\footnotesize} {{{habitat}}} \\
Dysmorphisme & \SetCell{font=\footnotesize} {{{dysmorphism}}} \\
Couleurs & \SetCell{font=\footnotesize} {{{colors}}} \\
Réaction à l'homme & \SetCell{font=\footnotesize} {{{default_human_reaction}}} \\
Variantes & \SetCell{font=\footnotesize} {{{variants}}}\\
Taille & \SetCell{font=\footnotesize} {{{size}}}\\
Mœurs & \SetCell{font=\footnotesize} {{{habits}}} \\
\end{tblr}
\vfill
\begin{tblr}{
@ -175,9 +176,9 @@ Mœurs & \SetCell{font=\footnotesize} {{habits}} \\
row{2,4,6}={font=\footnotesize}
}
\textbf{Description} \\
{{description}} \\
{{{description}}} \\
\textbf{Annotations} \\
{{annotations}} \\
{{{annotations}}} \\
\textbf{Récompenses} \\
\end{tblr}
\begin{tblr}{
@ -188,10 +189,10 @@ Mœurs & \SetCell{font=\footnotesize} {{habits}} \\
}
'''
blood_reward='''
\SetCell[c=2]{j} Sang (base, combat, dépeçage) & & {{blood_base}}, {{blood_battle}}, {{blood_carve}} \\
\SetCell[c=2]{j} Sang (base, combat, dépeçage) & & {{{blood_base}}}, {{{blood_battle}}}, {{{blood_carve}}} \\
'''
rewards_row=''' {{name}} & {{category}} & {{effect}} \\
rewards_row=''' {{{name}}} & {{{category}}} & {{{effect}}} \\
'''
rewards_end='''
\end{tblr}
@ -213,9 +214,11 @@ body_parts_intro='''
& Seuil & Prot & Intégrité & PV & Seuil & Prot & Intégrité & PV\\
\hline
'''
body_parts_row='''\SetCell{font=\footnotesize} {{body_part_name}} & ${{threshold_p1}} $ & ${{protection_p1}} $ & \SetCell{r,f}\tiny ${{integrity_p1}} $ & \SetCell{r,f}\tiny ${{life_points_p1}} $ & ${{threshold_p2}} $ & ${{protection_p2}} $ & \SetCell{r,f}\tiny ${{integrity_p2}} $ & \SetCell{r,f}\tiny ${{life_points_p2}} $\\'''
body_parts_row='''
\SetCell{font=\footnotesize} {{{body_part_name }}} & ${{{threshold_p1 }}} $ & ${{{protection_p1}}} {{{protection_total_p1 }}} $ & \SetCell{r,f}\tiny ${{{integrity_p1}}} $ & \SetCell{r,f}\tiny ${{{life_points_p1}}} $ & ${{{threshold_p2}}} $ & ${{{protection_p2}}} {{{protection_total_p2}}} $ & \SetCell{r,f}\tiny ${{{integrity_p2}}} $ & \SetCell{r,f}\tiny ${{{life_points_p2}}} $\\
'''
body_parts_end= ''' \hline
\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{annotations_master}}}\\
\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{{annotations_master}}}}\\
\hline
\end{tblr}'''
resists_intro=''' \begin{center}
@ -229,7 +232,7 @@ resists_intro=''' \begin{center}
\SetCell{c} Res & \slash & \pierce & \blunt & \symceleste & \symfire & \symearth & \symwood & \symmagma & \symabyss & \symwater & \symwind & \symice & \symthunder \\
\hline
'''
resists_row= ''' \SetCell{font=\footnotesize} {{body_part_name}} & ${{slash}} $ & ${{pierce}} $ & ${{blunt}} $ & ${{celestial}} $ & ${{fire}} $ & ${{earth}} $ & ${{wood}} $ & ${{magma}} $ & ${{celeste}} $ & ${{water}} $ & ${{wind}} $ & ${{ice}} $ & ${{thunder}} $ \\
resists_row= ''' \SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{slash}}} $ & ${{{pierce}}} $ & ${{{blunt}}} $ & ${{{celestial}}} $ & ${{{fire}}} $ & ${{{earth}}} $ & ${{{wood}}} $ & ${{{magma}}} $ & ${{{celeste}}} $ & ${{{water}}} $ & ${{{wind}}} $ & ${{{ice}}} $ & ${{{thunder}}} $ \\
'''
resists_end='''
\end{tblr}
@ -244,10 +247,10 @@ stats='''\begin{tblr}{
& \SetCell[c=2]{c} P1 & & \SetCell[c=2]{c} P2 & & & \SetCell[c=7]{c} Stats & & & & & & & & \SetCell[c=4]{c} Mouvement & & & & \\
\cline{2-3} \cline{4-5} \cline{7-13} \cline{15-18}
\rb{Initiative} & \rb{Valeur} & \rb{Actions} & \rb{Valeur} & \rb{Actions} & & \rb{Force} & \rb{Perception} & \rb{Volonté} & \rb{Res Alt} & \rb{Torque} & \rb{Vigilance} & \rb{Fatigue} & & \rb{Marche} & \rb{Trot} & \rb{Course} & \rb{Vol} \\
\SetCell{font=\footnotesize} $t_1 $ & ${{p1_init}} $ & $4 $A & ${{p2_init}} $ & $4 $A & & ${{strength}} $ & ${{perception}} $ & ${{willpower}} $ & ${{alteration_resistance}} $ & ${{torque}} $ & ${{awareness}} $ & ${{fatigue}} $ & & ${{mvt_walk}} $ & ${{mvt_trot}} $ & ${{mvt_run}} $ & ${{mvt_flight}} $ \\
\SetCell{font=\footnotesize} $t_1 $ & ${{{p1_init}}} $ & $4 $A & ${{{p2_init}}} $ & $4 $A & & ${{{strength}}} $ & ${{{perception}}} $ & ${{{willpower}}} $ & ${{{alteration_resistance}}} $ & ${{{torque}}} $ & ${{{awareness}}} $ & ${{{fatigue}}} $ & & ${{{mvt_walk}}} $ & ${{{mvt_trot}}} $ & ${{{mvt_run}}} $ & ${{{mvt_flight}}} $ \\
'''
init_rows='''
\SetCell{font=\footnotesize} $t_{{turn}} $ & ${{p1_value}} $ & {{pt1_actions}} & ${{p2_value}} $ & {{p2_actions}} \\
\SetCell{font=\footnotesize} $t_{{{turn}}} $ & ${{{p1_value}}} $ & {{{pt1_actions}}} & ${{{p2_value}}} $ & {{{p2_actions}}} \\
'''
init_end= '''
\end{tblr}
@ -268,15 +271,15 @@ attacks_intro= '''
'''
phase_row= '''
\SetHline{1}{0pt}
\SetCell[c=13]{white} {{phase_name}} & & & & & & & & & & \\
\SetCell[c=13]{white} {{{phase_name}}} & & & & & & & & & & \\
'''
attack_before_repeat=' \hline'
attack_color='\SetCell[r={{size}}]{bg={{color}}}' # Very ugly hack, going to bed
# attack_repeatable_row= ''' & {{name}} & {{short_name}} & {{prerequisites}} & {{atk_type}} & {{targetting}} & {{cost_fatigue}} & {{cost_action}} & {{element}} & {{damage_fatigue}} &{{damage_regular}} & {{effects}} & {{threshold_parry}} & {{threshold_dodge}} \\
attack_repeatable_row= ''' & {{name}} & {{atk_type}} & {{prerequisites}} & {{targetting}} & {{cost_fatigue}} & {{cost_action}} & {{element}} & {{damage_fatigue}} &{{damage_regular}} & {{effects}} & {{threshold_parry}} & {{threshold_dodge}} \\
attack_color='\SetCell[r={{{size}}}]{bg={{{color}}}}' # Very ugly hack, going to bed
# attack_repeatable_row= ''' & {{{name}}} & {{{short_name}}} & {{{prerequisites}}} & {{{atk_type}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} & {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\
attack_repeatable_row= ''' & {{{name}}} & {{{atk_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} & {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\
'''
attack_info_row='''& \SetCell[c=12]{j} {{description}} & & & & & & & & & & \\
attack_info_row='''& \SetCell[c=12]{j} {{{description}}} & & & & & & & & & & \\
\hline
'''
attacks_end= ''' \end{tblr}
@ -294,7 +297,7 @@ intent_table='''
row{2}={font=\footnotesize},
}
Plan de combat & Graphique d'intentions \\
{{battle_plan}} & {{intent_graph}} \\
{{{battle_plan}}} & {{{intent_graph}}} \\
\end{tblr}
\vfill
\pagebreak

@ -1 +1 @@
Subproject commit 8928f53a3d02d9fe618ee03166e417a408f1fc52
Subproject commit 27b578ce3b1202817e406ef2a762893432706eec