| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  | from typing import List, Iterable | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | from Options import Accessibility | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  | from test.general import generate_items, generate_locations, generate_test_multiworld | 
					
						
							| 
									
										
										
										
											2022-11-04 09:56:47 -07:00
										 |  |  | from Fill import FillError, balance_multiworld_progression, fill_restrictive, \ | 
					
						
							|  |  |  |     distribute_early_items, distribute_items_restrictive | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  | from BaseClasses import Entrance, LocationProgressType, MultiWorld, Region, Item, Location, \ | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |     ItemClassification | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  | from worlds.generic.Rules import CollectionRule, add_item_rule, locality_rules, set_rule | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | class PlayerDefinition(object): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |     multiworld: MultiWorld | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |     id: int | 
					
						
							|  |  |  |     menu: Region | 
					
						
							| 
									
										
										
										
											2022-01-06 06:09:15 +01:00
										 |  |  |     locations: List[Location] | 
					
						
							|  |  |  |     prog_items: List[Item] | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     basic_items: List[Item] | 
					
						
							|  |  |  |     regions: List[Region] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |     def __init__(self, multiworld: MultiWorld, id: int, menu: Region, locations: List[Location] = [], prog_items: List[Item] = [], basic_items: List[Item] = []): | 
					
						
							|  |  |  |         self.multiworld = multiworld | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.id = id | 
					
						
							|  |  |  |         self.menu = menu | 
					
						
							|  |  |  |         self.locations = locations | 
					
						
							|  |  |  |         self.prog_items = prog_items | 
					
						
							|  |  |  |         self.basic_items = basic_items | 
					
						
							|  |  |  |         self.regions = [menu] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def generate_region(self, parent: Region, size: int, access_rule: CollectionRule = lambda state: True) -> Region: | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         region_tag = f"_region{len(self.regions)}" | 
					
						
							|  |  |  |         region_name = f"player{self.id}{region_tag}" | 
					
						
							|  |  |  |         region = Region(f"player{self.id}{region_tag}", self.id, self.multiworld) | 
					
						
							|  |  |  |         self.locations += generate_locations(size, self.id, region, None, region_tag) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         entrance = Entrance(self.id, f"{region_name}_entrance", parent) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         parent.exits.append(entrance) | 
					
						
							|  |  |  |         entrance.connect(region) | 
					
						
							|  |  |  |         entrance.access_rule = access_rule | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.regions.append(region) | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.regions.append(region) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return region | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  | def fill_region(multiworld: MultiWorld, region: Region, items: List[Item]) -> List[Item]: | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     items = items.copy() | 
					
						
							|  |  |  |     while len(items) > 0: | 
					
						
							|  |  |  |         location = region.locations.pop(0) | 
					
						
							|  |  |  |         region.locations.append(location) | 
					
						
							|  |  |  |         if location.item: | 
					
						
							|  |  |  |             return items | 
					
						
							|  |  |  |         item = items.pop(0) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.push_item(location, item, False) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return items | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  | def region_contains(region: Region, item: Item) -> bool: | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     for location in region.locations: | 
					
						
							|  |  |  |         if location.item == item: | 
					
						
							|  |  |  |             return True | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     return False | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  | def generate_player_data(multiworld: MultiWorld, player_id: int, location_count: int = 0, prog_item_count: int = 0, basic_item_count: int = 0) -> PlayerDefinition: | 
					
						
							|  |  |  |     menu = multiworld.get_region("Menu", player_id) | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |     locations = generate_locations(location_count, player_id, menu, None) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |     prog_items = generate_items(prog_item_count, player_id, True) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |     multiworld.itempool += prog_items | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     basic_items = generate_items(basic_item_count, player_id, False) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |     multiworld.itempool += basic_items | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |     return PlayerDefinition(multiworld, player_id, menu, locations, prog_items, basic_items) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  | def names(objs: list) -> Iterable[str]: | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |     return map(lambda o: o.name, objs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | class TestFillRestrictive(unittest.TestCase): | 
					
						
							|  |  |  |     def test_basic_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Tests `fill_restrictive` fills and removes the locations and items from their respective lists""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |         item0 = player1.prog_items[0] | 
					
						
							|  |  |  |         item1 = player1.prog_items[1] | 
					
						
							|  |  |  |         loc0 = player1.locations[0] | 
					
						
							|  |  |  |         loc1 = player1.locations[1] | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |                          player1.locations, player1.prog_items) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(loc0.item, item1) | 
					
						
							|  |  |  |         self.assertEqual(loc1.item, item0) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |         self.assertEqual([], player1.locations) | 
					
						
							|  |  |  |         self.assertEqual([], player1.prog_items) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_ordered_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Tests `fill_restrictive` fulfills set rules""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |         items = player1.prog_items | 
					
						
							|  |  |  |         locations = player1.locations | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |             items[0].name, player1.id) and state.has(items[1].name, player1.id) | 
					
						
							|  |  |  |         set_rule(locations[1], lambda state: state.has( | 
					
						
							|  |  |  |             items[0].name, player1.id)) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |                          player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |         self.assertEqual(locations[0].item, items[0]) | 
					
						
							|  |  |  |         self.assertEqual(locations[1].item, items[1]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_partial_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Tests that `fill_restrictive` returns unfilled locations""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 3, 2) | 
					
						
							| 
									
										
										
										
											2021-12-30 10:50:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         item0 = player1.prog_items[0] | 
					
						
							|  |  |  |         item1 = player1.prog_items[1] | 
					
						
							|  |  |  |         loc0 = player1.locations[0] | 
					
						
							|  |  |  |         loc1 = player1.locations[1] | 
					
						
							|  |  |  |         loc2 = player1.locations[2] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-30 10:50:18 -07:00
										 |  |  |             item0.name, player1.id) and state.has(item1.name, player1.id) | 
					
						
							|  |  |  |         set_rule(loc1, lambda state: state.has( | 
					
						
							|  |  |  |             item0.name, player1.id)) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         # forces a swap | 
					
						
							| 
									
										
										
										
											2021-12-30 10:50:18 -07:00
										 |  |  |         set_rule(loc2, lambda state: state.has( | 
					
						
							|  |  |  |             item0.name, player1.id)) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-30 10:50:18 -07:00
										 |  |  |                          player1.locations, player1.prog_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(loc0.item, item0) | 
					
						
							|  |  |  |         self.assertEqual(loc1.item, item1) | 
					
						
							|  |  |  |         self.assertEqual(1, len(player1.locations)) | 
					
						
							|  |  |  |         self.assertEqual(player1.locations[0], loc2) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_minimal_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill for minimal player can have unreachable items""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         items = player1.prog_items | 
					
						
							|  |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.worlds[player1.id].options.accessibility = Accessibility.from_any(Accessibility.option_minimal) | 
					
						
							|  |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |             items[1].name, player1.id) | 
					
						
							|  |  |  |         set_rule(locations[1], lambda state: state.has( | 
					
						
							|  |  |  |             items[0].name, player1.id)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |                          player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |         self.assertEqual(locations[0].item, items[1]) | 
					
						
							|  |  |  |         # Unnecessary unreachable Item | 
					
						
							|  |  |  |         self.assertEqual(locations[1].item, items[0]) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  |     def test_minimal_mixed_fill(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         Test that fill for 1 minimal and 1 non-minimal player will correctly place items in a way that lets | 
					
						
							|  |  |  |         the non-minimal player get all items. | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 3, 3) | 
					
						
							|  |  |  |         player2 = generate_player_data(multiworld, 2, 3, 3) | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 05:13:14 -05:00
										 |  |  |         multiworld.worlds[player1.id].options.accessibility.value = Accessibility.option_minimal | 
					
						
							|  |  |  |         multiworld.worlds[player2.id].options.accessibility.value = Accessibility.option_full | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: True | 
					
						
							|  |  |  |         multiworld.completion_condition[player2.id] = lambda state: state.has(player2.prog_items[2].name, player2.id) | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         set_rule(player1.locations[1], lambda state: state.has(player1.prog_items[0].name, player1.id)) | 
					
						
							|  |  |  |         set_rule(player1.locations[2], lambda state: state.has(player1.prog_items[1].name, player1.id)) | 
					
						
							|  |  |  |         set_rule(player2.locations[1], lambda state: state.has(player2.prog_items[0].name, player2.id)) | 
					
						
							|  |  |  |         set_rule(player2.locations[2], lambda state: state.has(player2.prog_items[1].name, player2.id)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # force-place an item that makes it impossible to have all locations accessible | 
					
						
							|  |  |  |         player1.locations[0].place_locked_item(player1.prog_items[2]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # fill remaining locations with remaining items | 
					
						
							|  |  |  |         location_pool = player1.locations[1:] + player2.locations | 
					
						
							|  |  |  |         item_pool = player1.prog_items[:-1] + player2.prog_items | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, location_pool, item_pool) | 
					
						
							| 
									
										
										
										
											2024-08-23 01:15:05 +02:00
										 |  |  |         multiworld.state.sweep_for_advancements()  # collect everything | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # all of player2's locations and items should be accessible (not all of player1's) | 
					
						
							|  |  |  |         for item in player2.prog_items: | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             self.assertTrue(multiworld.state.has(item.name, player2.id), | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |                             f"{item} is unreachable in {item.location}") | 
					
						
							| 
									
										
										
										
											2023-06-25 02:55:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_reversed_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test a different set of rules can be satisfied""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |         item0 = player1.prog_items[0] | 
					
						
							|  |  |  |         item1 = player1.prog_items[1] | 
					
						
							|  |  |  |         loc0 = player1.locations[0] | 
					
						
							|  |  |  |         loc1 = player1.locations[1] | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             item0.name, player1.id) and state.has(item1.name, player1.id) | 
					
						
							|  |  |  |         set_rule(loc1, lambda state: state.has(item1.name, player1.id)) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |                          player1.locations, player1.prog_items) | 
					
						
							| 
									
										
										
										
											2021-12-18 17:54:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(loc0.item, item1) | 
					
						
							| 
									
										
										
										
											2021-12-20 17:47:04 -07:00
										 |  |  |         self.assertEqual(loc1.item, item0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_multi_step_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill is able to satisfy multiple spheres""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 4, 4) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         items = player1.prog_items | 
					
						
							|  |  |  |         locations = player1.locations | 
					
						
							| 
									
										
										
										
											2021-12-20 17:47:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             items[2].name, player1.id) and state.has(items[3].name, player1.id) | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |         set_rule(locations[1], lambda state: state.has( | 
					
						
							|  |  |  |             items[0].name, player1.id)) | 
					
						
							|  |  |  |         set_rule(locations[2], lambda state: state.has( | 
					
						
							|  |  |  |             items[1].name, player1.id)) | 
					
						
							|  |  |  |         set_rule(locations[3], lambda state: state.has( | 
					
						
							|  |  |  |             items[1].name, player1.id)) | 
					
						
							| 
									
										
										
										
											2021-12-20 17:47:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |                          player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-20 17:47:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |         self.assertEqual(locations[0].item, items[1]) | 
					
						
							|  |  |  |         self.assertEqual(locations[1].item, items[2]) | 
					
						
							|  |  |  |         self.assertEqual(locations[2].item, items[0]) | 
					
						
							|  |  |  |         self.assertEqual(locations[3].item, items[3]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_impossible_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill raises an error when it can't place any items""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |         items = player1.prog_items | 
					
						
							|  |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-28 11:57:48 -07:00
										 |  |  |             items[0].name, player1.id) and state.has(items[1].name, player1.id) | 
					
						
							|  |  |  |         set_rule(locations[1], lambda state: state.has( | 
					
						
							|  |  |  |             items[1].name, player1.id)) | 
					
						
							|  |  |  |         set_rule(locations[0], lambda state: state.has( | 
					
						
							|  |  |  |             items[0].name, player1.id)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertRaises(FillError, fill_restrictive, multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-30 08:22:46 -07:00
										 |  |  |                           player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-20 17:47:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_circular_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill raises an error when it can't place all items""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 3, 3) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         item0 = player1.prog_items[0] | 
					
						
							|  |  |  |         item1 = player1.prog_items[1] | 
					
						
							|  |  |  |         item2 = player1.prog_items[2] | 
					
						
							|  |  |  |         loc0 = player1.locations[0] | 
					
						
							|  |  |  |         loc1 = player1.locations[1] | 
					
						
							|  |  |  |         loc2 = player1.locations[2] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             item0.name, player1.id) and state.has(item1.name, player1.id) and state.has(item2.name, player1.id) | 
					
						
							|  |  |  |         set_rule(loc1, lambda state: state.has(item0.name, player1.id)) | 
					
						
							|  |  |  |         set_rule(loc2, lambda state: state.has(item1.name, player1.id)) | 
					
						
							|  |  |  |         set_rule(loc0, lambda state: state.has(item2.name, player1.id)) | 
					
						
							| 
									
										
										
										
											2021-12-30 08:22:46 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertRaises(FillError, fill_restrictive, multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-30 08:22:46 -07:00
										 |  |  |                           player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-20 18:14:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_competing_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill raises an error when it can't place items in a way to satisfy the conditions""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-20 18:14:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |         item0 = player1.prog_items[0] | 
					
						
							|  |  |  |         item1 = player1.prog_items[1] | 
					
						
							|  |  |  |         loc1 = player1.locations[1] | 
					
						
							| 
									
										
										
										
											2021-12-20 18:14:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             item0.name, player1.id) and state.has(item0.name, player1.id) and state.has(item1.name, player1.id) | 
					
						
							|  |  |  |         set_rule(loc1, lambda state: state.has(item0.name, player1.id) | 
					
						
							|  |  |  |                  and state.has(item1.name, player1.id)) | 
					
						
							| 
									
										
										
										
											2021-12-30 10:50:18 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertRaises(FillError, fill_restrictive, multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2021-12-30 08:22:46 -07:00
										 |  |  |                           player1.locations.copy(), player1.prog_items.copy()) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_multiplayer_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that items can be placed across worlds""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							|  |  |  |         player2 = generate_player_data(multiworld, 2, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             player1.prog_items[0].name, player1.id) and state.has( | 
					
						
							|  |  |  |             player1.prog_items[1].name, player1.id) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player2.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             player2.prog_items[0].name, player2.id) and state.has( | 
					
						
							|  |  |  |             player2.prog_items[1].name, player2.id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, player1.locations + | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |                          player2.locations, player1.prog_items + player2.prog_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(player1.locations[0].item, player1.prog_items[1]) | 
					
						
							|  |  |  |         self.assertEqual(player1.locations[1].item, player2.prog_items[1]) | 
					
						
							|  |  |  |         self.assertEqual(player2.locations[0].item, player1.prog_items[0]) | 
					
						
							|  |  |  |         self.assertEqual(player2.locations[1].item, player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |     def test_multiplayer_rules_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill across worlds satisfies the rules""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							|  |  |  |         player2 = generate_player_data(multiworld, 2, 2, 2) | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             player1.prog_items[0].name, player1.id) and state.has( | 
					
						
							|  |  |  |             player1.prog_items[1].name, player1.id) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player2.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |             player2.prog_items[0].name, player2.id) and state.has( | 
					
						
							|  |  |  |             player2.prog_items[1].name, player2.id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         set_rule(player2.locations[1], lambda state: state.has( | 
					
						
							|  |  |  |             player2.prog_items[0].name, player2.id)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, player1.locations + | 
					
						
							| 
									
										
										
										
											2021-12-21 22:55:10 -07:00
										 |  |  |                          player2.locations, player1.prog_items + player2.prog_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(player1.locations[0].item, player2.prog_items[0]) | 
					
						
							|  |  |  |         self.assertEqual(player1.locations[1].item, player2.prog_items[1]) | 
					
						
							|  |  |  |         self.assertEqual(player2.locations[0].item, player1.prog_items[0]) | 
					
						
							|  |  |  |         self.assertEqual(player2.locations[1].item, player1.prog_items[1]) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |     def test_restrictive_progress(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that various spheres with different requirements can be filled""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, prog_item_count=25) | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |         items = player1.prog_items.copy() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             names(player1.prog_items), player1.id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         player1.generate_region(player1.menu, 5) | 
					
						
							|  |  |  |         player1.generate_region(player1.menu, 5, lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             names(items[2:7]), player1.id)) | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         player1.generate_region(player1.menu, 5, lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             names(items[7:12]), player1.id)) | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         player1.generate_region(player1.menu, 5, lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             names(items[12:17]), player1.id)) | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         player1.generate_region(player1.menu, 5, lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             names(items[17:22]), player1.id)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         locations = multiworld.get_unfilled_locations() | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |                          locations, player1.prog_items) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |     def test_swap_to_earlier_location_with_item_rule(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that item swap happens and works as intended""" | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |         # test for PR#1109 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(1) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 4, 4) | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |         locations = player1.locations[:]  # copy required | 
					
						
							|  |  |  |         items = player1.prog_items[:]  # copy required | 
					
						
							|  |  |  |         # for the test to work, item and location order is relevant: Sphere 1 last, allowed_item not last | 
					
						
							|  |  |  |         for location in locations[:-1]:  # Sphere 2 | 
					
						
							|  |  |  |             # any one provides access to Sphere 2 | 
					
						
							|  |  |  |             set_rule(location, lambda state: any(state.has(item.name, player1.id) for item in items)) | 
					
						
							|  |  |  |         # forbid all but 1 item in Sphere 1 | 
					
						
							|  |  |  |         sphere1_loc = locations[-1] | 
					
						
							|  |  |  |         allowed_item = items[1] | 
					
						
							|  |  |  |         add_item_rule(sphere1_loc, lambda item_to_place: item_to_place == allowed_item) | 
					
						
							|  |  |  |         # test our rules | 
					
						
							|  |  |  |         self.assertTrue(location.can_fill(None, allowed_item, False), "Test is flawed") | 
					
						
							|  |  |  |         self.assertTrue(location.can_fill(None, items[2], False), "Test is flawed") | 
					
						
							|  |  |  |         self.assertTrue(sphere1_loc.can_fill(None, allowed_item, False), "Test is flawed") | 
					
						
							|  |  |  |         self.assertFalse(sphere1_loc.can_fill(None, items[2], False), "Test is flawed") | 
					
						
							|  |  |  |         # fill has to place items[1] in locations[0] which will result in a swap because of placement order | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, player1.locations, player1.prog_items) | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |         # assert swap happened | 
					
						
							|  |  |  |         self.assertTrue(sphere1_loc.item, "Did not swap required item into Sphere 1") | 
					
						
							|  |  |  |         self.assertEqual(sphere1_loc.item, allowed_item, "Wrong item in Sphere 1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-11 10:54:51 +01:00
										 |  |  |     def test_swap_to_earlier_location_with_item_rule2(self): | 
					
						
							|  |  |  |         """Test that swap works before all items are placed""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(1) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 5, 5) | 
					
						
							| 
									
										
										
										
											2023-11-11 10:54:51 +01:00
										 |  |  |         locations = player1.locations[:]  # copy required | 
					
						
							|  |  |  |         items = player1.prog_items[:]  # copy required | 
					
						
							|  |  |  |         # Two items provide access to sphere 2. | 
					
						
							|  |  |  |         # One of them is forbidden in sphere 1, the other is first placed in sphere 4 because of placement order, | 
					
						
							|  |  |  |         # requiring a swap. | 
					
						
							|  |  |  |         # There are spheres in between, so for the swap to work, it'll have to assume all other items are collected. | 
					
						
							|  |  |  |         one_to_two1 = items[4].name | 
					
						
							|  |  |  |         one_to_two2 = items[3].name | 
					
						
							|  |  |  |         three_to_four = items[2].name | 
					
						
							|  |  |  |         two_to_three1 = items[1].name | 
					
						
							|  |  |  |         two_to_three2 = items[0].name | 
					
						
							|  |  |  |         # Sphere 4 | 
					
						
							|  |  |  |         set_rule(locations[0], lambda state: ((state.has(one_to_two1, player1.id) or state.has(one_to_two2, player1.id)) | 
					
						
							|  |  |  |                                               and state.has(two_to_three1, player1.id) | 
					
						
							|  |  |  |                                               and state.has(two_to_three2, player1.id) | 
					
						
							|  |  |  |                                               and state.has(three_to_four, player1.id))) | 
					
						
							|  |  |  |         # Sphere 3 | 
					
						
							|  |  |  |         set_rule(locations[1], lambda state: ((state.has(one_to_two1, player1.id) or state.has(one_to_two2, player1.id)) | 
					
						
							|  |  |  |                                               and state.has(two_to_three1, player1.id) | 
					
						
							|  |  |  |                                               and state.has(two_to_three2, player1.id))) | 
					
						
							|  |  |  |         # Sphere 2 | 
					
						
							|  |  |  |         set_rule(locations[2], lambda state: state.has(one_to_two1, player1.id) or state.has(one_to_two2, player1.id)) | 
					
						
							|  |  |  |         # Sphere 1 | 
					
						
							|  |  |  |         sphere1_loc1 = locations[3] | 
					
						
							|  |  |  |         sphere1_loc2 = locations[4] | 
					
						
							|  |  |  |         # forbid one_to_two2 in sphere 1 to make the swap happen as described above | 
					
						
							|  |  |  |         add_item_rule(sphere1_loc1, lambda item_to_place: item_to_place.name != one_to_two2) | 
					
						
							|  |  |  |         add_item_rule(sphere1_loc2, lambda item_to_place: item_to_place.name != one_to_two2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Now fill should place one_to_two1 in sphere1_loc1 or sphere1_loc2 via swap, | 
					
						
							|  |  |  |         # which it will attempt before two_to_three and three_to_four are placed, testing the behavior. | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, player1.locations, player1.prog_items) | 
					
						
							| 
									
										
										
										
											2023-11-11 10:54:51 +01:00
										 |  |  |         # assert swap happened | 
					
						
							|  |  |  |         self.assertTrue(sphere1_loc1.item and sphere1_loc2.item, "Did not swap required item into Sphere 1") | 
					
						
							|  |  |  |         self.assertTrue(sphere1_loc1.item.name == one_to_two1 or | 
					
						
							|  |  |  |                         sphere1_loc2.item.name == one_to_two1, "Wrong item in Sphere 1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |     def test_double_sweep(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that sweep doesn't duplicate Event items when sweeping""" | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |         # test for PR1114 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(1) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 1, 1) | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  |         location = player1.locations[0] | 
					
						
							|  |  |  |         location.address = None | 
					
						
							|  |  |  |         item = player1.prog_items[0] | 
					
						
							|  |  |  |         item.code = None | 
					
						
							|  |  |  |         location.place_locked_item(item) | 
					
						
							| 
									
										
										
										
											2024-08-23 01:15:05 +02:00
										 |  |  |         multiworld.state.sweep_for_advancements() | 
					
						
							|  |  |  |         multiworld.state.sweep_for_advancements() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertTrue(multiworld.state.prog_items[item.player][item.name], "Sweep did not collect - Test flawed") | 
					
						
							|  |  |  |         self.assertEqual(multiworld.state.prog_items[item.player][item.name], 1, "Sweep collected multiple times") | 
					
						
							| 
									
										
										
										
											2022-10-18 10:20:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-29 19:54:48 +02:00
										 |  |  |     def test_correct_item_instance_removed_from_pool(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that a placed item gets removed from the submitted pool""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         player1 = generate_player_data(multiworld, 1, 2, 2) | 
					
						
							| 
									
										
										
										
											2023-07-29 19:54:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         player1.prog_items[0].name = "Different_item_instance_but_same_item_name" | 
					
						
							|  |  |  |         player1.prog_items[1].name = "Different_item_instance_but_same_item_name" | 
					
						
							|  |  |  |         loc0 = player1.locations[0] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_restrictive(multiworld, multiworld.state, | 
					
						
							| 
									
										
										
										
											2023-07-29 19:54:48 +02:00
										 |  |  |                          [loc0], player1.prog_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(1, len(player1.prog_items)) | 
					
						
							|  |  |  |         self.assertIsNot(loc0.item, player1.prog_items[0], "Filled item was still present in item pool") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | class TestDistributeItemsRestrictive(unittest.TestCase): | 
					
						
							|  |  |  |     def test_basic_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that distribute_items_restrictive is deterministic""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  |         prog_items = player1.prog_items | 
					
						
							|  |  |  |         basic_items = player1.basic_items | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-16 20:06:25 -04:00
										 |  |  |         self.assertEqual(locations[0].item, basic_items[1]) | 
					
						
							| 
									
										
										
										
											2024-04-14 13:37:48 -05:00
										 |  |  |         self.assertFalse(locations[0].advancement) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.assertEqual(locations[1].item, prog_items[0]) | 
					
						
							| 
									
										
										
										
											2024-04-14 13:37:48 -05:00
										 |  |  |         self.assertTrue(locations[1].advancement) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.assertEqual(locations[2].item, prog_items[1]) | 
					
						
							| 
									
										
										
										
											2024-04-14 13:37:48 -05:00
										 |  |  |         self.assertTrue(locations[2].advancement) | 
					
						
							| 
									
										
										
										
											2022-09-16 20:06:25 -04:00
										 |  |  |         self.assertEqual(locations[3].item, basic_items[0]) | 
					
						
							| 
									
										
										
										
											2024-04-14 13:37:48 -05:00
										 |  |  |         self.assertFalse(locations[3].advancement) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_excluded_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that distribute_items_restrictive doesn't put advancement items on excluded locations""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[1].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  |         locations[2].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertFalse(locations[1].item.advancement) | 
					
						
							|  |  |  |         self.assertFalse(locations[2].item.advancement) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_non_excluded_item_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that useful items aren't placed on excluded locations""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  |         basic_items = player1.basic_items | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[1].progress_type = LocationProgressType.EXCLUDED | 
					
						
							| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  |         basic_items[1].classification = ItemClassification.useful | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(locations[1].item, basic_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_too_many_excluded_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill fails if it can't place all progression items due to too many excluded locations""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[0].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  |         locations[1].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  |         locations[2].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertRaises(FillError, distribute_items_restrictive, multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_non_excluded_item_must_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that fill fails if it can't place useful items due to too many excluded locations""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  |         basic_items = player1.basic_items | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[1].progress_type = LocationProgressType.EXCLUDED | 
					
						
							|  |  |  |         locations[2].progress_type = LocationProgressType.EXCLUDED | 
					
						
							| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  |         basic_items[0].classification = ItemClassification.useful | 
					
						
							|  |  |  |         basic_items[1].classification = ItemClassification.useful | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.assertRaises(FillError, distribute_items_restrictive, multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_priority_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that priority locations receive advancement items""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[0].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         locations[3].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertTrue(locations[0].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(locations[3].item.advancement) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_excess_priority_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that if there's more priority locations than advancement items, they can still fill""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         locations = player1.locations | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations[0].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         locations[1].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         locations[2].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertFalse(locations[3].item.advancement) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_multiple_world_priority_distribute(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that priority fill can be satisfied for multiple worlds""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(3) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player2 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 2, 4, prog_item_count=1, basic_item_count=3) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player3 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 3, 6, prog_item_count=4, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         player1.locations[2].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         player1.locations[3].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         player2.locations[1].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         player3.locations[0].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         player3.locations[1].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         player3.locations[2].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  |         player3.locations[3].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertTrue(player1.locations[2].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player1.locations[3].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player2.locations[1].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player3.locations[0].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player3.locations[1].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player3.locations[2].item.advancement) | 
					
						
							|  |  |  |         self.assertTrue(player3.locations[3].item.advancement) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-15 20:35:27 +02:00
										 |  |  |     def test_deprioritized_does_not_land_on_priority(self): | 
					
						
							|  |  |  |         multiworld = generate_test_multiworld(1) | 
					
						
							|  |  |  |         player1 = generate_player_data(multiworld, 1, 2, prog_item_count=2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         player1.prog_items[0].classification |= ItemClassification.deprioritized | 
					
						
							|  |  |  |         player1.locations[0].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertFalse(player1.locations[0].item.deprioritized) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_deprioritized_still_goes_on_priority_ahead_of_filler(self): | 
					
						
							|  |  |  |         multiworld = generate_test_multiworld(1) | 
					
						
							|  |  |  |         player1 = generate_player_data(multiworld, 1, 2, prog_item_count=1, basic_item_count=1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         player1.prog_items[0].classification |= ItemClassification.deprioritized | 
					
						
							|  |  |  |         player1.locations[0].progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertTrue(player1.locations[0].item.advancement) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  |     def test_can_remove_locations_in_fill_hook(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that distribute_items_restrictive calls the fill hook and allows for item and location removal""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         removed_item: list[Item] = [] | 
					
						
							|  |  |  |         removed_location: list[Location] = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-16 20:06:25 -04:00
										 |  |  |         def fill_hook(progitempool, usefulitempool, filleritempool, fill_locations): | 
					
						
							|  |  |  |             removed_item.append(filleritempool.pop(0)) | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  |             removed_location.append(fill_locations.pop(0)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.worlds[player1.id].fill_hook = fill_hook | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-21 20:34:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertIsNone(removed_item[0].location) | 
					
						
							|  |  |  |         self.assertIsNone(removed_location[0].item) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 09:25:42 -07:00
										 |  |  |     def test_seed_robust_to_item_order(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test deterministic fill""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         mw1 = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-27 09:25:42 -07:00
										 |  |  |         gen1 = generate_player_data( | 
					
						
							|  |  |  |             mw1, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							|  |  |  |         distribute_items_restrictive(mw1) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         mw2 = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-27 09:25:42 -07:00
										 |  |  |         gen2 = generate_player_data( | 
					
						
							|  |  |  |             mw2, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							|  |  |  |         mw2.itempool.append(mw2.itempool.pop(0)) | 
					
						
							|  |  |  |         distribute_items_restrictive(mw2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[0].item, gen2.locations[0].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[1].item, gen2.locations[1].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[2].item, gen2.locations[2].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[3].item, gen2.locations[3].item) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_seed_robust_to_location_order(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test deterministic fill even if locations in a region are reordered""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         mw1 = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-27 09:25:42 -07:00
										 |  |  |         gen1 = generate_player_data( | 
					
						
							|  |  |  |             mw1, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							|  |  |  |         distribute_items_restrictive(mw1) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         mw2 = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-27 09:25:42 -07:00
										 |  |  |         gen2 = generate_player_data( | 
					
						
							|  |  |  |             mw2, 1, 4, prog_item_count=2, basic_item_count=2) | 
					
						
							|  |  |  |         reg = mw2.get_region("Menu", gen2.id) | 
					
						
							|  |  |  |         reg.locations.append(reg.locations.pop(0)) | 
					
						
							|  |  |  |         distribute_items_restrictive(mw2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[0].item, gen2.locations[0].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[1].item, gen2.locations[1].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[2].item, gen2.locations[2].item) | 
					
						
							|  |  |  |         self.assertEqual(gen1.locations[3].item, gen2.locations[3].item) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |     def test_can_reserve_advancement_items_for_general_fill(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that priority locations fill still satisfies item rules""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld() | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, location_count=5, prog_item_count=5) | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |         items = player1.prog_items | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has_all( | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  |             names(items), player1.id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         location = player1.locations[0] | 
					
						
							|  |  |  |         location.progress_type = LocationProgressType.PRIORITY | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         location.item_rule = lambda item: item not in items[:4] | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-29 09:20:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertEqual(location.item, items[4]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  |     def test_non_excluded_local_items(self): | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that local items get placed locally in a multiworld""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, location_count=5, basic_item_count=5) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  |         player2 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 2, location_count=5, basic_item_count=5) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         for item in multiworld.get_items(): | 
					
						
							| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  |             item.classification = ItemClassification.useful | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         multiworld.worlds[player1.id].options.local_items.value = set(names(player1.basic_items)) | 
					
						
							|  |  |  |         multiworld.worlds[player2.id].options.local_items.value = set(names(player2.basic_items)) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         locality_rules(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         distribute_items_restrictive(multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         for item in multiworld.get_items(): | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  |             self.assertEqual(item.player, item.location.player) | 
					
						
							| 
									
										
										
										
											2024-04-14 13:37:48 -05:00
										 |  |  |             self.assertFalse(item.location.advancement, False) | 
					
						
							| 
									
										
										
										
											2022-01-31 14:23:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 09:56:47 -07:00
										 |  |  |     def test_early_items(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that the early items API successfully places items early""" | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         mw = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2022-11-04 09:56:47 -07:00
										 |  |  |         player1 = generate_player_data(mw, 1, location_count=5, basic_item_count=5) | 
					
						
							|  |  |  |         player2 = generate_player_data(mw, 2, location_count=5, basic_item_count=5) | 
					
						
							| 
									
										
										
										
											2022-11-16 10:32:33 -06:00
										 |  |  |         mw.early_items[1][player1.basic_items[0].name] = 1 | 
					
						
							|  |  |  |         mw.early_items[2][player2.basic_items[2].name] = 1 | 
					
						
							|  |  |  |         mw.early_items[2][player2.basic_items[3].name] = 1 | 
					
						
							| 
									
										
										
										
											2022-11-04 09:56:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         early_items = [ | 
					
						
							|  |  |  |             player1.basic_items[0], | 
					
						
							|  |  |  |             player2.basic_items[2], | 
					
						
							|  |  |  |             player2.basic_items[3], | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # copied this code from the beginning of `distribute_items_restrictive` | 
					
						
							|  |  |  |         # before `distribute_early_items` is called | 
					
						
							|  |  |  |         fill_locations = sorted(mw.get_unfilled_locations()) | 
					
						
							|  |  |  |         mw.random.shuffle(fill_locations) | 
					
						
							|  |  |  |         itempool = sorted(mw.itempool) | 
					
						
							|  |  |  |         mw.random.shuffle(itempool) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         fill_locations, itempool = distribute_early_items(mw, fill_locations, itempool) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         remaining_p1 = [item for item in itempool if item.player == 1] | 
					
						
							|  |  |  |         remaining_p2 = [item for item in itempool if item.player == 2] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         assert len(itempool) == 7, f"number of items remaining after early_items: {len(itempool)}" | 
					
						
							|  |  |  |         assert len(remaining_p1) == 4, f"number of p1 items after early_items: {len(remaining_p1)}" | 
					
						
							|  |  |  |         assert len(remaining_p2) == 3, f"number of p2 items after early_items: {len(remaining_p1)}" | 
					
						
							|  |  |  |         for i in range(5): | 
					
						
							|  |  |  |             if i != 0: | 
					
						
							|  |  |  |                 assert player1.basic_items[i] in itempool, "non-early item to remain in itempool" | 
					
						
							|  |  |  |             if i not in {2, 3}: | 
					
						
							|  |  |  |                 assert player2.basic_items[i] in itempool, "non-early item to remain in itempool" | 
					
						
							|  |  |  |         for item in early_items: | 
					
						
							|  |  |  |             assert item not in itempool, "early item to be taken out of itempool" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         assert len(fill_locations) == len(mw.get_locations()) - len(early_items), \ | 
					
						
							|  |  |  |             f"early location count from {mw.get_locations()} to {len(fill_locations)} " \ | 
					
						
							|  |  |  |             f"after {len(early_items)} early items" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         items_in_locations = {loc.item for loc in mw.get_locations() if loc.item} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         assert len(items_in_locations) == len(early_items), \ | 
					
						
							|  |  |  |             f"{len(early_items)} early items in {len(items_in_locations)} locations" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for item in early_items: | 
					
						
							|  |  |  |             assert item in items_in_locations, "early item to be placed in location" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | class TestBalanceMultiworldProgression(unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  |     def assertRegionContains(self, region: Region, item: Item) -> bool: | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         for location in region.locations: | 
					
						
							|  |  |  |             if location.item and location.item == item: | 
					
						
							|  |  |  |                 return True | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         self.fail(f"Expected {region.name} to contain {item.name}.\n" | 
					
						
							|  |  |  |                   f"Contains{list(map(lambda location: location.item, region.locations))}") | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  |     def setUp(self) -> None: | 
					
						
							| 
									
										
										
										
											2024-05-02 03:01:59 -05:00
										 |  |  |         multiworld = generate_test_multiworld(2) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         self.multiworld = multiworld | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         player1 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 1, prog_item_count=2, basic_item_count=40) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.player1 = player1 | 
					
						
							|  |  |  |         player2 = generate_player_data( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, 2, prog_item_count=2, basic_item_count=40) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.player2 = player2 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player1.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |             player1.prog_items[0].name, player1.id) and state.has( | 
					
						
							|  |  |  |             player1.prog_items[1].name, player1.id) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         multiworld.completion_condition[player2.id] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |             player2.prog_items[0].name, player2.id) and state.has( | 
					
						
							|  |  |  |             player2.prog_items[1].name, player2.id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         items = player1.basic_items + player2.basic_items | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Sphere 1 | 
					
						
							|  |  |  |         region = player1.generate_region(player1.menu, 20) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         items = fill_region(multiworld, region, [ | 
					
						
							| 
									
										
										
										
											2022-01-27 21:40:08 -07:00
										 |  |  |             player1.prog_items[0]] + items) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Sphere 2 | 
					
						
							|  |  |  |         region = player1.generate_region( | 
					
						
							|  |  |  |             player1.regions[1], 20, lambda state: state.has(player1.prog_items[0].name, player1.id)) | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         items = fill_region( | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |             multiworld, region, [player1.prog_items[1], player2.prog_items[0]] + items) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Sphere 3 | 
					
						
							|  |  |  |         region = player2.generate_region( | 
					
						
							|  |  |  |             player2.menu, 20, lambda state: state.has(player2.prog_items[0].name, player2.id)) | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         fill_region(multiworld, region, [player2.prog_items[1]] + items) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  |     def test_balances_progression(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Tests that progression balancing moves progression items earlier""" | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         self.multiworld.worlds[self.player1.id].options.progression_balancing.value = 50 | 
					
						
							|  |  |  |         self.multiworld.worlds[self.player2.id].options.progression_balancing.value = 50 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         balance_multiworld_progression(self.multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[1], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  |     def test_balances_progression_light(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that progression balancing still moves items earlier on minimum value""" | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         self.multiworld.worlds[self.player1.id].options.progression_balancing.value = 1 | 
					
						
							|  |  |  |         self.multiworld.worlds[self.player2.id].options.progression_balancing.value = 1 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         balance_multiworld_progression(self.multiworld) | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # TODO: arrange for a result that's different from the default | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[1], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_balances_progression_heavy(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that progression balancing moves items earlier on maximum value""" | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         self.multiworld.worlds[self.player1.id].options.progression_balancing.value = 99 | 
					
						
							|  |  |  |         self.multiworld.worlds[self.player2.id].options.progression_balancing.value = 99 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         balance_multiworld_progression(self.multiworld) | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # TODO: arrange for a result that's different from the default | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[1], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_skips_balancing_progression(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that progression balancing is skipped when players have it disabled""" | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         self.multiworld.worlds[self.player1.id].options.progression_balancing.value = 0 | 
					
						
							|  |  |  |         self.multiworld.worlds[self.player2.id].options.progression_balancing.value = 0 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         balance_multiworld_progression(self.multiworld) | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_ignores_priority_locations(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |         """Test that progression items on priority locations don't get moved by balancing""" | 
					
						
							| 
									
										
										
										
											2024-11-01 07:43:28 -04:00
										 |  |  |         self.multiworld.worlds[self.player1.id].options.progression_balancing.value = 50 | 
					
						
							|  |  |  |         self.multiworld.worlds[self.player2.id].options.progression_balancing.value = 50 | 
					
						
							| 
									
										
										
										
											2022-05-11 00:13:21 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  |         self.player2.prog_items[0].location.progress_type = LocationProgressType.PRIORITY | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:38:00 -05:00
										 |  |  |         balance_multiworld_progression(self.multiworld) | 
					
						
							| 
									
										
										
										
											2022-01-19 20:19:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self.assertRegionContains( | 
					
						
							|  |  |  |             self.player1.regions[2], self.player2.prog_items[0]) |