use serde::{Deserialize, Serialize}; const ENEMIES_JSON: &str = include_str!("../../../../skara-brae-common/data/enemies.json"); const ZONES_JSON: &str = include_str!("../../../../skara-brae-common/data/adventures/zones.json"); #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EnemyDef { pub id: String, pub name: String, pub level: i32, pub stats: EnemyStats, pub hp: i32, pub attack_type: String, pub damage: i32, pub defense: i32, pub xp: i32, pub gold_min: i32, pub gold_max: i32, pub loot: Vec, pub description: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LootDrop { pub item_id: String, pub chance: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EnemyStats { pub strength: i64, pub intelligence: i64, pub dexterity: i64, pub constitution: i64, pub luck: i64, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EncounterEntry { pub enemy_id: String, pub weight: i32, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ZoneDef { pub id: String, pub name: String, pub min_level: i32, pub max_level: i32, pub nerve_cost: i32, pub description: String, pub encounters: Vec, } pub fn load_enemies() -> Vec { serde_json::from_str(ENEMIES_JSON).expect("failed to parse enemies.json") } pub fn load_zones() -> Vec { serde_json::from_str(ZONES_JSON).expect("failed to parse zones.json") } #[cfg(test)] mod tests { use super::*; #[test] fn enemies_json_parses() { assert!(!load_enemies().is_empty()); } #[test] fn zones_json_parses() { assert!(!load_zones().is_empty()); } }