Merged in DR v0.5.1.1

This commit is contained in:
codemann8
2021-08-31 19:39:23 -05:00
12 changed files with 122 additions and 40 deletions

View File

@@ -751,7 +751,7 @@ def handle_split_dungeons(dungeon_builders, recombinant_builders, entrances_map,
def main_dungeon_generation(dungeon_builders, recombinant_builders, connections_tuple, world, player):
entrances_map, potentials, connections = connections_tuple
enabled_entrances = {}
enabled_entrances = world.enabled_entrances[player] = {}
sector_queue = deque(dungeon_builders.values())
last_key, loops = None, 0
logging.getLogger('').info(world.fish.translate("cli", "cli", "generating.dungeon"))
@@ -1456,6 +1456,14 @@ def find_valid_combination(builder, start_regions, world, player, drop_keys=True
random.shuffle(sample_list)
proposal = kth_combination(sample_list[itr], builder.candidates, builder.key_doors_num)
# eliminate start region if portal marked as destination
excluded = {}
for region in start_regions:
portal = next((x for x in world.dungeon_portals[player] if x.door.entrance.parent_region == region), None)
if portal and portal.destination:
excluded[region] = None
start_regions = [x for x in start_regions if x not in excluded.keys()]
key_layout = build_key_layout(builder, start_regions, proposal, world, player)
while not validate_key_layout(key_layout, world, player):
itr += 1
@@ -1914,14 +1922,18 @@ def check_required_paths(paths, world, player):
if dungeon_name in world.dungeon_layouts[player].keys():
builder = world.dungeon_layouts[player][dungeon_name]
if len(paths[dungeon_name]) > 0:
states_to_explore = defaultdict(list)
states_to_explore = {}
for path in paths[dungeon_name]:
if type(path) is tuple:
states_to_explore[tuple([path[0]])] = path[1]
states_to_explore[tuple([path[0]])] = (path[1], 'any')
else:
states_to_explore[tuple(builder.path_entrances)].append(path)
common_starts = tuple(builder.path_entrances)
if common_starts not in states_to_explore:
states_to_explore[common_starts] = ([], 'all')
states_to_explore[common_starts][0].append(path)
cached_initial_state = None
for start_regs, dest_regs in states_to_explore.items():
for start_regs, info in states_to_explore.items():
dest_regs, path_type = info
if type(dest_regs) is not list:
dest_regs = [dest_regs]
check_paths = convert_regions(dest_regs, world, player)
@@ -1938,11 +1950,17 @@ def check_required_paths(paths, world, player):
cached_initial_state = state
else:
state = cached_initial_state
valid, bad_region = check_if_regions_visited(state, check_paths)
if path_type == 'any':
valid, bad_region = check_if_any_regions_visited(state, check_paths)
else:
valid, bad_region = check_if_all_regions_visited(state, check_paths)
if not valid:
if check_for_pinball_fix(state, bad_region, world, player):
explore_state(state, world, player)
valid, bad_region = check_if_regions_visited(state, check_paths)
if path_type == 'any':
valid, bad_region = check_if_any_regions_visited(state, check_paths)
else:
valid, bad_region = check_if_all_regions_visited(state, check_paths)
if not valid:
raise Exception('%s cannot reach %s' % (dungeon_name, bad_region.name))
@@ -1982,7 +2000,7 @@ def explore_state_not_inaccessible(state, world, player):
state.add_all_doors_check_unattached(connect_region, world, player)
def check_if_regions_visited(state, check_paths):
def check_if_any_regions_visited(state, check_paths):
valid = False
breaking_region = None
for region_target in check_paths:
@@ -1994,6 +2012,13 @@ def check_if_regions_visited(state, check_paths):
return valid, breaking_region
def check_if_all_regions_visited(state, check_paths):
for region_target in check_paths:
if not state.visited_at_all(region_target):
return False, region_target
return True, None
def check_for_pinball_fix(state, bad_region, world, player):
pinball_region = world.get_region('Skull Pinball', player)
# todo: lobby shuffle