You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
6.3 KiB

5 years ago
  1. #![allow(dead_code)]
  2. use std::collections::HashMap;
  3. use std::fs::File;
  4. use std::io::Read;
  5. use std::path::PathBuf;
  6. use serde::{Serialize, Deserialize};
  7. use crate::ship::room::{Difficulty, Episode, RoomMode};
  8. #[derive(Debug)]
  9. pub enum MonsterParseError {
  10. UnknownMonster(String),
  11. }
  12. pub struct MonsterStatError;
  13. #[derive(Debug, Serialize, Deserialize, Copy, Clone, Hash, Eq, PartialEq, enum_utils::FromStr, derive_more::Display)]
  14. pub enum MonsterType {
  15. Hildebear,
  16. Hildeblue,
  17. Mothmant,
  18. Monest,
  19. RagRappy,
  20. AlRappy,
  21. SavageWolf,
  22. BarbarousWolf,
  23. Booma,
  24. Gobooma,
  25. Gigobooma,
  26. GrassAssassin,
  27. PoisonLily,
  28. NarLily,
  29. NanoDragon,
  30. EvilShark,
  31. PalShark,
  32. GuilShark,
  33. PofuillySlime,
  34. PouillySlime,
  35. PanArms,
  36. Hidoom,
  37. Migium,
  38. Dubchic,
  39. Garanz,
  40. SinowBeat,
  41. SinowGold,
  42. Canadine,
  43. Canane,
  44. RingCanadine,
  45. Delsaber,
  46. ChaosSorcerer,
  47. BeeR,
  48. BeeL,
  49. DarkGunner,
  50. DeathGunner,
  51. ChaosBringer,
  52. DarkBelra,
  53. Claw,
  54. Bulk,
  55. Bulclaw,
  56. Dimenian,
  57. LaDimenian,
  58. SoDimenian,
  59. Dragon,
  60. DeRolLe,
  61. DeRolLeBody,
  62. DeRolLeMine,
  63. VolOptPartA,
  64. VolOptPillar,
  65. VolOptMonitor,
  66. VolOptAmp,
  67. VolOptCore,
  68. VolOptUnused,
  69. VolOpt,
  70. VolOptTrap,
  71. DarkFalz,
  72. DarkFalz1,
  73. DarkFalz2,
  74. DarkFalz3,
  75. Darvant,
  76. UltDarvant,
  77. Dubwitch,
  78. Gillchic,
  79. EventRappy,
  80. Merillia,
  81. Meriltas,
  82. Gee,
  83. GiGue,
  84. Mericarol,
  85. Merikle,
  86. Mericus,
  87. UlGibbon,
  88. ZolGibbon,
  89. Gibbles,
  90. SinowBerill,
  91. SinowSpigell,
  92. Dolmolm,
  93. Dolmdarl,
  94. Morfos,
  95. Recobox,
  96. Recon,
  97. SinowZoa,
  98. SinowZele,
  99. Deldepth,
  100. Delbiter,
  101. BarbaRay,
  102. PigRay,
  103. GolDragon,
  104. GalGryphon,
  105. OlgaFlow,
  106. OlgaFlow1,
  107. OlgaFlow2,
  108. Gael,
  109. Giel,
  110. StRappy,
  111. HalloRappy,
  112. EasterRappy,
  113. LoveRappy,
  114. IllGill,
  115. DelLily,
  116. Epsilon,
  117. Epsiguard,
  118. Boota,
  119. ZeBoota,
  120. BaBoota,
  121. SandRappyCrater,
  122. SandRappyDesert,
  123. ZuCrater,
  124. PazuzuCrater,
  125. Astark,
  126. SatelliteLizardCrater,
  127. YowieCrater,
  128. Dorphon,
  129. DorphonEclair,
  130. Goran,
  131. GoranDetonator,
  132. PyroGoran,
  133. DelRappyCrater,
  134. DelRappyDesert,
  135. MerissaA,
  136. MerissaAA,
  137. ZuDesert,
  138. PazuzuDesert,
  139. SatelliteLizardDesert,
  140. YowieDesert,
  141. Girtablulu,
  142. SaintMillion,
  143. Shambertin,
  144. Kondrieu,
  145. }
  146. #[derive(serde::Deserialize, Debug)]
  147. pub struct MonsterStats {
  148. pub atp: u16,
  149. pub mst: u16,
  150. pub evp: u16,
  151. pub hp: u16,
  152. pub dfp: u16,
  153. pub ata: u16,
  154. pub lck: u16,
  155. pub esp: u16,
  156. pub exp: u32,
  157. }
  158. fn load_battle_param(filename: &str) -> HashMap<MonsterType, MonsterStats> {
  159. let mut path = PathBuf::from("data/battle_param/");
  160. path.push(filename);
  161. let mut f = File::open(path).unwrap();
  162. let mut s = String::new();
  163. f.read_to_string(&mut s).unwrap();
  164. toml::from_str::<HashMap<String, MonsterStats>>(s.as_str()).unwrap()
  165. .into_iter()
  166. .map(|(monster_name, stats)| {
  167. (monster_name.parse().unwrap(), stats)
  168. }).collect()
  169. }
  170. pub fn load_monster_stats_table(mode: &RoomMode) -> Result<HashMap<MonsterType, MonsterStats>, MonsterStatError> {
  171. match mode {
  172. RoomMode::Multi {episode: Episode::One, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep1_multi_normal.toml")),
  173. RoomMode::Multi {episode: Episode::One, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep1_multi_hard.toml")),
  174. RoomMode::Multi {episode: Episode::One, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep1_multi_veryhard.toml")),
  175. RoomMode::Multi {episode: Episode::One, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep1_multi_ultimate.toml")),
  176. RoomMode::Multi {episode: Episode::Two, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep2_multi_normal.toml")),
  177. RoomMode::Multi {episode: Episode::Two, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep2_multi_hard.toml")),
  178. RoomMode::Multi {episode: Episode::Two, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep2_multi_veryhard.toml")),
  179. RoomMode::Multi {episode: Episode::Two, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep2_multi_ultimate.toml")),
  180. RoomMode::Multi {episode: Episode::Four, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep4_multi_normal.toml")),
  181. RoomMode::Multi {episode: Episode::Four, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep4_multi_hard.toml")),
  182. RoomMode::Multi {episode: Episode::Four, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep4_multi_veryhard.toml")),
  183. RoomMode::Multi {episode: Episode::Four, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep4_multi_ultimate.toml")),
  184. RoomMode::Single {episode: Episode::One, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep1_solo_normal.toml")),
  185. RoomMode::Single {episode: Episode::One, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep1_solo_hard.toml")),
  186. RoomMode::Single {episode: Episode::One, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep1_solo_veryhard.toml")),
  187. RoomMode::Single {episode: Episode::One, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep1_solo_ultimate.toml")),
  188. RoomMode::Single {episode: Episode::Two, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep2_solo_normal.toml")),
  189. RoomMode::Single {episode: Episode::Two, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep2_solo_hard.toml")),
  190. RoomMode::Single {episode: Episode::Two, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep2_solo_veryhard.toml")),
  191. RoomMode::Single {episode: Episode::Two, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep2_solo_ultimate.toml")),
  192. RoomMode::Single {episode: Episode::Four, difficulty: Difficulty::Normal} => Ok(load_battle_param("ep4_solo_normal.toml")),
  193. RoomMode::Single {episode: Episode::Four, difficulty: Difficulty::Hard} => Ok(load_battle_param("ep4_solo_hard.toml")),
  194. RoomMode::Single {episode: Episode::Four, difficulty: Difficulty::VeryHard} => Ok(load_battle_param("ep4_solo_veryhard.toml")),
  195. RoomMode::Single {episode: Episode::Four, difficulty: Difficulty::Ultimate} => Ok(load_battle_param("ep4_solo_ultimate.toml")),
  196. _ => Err(MonsterStatError),
  197. }
  198. }