|
|
|
@ -34,6 +34,7 @@ fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
|
|
|
|
let mut templates = Handlebars::new();
|
|
|
|
let mut templates = Handlebars::new();
|
|
|
|
template_load!(templates, &config.monster, common_part);
|
|
|
|
template_load!(templates, &config.monster, common_part);
|
|
|
|
template_load!(templates, &config.monster, master_part);
|
|
|
|
template_load!(templates, &config.monster, master_part);
|
|
|
|
|
|
|
|
template_load!(templates, &config.monster, meta_import);
|
|
|
|
templates.register_helper("plus", Box::new(plus));
|
|
|
|
templates.register_helper("plus", Box::new(plus));
|
|
|
|
Ok(templates)
|
|
|
|
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 all_monsters = fetch_all_creature_data(&connection, config, args.filter.filter.as_deref())?;
|
|
|
|
let templates = load_templates(config)?;
|
|
|
|
let templates = load_templates(config)?;
|
|
|
|
println!("Processing");
|
|
|
|
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 {
|
|
|
|
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) {
|
|
|
|
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)?)?;
|
|
|
|
write!(p_out, "{}", templates.render("common_part", &creature)?)?;
|
|
|
|
if args.master || args.all {
|
|
|
|
if args.master || args.all {
|
|
|
|
write!(m_out, "{}", templates.render("common_part", &creature)?)?;
|
|
|
|
write!(m_out, "{}", templates.render("common_part", &creature)?)?;
|
|
|
|
write!(m_out, "{}", templates.render("master_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 {
|
|
|
|
if args.player || args.all {
|
|
|
|
println!("Generating Player Bestiaire");
|
|
|
|
println!("Writing Player Bestiaire");
|
|
|
|
let path = format!("./{}/player_bestiaire.tex", args.destination);
|
|
|
|
let path = format!("./{}/player_bestiaire.tex", args.destination);
|
|
|
|
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
|
|
|
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 {
|
|
|
|
if args.master || args.all {
|
|
|
|
println!("Generating Master Bestiaire");
|
|
|
|
println!("Writing Master Bestiaire");
|
|
|
|
let path = format!("./{}/master_bestiaire.tex", args.destination);
|
|
|
|
let path = format!("./{}/master_bestiaire.tex", args.destination);
|
|
|
|
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
|
|
|
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(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|