2025-06-25 13:44:08 +03:00
|
|
|
use std::sync::OnceLock;
|
2025-06-25 02:15:27 +03:00
|
|
|
|
|
|
|
|
use askama::Template;
|
2025-06-25 13:44:08 +03:00
|
|
|
use blake3::Hash;
|
2025-06-25 02:15:27 +03:00
|
|
|
|
2025-06-26 01:08:13 +03:00
|
|
|
use crate::{
|
|
|
|
|
RuntimeModule,
|
|
|
|
|
common::{enemy::Enemy, materials::MaterialDrops},
|
|
|
|
|
create_file, create_hashes,
|
|
|
|
|
};
|
2025-06-25 02:15:27 +03:00
|
|
|
|
|
|
|
|
const MATERIAL_KINDS: &[&str] = &[
|
|
|
|
|
"lucid", "spirit", "power", "blaze", "frost", "thunder", "shiny", "bright", "mystery", "gale",
|
|
|
|
|
"mythril",
|
|
|
|
|
];
|
|
|
|
|
const DROPS_PATH: &str = "./input/kh1/drops";
|
2025-06-26 01:08:13 +03:00
|
|
|
const ENEMIES_PATH: &str = "./input/kh1/enemies";
|
2025-06-25 13:44:08 +03:00
|
|
|
static JS_HASH: OnceLock<Hash> = OnceLock::new();
|
2025-06-25 02:15:27 +03:00
|
|
|
|
|
|
|
|
#[derive(Template)]
|
|
|
|
|
#[template(path = "pages/kh1/drops.html")]
|
|
|
|
|
struct DropsTemplate {
|
|
|
|
|
pub drops: Vec<MaterialDrops>,
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
pub struct Module;
|
2025-06-25 02:15:27 +03:00
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
impl RuntimeModule for Module {
|
|
|
|
|
fn start_module() {
|
2025-06-26 01:08:13 +03:00
|
|
|
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
|
|
|
|
|
let enemies = Enemy::import(ENEMIES_PATH);
|
|
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
tracing::info!("Loading enemy drops data from {}", DROPS_PATH);
|
2025-06-26 01:08:13 +03:00
|
|
|
let drops = MaterialDrops::new(enemies);
|
2025-06-25 02:15:27 +03:00
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
tracing::info!("Generating the KH1 drops template");
|
|
|
|
|
let drops_template = DropsTemplate { drops };
|
|
|
|
|
|
|
|
|
|
create_file("./out/kh1", "drops", drops_template.render().unwrap()).unwrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_js_hash() -> String {
|
|
|
|
|
JS_HASH.get_or_init(|| create_hashes("kh1")).to_string()
|
|
|
|
|
}
|
2025-06-25 02:15:27 +03:00
|
|
|
}
|