From b558c054e96e6e60a97a7755ccec774b0b0e9413 Mon Sep 17 00:00:00 2001 From: compiling <8335770+compiling@users.noreply.github.com> Date: Sun, 24 May 2020 18:50:03 +1000 Subject: [PATCH] Inverted dungeonsfull fix - Force reusing an existing cave if there are not enough entrances to use a new one. --- EntranceShuffle.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/EntranceShuffle.py b/EntranceShuffle.py index 4b5660fb..4c53d6cd 100644 --- a/EntranceShuffle.py +++ b/EntranceShuffle.py @@ -1911,12 +1911,13 @@ def connect_mandatory_exits(world, entrances, caves, must_be_exits, player, dp_m random.shuffle(entrances) random.shuffle(caves) used_caves = [] + required_entrances = 0 # Number of entrances reserved for used_caves while must_be_exits: exit = must_be_exits.pop() # find multi exit cave cave = None for candidate in caves: - if not isinstance(candidate, str): + if not isinstance(candidate, str) and (candidate in used_caves or len(candidate) < len(entrances) - required_entrances): cave = candidate break @@ -1941,6 +1942,11 @@ def connect_mandatory_exits(world, entrances, caves, must_be_exits, player, dp_m for exit in cave[:-1]: connect_two_way(world,entrances.pop(),exit, player) else:#save for later so we can connect to multiple exits + if cave in used_caves: + required_entrances -= 1 + used_caves.remove(cave) + else: + required_entrances += len(cave)-1 caves.append(cave[0:-1]) random.shuffle(caves) used_caves.append(cave[0:-1])