From d532a579e8272b3d923985ec1fc339b9aaf0f785 Mon Sep 17 00:00:00 2001 From: codemann8 Date: Sun, 30 Oct 2022 15:52:40 -0500 Subject: [PATCH] Changed copy_world_limited to premature and made it only for one player --- EntranceShuffle.py | 12 +++---- Main.py | 80 ++++++++++++++++++++++----------------------- OverworldShuffle.py | 12 +++---- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/EntranceShuffle.py b/EntranceShuffle.py index 951c55f6..5ac4a5ac 100644 --- a/EntranceShuffle.py +++ b/EntranceShuffle.py @@ -1440,12 +1440,12 @@ def place_old_man(world, pool, player, ignore_list=[]): def junk_fill_inaccessible(world, player): - from Main import copy_world_limited + from Main import copy_world_premature find_inaccessible_regions(world, player) for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) base_world.override_bomb_check = True # remove regions that have a dungeon entrance @@ -1602,12 +1602,12 @@ def unbias_dungeons(Dungeon_Exits): def build_accessible_entrance_list(world, start_region, player, assumed_inventory=[], cross_world=False, region_rules=True, exit_rules=True, include_one_ways=False): - from Main import copy_world_limited + from Main import copy_world_premature from Items import ItemFactory for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) base_world.override_bomb_check = True connect_simple(base_world, 'Links House S&Q', start_region, player) @@ -1710,12 +1710,12 @@ def get_distant_entrances(world, start_entrance, player): def can_reach(world, entrance_name, region_name, player): - from Main import copy_world_limited + from Main import copy_world_premature from Items import ItemFactory for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) base_world.override_bomb_check = True entrance = world.get_entrance(entrance_name, player) diff --git a/Main.py b/Main.py index 0efc38ff..d7646f83 100644 --- a/Main.py +++ b/Main.py @@ -558,7 +558,7 @@ def copy_world(world): return ret -def copy_world_limited(world): +def copy_world_premature(world, player): # ToDo: Not good yet ret = World(world.players, world.owShuffle, world.owCrossed, world.owMixed, world.shuffle, world.doorShuffle, world.logic, world.mode, world.swords, world.difficulty, world.difficulty_adjustments, world.timer, world.progressive, world.goal, world.algorithm, @@ -621,63 +621,63 @@ def copy_world_limited(world): ret.is_copied_world = True - for player in range(1, world.players + 1): - create_regions(ret, player) - update_world_regions(ret, player) - if world.logic[player] in ('owglitches', 'nologic'): - create_owg_connections(ret, player) - create_flute_exits(ret, player) - create_dungeon_regions(ret, player) - create_owedges(ret, player) - create_shops(ret, player) - create_doors(ret, player) - create_rooms(ret, player) - create_dungeons(ret, player) + create_regions(ret, player) + update_world_regions(ret, player) + if world.logic[player] in ('owglitches', 'nologic'): + create_owg_connections(ret, player) + create_flute_exits(ret, player) + create_dungeon_regions(ret, player) + create_owedges(ret, player) + create_shops(ret, player) + create_doors(ret, player) + create_rooms(ret, player) + create_dungeons(ret, player) - for player in range(1, world.players + 1): - if world.mode[player] == 'standard': - parent = ret.get_region('Menu', player) - target = ret.get_region('Hyrule Castle Secret Entrance', player) - connection = Entrance(player, 'Uncle S&Q', parent) - parent.exits.append(connection) - connection.connect(target) + if world.mode[player] == 'standard': + parent = ret.get_region('Menu', player) + target = ret.get_region('Hyrule Castle Secret Entrance', player) + connection = Entrance(player, 'Uncle S&Q', parent) + parent.exits.append(connection) + connection.connect(target) # connect copied world copied_locations = {(loc.name, loc.player): loc for loc in ret.get_locations()} # caches all locations for region in world.regions: - copied_region = ret.get_region(region.name, region.player) - copied_region.is_light_world = region.is_light_world - copied_region.is_dark_world = region.is_dark_world - copied_region.dungeon = region.dungeon - copied_region.locations = [copied_locations[(location.name, location.player)] for location in region.locations if (location.name, location.player) in copied_locations] - for location in copied_region.locations: - location.parent_region = copied_region - for entrance in region.entrances: - ret.get_entrance(entrance.name, entrance.player).connect(copied_region) + if region.player == player: + copied_region = ret.get_region(region.name, region.player) + copied_region.is_light_world = region.is_light_world + copied_region.is_dark_world = region.is_dark_world + copied_region.dungeon = region.dungeon + copied_region.locations = [copied_locations[(location.name, location.player)] for location in region.locations if (location.name, location.player) in copied_locations] + for location in copied_region.locations: + location.parent_region = copied_region + for entrance in region.entrances: + ret.get_entrance(entrance.name, entrance.player).connect(copied_region) for item in world.precollected_items: - ret.push_precollected(ItemFactory(item.name, item.player)) + if item.player == player: + ret.push_precollected(ItemFactory(item.name, item.player)) for edge in world.owedges: - if edge.dest is not None: + if edge.player == player and edge.dest: copiededge = ret.check_for_owedge(edge.name, edge.player) if copiededge is not None: copiededge.dest = ret.check_for_owedge(edge.dest.name, edge.dest.player) for door in world.doors: - entrance = ret.check_for_entrance(door.name, door.player) - if entrance is not None: - destdoor = ret.check_for_door(entrance.door.name, entrance.door.player) - entrance.door = destdoor - if destdoor is not None: - destdoor.entrance = entrance + if door.player == player: + entrance = ret.check_for_entrance(door.name, door.player) + if entrance is not None: + destdoor = ret.check_for_door(entrance.door.name, entrance.door.player) + entrance.door = destdoor + if destdoor is not None: + destdoor.entrance = entrance ret.key_logic = world.key_logic.copy() from OverworldShuffle import categorize_world_regions - for player in range(1, world.players + 1): - categorize_world_regions(ret, player) - set_rules(ret, player) + categorize_world_regions(ret, player) + set_rules(ret, player) return ret diff --git a/OverworldShuffle.py b/OverworldShuffle.py index 340152a6..d88c8d58 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -904,13 +904,13 @@ def can_reach_smith(world, player): return found def build_sectors(world, player): - from Main import copy_world_limited + from Main import copy_world_premature from OWEdges import OWTileRegions # perform accessibility check on duplicate world for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) # build lists of contiguous regions accessible with full inventory (excl portals/mirror/flute/entrances) regions = list(OWTileRegions.copy().keys()) @@ -970,7 +970,7 @@ def build_sectors(world, player): def build_accessible_region_list(world, start_region, player, build_copy_world=False, cross_world=False, region_rules=True, ignore_ledges = False): from BaseClasses import CollectionState - from Main import copy_world_limited + from Main import copy_world_premature from Items import ItemFactory from Utils import stack_size3a @@ -997,7 +997,7 @@ def build_accessible_region_list(world, start_region, player, build_copy_world=F if build_copy_world: for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) base_world.override_bomb_check = True else: base_world = world @@ -1040,7 +1040,7 @@ def validate_layout(world, player): 'Pyramid Area': ['Pyramid Exit Ledge'] } - from Main import copy_world_limited + from Main import copy_world_premature from Utils import stack_size3a from EntranceShuffle import default_dungeon_connections, default_connector_connections, default_item_connections, default_shop_connections, default_drop_connections, default_dropexit_connections @@ -1073,7 +1073,7 @@ def validate_layout(world, player): for p in range(1, world.players + 1): world.key_logic[p] = {} - base_world = copy_world_limited(world) + base_world = copy_world_premature(world, player) explored_regions = list() if world.shuffle[player] in ['vanilla', 'dungeonssimple', 'dungeonsfull'] or not world.shufflelinks[player]: