Working enough

This commit is contained in:
Dandaedre 2026-07-16 20:05:41 +02:00
parent 7e021d644a
commit d01ce27d5b
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 166 additions and 36 deletions

113
badges/testmonster.tex Normal file
View File

@ -0,0 +1,113 @@
\begin{tblr}{
vspan=even, hspan=minimal,
colspec={X[-1] X[-1]},
cell{1}{1}={c=2}{c},
}
\includegraphics[height=5cm] ./bob.png & \\
& \\
Nom & Bobifron 3000 \\
Dénomination & \\
Calamité & Yanouïlle \\
Niveau de danger (HSE) & 9001 \\
& \\
Habitat & \SetCell{font=\footnotesize} House \\
Dysmorphisme & \SetCell{font=\footnotesize} \\
Couleurs & \SetCell{font=\footnotesize} 7 \\
Réaction à l'homme & \SetCell{font=\footnotesize} 8 \\
Variantes & \SetCell{font=\footnotesize} 8\\
Mœurs & \SetCell{font=\footnotesize} 9 \\
\end{tblr}
\vfill
\begin{tblr}{
colspec={X[-1]},
hline{2,4,6},
row{2,4,6}={font=\footnotesize}
}
\textbf{Description} \\
9 \\
\textbf{Annotations} \\
8 \\
\textbf{Récompenses} \\
\end{tblr}
\begin{tblr}{
colspec={X[-1] X[-1,c] X[-1,j]},
vspan=even, hspan=minimal,
row{1-Z}={font=\footnotesize},
rows={m},
}
\SetCell[c=2]{j} Sang (base, combat, dépeçage) & & 10, 5, 5 \\
Larewoard & Reward & 4\blood{}, 4\Tox. Gives much love. \\
\end{tblr}
\vfill
\begin{tblr}{
colspec={X[l,-1] X[-1] X[-1] X[] X[] X[-1] X[-1] X[] X[]},
rowspec={X[t] X[t,c] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[j,5em]},
hspan=minimal,
cell{1}{2}={c=4}{c},
cell{1}{6}={c=4}{c},
row{2,12}={font=\footnotesize},
vline{6} = {2-11}{solid},
}
& P1 & & & & P2 & \\
& Seuil & Prot & Intégrité & PV & Seuil & Prot & Intégrité & PV\\
\hline
\SetCell{font=\footnotesize} VV & $1$ & $2$ & \SetCell{r,f}\tiny$3$ & \SetCell{r,f}\tiny$4$ & $5$ & $6$ & \SetCell{r,f}\tiny$7$ & \SetCell{r,f}\tiny$8$\\ \hline
\SetCell[c=9]{j,h} {\textbf{Notes} \\ \\
\hline
\end{tblr} \center{
\begin{tblr}{
colspec={Q[3.5em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em]},
rowspec={Q[c,f] Q[c,m] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c]},
row{3-11}={font=\tiny},
}
& & & & & & & \small{*} & & & & \small{*} & \small{*} & \\
\SetCell{c} Res & \slash & \pierce & \blunt & \symceleste & \symfire & \symearth & \symwood & \symmagma & \symabyss & \symwater & \symwind & \symice & \symthunder \\
\hline
\SetCell{font=\footnotesize} & $9$ & $$ & $10$ & $12$ & $13$ & $15$ & $16$ & $14$ & $$ & $19$ & $18$ & $20$ & $21$ \\
\end{tblr}\begin{tblr}{
colspec={c c c c c c c c c c c c c c c c c c c},
row{2}={font=\footnotesize},
row{3-6}={font=\tiny},
}
& \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}}$ \\
\begin{tblr}{
colspec={c c c c c c c c c c c c c c c c c c c},
row{2}={font=\footnotesize},
row{3-6}={font=\tiny},
}
& \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$ & $500$ & $4$A & $22$ & $4$A & & $8$ & $6$ & $5$ & $4$ & $40$ & $6$ & $20$ & & $10$ & $20$ & $50$ & $0$ \\
\SetCell{font=\footnotesize}$t_2$ & $10$ & & $12$ & 52A \\
\SetCell{font=\footnotesize}$t_3$ & $5$ & & $2$ & 21A \\
\scriptsize{
\begin{tblr}{
colspec={X[0.05] X[4,l] X[1,c] X[1,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[2,r] X[2,c] X[0.3,c] X[0.3,c]},
hspan=minimal,
colsep=2pt,
row{2}={font=\tiny},
}
& & & & & \SetCell[c=2]{c} Coûts & & & \SetCell[c=2]{c} Dégâts & & & \SetCell[c=2]{c} Seuils & \\
\cline{6-7} \cline{9-10} \cline{12-13}
& \SetCell{c} & {ID} & {Type} & \rb{Ciblage} & \rb{Fatigue} & \rb{Action} & \rb{Élément} & \rb{Fatigue} & \SetCell{c} \rb{Normaux} & {Effets} & \rb{Parade} & \rb{Esquive} \\
\SetHline{1-13}{solid}
\end{tblr}
}
\vfill
\renewcommand{\rb}{\undefined}
\begin{tblr}{
colspec={X[7] X[3]},
rowspec={X[c] X[j,h,8cm]},
vline{2},
hline{2},
row{2}={font=\footnotesize},
}
Plan de combat & Graphique d'intentions \\
9 & 7 \\
\end{tblr}
\vfill

View File

@ -94,7 +94,6 @@ pub fn generate_monsters_tex(
write!(out, "{}", templates.render("resists_row", part)?)?;
}
write!(out, "{}", &config.monster.resists_end)?;
write!(out, "{}", &config.monster.stats)?;
write!(out, "{}", templates.render("stats", &creature.stats)?)?;
for init in MonsterRepetableInitRow::vec_from(
&creature.stats.p1_init,
@ -107,12 +106,11 @@ pub fn generate_monsters_tex(
{
write!(out, "{}", templates.render("init_rows", init)?)?;
}
write!(out, "{}", &config.monster.init_end)?;
let all_attacks = MonsterAllAttacks::from_retrieved_data(&creature.attacks.attacks);
println!("{:#?}", all_attacks);
all_attacks.to_tex(&templates, config)?;
write!(out, "{}", &config.monster.attacks_intro)?;
write!(out, "{}", all_attacks.to_tex(&templates, config)?)?;
write!(out, "{}", &config.monster.attacks_end)?;
write!(out, "{}", templates.render("intent_table", &creature.data)?)?;
@ -138,6 +136,7 @@ impl MonsterAllAttacks {
IndexMap::new();
let phase_name = phase.to_string();
phases.insert(phase_name.clone(), Vec::new());
// Pregroup attacks
for &atk in phase_atks {
if let Some(values) = grouped_attacks.get_mut(&atk.attack_group) {
values.push(atk);
@ -145,11 +144,13 @@ impl MonsterAllAttacks {
grouped_attacks.insert(&atk.attack_group, vec![atk]);
}
}
// Ungroup them to have nice bundles
for (group, atk) in grouped_attacks {
if group.is_some() {
let group_attack = MonsterFullAttack {
attacklist: atk.iter().map(|&v| v.clone()).collect(),
color: atk.first().unwrap().short_name.clone(),
// color: atk.first().unwrap().short_name.clone(),
size: atk.len() + 1,
description: atk.first().unwrap().effects.clone(),
};
phases.get_mut(&phase_name).unwrap().push(group_attack);
@ -160,7 +161,7 @@ impl MonsterAllAttacks {
.unwrap()
.push(MonsterFullAttack {
attacklist: vec![single_atk.clone()],
color: single_atk.short_name.clone(),
size: 2,
description: single_atk.effects.clone(),
});
}
@ -173,25 +174,36 @@ impl MonsterAllAttacks {
#[derive(Serialize)]
struct Coloring<'a> {
color: &'a str,
size: usize,
}
#[derive(Serialize)]
struct PhaseName<'a> {
phase_name: &'a String,
}
impl MonsterAllAttacks {
pub fn to_tex(&self, templates: &Handlebars<'_>, config: &Config) -> Result<String> {
let mut out = String::new();
for (phase, list_full_attacks) in &self.phases {
for (phase_name, list_full_attacks) in &self.phases {
// Print phase name
write!(out, "{}", templates.render("phase_row", phase)?)?;
write!(
out,
"{}",
templates.render("phase_row", &PhaseName { phase_name })?
)?;
for attack in list_full_attacks {
write!(out, "{}", config.monster.attack_before_repeat)?;
let color = Coloring {
size: attack.size,
color: config
.monster
.color_table
.inner
.get(&attack.attacklist[0].short_name)
.unwrap_or(&config.monster.default_color),
};
write!(out, "{}", templates.render("attack_color", &color)?)?;
for sub_attack in &attack.attacklist {
let color = Coloring {
color: config
.monster
.color_table
.inner
.get(&attack.color)
.unwrap_or(&config.monster.default_color),
};
write!(out, "{}", templates.render("attack_color", &color)?)?;
write!(
out,
"{}",
@ -205,9 +217,6 @@ impl MonsterAllAttacks {
templates.render("attack_info_row", &list_full_attacks[0])?
)?;
}
// Print all attacks in that phase
println!("{}", out);
}
Ok(out)
}

View File

@ -49,6 +49,8 @@ pub struct CreatureData {
/// Text columns – stored as plain UTF‑8 text in SQLite.
#[TEXT]
pub name: String,
#[TEXT]
pub denomination: Option<String>,
/// The calamity type of the creature
#[TEXT]
pub calamity: String,
@ -367,6 +369,7 @@ pub struct MonsterAllAttacks {
#[derive(Serialize, Deserialize, Debug)]
pub struct MonsterFullAttack {
pub attacklist: Vec<MonsterSingleAttack>,
pub color: String,
// pub color: String,
pub size: usize,
pub description: String,
}

View File

@ -154,7 +154,7 @@ intro = '''\begin{tblr}{
cell{1}{1}={c=2}{c},
}
\includegraphics[height=5cm]{{image}} & \\
\includegraphics[height=5cm]{ {{image}} } & \\
& \\
Nom & {{name}} \\
Dénomination & {{denomination}} \\
@ -193,8 +193,10 @@ blood_reward='''
rewards_row=''' {{name}} & {{category}} & {{effect}} \\
'''
rewards_end='''\end{tblr}
rewards_end='''
\end{tblr}
\vfill
\pagebreak
'''
body_parts_intro='''
@ -211,9 +213,9 @@ 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}} $ & \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_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}
@ -226,7 +228,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} {{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}
@ -241,16 +243,17 @@ 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}
}
\vfill '''
\vfill
'''
attacks_intro= '''
{\scriptsize
\begin{tblr}{
colspec={X[0.05] X[4,l] X[1,c] X[1,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[2,r] X[2,c] X[0.3,c] X[0.3,c]},
hspan=minimal,
@ -268,18 +271,20 @@ phase_row= '''
'''
attack_before_repeat=' \hline'
attack_color='\SetCell[r=2]{bg={{color}}}' # Very ugly hack, going to bed
attack_color='\SetCell[r={{size}}]{bg={{color}}}' # Very ugly hack, going to bed
attack_repeatable_row= ''' & {{name}} & {{short_name}} & {{atk_type}} & {{targetting}} & {{cost_fatigue}} & {{cost_action}} & {{element}} & {{damage_fatigue}} &{{damage_regular}} & {{effects}} & {{threshold_parry}} & {{threshold_dodge}} \\
'''
attack_info_row='''& \SetCell[c=12]{j} {{description}} & & & & & & & & & & \\
\hline
'''
attacks_end= ''' \end{tblr}
}
\vfill
\renewcommand{\rb}{\undefined}
'''
intent_table=''' \begin{tblr}{
intent_table='''
\pagebreak
\begin{tblr}{
colspec={X[7] X[3]},
rowspec={X[c] X[j,h,8cm]},
vline{2},
@ -292,7 +297,7 @@ Plan de combat & Graphique d'intentions \\
\vfill
'''
color_table='''
THB: \ravblue
TBD: \nocolor
THB: ravred
TBD:
'''
default_color='\blu'
default_color=''