Solves the multiline mistake
This commit is contained in:
parent
1c216df46d
commit
7ec926432e
|
|
@ -6,7 +6,7 @@ resolver = "3"
|
|||
# edition = "2024"
|
||||
# license = "MIT OR Apache-2.0"
|
||||
[workspace.package]
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ 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_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 +104,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 +139,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 +168,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 +199,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 +218,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 +234,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() {
|
||||
|
|
@ -247,7 +255,7 @@ fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize {
|
|||
#[derive(Serialize)]
|
||||
struct Coloring<'a> {
|
||||
color: &'a str,
|
||||
size: usize,
|
||||
// size: usize,
|
||||
}
|
||||
#[derive(Serialize)]
|
||||
struct PhaseName<'a> {
|
||||
|
|
@ -265,23 +273,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= '''
|
||||
|
|
@ -278,16 +275,10 @@ 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_info_row='''& \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\
|
||||
attack_info_row='''
|
||||
{{#if description_final}}& \SetCell[c=12]{j} {{{description_final}}} & & & & & & & & & & \\ {{/if}}
|
||||
\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}} \hline
|
||||
'''
|
||||
attacks_end= ''' \end{longtblr}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue