Make it run (no actual randomizing yet).

This commit is contained in:
Lyle Mantooth 2022-06-04 09:39:52 -04:00
parent 87b0476b7e
commit 1113adca98
Signed by: IslandUsurper
GPG key ID: 6DB52EAE123A5789
5 changed files with 196 additions and 27 deletions

29
enemize/src/randomize.rs Normal file
View file

@ -0,0 +1,29 @@
use std::path::Path;
use anyhow::ensure;
use crate::PatchSet;
use crate::option_flags::OptionFlags;
use crate::rom::RomData;
impl RomData {
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.");
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(())
}
}