From d8fd3d71115b3676be2078a91b1ae12283c73285 Mon Sep 17 00:00:00 2001 From: Wynd Date: Thu, 26 Jun 2025 01:08:13 +0300 Subject: [PATCH] New system for drop tracking combined into enemy data --- Cargo.toml | 1 + input/kh1/enemies/air-pirate.toml | 24 ++++++ input/kh1/enemies/air-soldier.toml | 24 ++++++ input/kh1/enemies/angel-star.toml | 18 ++++ input/kh1/enemies/aquatank.toml | 18 ++++ input/kh1/enemies/bandit.toml | 24 ++++++ input/kh1/enemies/barrel-spider.toml | 20 +++++ input/kh1/enemies/battleship.toml | 34 ++++++++ input/kh1/enemies/blue-rhapsody.toml | 30 +++++++ input/kh1/enemies/bouncywild.toml | 43 ++++++++++ input/kh1/enemies/darkball.toml | 24 ++++++ input/kh1/enemies/defender.toml | 29 +++++++ input/kh1/enemies/fat-bandit.toml | 24 ++++++ input/kh1/enemies/gargoyle.toml | 26 ++++++ input/kh1/enemies/green-requiem.toml | 33 +++++++ input/kh1/enemies/invisible.toml | 18 ++++ input/kh1/enemies/large-body.toml | 34 ++++++++ input/kh1/enemies/pirate.toml | 29 +++++++ input/kh1/enemies/shadow.toml | 19 ++++ input/kh1/enemies/soldier.toml | 14 +++ src/common.rs | 1 + src/common/enemy.rs | 90 +++++++++++++++++++ src/common/materials.rs | 124 ++++++++++++++++----------- src/kh1.rs | 12 ++- src/kh2.rs | 6 +- templates/macros/common/macros.html | 11 ++- templates/pages/kh1/drops.html | 2 +- templates/pages/kh2/drops.html | 2 +- 28 files changed, 671 insertions(+), 63 deletions(-) create mode 100644 input/kh1/enemies/air-pirate.toml create mode 100644 input/kh1/enemies/air-soldier.toml create mode 100644 input/kh1/enemies/angel-star.toml create mode 100644 input/kh1/enemies/aquatank.toml create mode 100644 input/kh1/enemies/bandit.toml create mode 100644 input/kh1/enemies/barrel-spider.toml create mode 100644 input/kh1/enemies/battleship.toml create mode 100644 input/kh1/enemies/blue-rhapsody.toml create mode 100644 input/kh1/enemies/bouncywild.toml create mode 100644 input/kh1/enemies/darkball.toml create mode 100644 input/kh1/enemies/defender.toml create mode 100644 input/kh1/enemies/fat-bandit.toml create mode 100644 input/kh1/enemies/gargoyle.toml create mode 100644 input/kh1/enemies/green-requiem.toml create mode 100644 input/kh1/enemies/invisible.toml create mode 100644 input/kh1/enemies/large-body.toml create mode 100644 input/kh1/enemies/pirate.toml create mode 100644 input/kh1/enemies/shadow.toml create mode 100644 input/kh1/enemies/soldier.toml create mode 100644 src/common/enemy.rs diff --git a/Cargo.toml b/Cargo.toml index 6fb1c89..18910d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } itertools = "0.14" blake3 = "1.8" +ordered-float = { version = "5.0", features = ["serde"] } [features] default = ["bbs", "ddd", "kh3", "kh2", "kh1"] diff --git a/input/kh1/enemies/air-pirate.toml b/input/kh1/enemies/air-pirate.toml new file mode 100644 index 0000000..6f025db --- /dev/null +++ b/input/kh1/enemies/air-pirate.toml @@ -0,0 +1,24 @@ +name = "Air Pirate" + +[[world]] +name = "Neverland" +room = "" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Mega-Potion" +kind = "item" +chance = 1 + +[[drops]] +name = "Power Gem" +kind = "material" +chance = 4 + + [drops.material] + category = "power" + kind = "gem" diff --git a/input/kh1/enemies/air-soldier.toml b/input/kh1/enemies/air-soldier.toml new file mode 100644 index 0000000..89ee0b8 --- /dev/null +++ b/input/kh1/enemies/air-soldier.toml @@ -0,0 +1,24 @@ +name = "Air Soldier" + +[[world]] +name = "" +room = "" + +[[drops]] +name = "Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 1 + +[[drops]] +name = "Spirit Gem" +kind = "material" +chance = 4 + + [drops.material] + category = "spirit" + kind = "gem" diff --git a/input/kh1/enemies/angel-star.toml b/input/kh1/enemies/angel-star.toml new file mode 100644 index 0000000..41a7311 --- /dev/null +++ b/input/kh1/enemies/angel-star.toml @@ -0,0 +1,18 @@ +name = "Angel Star" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Ether" +kind = "item" +chance = 2 + +[[drops]] +name = "Gale" +kind = "material" +chance = 4 + + [drops.material] + category = "stormy" + kind = "crystal" diff --git a/input/kh1/enemies/aquatank.toml b/input/kh1/enemies/aquatank.toml new file mode 100644 index 0000000..7fa241f --- /dev/null +++ b/input/kh1/enemies/aquatank.toml @@ -0,0 +1,18 @@ +name = "Aquatank" + +[[world]] +name = "Atlantica" + +[[drops]] +name = "Mega-Potion" +kind = "item" +chance = 4 + +[[drops]] +name = "Thunder Gem" +kind = "material" +chance = 8 + + [drops.material] + category = "thunder" + kind = "gem" diff --git a/input/kh1/enemies/bandit.toml b/input/kh1/enemies/bandit.toml new file mode 100644 index 0000000..039d1a1 --- /dev/null +++ b/input/kh1/enemies/bandit.toml @@ -0,0 +1,24 @@ +name = "Bandit" + +[[world]] +name = "Agrabah" + +[[world]] +name = "Monstro" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Blaze Gem" +kind = "material" +chance = 4 + + [drops.material] + category = "blaze" + kind = "gem" diff --git a/input/kh1/enemies/barrel-spider.toml b/input/kh1/enemies/barrel-spider.toml new file mode 100644 index 0000000..20ef3d9 --- /dev/null +++ b/input/kh1/enemies/barrel-spider.toml @@ -0,0 +1,20 @@ +name = "Barrel Spider" + +[[world]] +name = "Monstro" + +[[world]] +name = "Neverland" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Camping Set" +kind = "item" +chance = 1 + +[[drops]] +name = "Cottage" +kind = "item" +chance = 0.5 diff --git a/input/kh1/enemies/battleship.toml b/input/kh1/enemies/battleship.toml new file mode 100644 index 0000000..1d69cdd --- /dev/null +++ b/input/kh1/enemies/battleship.toml @@ -0,0 +1,34 @@ +name = "Battleship" + +[[world]] +name = "Neverland" + +[[drops]] +name = "Elixir" +kind = "item" +chance = 0.5 + +[[drops]] +name = "Elixir" +kind = "item" +chance = 1 +info = "Destroy the Stern, Cannons or Mast" + +[[drops]] +name = "Power Gem" +kind = "material" +chance = 4 + + [drops.material] + category = "power" + kind = "gem" + +[[drops]] +name = "Power Gem" +kind = "material" +chance = 8 +info = "Destroy the Stern, Cannons or Mast" + + [drops.material] + category = "power" + kind = "gem" diff --git a/input/kh1/enemies/blue-rhapsody.toml b/input/kh1/enemies/blue-rhapsody.toml new file mode 100644 index 0000000..98afed0 --- /dev/null +++ b/input/kh1/enemies/blue-rhapsody.toml @@ -0,0 +1,30 @@ +name = "Blue Rhapsody" + +[[world]] +name = "Traverse Town" + +[[world]] +name = "Wonderland" + +[[world]] +name = "Monstro" + +[[world]] +name = "Hollow Bastion" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Ether" +kind = "item" +chance = 1 + +[[drops]] +name = "Frost Shard" +kind = "material" +chance = 12 + + [drops.material] + category = "frost" + kind = "shard" diff --git a/input/kh1/enemies/bouncywild.toml b/input/kh1/enemies/bouncywild.toml new file mode 100644 index 0000000..704ae04 --- /dev/null +++ b/input/kh1/enemies/bouncywild.toml @@ -0,0 +1,43 @@ +name = "Bouncywild" + +[[world]] +name = "Deep Jungle" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Power Shard" +kind = "material" +chance = 8 + + [drops.material] + category = "power" + kind = "shard" + +[[drops]] +name = "Ether" +kind = "item" +chance = 20 +info = "When it slips on the banana peel" + +[[drops]] +name = "Mega-Ether" +kind = "item" +chance = 4 +info = "When it slips on the banana peel" + +[[drops]] +name = "Power Shard" +kind = "material" +chance = 8 +info = "When it slips on the banana peel" + + [drops.material] + category = "power" + kind = "shard" diff --git a/input/kh1/enemies/darkball.toml b/input/kh1/enemies/darkball.toml new file mode 100644 index 0000000..3d52c15 --- /dev/null +++ b/input/kh1/enemies/darkball.toml @@ -0,0 +1,24 @@ +name = "Darkball" + +[[world]] +name = "Traverse Town" + +[[world]] +name = "Hollow Bastion" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 1 + +[[drops]] +name = "Lucid Crystal" +kind = "material" +chance = 1 + + [drops.material] + category = "lucid" + kind = "crystal" diff --git a/input/kh1/enemies/defender.toml b/input/kh1/enemies/defender.toml new file mode 100644 index 0000000..d7ea895 --- /dev/null +++ b/input/kh1/enemies/defender.toml @@ -0,0 +1,29 @@ +name = "Defender" + +[[world]] +name = "Traverse Town" + +[[world]] +name = "Hollow Bastion" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Elixir" +kind = "item" +chance = 1 + +[[drops]] +name = "Bright Crystal" +kind = "material" +chance = 2 + + [drops.material] + category = "bright" + kind = "crystal" + +[[drops]] +name = "Defender" +kind = "equipment" +chance = 0.2 diff --git a/input/kh1/enemies/fat-bandit.toml b/input/kh1/enemies/fat-bandit.toml new file mode 100644 index 0000000..0ba490a --- /dev/null +++ b/input/kh1/enemies/fat-bandit.toml @@ -0,0 +1,24 @@ +name = "Fat Bandit" + +[[world]] +name = "Agrabah" + +[[world]] +name = "Monstro" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 4 + +[[drops]] +name = "Blaze Gem" +kind = "material" +chance = 8 + + [drops.material] + category = "blaze" + kind = "gem" diff --git a/input/kh1/enemies/gargoyle.toml b/input/kh1/enemies/gargoyle.toml new file mode 100644 index 0000000..009d91e --- /dev/null +++ b/input/kh1/enemies/gargoyle.toml @@ -0,0 +1,26 @@ +name = "Gargoyle" + +[[world]] +name = "Holloween Town" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Ether" +kind = "item" +chance = 1 + +[[drops]] +name = "Mega-Ether" +kind = "item" +chance = 0.5 + +[[drops]] +name = "Lucid Gem" +kind = "material" +chance = 2 + + [drops.material] + category = "lucid" + kind = "gem" diff --git a/input/kh1/enemies/green-requiem.toml b/input/kh1/enemies/green-requiem.toml new file mode 100644 index 0000000..3cdeb34 --- /dev/null +++ b/input/kh1/enemies/green-requiem.toml @@ -0,0 +1,33 @@ +name = "Green Requiem" + +[[world]] +name = "Traverse Town" + +[[world]] +name = "Agrabah" + +[[world]] +name = "Monstro" + +[[world]] +name = "Deep Jungle" + +[[world]] +name = "Hollow Bastion" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Ether" +kind = "item" +chance = 4 + +[[drops]] +name = "Bright Shard" +kind = "material" +chance = 10 + + [drops.material] + category = "bright" + kind = "shard" diff --git a/input/kh1/enemies/invisible.toml b/input/kh1/enemies/invisible.toml new file mode 100644 index 0000000..e1e617d --- /dev/null +++ b/input/kh1/enemies/invisible.toml @@ -0,0 +1,18 @@ +name = "Invisible" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Gale" +kind = "material" +chance = 4 + + [drops.material] + category = "stormy" + kind = "crystal" diff --git a/input/kh1/enemies/large-body.toml b/input/kh1/enemies/large-body.toml new file mode 100644 index 0000000..359c0e6 --- /dev/null +++ b/input/kh1/enemies/large-body.toml @@ -0,0 +1,34 @@ +name = "Large Body" + +[[world]] +name = "Traverse Town" + +[[world]] +name = "Wonderland" + +[[world]] +name = "Agrabah" +marked = true + +[[world]] +name = "Monstro" + +[[world]] +name = "Hollow Bastion" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 4 + +[[drops]] +name = "Spirit Shard" +kind = "material" +chance = 10 + + [drops.material] + category = "spirit" + kind = "shard" diff --git a/input/kh1/enemies/pirate.toml b/input/kh1/enemies/pirate.toml new file mode 100644 index 0000000..1c82b9a --- /dev/null +++ b/input/kh1/enemies/pirate.toml @@ -0,0 +1,29 @@ +name = "Pirate" + +[[world]] +name = "Neverland" + +[[world]] +name = "Monstro" + +[[world]] +name = "End of the World" + +[[drops]] +name = "Hi-Potion" +kind = "item" +chance = 2 + +[[drops]] +name = "Mega-Potion" +kind = "item" +chance = 1 + +[[drops]] +name = "Power Gem" +kind = "material" +chance = 4 + + [drops.material] + category = "power" + kind = "gem" diff --git a/input/kh1/enemies/shadow.toml b/input/kh1/enemies/shadow.toml new file mode 100644 index 0000000..431434a --- /dev/null +++ b/input/kh1/enemies/shadow.toml @@ -0,0 +1,19 @@ +name = "Shadow" + +[[world]] +name = "Traverse Town" +room = "" + +[[drops]] +name = "Potion" +kind = "item" +chance = 6 + +[[drops]] +name = "Lucid Shard" +kind = "material" +chance = 3 + + [drops.material] + category = "lucid" + kind = "shard" diff --git a/input/kh1/enemies/soldier.toml b/input/kh1/enemies/soldier.toml new file mode 100644 index 0000000..84c9b2d --- /dev/null +++ b/input/kh1/enemies/soldier.toml @@ -0,0 +1,14 @@ +name = "Soldier" + +[[world]] +name = "Traverse Town" +room = "" + +[[drops]] +name = "Spirit Shard" +kind = "material" +chance = 6 + + [drops.material] + category = "spirit" + kind = "shard" diff --git a/src/common.rs b/src/common.rs index d777b82..8d03643 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,2 +1,3 @@ pub mod direction; +pub mod enemy; pub mod materials; diff --git a/src/common/enemy.rs b/src/common/enemy.rs new file mode 100644 index 0000000..1277103 --- /dev/null +++ b/src/common/enemy.rs @@ -0,0 +1,90 @@ +use std::{fmt::Display, path::PathBuf}; + +use serde::Deserialize; + +use super::materials::MaterialDetails; + +#[derive(Debug, Deserialize, PartialEq, Eq)] +pub struct Enemy { + pub name: String, + pub icon: Option, + pub world: Vec, + pub drops: Vec, +} + +impl Enemy { + pub fn import(path: &str) -> Vec { + let mut enemies: Vec = vec![]; + + // Loading multiple files into one vector due to the size of each board + let paths = std::fs::read_dir(path) + .unwrap() + .filter_map(|f| f.ok()) + .map(|f| f.path()) + .filter_map(|p| match p.extension().is_some_and(|e| e == "toml") { + true => Some(p), + false => None, + }) + .collect::>(); + + for path in paths { + let enemy_str = std::fs::read_to_string(path).unwrap(); + let mut enemy = toml::from_str::(&enemy_str).unwrap(); + enemy + .drops + .iter_mut() + .for_each(|d| d.from = enemy.name.clone()); + enemies.push(enemy); + } + + enemies + } +} + +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +pub struct EnemyDrop { + pub name: String, + #[serde(skip)] + pub from: String, + pub chance: EnemyDropChance, + pub kind: EnemyDropKind, + pub icon: Option, + pub info: Option, + pub material: Option, +} + +impl EnemyDrop { + pub fn texture(&self) -> String { + self.from.replace(" ", "_").to_lowercase() + } +} + +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[serde(rename_all = "lowercase")] +pub enum EnemyDropKind { + Item, + Material, + Equipment, +} + +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[serde(untagged)] +pub enum EnemyDropChance { + Fixed(ordered_float::OrderedFloat), + Variable(String), +} + +impl Display for EnemyDropChance { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EnemyDropChance::Fixed(val) => f.write_str(&format!("{val}%")), + EnemyDropChance::Variable(val) => f.write_str(val), + } + } +} + +#[derive(Debug, Deserialize, PartialEq, Eq)] +pub struct SpawnLocation { + pub name: String, + pub room: Option, +} diff --git a/src/common/materials.rs b/src/common/materials.rs index 0e5b5e6..7d3baf6 100644 --- a/src/common/materials.rs +++ b/src/common/materials.rs @@ -1,80 +1,100 @@ -use std::{fmt::Display, path::PathBuf}; +use std::{collections::HashMap, fmt::Display}; use serde::Deserialize; -#[derive(Debug, Deserialize, PartialEq, Eq)] -pub struct EnemyDrop { - pub from: String, - pub chance: EnemyDropChance, +use super::enemy::{Enemy, EnemyDrop}; - #[serde(default)] - pub info: Option, +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +pub struct MaterialDetails { + pub category: String, + pub kind: MaterialKind, } -impl EnemyDrop { - pub fn texture(&self) -> String { - self.from.replace(" ", "_").to_lowercase() - } +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[serde(rename_all = "lowercase")] +pub enum MaterialKind { + Shard, + Stone, + Gem, + Crystal, } -#[derive(Debug, Deserialize, PartialEq, Eq)] -#[serde(untagged)] -pub enum EnemyDropChance { - Fixed(u8), - Variable(String), -} - -impl Display for EnemyDropChance { +impl Display for MaterialKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - EnemyDropChance::Fixed(val) => f.write_str(&format!("{val}%")), - EnemyDropChance::Variable(val) => f.write_str(val), + MaterialKind::Shard => f.write_str("shard"), + MaterialKind::Stone => f.write_str("stone"), + MaterialKind::Gem => f.write_str("gem"), + MaterialKind::Crystal => f.write_str("crystal"), } } } -#[derive(Debug, Default, Deserialize, PartialEq, Eq)] -#[serde(default)] +#[derive(Debug, PartialEq, Eq)] pub struct MaterialDrops { - pub kind: String, - pub shard: Vec, - pub stone: Vec, - pub gem: Vec, - pub crystal: Vec, + pub name: String, + pub icon: String, + pub category: String, + pub kind: MaterialKind, + pub drops: Vec, +} + +impl PartialOrd for MaterialDrops { + fn partial_cmp(&self, other: &Self) -> Option { + if self.category.cmp(&other.category) == std::cmp::Ordering::Equal { + return Some(self.kind.cmp(&other.kind)); + } + + Some(self.category.cmp(&other.category)) + } } impl MaterialDrops { - pub fn import(path: &str) -> Vec { - let mut drops: Vec = vec![]; + pub fn new(enemies: Vec) -> Vec { + let mut mat_map = HashMap::<(String, MaterialKind), MaterialDrops>::new(); - // Loading multiple files into one vector due to the size of each board - let paths = std::fs::read_dir(path) - .unwrap() - .filter_map(|f| f.ok()) - .map(|f| f.path()) - .filter_map(|p| match p.extension().is_some_and(|e| e == "toml") { - true => Some(p), - false => None, - }) - .collect::>(); + for enemy in enemies { + for drop in &enemy.drops { + let Some(material) = &drop.material else { + continue; + }; - for path in paths { - let drops_str = std::fs::read_to_string(path).unwrap(); - let enemy_drops = toml::from_str::(&drops_str).unwrap(); - drops.push(enemy_drops); + let key = (material.category.clone(), material.kind.clone()); + + mat_map + .entry(key) + .and_modify(|d| d.drops.push(drop.clone())) + .or_insert(MaterialDrops { + name: drop.name.to_string(), + icon: "".to_string(), + category: material.category.clone(), + kind: material.kind.clone(), + drops: vec![drop.clone()], + }); + } } - drops.sort_by(|a, b| a.kind.cmp(&b.kind)); - drops + let mut values: Vec = mat_map.into_values().collect(); + + values.sort_by(|a, b| a.partial_cmp(b).unwrap()); + + values } - pub fn drops(&self, kind: &str) -> &[EnemyDrop] { + pub fn drops(&self, kind: &str) -> Vec<&EnemyDrop> { match kind { - "shard" => &self.shard, - "stone" => &self.stone, - "gem" => &self.gem, - "crystal" => &self.crystal, - _ => &self.shard, + "shard" => self.get_drop_kind(MaterialKind::Shard), + "stone" => self.get_drop_kind(MaterialKind::Stone), + "gem" => self.get_drop_kind(MaterialKind::Gem), + "crystal" => self.get_drop_kind(MaterialKind::Crystal), + _ => vec![], } } + + fn get_drop_kind(&self, kind: MaterialKind) -> Vec<&EnemyDrop> { + self.drops + .iter() + .filter(|d| d.material.as_ref().map(|m| m.kind == kind).unwrap_or(false)) + .collect::>() + } } diff --git a/src/kh1.rs b/src/kh1.rs index 8e9c3f5..654bd09 100644 --- a/src/kh1.rs +++ b/src/kh1.rs @@ -3,13 +3,18 @@ use std::sync::OnceLock; use askama::Template; use blake3::Hash; -use crate::{RuntimeModule, common::materials::MaterialDrops, create_file, create_hashes}; +use crate::{ + RuntimeModule, + common::{enemy::Enemy, materials::MaterialDrops}, + 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(); #[derive(Template)] @@ -22,8 +27,11 @@ pub struct Module; impl RuntimeModule for Module { fn start_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::import(DROPS_PATH); + let drops = MaterialDrops::new(enemies); tracing::info!("Generating the KH1 drops template"); let drops_template = DropsTemplate { drops }; diff --git a/src/kh2.rs b/src/kh2.rs index cf5481f..a684875 100644 --- a/src/kh2.rs +++ b/src/kh2.rs @@ -33,12 +33,12 @@ pub struct Module; impl RuntimeModule for Module { fn start_module() { tracing::info!("Loading enemy drops data from {}", DROPS_PATH); - let drops = MaterialDrops::import(DROPS_PATH); + // let drops = MaterialDrops::import(DROPS_PATH); tracing::info!("Generating the KH2 drops template"); - let drops_template = DropsTemplate { drops }; + // let drops_template = DropsTemplate { drops }; - create_file("./out/kh2", "drops", drops_template.render().unwrap()).unwrap(); + // create_file("./out/kh2", "drops", drops_template.render().unwrap()).unwrap(); } fn get_js_hash() -> String { diff --git a/templates/macros/common/macros.html b/templates/macros/common/macros.html index 3deae41..dcb0315 100644 --- a/templates/macros/common/macros.html +++ b/templates/macros/common/macros.html @@ -1,18 +1,21 @@ {% macro drop(label) %} - {% let drops = category.drops(label) %} + {% let drops = drop.drops(label) %} {% if drops.len() > 0 %}
-

{{ category.kind|capitalize +}} {{+ label|capitalize }}

+ + + +

{{ drop.name }}

diff --git a/templates/pages/kh1/drops.html b/templates/pages/kh1/drops.html index f8f73af..4e12e7b 100644 --- a/templates/pages/kh1/drops.html +++ b/templates/pages/kh1/drops.html @@ -14,7 +14,7 @@ {% include "components/common/kind-filters.html" %}
- {% for category in drops %} + {% for drop in drops %} {% call macros::drop("shard") %} {% call macros::drop("stone") %} {% call macros::drop("gem") %} diff --git a/templates/pages/kh2/drops.html b/templates/pages/kh2/drops.html index b0da5a0..a3ea88c 100644 --- a/templates/pages/kh2/drops.html +++ b/templates/pages/kh2/drops.html @@ -14,7 +14,7 @@ {% include "components/common/kind-filters.html" %}
- {% for category in drops %} + {% for drop in drops %} {% call macros::drop("shard") %} {% call macros::drop("stone") %} {% call macros::drop("gem") %}