Add RomData, OptionFlags, and enums for them.

Fun error handling with automatic, fallible conversion to and from u8s
for the enums.
This commit is contained in:
Lyle Mantooth 2022-05-29 10:22:34 -04:00
parent c81348fb10
commit a161d9090e
Signed by: IslandUsurper
GPG key ID: 6DB52EAE123A5789
8 changed files with 860 additions and 6 deletions

48
enemize/src/bosses/mod.rs Normal file
View file

@ -0,0 +1,48 @@
use std::marker::PhantomData;
use crate::InvalidEnumError;
#[derive(Debug)]
#[repr(u8)]
pub enum BossType {
Kholdstare,
Moldorm,
Mothula,
Vitreous,
Helmasaur,
Armos,
Lanmola,
Blind,
Arrghus,
Trinexx,
// Don't use these. They are only for manual settings passed in by the randomizer web app.
Agahnim,
Agahnim2,
Ganon,
NoBoss = 255,
}
impl TryFrom<u8> for BossType {
type Error = InvalidEnumError<Self>;
fn try_from(byte: u8) -> Result<Self, Self::Error> {
match byte {
0 => Ok(Self::Kholdstare),
1 => Ok(Self::Moldorm),
2 => Ok(Self::Mothula),
3 => Ok(Self::Vitreous),
4 => Ok(Self::Helmasaur),
5 => Ok(Self::Armos),
6 => Ok(Self::Lanmola),
7 => Ok(Self::Blind),
8 => Ok(Self::Arrghus),
9 => Ok(Self::Trinexx),
10 => Ok(Self::Agahnim),
11 => Ok(Self::Agahnim2),
12 => Ok(Self::Ganon),
255 => Ok(Self::NoBoss),
_ => Err(InvalidEnumError(PhantomData))
}
}
}