2022-06-04 09:39:52 -04:00
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use anyhow::ensure;
|
|
|
|
|
|
|
|
use crate::option_flags::OptionFlags;
|
|
|
|
use crate::rom::RomData;
|
2022-06-04 09:41:29 -04:00
|
|
|
use crate::PatchSet;
|
2022-06-04 09:39:52 -04:00
|
|
|
|
|
|
|
impl RomData {
|
2022-06-04 09:41:29 -04:00
|
|
|
pub fn randomize(
|
|
|
|
&mut self,
|
|
|
|
base_patch: &Path,
|
|
|
|
option_flags: OptionFlags,
|
|
|
|
seed: i32,
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
ensure!(
|
|
|
|
self.is_randomizer(),
|
|
|
|
"Enemizer only supports randomizer ROMs for input."
|
|
|
|
);
|
2022-06-04 09:39:52 -04:00
|
|
|
ensure!(!self.is_race(), "Enemizer does not support race roms.");
|
|
|
|
|
|
|
|
if self.is_enemizer() {
|
|
|
|
// Reuse seed in ROM, not the one given.
|
|
|
|
self.reset_enemizer();
|
|
|
|
} else {
|
|
|
|
self.set_enemizer_seed(seed);
|
|
|
|
}
|
|
|
|
|
|
|
|
self.expand_rom();
|
|
|
|
self.set_info_flags(option_flags)?;
|
|
|
|
|
|
|
|
let patches = PatchSet::load(base_patch)?;
|
|
|
|
patches.patch_rom(self);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|