Bad multithread tentative
This commit is contained in:
parent
c008e16556
commit
d79ddf6255
|
|
@ -128,6 +128,9 @@ pub struct MonsterMarkup {
|
|||
|
||||
/// Master part of monsters
|
||||
pub master_part: String,
|
||||
|
||||
/// The list of all includes
|
||||
pub meta_import: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
|
|||
let mut templates = Handlebars::new();
|
||||
template_load!(templates, &config.monster, common_part);
|
||||
template_load!(templates, &config.monster, master_part);
|
||||
template_load!(templates, &config.monster, meta_import);
|
||||
templates.register_helper("plus", Box::new(plus));
|
||||
Ok(templates)
|
||||
}
|
||||
|
|
@ -47,31 +48,66 @@ pub fn generate_monsters_tex(
|
|||
let all_monsters = fetch_all_creature_data(&connection, config, args.filter.filter.as_deref())?;
|
||||
let templates = load_templates(config)?;
|
||||
println!("Processing");
|
||||
let mut m_out = String::new();
|
||||
let mut p_out = String::new();
|
||||
|
||||
let mut player_files: Vec<String> = Vec::new();
|
||||
let mut master_files: Vec<String> = Vec::new();
|
||||
|
||||
for creature in &all_monsters {
|
||||
let mut m_out = String::new();
|
||||
let mut p_out = String::new();
|
||||
if !creature.data.show_to_master.is_none_or(|v| v == 0) {
|
||||
println!(" > {}", creature.name);
|
||||
};
|
||||
println!(" > MASTER : Processing {}", creature.name);
|
||||
master_files.push(format!("./Bestiaire/master_{}.tex", creature.id));
|
||||
}
|
||||
if !creature.data.show_to_players.is_none_or(|v| v == 0) {
|
||||
println!(" > PLAYER : Processing {}", creature.name);
|
||||
player_files.push(format!("./Bestiaire/player_{}.tex", creature.id));
|
||||
// player_files.push(format!("./{}/player_{}", args.destination, creature.id));
|
||||
}
|
||||
write!(p_out, "{}", templates.render("common_part", &creature)?)?;
|
||||
if args.master || args.all {
|
||||
write!(m_out, "{}", templates.render("common_part", &creature)?)?;
|
||||
write!(m_out, "{}", templates.render("master_part", &creature)?)?;
|
||||
}
|
||||
if args.player || args.all {
|
||||
println!(" > PLAYER : Writing creature {}", creature.name);
|
||||
let path = format!("./{}/player_{}.tex", args.destination, creature.id);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", p_out).context(format!("Writing {}", path))?;
|
||||
}
|
||||
if args.master || args.all {
|
||||
println!(" > MASTER : Writing creature {}", creature.name);
|
||||
let path = format!("./{}/master_{}.tex", args.destination, creature.id);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", m_out).context(format!("Writing {}", path))?;
|
||||
}
|
||||
}
|
||||
|
||||
if args.player || args.all {
|
||||
println!("Generating Player Bestiaire");
|
||||
println!("Writing Player Bestiaire");
|
||||
let path = format!("./{}/player_bestiaire.tex", args.destination);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", p_out).context(format!("Writing {}", path))?;
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
templates
|
||||
.render("meta_import", &master_files)
|
||||
.context("Processing meta import")?
|
||||
)
|
||||
.context(format!("Writing {}", path))?;
|
||||
}
|
||||
if args.master || args.all {
|
||||
println!("Generating Master Bestiaire");
|
||||
println!("Writing Master Bestiaire");
|
||||
let path = format!("./{}/master_bestiaire.tex", args.destination);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", m_out).context(format!("Writing {}", path))?;
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
templates
|
||||
.render("meta_import", &master_files)
|
||||
.context("Processing meta import")?
|
||||
)
|
||||
.context(format!("Writing {}", path))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,11 @@ Plan de combat {{#if intent_graph}}& Graphique d'intentions{{/if}} \\
|
|||
\pagebreak
|
||||
{{/with}}
|
||||
'''
|
||||
meta_import = '''
|
||||
{{#each this}}
|
||||
\include{ {{{~this~}}} }
|
||||
{{/each}}
|
||||
'''
|
||||
color_table='''
|
||||
ATK: ravred
|
||||
MVT: ravblu
|
||||
|
|
|
|||
Loading…
Reference in New Issue