Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landstalker: remove global ref to multiworld #4175

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions worlds/landstalker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LandstalkerWorld(World):
item_name_to_id = build_item_name_to_id_table()
location_name_to_id = build_location_name_to_id_table()

cached_spheres: ClassVar[List[Set[Location]]]
cached_spheres: List[Set[Location]]

def __init__(self, multiworld, player):
super().__init__(multiworld, player)
Expand All @@ -47,6 +47,7 @@ def __init__(self, multiworld, player):
self.dark_region_ids = []
self.teleport_tree_pairs = []
self.jewel_items = []
self.cached_spheres = []

def fill_slot_data(self) -> dict:
# Generate hints.
Expand Down Expand Up @@ -220,14 +221,17 @@ def get_starting_health(self):
return 4

@classmethod
def stage_post_fill(cls, multiworld):
def stage_post_fill(cls, multiworld: MultiWorld):
# Cache spheres for hint calculation after fill completes.
cls.cached_spheres = list(multiworld.get_spheres())
cached_spheres = list(multiworld.get_spheres())
for world in multiworld.get_game_worlds(cls.game):
world.cached_spheres = cached_spheres

@classmethod
def stage_modify_multidata(cls, *_):
def stage_modify_multidata(cls, multiworld: MultiWorld, *_):
# Clean up all references in cached spheres after generation completes.
del cls.cached_spheres
for world in multiworld.get_game_worlds(cls.game):
world.cached_spheres = []

def adjust_shop_prices(self):
# Calculate prices for items in shops once all items have their final position
Expand Down
Loading