Skip to content

Commit

Permalink
Merge pull request #1606 from pbeierle22/custom-location-shuffle-logi…
Browse files Browse the repository at this point in the history
…c-fix

custom location shuffle updates logic once more
  • Loading branch information
pbeierle22 authored Sep 11, 2023
2 parents c085e98 + 6368d88 commit 38a1838
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 52 deletions.
4 changes: 2 additions & 2 deletions randomizer/Lists/DoorLocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def assignDoor(self, kong):
self.placed = "wrinkly"
self.assigned_kong = kong

def assignPortal(self):
def assignPortal(self, spoiler):
"""Assign T&S Portal to slot."""
self.placed = "tns"
portal_region = RegionList[self.logicregion]
portal_region = spoiler.RegionList[self.logicregion]
boss_region_id = GetBossLobbyRegionIdForRegion(self.logicregion, portal_region)
portal_region.exits.append(TransitionFront(boss_region_id, lambda l: self.logic))

Expand Down
14 changes: 1 addition & 13 deletions randomizer/ShuffleCrates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@

def addCrate(spoiler, MelonCrate: CustomLocation, enum_val: int, name: str, level: Levels):
"""Add crate to relevant Logic Region."""
level_to_enum = {
Levels.DKIsles: randomizer.LogicFiles.DKIsles.LogicRegions,
Levels.JungleJapes: randomizer.LogicFiles.JungleJapes.LogicRegions,
Levels.AngryAztec: randomizer.LogicFiles.AngryAztec.LogicRegions,
Levels.FranticFactory: randomizer.LogicFiles.FranticFactory.LogicRegions,
Levels.GloomyGalleon: randomizer.LogicFiles.GloomyGalleon.LogicRegions,
Levels.FungiForest: randomizer.LogicFiles.FungiForest.LogicRegions,
Levels.CrystalCaves: randomizer.LogicFiles.CrystalCaves.LogicRegions,
Levels.CreepyCastle: randomizer.LogicFiles.CreepyCastle.LogicRegions,
Levels.HideoutHelm: randomizer.LogicFiles.HideoutHelm.LogicRegions,
}
level_to_name = {
Levels.DKIsles: "Isles",
Levels.JungleJapes: "Japes",
Expand All @@ -41,8 +30,7 @@ def addCrate(spoiler, MelonCrate: CustomLocation, enum_val: int, name: str, leve
Levels.CreepyCastle: "Castle",
Levels.HideoutHelm: "Helm",
}
level_data = level_to_enum[level]
level_data[MelonCrate.logic_region].locations.append(LocationLogic(enum_val, MelonCrate.logic))
spoiler.RegionList[MelonCrate.logic_region].locations.append(LocationLogic(enum_val, MelonCrate.logic))
spoiler.LocationList[enum_val].name = f"{level_to_name[level]} MelonCrate: {name}"
spoiler.LocationList[enum_val].default_mapid_data[0].map = MelonCrate.map
spoiler.LocationList[enum_val].level = level
Expand Down
8 changes: 4 additions & 4 deletions randomizer/ShuffleDoors.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def ShuffleDoors(spoiler):
available_portals = [door for door in available_portals if door_locations[level][door].group != selected_portal.group]
# update available_doors separately as wrinkly doors should not be affected by the T&S grouping
available_doors.remove(selected_door_index)
selected_portal.assignPortal()
selected_portal.assignPortal(spoiler)
human_portal_doors[level_list[level]]["T&S #" + str(new_portal + 1)] = selected_portal.name
shuffled_door_data[level].append((selected_door_index, "tns"))
else:
Expand All @@ -97,7 +97,7 @@ def ShuffleDoors(spoiler):
available_portals = [door for door in available_portals if door_locations[level][door].group != selected_portal.group]
# update available_doors separately as wrinkly doors should not be affected by the T&S grouping
available_doors.remove(selected_door_index)
selected_portal.assignPortal()
selected_portal.assignPortal(spoiler)
human_portal_doors[level_list[level]]["T&S #" + str(new_portal + 1)] = selected_portal.name
shuffled_door_data[level].append((selected_door_index, "tns"))
if spoiler.settings.wrinkly_location_rando:
Expand Down Expand Up @@ -158,7 +158,7 @@ def ShuffleVanillaDoors(spoiler):
locked_tns_options = [idx for idx in vanilla_door_indexes if door_locations[level][idx].default_placed == "tns" and door_locations[level][idx].door_type != "wrinkly"]
locked_tns_index = random.choice(locked_tns_options)
locked_tns = door_locations[level][locked_tns_index]
locked_tns.assignPortal()
locked_tns.assignPortal(spoiler)
human_portal_doors[level_list[level]]["T&S #1"] = locked_tns.name
shuffled_door_data[level].append((locked_tns_index, "tns"))
vanilla_door_indexes.remove(locked_tns_index)
Expand All @@ -182,7 +182,7 @@ def ShuffleVanillaDoors(spoiler):
vanilla_door = door_locations[level][door_index]
if vanilla_door.placed == "none" and vanilla_door.default_placed == "tns" and vanilla_door.door_type != "wrinkly":
placed_tns_count += 1
vanilla_door.assignPortal()
vanilla_door.assignPortal(spoiler)
human_portal_doors[level_list[level]]["T&S #" + str(placed_tns_count)] = vanilla_door.name
shuffled_door_data[level].append((door_index, "tns"))

Expand Down
2 changes: 1 addition & 1 deletion randomizer/ShuffleExits.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def ExitShuffle(spoiler):
raise Ex.EntranceAttemptCountExceeded
retries += 1
js.postMessage("Entrance placement failed. Retrying. Tries: " + str(retries))
Reset()
Reset(spoiler)


def UpdateLevelProgression(settings: Settings):
Expand Down
19 changes: 2 additions & 17 deletions randomizer/ShuffleFairies.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ def ShuffleFairyLocations(spoiler: Spoiler):
spoiler.fairy_locations = {}
spoiler.fairy_locations_human = {}
spoiler.fairy_data_table = [None] * 20
level_to_enum = {
Levels.DKIsles: randomizer.LogicFiles.DKIsles.LogicRegions,
Levels.JungleJapes: randomizer.LogicFiles.JungleJapes.LogicRegions,
Levels.AngryAztec: randomizer.LogicFiles.AngryAztec.LogicRegions,
Levels.FranticFactory: randomizer.LogicFiles.FranticFactory.LogicRegions,
Levels.GloomyGalleon: randomizer.LogicFiles.GloomyGalleon.LogicRegions,
Levels.FungiForest: randomizer.LogicFiles.FungiForest.LogicRegions,
Levels.CrystalCaves: randomizer.LogicFiles.CrystalCaves.LogicRegions,
Levels.CreepyCastle: randomizer.LogicFiles.CreepyCastle.LogicRegions,
Levels.HideoutHelm: randomizer.LogicFiles.HideoutHelm.LogicRegions,
}
level_to_name = {
Levels.DKIsles: "Isles",
Levels.JungleJapes: "Japes",
Expand Down Expand Up @@ -136,13 +125,9 @@ def ShuffleFairyLocations(spoiler: Spoiler):
"id": -1 if not is_vanilla else data.id,
"shift": -1 if not is_vanilla else data.shift,
}
# Logic
# Remove old from logic
for logic_region in level_to_enum[level]:
level_to_enum[level][logic_region].locations = [loc for loc in level_to_enum[level][logic_region].locations if loc.id != data.location]
# Re-insert into logic
# Insert into logic
new_region = fairy_locations[level][x].region
level_to_enum[level][new_region].locations.append(LocationLogic(data.location, fairy_locations[level][x].logic))
spoiler.RegionList[new_region].locations.append(LocationLogic(data.location, fairy_locations[level][x].logic))
spoiler.LocationList[data.location].name = f"{level_to_name[level]} Fairy ({fairy_locations[level][x].name})"


Expand Down
19 changes: 4 additions & 15 deletions randomizer/ShufflePatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@

def addPatch(spoiler: Spoiler, patch: CustomLocation, enum_val: int, name: str, level: Levels):
"""Add patch to relevant Logic Region."""
level_to_enum = {
Levels.DKIsles: randomizer.LogicFiles.DKIsles.LogicRegions,
Levels.JungleJapes: randomizer.LogicFiles.JungleJapes.LogicRegions,
Levels.AngryAztec: randomizer.LogicFiles.AngryAztec.LogicRegions,
Levels.FranticFactory: randomizer.LogicFiles.FranticFactory.LogicRegions,
Levels.GloomyGalleon: randomizer.LogicFiles.GloomyGalleon.LogicRegions,
Levels.FungiForest: randomizer.LogicFiles.FungiForest.LogicRegions,
Levels.CrystalCaves: randomizer.LogicFiles.CrystalCaves.LogicRegions,
Levels.CreepyCastle: randomizer.LogicFiles.CreepyCastle.LogicRegions,
}
level_to_name = {
Levels.DKIsles: "Isles",
Levels.JungleJapes: "Japes",
Expand All @@ -38,14 +28,13 @@ def addPatch(spoiler: Spoiler, patch: CustomLocation, enum_val: int, name: str,
Levels.CrystalCaves: "Caves",
Levels.CreepyCastle: "Castle",
}
level_data = level_to_enum[level]
level_data[patch.logic_region].locations.append(LocationLogic(enum_val, patch.logic))
spoiler.RegionList[patch.logic_region].locations.append(LocationLogic(enum_val, patch.logic))
spoiler.LocationList[enum_val].name = f"{level_to_name[level]} Dirt: {name}"
spoiler.LocationList[enum_val].default_mapid_data[0].map = patch.map
spoiler.LocationList[enum_val].level = level


def removePatches():
def removePatches(spoiler):
"""Remove all patches from Logic regions."""
level_logic_regions = [
randomizer.LogicFiles.DKIsles.LogicRegions,
Expand All @@ -59,13 +48,13 @@ def removePatches():
]
for level in level_logic_regions:
for region in level:
region_data = level[region]
region_data = spoiler.RegionList[region]
region_data.locations = [x for x in region_data.locations if x.id < Locations.RainbowCoin_Location00 or x.id > Locations.RainbowCoin_Location15]


def ShufflePatches(spoiler: Spoiler, human_spoiler):
"""Shuffle Dirt Patch Locations."""
removePatches()
removePatches(spoiler)
spoiler.dirt_patch_placement = []
total_dirt_patch_list = {
Levels.DKIsles: [],
Expand Down

0 comments on commit 38a1838

Please sign in to comment.