use askama::Template; use food::Recipes; use ingredient::Ingredient; use crate::{ RuntimeModule, common::{Game, drops::Drops, enemy::Enemy}, create_file, }; mod food; mod ingredient; const ENEMIES_PATH: &str = "./input/kh3/enemies"; const RECIPES_PATH: &str = "./input/kh3/recipes.toml"; const INGREDIENTS_PATH: &str = "./input/kh3/ingredients"; #[derive(Template)] #[template(path = "pages/kh3/drops.html")] struct DropsTemplate { pub data: Drops, } #[derive(Template)] #[template(path = "pages/kh3/food-sim.html")] struct RecipesTemplate { pub recipes: Recipes, } #[derive(Template)] #[template(path = "pages/kh3/ingredients.html")] struct IngredientsTemplate { pub ingredients: Vec, } 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 = Drops::new(Game::Kh3, enemies); tracing::info!("Loading ingredients data from {}", ENEMIES_PATH); let ingredients = Ingredient::import(INGREDIENTS_PATH); 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_str).unwrap(); tracing::info!("Generating the KH3 drops template"); let drops_template = DropsTemplate { data: drops }; create_file("./out/kh3", "drops", drops_template).unwrap(); tracing::info!("Generating the KH3 ingredients template"); let ingredients_template = IngredientsTemplate { ingredients }; create_file("./out/kh3", "ingredients", ingredients_template).unwrap(); tracing::info!("Generating the KH3 recipes template"); let food_template = RecipesTemplate { recipes }; create_file("./out/kh3", "food-sim", food_template).unwrap(); } }