From 7e617fe956c8a9574cacd9547ea6d748fb33216d Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 31 Jan 2020 08:54:23 -0800 Subject: [PATCH] init monster code --- src/ship/mod.rs | 1 + src/ship/monster.rs | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/ship/monster.rs diff --git a/src/ship/mod.rs b/src/ship/mod.rs index 78a2eef..f55a4aa 100644 --- a/src/ship/mod.rs +++ b/src/ship/mod.rs @@ -3,3 +3,4 @@ pub mod location; pub mod character; pub mod room; pub mod items; +pub mod monster; diff --git a/src/ship/monster.rs b/src/ship/monster.rs new file mode 100644 index 0000000..d04b3e4 --- /dev/null +++ b/src/ship/monster.rs @@ -0,0 +1,48 @@ +use std::convert::TryFrom; + + +#[derive(Debug)] +pub enum MonsterParseError { + UnknownMonster(String), +} + + +#[derive(Debug, Copy, Clone)] +pub enum MonsterType { + Booma, + Gobooma, + Gigobooma, + RagRappy, + AlRappy, + BarbarousWolf, + SavageWolf, + Hildebear, + Hildeblue, + Monest, + Mothmant, + + EvilShark, + PalShark, + GuilShark, + // etc... + +} + + +impl TryFrom<&str> for MonsterType { + type Error = MonsterParseError; + + fn try_from(monster: &str) -> Result { + match monster { + "Booma" | "Bartle" => Ok(MonsterType::Booma), + "Gobooma" | "Barble" => Ok(MonsterType::Gobooma), + "Gigobooma" | "Tollaw" => Ok(MonsterType::Gigobooma), + // etc... + _ => Err(MonsterParseError::UnknownMonster(monster.to_owned())) + } + } + + + + +}