diff --git a/src/kh1.rs b/src/kh1.rs index 654bd09..9d5ea5b 100644 --- a/src/kh1.rs +++ b/src/kh1.rs @@ -2,6 +2,7 @@ use std::sync::OnceLock; use askama::Template; use blake3::Hash; +use itertools::Itertools; use crate::{ RuntimeModule, @@ -9,11 +10,6 @@ use crate::{ create_file, create_hashes, }; -const MATERIAL_KINDS: &[&str] = &[ - "lucid", "spirit", "power", "blaze", "frost", "thunder", "shiny", "bright", "mystery", "gale", - "mythril", -]; -const DROPS_PATH: &str = "./input/kh1/drops"; const ENEMIES_PATH: &str = "./input/kh1/enemies"; static JS_HASH: OnceLock = OnceLock::new(); @@ -21,6 +17,7 @@ static JS_HASH: OnceLock = OnceLock::new(); #[template(path = "pages/kh1/drops.html")] struct DropsTemplate { pub drops: Vec, + pub material_kinds: Vec, } pub struct Module; @@ -30,11 +27,14 @@ impl RuntimeModule for Module { tracing::info!("Loading enemy data from {}", ENEMIES_PATH); let enemies = Enemy::import(ENEMIES_PATH); - tracing::info!("Loading enemy drops data from {}", DROPS_PATH); let drops = MaterialDrops::new(enemies); + let material_kinds = drops.iter().map(|d| d.category.clone()).dedup().collect(); tracing::info!("Generating the KH1 drops template"); - let drops_template = DropsTemplate { drops }; + let drops_template = DropsTemplate { + drops, + material_kinds, + }; create_file("./out/kh1", "drops", drops_template.render().unwrap()).unwrap(); } diff --git a/src/kh2.rs b/src/kh2.rs index a684875..83df266 100644 --- a/src/kh2.rs +++ b/src/kh2.rs @@ -26,6 +26,7 @@ static JS_HASH: OnceLock = OnceLock::new(); #[template(path = "pages/kh2/drops.html")] struct DropsTemplate { pub drops: Vec, + pub material_kinds: Vec, } pub struct Module; diff --git a/templates/components/common/kind-filters.html b/templates/components/common/kind-filters.html index ac31661..d182a88 100644 --- a/templates/components/common/kind-filters.html +++ b/templates/components/common/kind-filters.html @@ -1,4 +1,4 @@ -{% for kind in MATERIAL_KINDS %} +{% for kind in material_kinds %}