diff --git a/Cargo.toml b/Cargo.toml index 86120e6..34d0e3d 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.6" +version = "0.3.7" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -50,6 +50,7 @@ phf = { version = "0.14.0", features = ["macros"] } regex = "1.13.0" regex_static = "0.1.1" serde = { version = "1.0.228", features = ["derive", "alloc"] } +serde_json = { version = "1.0.150", features = ["alloc"] } csv = "1.4.0" ron = "0.12.2" glob = "0.3.3" diff --git a/crates/make/src/makepdf_structs.rs b/crates/make/src/makepdf_structs.rs index 2d51273..f11bc83 100644 --- a/crates/make/src/makepdf_structs.rs +++ b/crates/make/src/makepdf_structs.rs @@ -237,12 +237,16 @@ pub(super) enum LineType { #[token("Remove \\makeglossaries if you don't want any glossaries.")] NoGlossary, + #[regex(r"No file [^$]\.gls\.", |_| "".to_string())] + /// The glossary file wasn't found + NoGlossaryFile(String), + #[regex( - r" ?\)? VerboseLevel::Critical, LineType::PackageWarningPrs(_) => VerboseLevel::Critical, LineType::NoGlossary => VerboseLevel::Warning, - LineType::Fontawesome => VerboseLevel::Info, + LineType::FontAwesome => VerboseLevel::Info, + LineType::NoGlossaryFile(_) => VerboseLevel::Warning, } } } diff --git a/crates/monsters/Cargo.toml b/crates/monsters/Cargo.toml index 4011bef..a252d1c 100644 --- a/crates/monsters/Cargo.toml +++ b/crates/monsters/Cargo.toml @@ -12,6 +12,7 @@ indexmap = {workspace = true} serde = {workspace = true} rusqlite = {workspace = true} serde_rusqlite = {workspace = true} +serde_json = {workspace = true} strum = { version = "0.28.0", features = ["derive"] } handlebars = "6.4.3" diff --git a/crates/monsters/src/monster_database.rs b/crates/monsters/src/monster_database.rs index dd5787a..83eb683 100644 --- a/crates/monsters/src/monster_database.rs +++ b/crates/monsters/src/monster_database.rs @@ -47,7 +47,7 @@ pub(crate) fn fetch_all_data(connection: Connection) -> Result, connection, creature, "creature_body_parts", - Some("body_part_name") + None ); let creature_stats = diff --git a/crates/monsters/src/monster_export.rs b/crates/monsters/src/monster_export.rs index d6d6697..edc2e0a 100644 --- a/crates/monsters/src/monster_export.rs +++ b/crates/monsters/src/monster_export.rs @@ -3,19 +3,16 @@ use anyhow::{Context, Result}; use cli_parser::Config; use config::monsters::MonsterConfig; -use handlebars::Handlebars; +use handlebars::{Handlebars, handlebars_helper}; use indexmap::IndexMap; use rusqlite::Connection; use serde::Serialize; -use std::fmt::Write; -use std::fs::File; -use std::io::Write as OtherWrite; +use std::{fmt::Write, fs::File, io::Write as OtherWrite}; -use crate::{ - monster_database::fetch_all_data, - monster_structs::{ - MonsterAllAttacks, MonsterFullAttack, MonsterRepetableInitRow, MonsterSingleAttack, - }, +use crate::monster_database::fetch_all_data; +use crate::monster_structs::{ + CreatureBodyPart, CreatureStats, MonsterAllAttacks, MonsterFullAttack, MonsterRepetableInitRow, + MonsterSingleAttack, }; /// Load a template from a struct field into a `templates` collection. @@ -39,6 +36,8 @@ macro_rules! template_load { // fn export_to_tex(self) -> String; // } +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); @@ -54,6 +53,7 @@ fn load_templates(config: &Config) -> Result> { template_load!(templates, &config.monster, attack_repeatable_row); template_load!(templates, &config.monster, attack_info_row); template_load!(templates, &config.monster, intent_table); + templates.register_helper("plus", Box::new(plus)); Ok(templates) } @@ -95,18 +95,27 @@ 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() { + #[derive(Serialize)] + struct UnionCreature<'a> { + part: &'a CreatureBodyPart, + stats: &'a CreatureStats, + } + let temp_creature = UnionCreature { + part, + stats: &creature.stats, + }; 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); + // 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)? + templates.render("body_parts_row", &temp_creature)? )?; } write!( @@ -193,13 +202,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 +222,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 +235,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, diff --git a/crates/monsters/src/monster_structs.rs b/crates/monsters/src/monster_structs.rs index 742a4ee..dc68e68 100644 --- a/crates/monsters/src/monster_structs.rs +++ b/crates/monsters/src/monster_structs.rs @@ -62,40 +62,40 @@ pub struct CreatureData { pub danger_level: i64, /// Type of habitat #[TEXT] - pub habitat: String, + pub habitat: Option, /// Wether a dismorphism exists #[TEXT] - pub dysmorphism: String, + pub dysmorphism: Option, /// Monster size #[TEXT] pub size: Option, /// Generic color describing the creature #[TEXT] - pub colors: String, + pub colors: Option, /// Default reaction to human presence #[TEXT] - pub default_human_reaction: String, + pub default_human_reaction: Option, /// Known variants #[TEXT] - pub variants: String, + pub variants: Option, /// General habits #[TEXT] - pub habits: String, + pub habits: Option, /// Generic creature description #[TEXT] - pub description: String, + pub description: Option, /// Annotations #[TEXT] - pub annotations: String, + pub annotations: Option, /// Annotations GM #[TEXT] pub annotations_master: Option, /// The battle plan of the creature #[TEXT] - pub battle_plan: String, + pub battle_plan: Option, /// The graph of intents (image) #[TEXT] - pub intent_graph: String, + pub intent_graph: Option, /// Wether to show it to players #[INTEGER] pub show_to_master: Option, @@ -121,6 +121,9 @@ pub struct CreatureReward { /// Category of the ability #[TEXT] pub category: String, + /// The cost of the reward + #[TEXT] + pub cost: Option, /// Effect of the ability pub effect: String, } @@ -284,6 +287,10 @@ pub struct CreatureStats { #[INTEGER] pub fatigue: i64, #[INTEGER] + pub physical_bonus_dmg: i64, + #[INTEGER] + pub elemental_bonus_dmg: Option, + #[INTEGER] pub mvt_walk: i64, #[INTEGER] pub mvt_trot: i64, diff --git a/crates/weaponry/Cargo.toml b/crates/weaponry/Cargo.toml index 26df699..b94b176 100644 --- a/crates/weaponry/Cargo.toml +++ b/crates/weaponry/Cargo.toml @@ -14,7 +14,7 @@ comfy-table = "7.2.2" probability = "0.20.3" rusqlite = {workspace = true} serde_rusqlite = {workspace = true} -serde_json = { version = "1.0.150", features = ["alloc"] } +serde_json = {workspace = true} strum = { version = "0.28.0", features = ["derive"] } thiserror = "2.0.18" charming = { version = "0.4.0", features = [] } diff --git a/helper_config.toml b/helper_config.toml index 55bc0bf..5ca1368 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -154,45 +154,45 @@ 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}}} \\ -& \\ -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} +{{#if denomination}}Dénomination & {{{denomination}}} \\ +{{/if}}{{#if calamity}}Calamité & {{{calamity}}} \\ +{{/if}}{{#if danger_level}}Niveau de danger (HSE) & {{{danger_level}}} \\ +{{/if}}& \\ +{{#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}{ colspec={X[-1]}, 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}{ - colspec={X[1] X[1,c] X[5,j]}, + colspec={X[1] X[1,c] X[2,c] X[3,j]}, vspan=even, hspan=minimal, row{1-Z}={font=\footnotesize}, rows={m}, } ''' blood_reward=''' - \SetCell[c=2]{j} Sang (base, combat, dépeçage) & & {{{blood_base}}}, {{{blood_battle}}}, {{{blood_carve}}} \\ + \SetCell[c=3]{j} Sang (base, combat, dépeçage) & & & {{{blood_base}}}, {{{blood_battle}}}, {{{blood_carve}}} \\ ''' -rewards_row=''' {{{name}}} & {{{category}}} & {{{effect}}} \\ +rewards_row=''' {{{name}}} & {{{category}}} & {{#if cost}} {{{cost}}} & {{{effect}}} {{else}} \SetCell[c=2]{j} {{{effect}}} & {{/if}} \\ ''' rewards_end=''' \end{tblr} @@ -212,13 +212,15 @@ body_parts_intro=''' } & P1 & & & & P2 & \\ & Seuil & Prot & Intégrité & PV & Seuil & Prot & Intégrité & PV\\ -\hline -''' -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}}}}\\ +\hline ''' +# 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_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} @@ -227,7 +229,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 @@ -240,14 +241,14 @@ resists_end=''' ''' stats='''\begin{tblr}{ - colspec={c c c c c c c c c c c c c c c c c c c}, + 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}, } - & \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[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}}\\ +\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}}} \\ @@ -274,12 +275,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 +296,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 @@ -328,5 +333,6 @@ SRG: ravpur HRG: ravpur BAD: ravora BIS: ravredD +BYP: ravredD ''' default_color='' diff --git a/ravenous_databases b/ravenous_databases index ec988aa..fbd9ba5 160000 --- a/ravenous_databases +++ b/ravenous_databases @@ -1 +1 @@ -Subproject commit ec988aabeb3c94233d7f60deef2ff3873c8e9100 +Subproject commit fbd9ba5052cd95f081db4bdeb9f3e04b6b5898fe