Skip to content

Commit

Permalink
SoE: create regions cleanup and speedup (ArchipelagoMW#2361)
Browse files Browse the repository at this point in the history
* SoE: create regions cleanup and speedup

keep local reference instead of hitting multiworld cache
also technically fixes a bug where all locations are in 'menu', not 'ingame'

* SoE: somplify region connection
  • Loading branch information
black-sliver authored and FlySniper committed Nov 14, 2023
1 parent e725b75 commit d366f44
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions worlds/soe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,23 @@ def create_regions(self):
max_difficulty = 1 if self.multiworld.difficulty[self.player] == Difficulty.option_easy else 256

# TODO: generate *some* regions from locations' requirements?
r = Region('Menu', self.player, self.multiworld)
r.exits = [Entrance(self.player, 'New Game', r)]
self.multiworld.regions += [r]
menu = Region('Menu', self.player, self.multiworld)
self.multiworld.regions += [menu]

def get_sphere_index(evermizer_loc):
"""Returns 0, 1 or 2 for locations in spheres 1, 2, 3+"""
if len(evermizer_loc.requires) == 1 and evermizer_loc.requires[0][1] != pyevermizer.P_WEAPON:
return 2
return min(2, len(evermizer_loc.requires))

# create ingame region
ingame = Region('Ingame', self.player, self.multiworld)

# group locations into spheres (1, 2, 3+ at index 0, 1, 2)
spheres: typing.Dict[int, typing.Dict[int, typing.List[SoELocation]]] = {}
for loc in _locations:
spheres.setdefault(get_sphere_index(loc), {}).setdefault(loc.type, []).append(
SoELocation(self.player, loc.name, self.location_name_to_id[loc.name], r,
SoELocation(self.player, loc.name, self.location_name_to_id[loc.name], ingame,
loc.difficulty > max_difficulty))

# location balancing data
Expand Down Expand Up @@ -280,18 +282,16 @@ def sphere1_blocked_items_rule(item):
late_locations = self.multiworld.random.sample(late_bosses, late_count)

# add locations to the world
r = Region('Ingame', self.player, self.multiworld)
for sphere in spheres.values():
for locations in sphere.values():
for location in locations:
r.locations.append(location)
ingame.locations.append(location)
if location.name in late_locations:
location.progress_type = LocationProgressType.PRIORITY

r.locations.append(SoELocation(self.player, 'Done', None, r))
self.multiworld.regions += [r]

self.multiworld.get_entrance('New Game', self.player).connect(self.multiworld.get_region('Ingame', self.player))
ingame.locations.append(SoELocation(self.player, 'Done', None, ingame))
menu.connect(ingame, "New Game")
self.multiworld.regions += [ingame]

def create_items(self):
# add regular items to the pool
Expand Down

0 comments on commit d366f44

Please sign in to comment.