Skip to content

Commit

Permalink
Core: Purge the evil (world: MultiWorld) (#2749)
Browse files Browse the repository at this point in the history
* Purge the evil

* Some files didn't save

* Fix a couple of missed string references

* multi_world -> multiworld
  • Loading branch information
PoryGone authored Feb 4, 2024
1 parent 6c19bc4 commit 281fe01
Show file tree
Hide file tree
Showing 7 changed files with 431 additions and 431 deletions.
10 changes: 5 additions & 5 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ def __repr__(self):
return self.__str__()

def __str__(self):
world = self.parent_region.multiworld if self.parent_region else None
return world.get_name_string_for_object(self) if world else f'{self.name} (Player {self.player})'
multiworld = self.parent_region.multiworld if self.parent_region else None
return multiworld.get_name_string_for_object(self) if multiworld else f'{self.name} (Player {self.player})'


class Region:
Expand Down Expand Up @@ -1040,8 +1040,8 @@ def __repr__(self):
return self.__str__()

def __str__(self):
world = self.parent_region.multiworld if self.parent_region and self.parent_region.multiworld else None
return world.get_name_string_for_object(self) if world else f'{self.name} (Player {self.player})'
multiworld = self.parent_region.multiworld if self.parent_region and self.parent_region.multiworld else None
return multiworld.get_name_string_for_object(self) if multiworld else f'{self.name} (Player {self.player})'

def __hash__(self):
return hash((self.name, self.player))
Expand Down Expand Up @@ -1175,7 +1175,7 @@ def set_entrance(self, entrance: str, exit_: str, direction: str, player: int) -
{"player": player, "entrance": entrance, "exit": exit_, "direction": direction}

def create_playthrough(self, create_paths: bool = True) -> None:
"""Destructive to the world while it is run, damage gets repaired afterwards."""
"""Destructive to the multiworld while it is run, damage gets repaired afterwards."""
from itertools import chain
# get locations containing progress items
multiworld = self.multiworld
Expand Down
186 changes: 93 additions & 93 deletions Fill.py

Large diffs are not rendered by default.

286 changes: 143 additions & 143 deletions Main.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions OoTAdjuster.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def set_icon(window):
window.tk.call('wm', 'iconphoto', window._w, logo)

def adjust(args):
# Create a fake world and OOTWorld to use as a base
world = MultiWorld(1)
world.per_slot_randoms = {1: random}
ootworld = OOTWorld(world, 1)
# Create a fake multiworld and OOTWorld to use as a base
multiworld = MultiWorld(1)
multiworld.per_slot_randoms = {1: random}
ootworld = OOTWorld(multiworld, 1)
# Set options in the fake OOTWorld
for name, option in chain(cosmetic_options.items(), sfx_options.items()):
result = getattr(args, name, None)
Expand Down
4 changes: 2 additions & 2 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ def visualize_regions(root_region: Region, file_name: str, *,
Example usage in Main code:
from Utils import visualize_regions
for player in world.player_ids:
visualize_regions(world.get_region("Menu", player), f"{world.get_out_file_name_base(player)}.puml")
for player in multiworld.player_ids:
visualize_regions(multiworld.get_region("Menu", player), f"{multiworld.get_out_file_name_base(player)}.puml")
"""
assert root_region.multiworld, "The multiworld attribute of root_region has to be filled"
from BaseClasses import Entrance, Item, Location, LocationProgressType, MultiWorld, Region
Expand Down
350 changes: 175 additions & 175 deletions test/general/test_fill.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions test/general/test_reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def test_default_all_state_can_reach_everything(self):
for game_name, world_type in AutoWorldRegister.world_types.items():
unreachable_regions = self.default_settings_unreachable_regions.get(game_name, set())
with self.subTest("Game", game=game_name):
world = setup_solo_multiworld(world_type)
excluded = world.worlds[1].options.exclude_locations.value
state = world.get_all_state(False)
for location in world.get_locations():
multiworld = setup_solo_multiworld(world_type)
excluded = multiworld.worlds[1].options.exclude_locations.value
state = multiworld.get_all_state(False)
for location in multiworld.get_locations():
if location.name not in excluded:
with self.subTest("Location should be reached", location=location):
self.assertTrue(location.can_reach(state), f"{location.name} unreachable")

for region in world.get_regions():
for region in multiworld.get_regions():
if region.name in unreachable_regions:
with self.subTest("Region should be unreachable", region=region):
self.assertFalse(region.can_reach(state))
Expand All @@ -53,15 +53,15 @@ def test_default_all_state_can_reach_everything(self):
self.assertTrue(region.can_reach(state))

with self.subTest("Completion Condition"):
self.assertTrue(world.can_beat_game(state))
self.assertTrue(multiworld.can_beat_game(state))

def test_default_empty_state_can_reach_something(self):
"""Ensure empty state can reach at least one location with the defined options"""
for game_name, world_type in AutoWorldRegister.world_types.items():
with self.subTest("Game", game=game_name):
world = setup_solo_multiworld(world_type)
state = CollectionState(world)
all_locations = world.get_locations()
multiworld = setup_solo_multiworld(world_type)
state = CollectionState(multiworld)
all_locations = multiworld.get_locations()
if all_locations:
locations = set()
for location in all_locations:
Expand Down

0 comments on commit 281fe01

Please sign in to comment.