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:
		
							parent
							
								
									c81348fb10
								
							
						
					
					
						commit
						a161d9090e
					
				
					 8 changed files with 860 additions and 6 deletions
				
			
		
							
								
								
									
										48
									
								
								enemize/src/bosses/mod.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								enemize/src/bosses/mod.rs
									
										
									
									
									
										Normal 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))
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue