Check for ROMs at beginning of generation (#475)
This commit is contained in:
parent
e8579771a5
commit
894a30b9bd
2
Main.py
2
Main.py
|
@ -93,6 +93,8 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
f"Location IDs: {min(cls.location_id_to_name):{numlength}} - "
|
f"Location IDs: {min(cls.location_id_to_name):{numlength}} - "
|
||||||
f"{max(cls.location_id_to_name):{numlength}}")
|
f"{max(cls.location_id_to_name):{numlength}}")
|
||||||
|
|
||||||
|
AutoWorld.call_stage(world, "assert_generate")
|
||||||
|
|
||||||
AutoWorld.call_all(world, "generate_early")
|
AutoWorld.call_all(world, "generate_early")
|
||||||
|
|
||||||
logger.info('')
|
logger.info('')
|
||||||
|
|
|
@ -426,6 +426,9 @@ In addition, the following methods can be implemented and attributes can be set
|
||||||
* `required_client_version: Tuple(int, int, int)`
|
* `required_client_version: Tuple(int, int, int)`
|
||||||
Client version as tuple of 3 ints to make sure the client is compatible to
|
Client version as tuple of 3 ints to make sure the client is compatible to
|
||||||
this world (e.g. implements all required features) when connecting.
|
this world (e.g. implements all required features) when connecting.
|
||||||
|
* `assert_generate(cls, world)` is a class method called at the start of
|
||||||
|
generation to check the existence of prerequisite files, usually a ROM for
|
||||||
|
games which require one.
|
||||||
|
|
||||||
#### generate_early
|
#### generate_early
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,12 @@ class World(metaclass=AutoWorldRegister):
|
||||||
# can also be implemented as a classmethod and called "stage_<original_name>",
|
# can also be implemented as a classmethod and called "stage_<original_name>",
|
||||||
# in that case the MultiWorld object is passed as an argument and it gets called once for the entire multiworld.
|
# in that case the MultiWorld object is passed as an argument and it gets called once for the entire multiworld.
|
||||||
# An example of this can be found in alttp as stage_pre_fill
|
# An example of this can be found in alttp as stage_pre_fill
|
||||||
|
@classmethod
|
||||||
|
def assert_generate(cls) -> None:
|
||||||
|
"""Checks that a game is capable of generating, usually checks for some base file like a ROM.
|
||||||
|
Not run for unittests since they don't produce output"""
|
||||||
|
pass
|
||||||
|
|
||||||
def generate_early(self) -> None:
|
def generate_early(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,12 @@ class ALTTPWorld(World):
|
||||||
self.has_progressive_bows = False
|
self.has_progressive_bows = False
|
||||||
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_assert_generate(cls, world):
|
||||||
|
rom_file = get_base_rom_path()
|
||||||
|
if not os.path.exists(rom_file):
|
||||||
|
raise FileNotFoundError(rom_file)
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
player = self.player
|
player = self.player
|
||||||
world = self.world
|
world = self.world
|
||||||
|
|
|
@ -89,6 +89,10 @@ class OOTWorld(World):
|
||||||
self.hint_data_available = threading.Event()
|
self.hint_data_available = threading.Event()
|
||||||
super(OOTWorld, self).__init__(world, player)
|
super(OOTWorld, self).__init__(world, player)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_assert_generate(cls, world: MultiWorld):
|
||||||
|
rom = Rom(file=get_options()['oot_options']['rom_file'])
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
# Player name MUST be at most 16 bytes ascii-encoded, otherwise won't write to ROM correctly
|
# Player name MUST be at most 16 bytes ascii-encoded, otherwise won't write to ROM correctly
|
||||||
if len(bytes(self.world.get_player_name(self.player), 'ascii')) > 16:
|
if len(bytes(self.world.get_player_name(self.player), 'ascii')) > 16:
|
||||||
|
|
|
@ -83,6 +83,12 @@ class SMWorld(World):
|
||||||
self.rom_name_available_event = threading.Event()
|
self.rom_name_available_event = threading.Event()
|
||||||
super().__init__(world, player)
|
super().__init__(world, player)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_assert_generate(cls, world):
|
||||||
|
rom_file = get_base_rom_path()
|
||||||
|
if not os.path.exists(rom_file):
|
||||||
|
raise FileNotFoundError(rom_file)
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
Logic.factory('vanilla')
|
Logic.factory('vanilla')
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ class SMZ3World(World):
|
||||||
self.unreachable = []
|
self.unreachable = []
|
||||||
super().__init__(world, player)
|
super().__init__(world, player)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_assert_generate(cls, world):
|
||||||
|
base_combined_rom = get_base_rom_bytes()
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
config = Config({})
|
config = Config({})
|
||||||
config.GameMode = GameMode.Multiworld
|
config.GameMode = GameMode.Multiworld
|
||||||
|
|
|
@ -175,6 +175,12 @@ class SoEWorld(World):
|
||||||
res.trap = item.type == pyevermizer.CHECK_TRAP
|
res.trap = item.type == pyevermizer.CHECK_TRAP
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_assert_generate(cls, world):
|
||||||
|
rom_file = get_base_rom_path()
|
||||||
|
if not os.path.exists(rom_file):
|
||||||
|
raise FileNotFoundError(rom_file)
|
||||||
|
|
||||||
def create_regions(self):
|
def create_regions(self):
|
||||||
# TODO: generate *some* regions from locations' requirements?
|
# TODO: generate *some* regions from locations' requirements?
|
||||||
r = Region('Menu', RegionType.Generic, 'Menu', self.player, self.world)
|
r = Region('Menu', RegionType.Generic, 'Menu', self.player, self.world)
|
||||||
|
|
Loading…
Reference in New Issue