use askama::Template;

use crate::{
	RuntimeModule,
	common::{Game, GameProps, drops::Drops, enemy::Enemy},
	create_file,
};

const ENEMIES_PATH: &str = "./input/kh2fm/enemies";

#[derive(Template)]
#[template(path = "pages/kh2/drops.html")]
struct DropsTemplate {
	pub data: Drops,
}

pub struct Module;

impl RuntimeModule for Module {
	fn start_module() {
		tracing::info!("Loading KH2FM enemy data from {}", ENEMIES_PATH);
		let enemies = Enemy::import(ENEMIES_PATH);

		let drops = Drops::new(Game::Kh2(GameProps::final_mix()), enemies);

		tracing::info!("Generating KH2FM drops template");
		let drops_template = DropsTemplate { data: drops };

		create_file("./out/kh2fm", "drops", drops_template).unwrap();
	}
}
