LTTP: make the enemizer check a property and only check for it once instead of per world (#1448)
* LTTP: do the enemizer check in `stage_assert_generate` and break after checking any world for enemizer succeeds * use multiworld * catch a missed `used_enemizer` check and add typing * more typing
This commit is contained in:
parent
7cbeb8438b
commit
f078750b72
|
@ -20,7 +20,7 @@ import concurrent.futures
|
||||||
import bsdiff4
|
import bsdiff4
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
from BaseClasses import CollectionState, Region, Location
|
from BaseClasses import CollectionState, Region, Location, MultiWorld
|
||||||
from worlds.alttp.Shops import ShopType, ShopPriceType
|
from worlds.alttp.Shops import ShopType, ShopPriceType
|
||||||
from worlds.alttp.Dungeons import dungeon_music_addresses
|
from worlds.alttp.Dungeons import dungeon_music_addresses
|
||||||
from worlds.alttp.Regions import location_table, old_location_address_to_new_location_address
|
from worlds.alttp.Regions import location_table, old_location_address_to_new_location_address
|
||||||
|
@ -765,7 +765,7 @@ def get_nonnative_item_sprite(item: str) -> int:
|
||||||
# https://discord.com/channels/731205301247803413/827141303330406408/852102450822905886
|
# https://discord.com/channels/731205301247803413/827141303330406408/852102450822905886
|
||||||
|
|
||||||
|
|
||||||
def patch_rom(world, rom, player, enemized):
|
def patch_rom(world: MultiWorld, rom: LocalRom, player: int, enemized: bool):
|
||||||
local_random = world.per_slot_randoms[player]
|
local_random = world.per_slot_randoms[player]
|
||||||
|
|
||||||
# patch items
|
# patch items
|
||||||
|
|
|
@ -5,7 +5,7 @@ import threading
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import Utils
|
import Utils
|
||||||
from BaseClasses import Item, CollectionState, Tutorial
|
from BaseClasses import Item, CollectionState, Tutorial, MultiWorld
|
||||||
from .Dungeons import create_dungeons
|
from .Dungeons import create_dungeons
|
||||||
from .EntranceShuffle import link_entrances, link_inverted_entrances, plando_connect, \
|
from .EntranceShuffle import link_entrances, link_inverted_entrances, plando_connect, \
|
||||||
indirect_connections, indirect_connections_inverted, indirect_connections_not_inverted
|
indirect_connections, indirect_connections_inverted, indirect_connections_not_inverted
|
||||||
|
@ -151,16 +151,18 @@ class ALTTPWorld(World):
|
||||||
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def stage_assert_generate(cls, world):
|
def stage_assert_generate(cls, multiworld: MultiWorld):
|
||||||
rom_file = get_base_rom_path()
|
rom_file = get_base_rom_path()
|
||||||
if not os.path.exists(rom_file):
|
if not os.path.exists(rom_file):
|
||||||
raise FileNotFoundError(rom_file)
|
raise FileNotFoundError(rom_file)
|
||||||
if world.is_race:
|
if multiworld.is_race:
|
||||||
import xxtea
|
import xxtea
|
||||||
|
for player in multiworld.get_game_players(cls.game):
|
||||||
|
if multiworld.worlds[player].use_enemizer:
|
||||||
|
check_enemizer(multiworld.worlds[player].enemizer_path)
|
||||||
|
break
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
if self.use_enemizer():
|
|
||||||
check_enemizer(self.enemizer_path)
|
|
||||||
|
|
||||||
player = self.player
|
player = self.player
|
||||||
world = self.multiworld
|
world = self.multiworld
|
||||||
|
@ -369,19 +371,20 @@ class ALTTPWorld(World):
|
||||||
def stage_post_fill(cls, world):
|
def stage_post_fill(cls, world):
|
||||||
ShopSlotFill(world)
|
ShopSlotFill(world)
|
||||||
|
|
||||||
def use_enemizer(self):
|
@property
|
||||||
|
def use_enemizer(self) -> bool:
|
||||||
world = self.multiworld
|
world = self.multiworld
|
||||||
player = self.player
|
player = self.player
|
||||||
return (world.boss_shuffle[player] or world.enemy_shuffle[player]
|
return bool(world.boss_shuffle[player] or world.enemy_shuffle[player]
|
||||||
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
|
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
|
||||||
or world.pot_shuffle[player] or world.bush_shuffle[player]
|
or world.pot_shuffle[player] or world.bush_shuffle[player]
|
||||||
or world.killable_thieves[player])
|
or world.killable_thieves[player])
|
||||||
|
|
||||||
def generate_output(self, output_directory: str):
|
def generate_output(self, output_directory: str):
|
||||||
world = self.multiworld
|
world = self.multiworld
|
||||||
player = self.player
|
player = self.player
|
||||||
try:
|
try:
|
||||||
use_enemizer = self.use_enemizer()
|
use_enemizer = self.use_enemizer
|
||||||
|
|
||||||
rom = LocalRom(get_base_rom_path())
|
rom = LocalRom(get_base_rom_path())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue