|
|
@ -210,16 +210,15 @@ impl MapArea { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: rename this to something less silly
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct MapAreaMapper(HashMap<u16, MapArea>);
|
|
|
|
pub struct MapAreaLookup(HashMap<u16, MapArea>);
|
|
|
|
|
|
|
|
impl MapAreaMapper {
|
|
|
|
impl MapAreaLookup {
|
|
|
|
pub fn get_area_map(&self, map_area: u16) -> Result<&MapArea, MapAreaError> {
|
|
|
|
self.0.get(&map_area).ok_or(MapAreaError::UnknownMapArea(map_area))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_ep1_maps() -> MapAreaMapper {
|
|
|
|
fn default_ep1_maps() -> MapAreaLookup {
|
|
|
|
let mut ep1 = HashMap::new();
|
|
|
|
ep1.insert(0, MapArea::Pioneer2Ep1);
|
|
|
|
ep1.insert(1, MapArea::Forest1);
|
|
|
@ -236,10 +235,10 @@ impl MapAreaMapper { |
|
|
|
ep1.insert(12, MapArea::DeRolLe);
|
|
|
|
ep1.insert(13, MapArea::VolOpt);
|
|
|
|
ep1.insert(14, MapArea::DarkFalz);
|
|
|
|
MapAreaMapper(ep1)
|
|
|
|
MapAreaLookup(ep1)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_ep2_maps() -> MapAreaMapper {
|
|
|
|
fn default_ep2_maps() -> MapAreaLookup {
|
|
|
|
let mut ep2 = HashMap::new();
|
|
|
|
ep2.insert(0, MapArea::Pioneer2Ep2);
|
|
|
|
ep2.insert(1, MapArea::VrTempleAlpha);
|
|
|
@ -259,10 +258,10 @@ impl MapAreaMapper { |
|
|
|
ep2.insert(15, MapArea::GolDragon);
|
|
|
|
ep2.insert(16, MapArea::SeasideNight);
|
|
|
|
ep2.insert(17, MapArea::Tower);
|
|
|
|
MapAreaMapper(ep2)
|
|
|
|
MapAreaLookup(ep2)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_ep4_maps() -> MapAreaMapper {
|
|
|
|
fn default_ep4_maps() -> MapAreaLookup {
|
|
|
|
let mut ep4 = HashMap::new();
|
|
|
|
ep4.insert(0, MapArea::Pioneer2Ep4);
|
|
|
|
ep4.insert(1, MapArea::CraterEast);
|
|
|
@ -274,36 +273,36 @@ impl MapAreaMapper { |
|
|
|
ep4.insert(7, MapArea::SubDesert2);
|
|
|
|
ep4.insert(8, MapArea::SubDesert3);
|
|
|
|
ep4.insert(9, MapArea::SaintMillion);
|
|
|
|
MapAreaMapper(ep4)
|
|
|
|
MapAreaLookup(ep4)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new(episode: &Episode) -> MapAreaMapper {
|
|
|
|
pub fn new(episode: &Episode) -> MapAreaLookup {
|
|
|
|
match episode {
|
|
|
|
Episode::One => MapAreaMapper::default_ep1_maps(),
|
|
|
|
Episode::Two => MapAreaMapper::default_ep2_maps(),
|
|
|
|
Episode::Four => MapAreaMapper::default_ep4_maps(),
|
|
|
|
Episode::One => MapAreaLookup::default_ep1_maps(),
|
|
|
|
Episode::Two => MapAreaLookup::default_ep2_maps(),
|
|
|
|
Episode::Four => MapAreaLookup::default_ep4_maps(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct MapAreaMapperBuilder {
|
|
|
|
pub struct MapAreaLookupBuilder {
|
|
|
|
map_areas: HashMap<u16, MapArea>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MapAreaMapperBuilder {
|
|
|
|
pub fn new() -> MapAreaMapperBuilder {
|
|
|
|
MapAreaMapperBuilder {
|
|
|
|
impl MapAreaLookupBuilder {
|
|
|
|
pub fn new() -> MapAreaLookupBuilder {
|
|
|
|
MapAreaLookupBuilder {
|
|
|
|
map_areas: HashMap::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add(mut self, value: u16, map_area: MapArea) -> MapAreaMapperBuilder {
|
|
|
|
pub fn add(mut self, value: u16, map_area: MapArea) -> MapAreaLookupBuilder {
|
|
|
|
self.map_areas.insert(value, map_area);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn build(self) -> MapAreaMapper {
|
|
|
|
MapAreaMapper(self.map_areas)
|
|
|
|
pub fn build(self) -> MapAreaLookup {
|
|
|
|
MapAreaLookup(self.map_areas)
|
|
|
|
}
|
|
|
|
}
|