Core: rename world to multiworld (#931)

* rename references to `Multiworld` in core to `multiworld` instead of `world`

* fix smz3

* fix oot

* fix low hanging fruit

* revert mysteriously broken spacing in world api.md

* fix more randomly broken spacing

* hate

* that better be all of it

* begrudgingly move over smw

* ._.

* missed some worlds

* this is getting tedious now

* Missed some self.world definitions

Co-authored-by: espeon65536 <espeon65536@gmail.com>
Co-authored-by: Zach Parks <zach@alliware.com>
This commit is contained in:
alwaysintreble
2022-10-31 21:41:21 -05:00
committed by GitHub
parent 87f4a97f1e
commit 2af510328e
85 changed files with 1623 additions and 1621 deletions

View File

@@ -22,29 +22,29 @@ class WorldTestBase(unittest.TestCase):
def world_setup(self, seed: typing.Optional[int] = None) -> None:
if not hasattr(self, "game"):
raise NotImplementedError("didn't define game name")
self.world = MultiWorld(1)
self.world.game[1] = self.game
self.world.player_name = {1: "Tester"}
self.world.set_seed(seed)
self.multiworld = MultiWorld(1)
self.multiworld.game[1] = self.game
self.multiworld.player_name = {1: "Tester"}
self.multiworld.set_seed(seed)
args = Namespace()
for name, option in AutoWorld.AutoWorldRegister.world_types[self.game].option_definitions.items():
setattr(args, name, {
1: option.from_any(self.options.get(name, getattr(option, "default")))
})
self.world.set_options(args)
self.world.set_default_common_options()
self.multiworld.set_options(args)
self.multiworld.set_default_common_options()
for step in gen_steps:
call_all(self.world, step)
call_all(self.multiworld, step)
def collect_all_but(self, item_names: typing.Union[str, typing.Iterable[str]]) -> None:
if isinstance(item_names, str):
item_names = (item_names,)
for item in self.world.get_items():
for item in self.multiworld.get_items():
if item.name not in item_names:
self.world.state.collect(item)
self.multiworld.state.collect(item)
def get_item_by_name(self, item_name: str) -> Item:
for item in self.world.get_items():
for item in self.multiworld.get_items():
if item.name == item_name:
return item
raise ValueError("No such item")
@@ -52,7 +52,7 @@ class WorldTestBase(unittest.TestCase):
def get_items_by_name(self, item_names: typing.Union[str, typing.Iterable[str]]) -> typing.List[Item]:
if isinstance(item_names, str):
item_names = (item_names,)
return [item for item in self.world.itempool if item.name in item_names]
return [item for item in self.multiworld.itempool if item.name in item_names]
def collect_by_name(self, item_names: typing.Union[str, typing.Iterable[str]]) -> typing.List[Item]:
""" collect all of the items in the item pool that have the given names """
@@ -64,21 +64,21 @@ class WorldTestBase(unittest.TestCase):
if isinstance(items, Item):
items = (items,)
for item in items:
self.world.state.collect(item)
self.multiworld.state.collect(item)
def remove(self, items: typing.Union[Item, typing.Iterable[Item]]) -> None:
if isinstance(items, Item):
items = (items,)
for item in items:
if item.location and item.location.event and item.location in self.world.state.events:
self.world.state.events.remove(item.location)
self.world.state.remove(item)
if item.location and item.location.event and item.location in self.multiworld.state.events:
self.multiworld.state.events.remove(item.location)
self.multiworld.state.remove(item)
def can_reach_location(self, location: str) -> bool:
return self.world.state.can_reach(location, "Location", 1)
return self.multiworld.state.can_reach(location, "Location", 1)
def count(self, item_name: str) -> int:
return self.world.state.count(item_name, 1)
return self.multiworld.state.count(item_name, 1)
def assertAccessDependency(self,
locations: typing.List[str],
@@ -86,8 +86,8 @@ class WorldTestBase(unittest.TestCase):
all_items = [item_name for item_names in possible_items for item_name in item_names]
self.collect_all_but(all_items)
for location in self.world.get_locations():
self.assertEqual(self.world.state.can_reach(location), location.name not in locations)
for location in self.multiworld.get_locations():
self.assertEqual(self.multiworld.state.can_reach(location), location.name not in locations)
for item_names in possible_items:
items = self.collect_by_name(item_names)
for location in locations:
@@ -95,4 +95,4 @@ class WorldTestBase(unittest.TestCase):
self.remove(items)
def assertBeatable(self, beatable: bool):
self.assertEqual(self.world.can_beat_game(self.world.state), beatable)
self.assertEqual(self.multiworld.can_beat_game(self.multiworld.state), beatable)

View File

@@ -9,7 +9,7 @@ class OptionsTest(ZillionTestBase):
def test_validate_default(self) -> None:
self.world_setup()
validate(self.world, 1)
validate(self.multiworld, 1)
def test_vblr_ap_to_zz(self) -> None:
""" all of the valid values for the AP options map to valid values for ZZ options """
@@ -20,7 +20,7 @@ class OptionsTest(ZillionTestBase):
for value in vblr_class.name_lookup.values():
self.options = {option_name: value}
self.world_setup()
zz_options, _item_counts = validate(self.world, 1)
zz_options, _item_counts = validate(self.multiworld, 1)
assert getattr(zz_options, option_name) in VBLR_CHOICES
# TODO: test validate with invalid combinations of options

View File

@@ -13,7 +13,7 @@ class ZillionTestBase(WorldTestBase):
This makes sure that gun 3 is required by making all the canisters
in O-7 (including key word canisters) require gun 3.
"""
zz_world = cast(ZillionWorld, self.world.worlds[1])
zz_world = cast(ZillionWorld, self.multiworld.worlds[1])
assert zz_world.zz_system.randomizer
for zz_loc_name, zz_loc in zz_world.zz_system.randomizer.locations.items():
if zz_loc_name.startswith("r15c6"):