use askama::Template; use itertools::Itertools; use crate::{ RuntimeModule, common::{Game, enemy::Enemy, materials::MaterialDrops, synthesis::SynthesisData}, create_file, }; const ENEMIES_PATH: &str = "./input/kh1/enemies"; const SYNTHESIS_PATH: &str = "./input/kh1/synthesis.toml"; #[derive(Template)] #[template(path = "pages/kh1/drops.html")] struct DropsTemplate { pub game: Game, pub drops: Vec, pub material_kinds: Vec, } #[derive(Template)] #[template(path = "pages/kh1/synth.html")] struct SynthTemplate { pub data: SynthesisData, } pub struct Module; impl RuntimeModule for Module { fn start_module() { tracing::info!("Loading enemy data from {}", ENEMIES_PATH); let enemies = Enemy::import(ENEMIES_PATH); let drops = MaterialDrops::new(enemies); let material_kinds = drops .iter() .map(|d| d.category.get_category(&Game::Kh1)) .dedup() .collect(); tracing::info!("Loading synthesis data from {}", SYNTHESIS_PATH); let synth = SynthesisData::new(SYNTHESIS_PATH); tracing::info!("Generating the KH1 drops template"); let drops_template = DropsTemplate { game: Game::Kh1, drops, material_kinds, }; create_file("./out/kh1", "drops", drops_template).unwrap(); tracing::info!("Generating the KH1 synth template"); let synth_template = SynthTemplate { data: synth }; create_file("./out/kh1", "synth", synth_template).unwrap(); } }