database_monsters #124
|
|
@ -6,7 +6,7 @@ resolver = "3"
|
|||
# edition = "2024"
|
||||
# license = "MIT OR Apache-2.0"
|
||||
[workspace.package]
|
||||
version = "0.3.7"
|
||||
version = "0.3.9"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ pub enum VerboseLevel {
|
|||
Error,
|
||||
/// Uncatchable errors
|
||||
Critical,
|
||||
/// Interactive prompt context, only useful in interactive mode
|
||||
InteractiveContext,
|
||||
/// Literrally uncatchable things
|
||||
Uncatchable,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,9 +104,8 @@ pub struct MonsterMarkup {
|
|||
/// 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,
|
||||
|
||||
// /// The color of the attack row
|
||||
// pub attack_color: String,
|
||||
/// Before attack
|
||||
pub attack_before_repeat: String,
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,14 @@ use tokio::{
|
|||
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
|
||||
use crate::makepdf_functions::{
|
||||
BuilderParseResult, make_clean, make_file, make_glossaries, make_list,
|
||||
};
|
||||
use crate::makepdf_structs::{
|
||||
BuildInfo, COL_INFO, COL_NORMAL, LineType, Status, TXT_BOXX, TXT_CNTX, TXT_CRIT, TXT_ERRR,
|
||||
TXT_INFO, TXT_MISC, TXT_UKNW, TXT_WARN,
|
||||
};
|
||||
use crate::{
|
||||
makepdf_functions::{BuilderParseResult, make_clean, make_file, make_glossaries, make_list},
|
||||
makepdf_structs::TXT_ICTX,
|
||||
};
|
||||
|
||||
/// Make a pdf spawning a subprocess
|
||||
pub fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
|
||||
|
|
@ -284,6 +285,15 @@ fn checkline(
|
|||
*TXT_CNTX,
|
||||
COL_NORMAL.apply_to(final_line)
|
||||
)), // Context tends to be shit ))?
|
||||
VerboseLevel::InteractiveContext => {
|
||||
if !args.non_interactive {
|
||||
pb.println(format!(
|
||||
"{} {:?}",
|
||||
*TXT_ICTX,
|
||||
COL_NORMAL.apply_to(final_line)
|
||||
))
|
||||
}
|
||||
}
|
||||
VerboseLevel::Info => {
|
||||
status.info += 1;
|
||||
pb.println(format!(
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ pub(super) static TXT_BOXX: LazyLock<String> =
|
|||
/// Filler box for the [CNTX] text box
|
||||
pub(super) static TXT_CNTX: LazyLock<String> =
|
||||
LazyLock::new(|| format!("{}", COL_CONTEXT.apply_to(&"[CNTX]")));
|
||||
/// Filler box for the [CNTX] text box
|
||||
pub(super) static TXT_ICTX: LazyLock<String> =
|
||||
LazyLock::new(|| format!("{}", COL_CONTEXT.apply_to(&"[ICTX]")));
|
||||
/// Filler box for the [INFO] text box
|
||||
pub(super) static TXT_INFO: LazyLock<String> =
|
||||
LazyLock::new(|| format!("{}", COL_INFO.apply_to(&"[INFO]")));
|
||||
|
|
@ -234,10 +237,10 @@ pub(super) enum LineType {
|
|||
|
||||
/// Glossary will not be built
|
||||
#[token("This document will not have a glossary.")]
|
||||
#[token("Remove \\makeglossaries if you don't want any glossaries.")]
|
||||
#[token("Remove .makeglossaries if you don't want any glossaries.")]
|
||||
NoGlossary,
|
||||
|
||||
#[regex(r"No file [^$]\.gls\.", |_| "".to_string())]
|
||||
#[regex(r"No file [^$]+\.gls\.", |lex| lex.slice().replace("No file ", ""))]
|
||||
/// The glossary file wasn't found
|
||||
NoGlossaryFile(String),
|
||||
|
||||
|
|
@ -262,6 +265,15 @@ pub(super) enum LineType {
|
|||
#[regex(r"\([A-z_-]+\) [^\n]+", |lex| split_by(")",&lex.slice()[1..]), allow_greedy=true)]
|
||||
PackageContext((String, String)),
|
||||
|
||||
/// You should read the LaTex manual
|
||||
#[token("See the pdftex.def package documentation for explanation.", |lex| lex.slice().to_string())]
|
||||
#[token("See the LaTeX manual or LaTeX Companion for explanation.", |lex| lex.slice().to_string())]
|
||||
HelpGiven(String),
|
||||
|
||||
/// Interactive prompt
|
||||
#[token("Type H for immediate help.")]
|
||||
Prompt,
|
||||
|
||||
/// Loading (Load something)
|
||||
#[regex(r"(\)+ )?\(/usr[^)]*", |lex| lex.slice().split("/").last().unwrap_or("").to_string())]
|
||||
Loading(String),
|
||||
|
|
@ -284,9 +296,10 @@ pub(super) enum LineType {
|
|||
#[token("Transcript written on")]
|
||||
Log,
|
||||
|
||||
// /// Barely parsable data
|
||||
// #[regex(r"\)+")]
|
||||
// Garbage,
|
||||
/// Useless help line
|
||||
#[regex(r"\.\.\.")]
|
||||
Garbage,
|
||||
|
||||
/// Empty line, to discard
|
||||
Empty,
|
||||
|
||||
|
|
@ -301,6 +314,22 @@ pub(super) enum LineType {
|
|||
/// Transcript
|
||||
#[token("(see the transcript file for additional information)")]
|
||||
Transcript,
|
||||
// /// Known Errors
|
||||
|
||||
// ! Package pdftex.def Error: File `./Images/Bestiaire/Mjonn Alpha des Brumes.jpg' not found: using draft setting. // ! LaTeX Error: \begin{tblr} on input line 587 ended by \end{longtblr}.
|
||||
// /// Unmatch begin and end environement
|
||||
// #[token("! LeTex Error")]
|
||||
// UnmatchedSequences,
|
||||
// /// A \ something was used without being defined
|
||||
// #[token("! Undefined control sequence.")]
|
||||
// UndefinedControlSequence,
|
||||
|
||||
// /// Error Context
|
||||
// #[regex(r"l\.\d+ [^\n]+", |lex| split_by(" ",lex.slice()), allow_greedy=true) ]
|
||||
// #[regex(r".+\[^\]+", |lex| split_by("\\",lex.slice()), allow_greedy=true) ]
|
||||
// #[regex(" +\\[^\n]+", |lex|{("".to_string(),lex.slice().trim_start().to_string())},allow_greedy = true)]
|
||||
// // #[regex(r"\(\./[A-z/_-]+\.(gls|tex)", |lex| lex.slice().split("(").nth(1).unwrap_or("").to_string())]
|
||||
// ErrorContext((String, String)),
|
||||
}
|
||||
|
||||
impl LineType {
|
||||
|
|
@ -349,6 +378,12 @@ impl LineType {
|
|||
LineType::NoGlossary => VerboseLevel::Warning,
|
||||
LineType::FontAwesome => VerboseLevel::Info,
|
||||
LineType::NoGlossaryFile(_) => VerboseLevel::Warning,
|
||||
LineType::HelpGiven(_) => VerboseLevel::Context,
|
||||
LineType::Prompt => VerboseLevel::InteractiveContext,
|
||||
LineType::Garbage => VerboseLevel::None,
|
||||
// LineType::ErrorContext(_) => VerboseLevel::Error,
|
||||
// LineType::UndefinedControlSequence => VerboseLevel::Error,
|
||||
// LineType::UnmatchedSequences => VerboseLevel::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
|
|||
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_color);
|
||||
template_load!(templates, &config.monster, attack_repeatable_row);
|
||||
template_load!(templates, &config.monster, attack_info_row);
|
||||
template_load!(templates, &config.monster, intent_table);
|
||||
|
|
@ -104,14 +103,6 @@ pub fn generate_monsters_tex(
|
|||
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);
|
||||
// println!("{:#?}", templates.render("body_parts_row", &fixed_part)?);
|
||||
write!(
|
||||
master_out,
|
||||
"{}",
|
||||
|
|
@ -147,7 +138,8 @@ pub fn generate_monsters_tex(
|
|||
}
|
||||
write!(master_out, "{}", &config.monster.init_end)?;
|
||||
|
||||
let all_attacks = MonsterAllAttacks::from_retrieved_data(&creature.attacks.attacks);
|
||||
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)?;
|
||||
|
|
@ -175,7 +167,10 @@ pub fn generate_monsters_tex(
|
|||
}
|
||||
|
||||
impl MonsterAllAttacks {
|
||||
pub fn from_retrieved_data(original_data: &[MonsterSingleAttack]) -> MonsterAllAttacks {
|
||||
pub fn from_retrieved_data(
|
||||
original_data: &[MonsterSingleAttack],
|
||||
config: &Config,
|
||||
) -> MonsterAllAttacks {
|
||||
let mut initial_phases: IndexMap<&String, Vec<&MonsterSingleAttack>> = IndexMap::new();
|
||||
let mut phases: IndexMap<String, Vec<MonsterFullAttack>> = IndexMap::new();
|
||||
// Intermediate split with hashmaps
|
||||
|
|
@ -203,9 +198,10 @@ impl MonsterAllAttacks {
|
|||
for (group, atk) in grouped_attacks {
|
||||
if group.is_some() {
|
||||
let monster_first_atk = atk.first().unwrap();
|
||||
let color = color(monster_first_atk, config);
|
||||
let group_attack = MonsterFullAttack {
|
||||
color,
|
||||
attacklist: atk.iter().map(|&v| v.clone()).collect(),
|
||||
// color: atk.first().unwrap().attack_type.clone(),
|
||||
size: atk.len() + number_of_description(monster_first_atk),
|
||||
description_final: monster_first_atk
|
||||
.description_all
|
||||
|
|
@ -221,6 +217,7 @@ impl MonsterAllAttacks {
|
|||
.get_mut(&phase_name)
|
||||
.unwrap()
|
||||
.push(MonsterFullAttack {
|
||||
color: color(single_atk, config),
|
||||
attacklist: vec![single_atk.clone()],
|
||||
size: 1 + number_of_description(&single_atk),
|
||||
description_final: single_atk
|
||||
|
|
@ -236,6 +233,16 @@ impl MonsterAllAttacks {
|
|||
}
|
||||
}
|
||||
|
||||
fn color(atk: &MonsterSingleAttack, config: &Config) -> String {
|
||||
config
|
||||
.monster
|
||||
.color_table
|
||||
.inner
|
||||
.get(&atk.attack_type)
|
||||
.unwrap_or(&config.monster.default_color)
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// The number of description fields
|
||||
fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize {
|
||||
if monster_first_atk.description_all.is_some() {
|
||||
|
|
@ -245,11 +252,6 @@ fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize {
|
|||
}
|
||||
}
|
||||
#[derive(Serialize)]
|
||||
struct Coloring<'a> {
|
||||
color: &'a str,
|
||||
size: usize,
|
||||
}
|
||||
#[derive(Serialize)]
|
||||
struct PhaseName<'a> {
|
||||
phase_name: &'a String,
|
||||
}
|
||||
|
|
@ -265,23 +267,11 @@ impl MonsterAllAttacks {
|
|||
)?;
|
||||
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].attack_type)
|
||||
.unwrap_or(&config.monster.default_color),
|
||||
};
|
||||
write!(out, "{}", templates.render("attack_color", &color)?)?;
|
||||
for sub_attack in &attack.attacklist {
|
||||
write!(
|
||||
out,
|
||||
"{}",
|
||||
templates.render("attack_repeatable_row", sub_attack)?
|
||||
)?;
|
||||
}
|
||||
write!(
|
||||
out,
|
||||
"{}",
|
||||
templates.render("attack_repeatable_row", &attack)?
|
||||
)?;
|
||||
write!(out, "{}", templates.render("attack_info_row", attack)?)?;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -394,7 +394,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_final: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,9 +213,6 @@ 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_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= '''
|
||||
|
|
@ -258,8 +255,9 @@ init_end= '''
|
|||
\vfill
|
||||
'''
|
||||
attacks_intro= '''
|
||||
\pagebreak
|
||||
{\scriptsize
|
||||
\begin{tblr}{
|
||||
\begin{longtblr}{
|
||||
colspec={X[0.05] X[2.5,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[4,l] X[0.3,c] X[0.3,c]},
|
||||
hspan=minimal,
|
||||
colsep=2pt,
|
||||
|
|
@ -277,18 +275,12 @@ phase_row= '''
|
|||
|
||||
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_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}} \hline
|
||||
'''
|
||||
# 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}
|
||||
attacks_end= ''' \end{longtblr}
|
||||
}
|
||||
\vfill
|
||||
'''
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit fbd9ba5052cd95f081db4bdeb9f3e04b6b5898fe
|
||||
Subproject commit 5570da8b814f0d3925d0369131ae9baad72a31e8
|
||||
Loading…
Reference in New Issue