From 59a78f4236d52a075c65e49b52e6e2f595788e3a Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 20 Jul 2026 19:39:22 +0200 Subject: [PATCH 1/2] Way better model --- Cargo.toml | 2 +- crates/config/src/monsters.rs | 68 +---------- crates/monsters/src/monster_database.rs | 15 ++- crates/monsters/src/monster_export.rs | 143 +++--------------------- crates/monsters/src/monster_structs.rs | 16 ++- helper_config.toml | 109 +++++++++--------- 6 files changed, 106 insertions(+), 247 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d8cc0e8..afde8de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,6 @@ glob = "0.3.3" tokio = { version = "1.52.3", features = ["full"] } dynfmt = { version = "0.1.5", features = ["curly"] } pretty_assertions = "^1.4" -indexmap = "2.14.0" +indexmap = {version= "2.14.0", features= ["serde"]} rusqlite = { version = "0.40.1" } # , features = ["bundled"] serde_rusqlite = "0.43.0" diff --git a/crates/config/src/monsters.rs b/crates/config/src/monsters.rs index 2a0bad6..7f11205 100644 --- a/crates/config/src/monsters.rs +++ b/crates/config/src/monsters.rs @@ -56,74 +56,18 @@ pub enum MonsterTarget { #[allow(dead_code)] #[derive(Deserialize)] pub struct MonsterMarkup { - /// Header of the page (image + basic attributes). - pub intro: String, - - /// Body‑parts section header. - pub body_parts_intro: String, - - /// One row of the body‑parts table. - pub body_parts_row: String, - - /// Body‑parts table footer. - pub body_parts_end: String, - - /// Rewards section header (the table that lists each reward). - pub rewards_row: String, - - /// Rewards table footer. - pub rewards_end: String, - - /// Resists section header. - pub resists_intro: String, - - /// The blood reward template. - pub blood_reward: String, - - /// One line of the resistances table. - pub resists_row: String, - - /// Resists table footer. - pub resists_end: String, - - /// Stats section (movement, initiative, etc.). - pub stats: String, - - /// The row of initiatives (turn 2 onwards) - pub init_rows: String, - - /// The end of the initiatives - pub init_end: String, - - /// Header of the attacks section. - pub attacks_intro: String, - - /// Footer of the attacks section. - pub attacks_end: String, - - /// Row used for each attack’s data (IDs, types, damage, etc.). - pub phase_row: String, - - // /// The color of the attack row - // pub attack_color: String, - /// Before attack - pub attack_before_repeat: String, - - /// Row that lists repeatable attacks. - pub attack_repeatable_row: String, - - /// Row that contains additional information for an attack. - pub attack_info_row: String, - - /// The intent table & Battle plan - pub intent_table: String, - /// Color map #[serde(deserialize_with = "parse_monster_color")] pub color_table: MonsterColor, /// Default color pub default_color: String, + + /// Common part of monsters + pub common_part: String, + + /// Master part of monsters + pub master_part: String, } /// Ghetto color import diff --git a/crates/monsters/src/monster_database.rs b/crates/monsters/src/monster_database.rs index 83eb683..e97901e 100644 --- a/crates/monsters/src/monster_database.rs +++ b/crates/monsters/src/monster_database.rs @@ -1,11 +1,12 @@ #![allow(dead_code)] -use crate::monster_structs::{self, CreatureReward}; +use crate::monster_structs::{self, CreatureReward, MonsterAllAttacks, MonsterRepetableInitRow}; use crate::monster_structs::{ CreatureBodyPart, CreatureData, CreatureListAttacks, CreatureStats, FullMonster, MonsterSingleAttack, }; use anyhow::{Context, anyhow}; +use cli_parser::Config; use rusqlite::Connection; use serde::de::DeserializeOwned; @@ -25,7 +26,10 @@ macro_rules! fetch_from { /// Fetch all data from the database // TODO: WARN the master filter is hardcoded here -pub(crate) fn fetch_all_data(connection: Connection) -> Result, anyhow::Error> { +pub(crate) fn fetch_all_data( + connection: Connection, + config: &Config, +) -> Result, anyhow::Error> { let list_creatures = generic_deserialize::( &connection, "creature", @@ -71,7 +75,14 @@ pub(crate) fn fetch_all_data(connection: Connection) -> Result, finished_creatures.push(FullMonster { id: creature.id, name: creature.name.clone(), + init_full: MonsterRepetableInitRow::vec_from( + &creature_stats.p1_init, + &creature_stats.p2_init, + &creature_stats.p1_actions, + &creature_stats.p2_actions, + ), stats: creature_stats, + all_attacks: MonsterAllAttacks::from_retrieved_data(&creature_attacks, config), attacks: CreatureListAttacks { attacks: creature_attacks, }, diff --git a/crates/monsters/src/monster_export.rs b/crates/monsters/src/monster_export.rs index 51b8811..687ce94 100644 --- a/crates/monsters/src/monster_export.rs +++ b/crates/monsters/src/monster_export.rs @@ -6,14 +6,10 @@ use config::monsters::MonsterConfig; use handlebars::{Handlebars, handlebars_helper}; use indexmap::IndexMap; use rusqlite::Connection; -use serde::Serialize; use std::{fmt::Write, fs::File, io::Write as OtherWrite}; use crate::monster_database::fetch_all_data; -use crate::monster_structs::{ - CreatureBodyPart, CreatureStats, MonsterAllAttacks, MonsterFullAttack, MonsterRepetableInitRow, - MonsterSingleAttack, -}; +use crate::monster_structs::{MonsterAllAttacks, MonsterFullAttack, MonsterSingleAttack}; /// Load a template from a struct field into a `templates` collection. /// @@ -40,128 +36,46 @@ handlebars_helper!(plus: |x:i64 ,y:Option| x+y.unwrap_or(0)); fn load_templates(config: &Config) -> Result> { let mut templates = Handlebars::new(); - template_load!(templates, &config.monster, intro); - template_load!(templates, &config.monster, body_parts_row); - template_load!(templates, &config.monster, body_parts_end); - template_load!(templates, &config.monster, blood_reward); - template_load!(templates, &config.monster, rewards_row); - template_load!(templates, &config.monster, init_rows); - template_load!(templates, &config.monster, resists_row); - template_load!(templates, &config.monster, stats); - template_load!(templates, &config.monster, phase_row); - template_load!(templates, &config.monster, attack_repeatable_row); - template_load!(templates, &config.monster, attack_info_row); - template_load!(templates, &config.monster, intent_table); + template_load!(templates, &config.monster, common_part); + template_load!(templates, &config.monster, master_part); templates.register_helper("plus", Box::new(plus)); Ok(templates) } -// TODO: Create a method on the struct instead of this inane bs /// Export a tex with the given config and arguments pub fn generate_monsters_tex( args: &MonsterConfig, config: &Config, connection: Connection, ) -> std::result::Result<(), anyhow::Error> { - let all_monsters = fetch_all_data(connection)?; + let all_monsters = fetch_all_data(connection, config)?; let templates = load_templates(config)?; println!("Processing"); - let mut player_out = String::new(); - let mut master_out = String::new(); + let mut m_out = String::new(); + let mut p_out = String::new(); for creature in &all_monsters { - // if !creature.data.show_to_master.is_none_or(|v| v == 0) { - // println!(" > {}", creature.name); - // }; - write!(player_out, "{}", templates.render("intro", &creature.data)?)?; - write!(master_out, "{}", templates.render("intro", &creature.data)?)?; - write!( - player_out, - "{}", - templates.render("blood_reward", &creature.stats)? - )?; - write!( - master_out, - "{}", - templates.render("blood_reward", &creature.stats)? - )?; - for reward in creature.rewards.rewards.iter() { - write!(player_out, "{}", templates.render("rewards_row", reward)?)?; - write!(master_out, "{}", templates.render("rewards_row", reward)?)?; - } - write!(player_out, "{}", &config.monster.rewards_end)?; - write!(master_out, "{}", &config.monster.rewards_end)?; + if !creature.data.show_to_master.is_none_or(|v| v == 0) { + println!(" > {}", creature.name); + }; + write!(p_out, "{}", templates.render("common_part", &creature)?)?; if args.master || args.all { - write!(master_out, "{}", &config.monster.body_parts_intro)?; - for part in creature.body_parts.body_parts.iter() { - #[derive(Serialize)] - struct UnionCreature<'a> { - part: &'a CreatureBodyPart, - stats: &'a CreatureStats, - } - let temp_creature = UnionCreature { - part, - stats: &creature.stats, - }; - write!( - master_out, - "{}", - templates.render("body_parts_row", &temp_creature)? - )?; - } - write!( - master_out, - "{}", - templates.render("body_parts_end", &creature.data)? - )?; - // 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, "{}", &config.monster.resists_end)?; - write!( - master_out, - "{}", - templates.render("stats", &creature.stats)? - )?; - for init in MonsterRepetableInitRow::vec_from( - &creature.stats.p1_init, - &creature.stats.p2_init, - &creature.stats.p1_actions, - &creature.stats.p2_actions, - ) - .iter() - .skip(1) - { - write!(master_out, "{}", templates.render("init_rows", init)?)?; - } - write!(master_out, "{}", &config.monster.init_end)?; - - let all_attacks = - MonsterAllAttacks::from_retrieved_data(&creature.attacks.attacks, config); - write!(master_out, "{}", &config.monster.attacks_intro)?; - write!(master_out, "{}", all_attacks.to_tex(&templates, config)?)?; - write!(master_out, "{}", &config.monster.attacks_end)?; - write!( - master_out, - "{}", - templates.render("intent_table", &creature.data)? - )?; + write!(m_out, "{}", templates.render("common_part", &creature)?)?; + write!(m_out, "{}", templates.render("master_part", &creature)?)?; } } + if args.player || args.all { println!("Generating Player Bestiaire"); 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))?; + write!(f, "{}", p_out).context(format!("Writing {}", &path))?; } if args.master || args.all { println!("Generating Master Bestiaire"); 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))?; + write!(f, "{}", m_out).context(format!("Writing {}", &path))?; } Ok(()) } @@ -251,30 +165,3 @@ fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize { 0 } } -#[derive(Serialize)] -struct PhaseName<'a> { - phase_name: &'a String, -} -impl MonsterAllAttacks { - pub fn to_tex(&self, templates: &Handlebars<'_>, config: &Config) -> Result { - let mut out = String::new(); - for (phase_name, list_full_attacks) in &self.phases { - // Print phase name - write!( - out, - "{}", - templates.render("phase_row", &PhaseName { phase_name })? - )?; - for attack in list_full_attacks { - write!(out, "{}", config.monster.attack_before_repeat)?; - write!( - out, - "{}", - templates.render("attack_repeatable_row", &attack)? - )?; - write!(out, "{}", templates.render("attack_info_row", attack)?)?; - } - } - Ok(out) - } -} diff --git a/crates/monsters/src/monster_structs.rs b/crates/monsters/src/monster_structs.rs index 8c9c20d..5b96e3c 100644 --- a/crates/monsters/src/monster_structs.rs +++ b/crates/monsters/src/monster_structs.rs @@ -17,6 +17,9 @@ use more_fields::FieldsAsSlice; use serde::{Deserialize, Serialize}; /// A monster ready for consumption by other modules. +/// +/// This struct is extremely export centric +#[derive(Serialize)] pub struct FullMonster { /// Unique identifier, derived when the monster is instantiated. pub id: i64, @@ -27,9 +30,15 @@ pub struct FullMonster { /// Serialized generic data directly copied from the database table. pub data: CreatureData, + /// Weird init & actions repeat + pub init_full: Vec, + /// Collection of attacks, wrapped in a helper that exposes useful functions. pub attacks: CreatureListAttacks, + /// Merge of all attacks in a convenient-ish hashmap + pub all_attacks: MonsterAllAttacks, + /// Collection of resistances, wrapped in a helper for convenient iteration. pub body_parts: CreatureListBodyParts, @@ -105,6 +114,7 @@ pub struct CreatureData { } /// A helper wrapper around all rewards +#[derive(Serialize)] pub struct CreatureListRewards { pub rewards: Vec, } @@ -133,6 +143,7 @@ pub struct CreatureReward { /// The inner vector holds individual attack rows (`MonsterSingleAttack`); /// helper methods on this struct (not shown here) can split or aggregate /// these rows into more ergonomic data structures. +#[derive(Serialize)] pub struct CreatureListAttacks { /// All attack rows for the monster, as read from the database. pub attacks: Vec, @@ -143,6 +154,7 @@ pub struct CreatureListAttacks { /// The inner vector contains `MonsterSingleResistance` entries; methods /// on this struct can provide iterators or lookup functions that are /// easier to consume than raw rows. +#[derive(Serialize)] pub struct CreatureListBodyParts { /// All resistance rows for the monster, as read from the database. pub body_parts: Vec, @@ -385,8 +397,10 @@ impl Serialize for MonsterInitString { /// The full list of all monster attacks /// /// Split by phasing -#[derive(Debug)] +#[derive(Debug, Deserialize, Serialize)] pub struct MonsterAllAttacks { + // #[serde(flatten)] + // #[serde(with = "indexmap::map::serde_seq")] pub phases: IndexMap>, } /// A single attack, grouping all sub attacks diff --git a/helper_config.toml b/helper_config.toml index 22ceae1..e36b1c0 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -148,7 +148,9 @@ end_long_side = ''' \hline end_empty = "" [monster] -intro = '''\begin{tblr}{ +common_part = ''' +{{#with data}} +\begin{tblr}{ vspan=even, hspan=minimal, colspec={X[-1] X[-1]}, cell{1}{1}={c=2}{c}, @@ -167,6 +169,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 de pas & \SetCell{font=\footnotesize} {{{traces}}}\\ {{/if}}{{#if habits}}Mœurs & \SetCell{font=\footnotesize} {{{habits}}} \\ {{/if}}\end{tblr} \vfill @@ -186,22 +189,15 @@ Nom & {{{name}}} \\ vspan=even, hspan=minimal, row{1-Z}={font=\footnotesize}, rows={m}, -} -''' -blood_reward=''' - \SetCell[c=3]{j} Sang (base, combat, dépeçage) & & & {{{blood_base}}}, {{{blood_battle}}}, {{{blood_carve}}} \\ -''' - -rewards_row=''' {{{name}}} & {{{category}}} & {{#if cost}} {{{cost}}} & {{{effect}}} {{else}} \SetCell[c=2]{j} {{{effect}}} & {{/if}} \\ -''' -rewards_end=''' +} {{/with}}{{#with stats}} +\SetCell[c=3]{j} Sang (base, combat, dépeçage) & & & {{{blood_base}}}, {{{blood_battle}}}, {{{blood_carve}}} \\ {{/with}}{{#with rewards}}{{#each rewards}} +{{{name}}} & {{{category}}} & {{#if cost}} {{{cost}}} & {{{effect}}} {{else}} \SetCell[c=2]{j} {{{effect}}} & {{/if}} \\ {{/each}}{{/with}} \end{tblr} \vfill \pagebreak ''' - -body_parts_intro=''' -\begin{tblr}{ +master_part = ''' + \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, @@ -212,15 +208,19 @@ body_parts_intro=''' } & P1 & & & & P2 & \\ & Seuil & Prot & Intégrité & PV & Seuil & Prot & Intégrité & PV\\ -\hline ''' -body_parts_row='''{{#with stats as | s | }} {{#with ../part}} -\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}}} $\\ {{/with}} {{/with}} ''' -body_parts_end= ''' -{{#if annotations_master}} \hline -\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{{annotations_master}}}}\\ {{/if}} \hline -\end{tblr}''' -resists_intro=''' \begin{center} +{{#with stats as |s|}} +{{#each ../body_parts.body_parts}} +\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}} +\hline +\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{{data.annotations_master}}}}\\ +{{/if}} +\hline +\end{tblr} +\begin{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]}, @@ -229,15 +229,13 @@ 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_end=''' +{{#each body_parts.body_parts}} +\SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{slash}}} $ & ${{{pierce}}} $ & ${{{blunt}}} $ & ${{{celestial}}} $ & ${{{fire}}} $ & ${{{earth}}} $ & ${{{wood}}} $ & ${{{magma}}} $ & ${{{celeste}}} $ & ${{{water}}} $ & ${{{wind}}} $ & ${{{ice}}} $ & ${{{thunder}}} $ \\ +{{/each}} \end{tblr} \end{center} -''' -stats='''\begin{tblr}{ +\begin{tblr}{ colspec={c c c c c c c c c c c c c c c c c c c c c {{#if elemental_bonus}}c{{/if}}}, row{2}={font=\footnotesize}, row{3-6}={font=\tiny}, @@ -245,16 +243,19 @@ stats='''\begin{tblr}{ & \SetCell[c=2]{c} P1 & & \SetCell[c=2]{c} P2 & & & \SetCell[c=7]{c} Stats & & & & & & & & \SetCell[c=4]{c} Mouvement & & & & & Extra & \\ \cline{2-3} \cline{4-5} \cline{7-13} \cline{15-18} \cline{20-21} \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} & & \rb{Bon. Phy} {{#if elemental_bonus_dmg}}& \rb{Bon. Élém} {{/if}}\\ +{{#each init_full}} +{{#if @index}} +\SetCell{font=\footnotesize} $t_{{(plus @index 1)}} $ & ${{{p1_value}}} $ & {{{pt1_actions}}} & ${{{p2_value}}} $ & {{{p2_actions}}} \\ +{{else}} +{{#with ../stats~}} \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}}} $ & & ${{{physical_bonus_dmg}}} $ {{#if elemental_bonus_dmg}} & ${{elemental_bonus_dmg}} $ {{/if}} \\ -''' -init_rows=''' -\SetCell{font=\footnotesize} $t_{{{turn}}} $ & ${{{p1_value}}} $ & {{{pt1_actions}}} & ${{{p2_value}}} $ & {{{p2_actions}}} \\ -''' -init_end= ''' +{{/with}} +{{/if}} +{{/each}} \end{tblr} \vfill -''' -attacks_intro= ''' + +{{#if (len all_attacks.phases)}} \pagebreak {\scriptsize \begin{longtblr}{ @@ -262,30 +263,31 @@ attacks_intro= ''' hspan=minimal, colsep=2pt, row{2}={font=\tiny}, + rowshead=2, } & & & & & \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} & {Type} & {Préquis} & \rb{Ciblage} & \rb{Fatigue} & \rb{Action} & \rb{Élément} & \rb{Fatigue} & \SetCell{c} \rb{Normaux} & {Effets} & \rb{Parade} & \rb{Esquive} \\ -\SetHline{1-13}{solid} -''' -phase_row= ''' +{{#each all_attacks.phases as | phase |}} \SetHline{1}{0pt} -\SetCell[c=13]{white} {{{phase_name}}} & & & & & & & & & & \\ -''' - -attack_before_repeat=''' \hline -''' -attack_repeatable_row= '''{{#each attacklist}}\SetCell{bg={{{../color}}}} & {{{name}}} & {{{attack_type}}} & {{{prerequisites}}} & {{{targetting}}} & {{{cost_fatigue}}} & {{{cost_action}}} & {{{element}}} & {{{damage_fatigue}}} &{{{damage_regular}}} {{{success}}}& {{{effects}}} & {{{threshold_parry}}} & {{{threshold_dodge}}} \\ -{{/each}} ''' -attack_info_row='''{{#if description_final}}\SetCell{bg={{{color}}}} & \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\ +{{#if @first}} + & {\scriptsize\SetCell{white} \textsc{ {{{@key}}} }} & {Type} & {Préquis} & \rb{Ciblage} & \rb{Fatigue} & \rb{Action} & \rb{Élément} & \rb{Fatigue} & \SetCell{c} \rb{Normaux} & {Effets} & \rb{Parade} & \rb{Esquive} \\ +{{else}} +\SetCell[c=13]{white} \textsc{ {{{@key}}} } & & & & & & & & & & \\ +{{/if}} +{{#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}}} \\ +{{/each}} +{{#if description_final}}\SetCell{bg={{{color}}}} & \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\ {{/if}} \hline -''' -attacks_end= ''' \end{longtblr} +{{/each}} +{{/each}} +\end{longtblr} } \vfill -''' - -intent_table=''' +{{/if}} +{{#with data}} \pagebreak \begin{tblr}{ colspec={X[7] {{#if intent_graph}}|X[3] {{/if}} }, @@ -293,11 +295,12 @@ intent_table=''' hline{2}, row{2}={font=\footnotesize}, } -Plan de combat {{#if intent_graph}}& Graphique d'intentions \\ {{/if}} -{{{battle_plan}}} {{#if intent_graph}}& {{{intent_graph}}} \\ {{/if}} +Plan de combat {{#if intent_graph}}& Graphique d'intentions{{/if}} \\ +{{{battle_plan}}} {{#if intent_graph}}& {{{intent_graph}}}{{/if}} \\ \end{tblr} \vfill \pagebreak +{{/with}} ''' color_table=''' ATK: ravred -- 2.45.1 From c74de46f8b760c7c6b7b16ee39f7470037693f90 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 20 Jul 2026 20:03:35 +0200 Subject: [PATCH 2/2] Adds an error recap --- Cargo.toml | 2 +- crates/make/src/makepdf.rs | 7 ++++++- crates/make/src/makepdf_structs.rs | 18 +++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index afde8de..7798d1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "3" # edition = "2024" # license = "MIT OR Apache-2.0" [workspace.package] -version = "0.3.9" +version = "0.3.10" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/make/src/makepdf.rs b/crates/make/src/makepdf.rs index 38096e1..af25c72 100644 --- a/crates/make/src/makepdf.rs +++ b/crates/make/src/makepdf.rs @@ -268,6 +268,10 @@ fn checkline( return Ok(()); } + if final_line.vlvl() >= VerboseLevel::Error { + let v = final_line.clone(); + let _ = status.first_error.set(v); + } match &final_line.vlvl() { VerboseLevel::None => (), VerboseLevel::Misc => pb.println(format!( @@ -327,7 +331,7 @@ fn checkline( )) } VerboseLevel::Uncatchable => { - // status.errors += 1; + status.errors += 1; pb.println(format!( "{} {}", *TXT_UKNW, @@ -335,5 +339,6 @@ fn checkline( )) } } + Ok(()) } diff --git a/crates/make/src/makepdf_structs.rs b/crates/make/src/makepdf_structs.rs index 3bad49a..70d1aaf 100644 --- a/crates/make/src/makepdf_structs.rs +++ b/crates/make/src/makepdf_structs.rs @@ -7,6 +7,7 @@ use config::make::VerboseLevel; use logos::Logos; use serde::{Deserialize, Serialize}; use std::{ + cell::OnceCell, io::{Read, Write}, sync::LazyLock, time::{Duration, Instant}, @@ -141,7 +142,7 @@ impl BuildInfo { /// The line encountered // #[allow(unused)] -#[derive(Debug, Logos, PartialEq)] +#[derive(Debug, Logos, PartialEq, Clone)] #[logos(skip r"[) ]+")] pub(super) enum LineType { /// The tex building mode : entering extended mode @@ -407,8 +408,8 @@ pub(super) struct Status { pub(super) warnings: usize, /// Only makes sense with non-interactie builds pub(super) errors: usize, - // /// List of all recoverable - // pub(super) v_errors: Vec, + /// List of all recoverable + pub(super) first_error: OnceCell, } impl Status { @@ -418,6 +419,7 @@ impl Status { info: 0, warnings: 0, errors: 0, + first_error: OnceCell::new(), } } @@ -429,6 +431,16 @@ impl Status { file_info: BuilderParseResult, ) { let col_bld = COL_INFO.clone().bold(); + if self.errors > 3 { + println!( + "{} {}", + col_bld.apply_to("[RCAP]"), + COL_NORMAL.apply_to(format!( + "The first error encountered was: {:?}", + self.first_error.get() + )) + ); + } println!(); println!( "{} {}", -- 2.45.1