Skip to content
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6d1c1a9
move item links out of main
alwaysintreble Aug 4, 2023
c7875c0
add a unit test for item links
alwaysintreble Aug 4, 2023
546a4f2
drop the random object creation
alwaysintreble Aug 5, 2023
0449dc9
have item links test generate both with and without link replacement
alwaysintreble Aug 10, 2023
4678be2
Merge remote-tracking branch 'Main/main' into test-item-links
alwaysintreble Oct 28, 2023
f879adf
assert that the multiworld can be beaten
alwaysintreble Oct 28, 2023
2f83fde
item link checking uses the new options API
alwaysintreble Oct 28, 2023
fdb63e0
Merge branch 'main' into test-item-links
alwaysintreble Nov 27, 2023
4a69998
missed merge conflict due to the refactor
alwaysintreble Nov 27, 2023
6a95cba
_recache is gone now
alwaysintreble Nov 27, 2023
5d9b334
Merge remote-tracking branch 'Main/main' into test-item-links
alwaysintreble Mar 6, 2024
761e967
Merge branch 'main' into test-item-links
Berserker66 Apr 17, 2024
0b76c5b
repair imports
alwaysintreble Apr 17, 2024
2160b95
Merge branch 'main' into test-item-links
alwaysintreble Oct 23, 2024
6500210
Merge branch 'main' into test-item-links
NewSoupVi Nov 28, 2024
6c07849
Merge branch 'main' into test-item-links
Exempt-Medic Jan 13, 2025
5bd167b
Merge branch 'main' into test-item-links
alwaysintreble Mar 17, 2025
9fe1418
add connect_entrances to the calls and output the seed
alwaysintreble Mar 17, 2025
615e76e
Merge branch 'main' into test-item-links
alwaysintreble Mar 29, 2025
7189c4e
remove duplicate code
alwaysintreble Mar 30, 2025
ec1b937
Merge branch 'main' into test-item-links
Exempt-Medic Apr 24, 2025
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
49 changes: 47 additions & 2 deletions test/general/test_items.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
from argparse import Namespace
from typing import Type

from BaseClasses import CollectionState
from worlds.AutoWorld import AutoWorldRegister, call_all
from BaseClasses import CollectionState, MultiWorld
from Fill import distribute_items_restrictive
from Options import ItemLinks
from worlds.AutoWorld import AutoWorldRegister, World, call_all
from . import setup_solo_multiworld


Expand Down Expand Up @@ -83,6 +87,47 @@ def test_items_in_datapackage(self):
multiworld = setup_solo_multiworld(world_type)
for item in multiworld.itempool:
self.assertIn(item.name, world_type.item_name_to_id)

def test_item_links(self) -> None:
"""
Tests item link creation by creating a multiworld of 2 worlds for every game and linking their items together.
"""
def setup_link_multiworld(world: Type[World], link_replace: bool) -> None:
multiworld = MultiWorld(2)
multiworld.game = {1: world.game, 2: world.game}
multiworld.player_name = {1: "Linker 1", 2: "Linker 2"}
multiworld.set_seed()
item_link_group = [{
"name": "ItemLinkTest",
"item_pool": ["Everything"],
"link_replacement": link_replace,
"replacement_item": None,
}]
args = Namespace()
for name, option in world.options_dataclass.type_hints.items():
setattr(args, name, {1: option.from_any(option.default), 2: option.from_any(option.default)})
setattr(args, "item_links",
{1: ItemLinks.from_any(item_link_group), 2: ItemLinks.from_any(item_link_group)})
multiworld.set_options(args)
multiworld.set_item_links()
# groups get added to state during its constructor so this has to be after item links are set
multiworld.state = CollectionState(multiworld)
gen_steps = ("generate_early", "create_regions", "create_items", "set_rules", "connect_entrances", "generate_basic")
for step in gen_steps:
call_all(multiworld, step)
# link the items together and attempt to fill
multiworld.link_items()
multiworld._all_state = None
call_all(multiworld, "pre_fill")
distribute_items_restrictive(multiworld)
call_all(multiworld, "post_fill")
self.assertTrue(multiworld.can_beat_game(CollectionState(multiworld)), f"seed = {multiworld.seed}")

for game_name, world_type in AutoWorldRegister.world_types.items():
with self.subTest("Can generate with link replacement", game=game_name):
setup_link_multiworld(world_type, True)
with self.subTest("Can generate without link replacement", game=game_name):
setup_link_multiworld(world_type, False)

def test_itempool_not_modified(self):
"""Test that worlds don't modify the itempool after `create_items`"""
Expand Down
Loading