49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
|
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))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|