From 4ea0eda0b930e05a02be93039f8dcc9edb8c55c3 Mon Sep 17 00:00:00 2001 From: codemann8 Date: Wed, 22 Feb 2023 17:37:27 -0600 Subject: [PATCH] Initializing districts after OWR so ER can use them --- Main.py | 3 +++ source/item/District.py | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Main.py b/Main.py index c05828fc..4a7407be 100644 --- a/Main.py +++ b/Main.py @@ -30,6 +30,7 @@ from Fill import sell_potions, sell_keys, balance_multiworld_progression, balanc from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops, fill_specific_items, create_farm_locations from Utils import output_path, parse_player_names +from source.item.District import init_districts from source.item.FillUtil import create_item_pool_config, massage_item_pool, district_item_pool_config from source.overworld.EntranceShuffle2 import link_entrances_new from source.tools.BPS import create_bps_from_data @@ -224,6 +225,8 @@ def main(args, seed=None, fish=None): update_world_regions(world, player) mark_light_dark_world_regions(world, player) create_dynamic_exits(world, player) + + init_districts(world) logger.info(world.fish.translate("cli","cli","shuffling.world")) diff --git a/source/item/District.py b/source/item/District.py index d9e9e23e..3cd58a1f 100644 --- a/source/item/District.py +++ b/source/item/District.py @@ -43,7 +43,7 @@ def create_district_helper(world, player): world.districts[player] = districts -def resolve_districts(world): +def init_districts(world): def exclude_area(world, owid, area, player): # area can be a region or entrancecurrently, could potentially be a problem later if name collision std_regions = ['Pyramid Ledge', 'Pyramid Hole', 'Pyramid Entrance'] @@ -54,14 +54,7 @@ def resolve_districts(world): return False create_districts(world) - state = CollectionState(world) - state.sweep_for_events() for player in range(1, world.players + 1): - # these are not static for OWR - but still important - inaccessible = [r for r in inaccessible_regions_std if not world.is_tile_swapped(OWTileRegions[r], player)] - inaccessible = inaccessible + [r for r in inaccessible_regions_inv if world.is_tile_swapped(OWTileRegions[r], player)] - check_set = find_reachable_locations(state, player) - # adding regions to districts for owid, (alt_regions, alt_districts, default_districts) in OWTileDistricts.items(): idx = 0 if (world.mode[player] == 'inverted') == world.is_tile_swapped(owid, player) else 1 @@ -81,7 +74,26 @@ def resolve_districts(world): world.districts[player][alt_districts[(idx + 1) % 2]].regions.append(region) else: world.districts[player][default_districts[(idx + 1) % 2]].regions.append(region) - + + # adding entrances to districts + for name, district in world.districts[player].items(): + if not district.dungeon: + for region_name in district.regions: + region = world.get_region(region_name, player) + for exit in region.exits: + if exit.spot_type == 'Entrance' and not exclude_area(world, OWTileRegions[region.name], exit.name, player): + district.entrances.append(exit.name) + + +def resolve_districts(world): + state = CollectionState(world) + state.sweep_for_events() + for player in range(1, world.players + 1): + # these are not static for OWR - but still important + inaccessible = [r for r in inaccessible_regions_std if not world.is_tile_swapped(OWTileRegions[r], player)] + inaccessible = inaccessible + [r for r in inaccessible_regions_inv if world.is_tile_swapped(OWTileRegions[r], player)] + check_set = find_reachable_locations(state, player) + for name, district in world.districts[player].items(): if district.dungeon: layout = world.dungeon_layouts[player][district.dungeon] @@ -93,9 +105,6 @@ def resolve_districts(world): for location in region.locations: if not location.item and location.real: district.locations.add(location.name) - for exit in region.exits: - if exit.spot_type == 'Entrance' and not exclude_area(world, OWTileRegions[region.name], exit.name, player): - district.entrances.append(exit.name) for entrance in district.entrances: ent = world.get_entrance(entrance, player) queue = deque([ent.connected_region])