Conditionnal viewing (most)

This commit is contained in:
Dandaedre 2026-07-19 02:44:42 +02:00
parent 6da458a236
commit 536ef42d70
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 57 additions and 45 deletions

View File

@ -242,11 +242,11 @@ pub(super) enum LineType {
NoGlossaryFile(String),
#[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
Fontawesome,
FontAwesome,
/// The warning generated by a package
#[regex(r"Package [A-z_-]+ Warning: [^\n]+", |lex| split_by(":",lex.slice()), allow_greedy=true)]
@ -347,7 +347,7 @@ impl LineType {
LineType::BoxFullnessPrs => VerboseLevel::Critical,
LineType::PackageWarningPrs(_) => VerboseLevel::Critical,
LineType::NoGlossary => VerboseLevel::Warning,
LineType::Fontawesome => VerboseLevel::Info,
LineType::FontAwesome => VerboseLevel::Info,
LineType::NoGlossaryFile(_) => VerboseLevel::Warning,
}
}

View File

@ -193,13 +193,12 @@ impl MonsterAllAttacks {
// Ungroup them to have nice bundles
for (group, atk) in grouped_attacks {
if group.is_some() {
let monster_first_atk = atk.first().unwrap();
let group_attack = MonsterFullAttack {
attacklist: atk.iter().map(|&v| v.clone()).collect(),
// color: atk.first().unwrap().attack_type.clone(),
size: atk.len() + 1,
description_final: atk
.first()
.unwrap()
size: atk.len() + number_of_description(monster_first_atk),
description_final: monster_first_atk
.description_all
.clone()
.unwrap_or_default(),
@ -214,7 +213,7 @@ impl MonsterAllAttacks {
.unwrap()
.push(MonsterFullAttack {
attacklist: vec![single_atk.clone()],
size: 2,
size: 1 + number_of_description(&single_atk),
description_final: single_atk
.description_all
.clone()
@ -227,6 +226,15 @@ impl MonsterAllAttacks {
Self { phases }
}
}
/// The number of description fields
fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize {
if monster_first_atk.description_all.is_some() {
1
} else {
0
}
}
#[derive(Serialize)]
struct Coloring<'a> {
color: &'a str,

View File

@ -62,40 +62,40 @@ pub struct CreatureData {
pub danger_level: i64,
/// Type of habitat
#[TEXT]
pub habitat: String,
pub habitat: Option<String>,
/// Wether a dismorphism exists
#[TEXT]
pub dysmorphism: String,
pub dysmorphism: Option<String>,
/// Monster size
#[TEXT]
pub size: Option<String>,
/// Generic color describing the creature
#[TEXT]
pub colors: String,
pub colors: Option<String>,
/// Default reaction to human presence
#[TEXT]
pub default_human_reaction: String,
pub default_human_reaction: Option<String>,
/// Known variants
#[TEXT]
pub variants: String,
pub variants: Option<String>,
/// General habits
#[TEXT]
pub habits: String,
pub habits: Option<String>,
/// Generic creature description
#[TEXT]
pub description: String,
pub description: Option<String>,
/// Annotations
#[TEXT]
pub annotations: String,
pub annotations: Option<String>,
/// Annotations GM
#[TEXT]
pub annotations_master: Option<String>,
/// The battle plan of the creature
#[TEXT]
pub battle_plan: String,
pub battle_plan: Option<String>,
/// The graph of intents (image)
#[TEXT]
pub intent_graph: String,
pub intent_graph: Option<String>,
/// Wether to show it to players
#[INTEGER]
pub show_to_master: Option<i64>,

View File

@ -154,20 +154,20 @@ intro = '''\begin{tblr}{
cell{1}{1}={c=2}{c},
}
\includegraphics[height=5cm]{ {{{image}}} } & \\
{{#if image}}\includegraphics[height=5cm]{ {{{image}}} } & \\{{/if}}
& \\
Nom & {{{name}}} \\
Dénomination & {{{denomination}}} \\
Calamité & {{{calamity}}} \\
Niveau de danger (HSE) & {{{danger_level}}} \\
{{#if denomination}}Dénomination & {{{denomination}}} \\ {{/if}}
{{#if calamity}}Calamité & {{{calamity}}} \\ {{/if}}
{{#if danger_level}}Niveau de danger (HSE) & {{{danger_level}}} \\ {{/if}}
& \\
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}}} \\
{{#if habitat}}Habitat & \SetCell{font=\footnotesize} {{{habitat}}} \\ {{/if}}
{{#if dysmorphism}}Dysmorphisme & \SetCell{font=\footnotesize} {{{dysmorphism}}} \\ {{/if}}
{{#if colors}}Couleurs & \SetCell{font=\footnotesize} {{{colors}}} \\ {{/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 habits}}Mœurs & \SetCell{font=\footnotesize} {{{habits}}} \\ {{/if}}
\end{tblr}
\vfill
\begin{tblr}{
@ -175,10 +175,10 @@ Mœurs & \SetCell{font=\footnotesize} {{{habits}}} \\
hline{2,4,6},
row{2,4,6}={font=\footnotesize}
}
\textbf{Description} \\
{{{description}}} \\
\textbf{Annotations} \\
{{{annotations}}} \\
{{#if description}}\textbf{Description} \\
{{{description}}} \\ {{/if}}
{{#if annotations}}\textbf{Annotations} \\
{{{annotations}}} \\ {{/if}}
\textbf{Récompenses} \\
\end{tblr}
\begin{tblr}{
@ -217,8 +217,9 @@ body_parts_intro='''
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}}}}\\
body_parts_end= '''
{{#if annotations_master}} \hline
\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{{annotations_master}}}}\\ {{/if}}
\hline
\end{tblr}'''
resists_intro=''' \begin{center}
@ -227,7 +228,6 @@ resists_intro=''' \begin{center}
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
@ -274,12 +274,17 @@ phase_row= '''
\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}}} & {{{attack_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} {{{success}}}& {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\
attack_before_repeat=''' \hline
'''
attack_info_row='''& \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\
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}}} & {{{attack_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} {{{success}}}& {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\
'''
# attack_info_row='''& \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\
attack_info_row='''
{{#if description_final}}& \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\ {{/if}}
\hline
'''
attacks_end= ''' \end{tblr}
@ -290,14 +295,13 @@ attacks_end= ''' \end{tblr}
intent_table='''
\pagebreak
\begin{tblr}{
colspec={X[7] X[3]},
colspec={X[7] {{#if intent_graph}}|X[3] {{/if}} },
rowspec={X[c] X[j,h,8cm]},
vline{2},
hline{2},
row{2}={font=\footnotesize},
}
Plan de combat & Graphique d'intentions \\
{{{battle_plan}}} & {{{intent_graph}}} \\
Plan de combat {{#if intent_graph}}& Graphique d'intentions \\ {{/if}}
{{{battle_plan}}} {{#if intent_graph}}& {{{intent_graph}}} \\ {{/if}}
\end{tblr}
\vfill
\pagebreak