2025-06-24 19:56:47 +03:00
|
|
|
use askama::Template;
|
|
|
|
|
use food::Recipes;
|
2025-01-27 14:55:10 +02:00
|
|
|
|
2025-07-08 00:47:18 +03:00
|
|
|
use crate::{
|
|
|
|
|
RuntimeModule,
|
2025-07-13 23:56:34 +03:00
|
|
|
common::{Game, drops::Drops, enemy::Enemy},
|
2025-07-08 00:47:18 +03:00
|
|
|
create_file,
|
|
|
|
|
};
|
2025-01-31 15:06:04 +02:00
|
|
|
|
2025-06-24 19:56:47 +03:00
|
|
|
mod food;
|
2025-01-27 14:55:10 +02:00
|
|
|
|
2025-07-08 00:47:18 +03:00
|
|
|
const ENEMIES_PATH: &str = "./input/kh3/enemies";
|
2025-06-24 19:56:47 +03:00
|
|
|
const RECIPES_PATH: &str = "./input/kh3/recipes.toml";
|
2025-01-27 14:55:10 +02:00
|
|
|
|
2025-07-08 00:47:18 +03:00
|
|
|
#[derive(Template)]
|
|
|
|
|
#[template(path = "pages/kh3/drops.html")]
|
|
|
|
|
struct DropsTemplate {
|
2025-07-13 23:56:34 +03:00
|
|
|
pub data: Drops,
|
2025-07-08 00:47:18 +03:00
|
|
|
}
|
|
|
|
|
|
2025-01-27 14:55:10 +02:00
|
|
|
#[derive(Template)]
|
2025-01-31 15:06:04 +02:00
|
|
|
#[template(path = "pages/kh3/food-sim.html")]
|
2025-01-27 14:55:10 +02:00
|
|
|
struct RecipesTemplate {
|
|
|
|
|
pub recipes: Recipes,
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
pub struct Module;
|
|
|
|
|
|
|
|
|
|
impl RuntimeModule for Module {
|
|
|
|
|
fn start_module() {
|
2025-07-08 00:47:18 +03:00
|
|
|
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
|
|
|
|
|
let enemies = Enemy::import(ENEMIES_PATH);
|
|
|
|
|
|
2025-07-13 23:56:34 +03:00
|
|
|
let drops = Drops::new(Game::Kh3, enemies);
|
2025-07-08 00:47:18 +03:00
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
tracing::info!("Loading recipes data from {}", RECIPES_PATH);
|
|
|
|
|
let recipes_str = std::fs::read_to_string(RECIPES_PATH).unwrap();
|
|
|
|
|
let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap();
|
|
|
|
|
|
2025-07-08 00:47:18 +03:00
|
|
|
tracing::info!("Generating the KH3 drops template");
|
2025-07-13 23:56:34 +03:00
|
|
|
let drops_template = DropsTemplate { data: drops };
|
2025-07-08 00:47:18 +03:00
|
|
|
|
|
|
|
|
create_file("./out/kh3", "drops", drops_template).unwrap();
|
|
|
|
|
|
2025-06-25 13:44:08 +03:00
|
|
|
tracing::info!("Generating the KH3 recipes template");
|
|
|
|
|
let food_template = RecipesTemplate { recipes };
|
2025-01-27 14:55:10 +02:00
|
|
|
|
2025-06-29 14:03:58 +03:00
|
|
|
create_file("./out/kh3", "food-sim", food_template).unwrap();
|
2025-06-25 13:44:08 +03:00
|
|
|
}
|
2025-01-27 14:55:10 +02:00
|
|
|
}
|