2023-10-10 15:30:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from BaseClasses import CollectionState, ItemClassification
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-29 19:47:37 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.Dungeons import get_dungeon_item_pool
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-24 05:38:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.EntranceShuffle import mandatory_connections, connect_simple
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-20 19:57:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.ItemPool import difficulties
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 01:18:25 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.Items import item_factory
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-30 23:29:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.Regions import create_regions
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-30 23:43:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.Shops import create_shops
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.alttp.test import LTTPTestBase
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								class TestDungeon(LTTPTestBase):
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def setUp(self):
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.world_setup()
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-10 19:54:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.starting_regions = []  # Where to start exploring
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.remove_exits = []      # Block dungeon exits
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-18 18:33:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.worlds[1].difficulty_requirements = difficulties['normal']
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-18 17:41:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.worlds[1].options.bombless_start.value = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.worlds[1].options.shuffle_capacity_upgrades.value = 2
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        create_regions(self.multiworld, 1)
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-20 19:57:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.worlds[1].create_dungeons()
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        create_shops(self.multiworld, 1)
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for exitname, regionname in mandatory_connections:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            connect_simple(self.multiworld, exitname, regionname, 1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        connect_simple(self.multiworld, 'Big Bomb Shop', 'Big Bomb Shop', 1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.get_region('Menu', 1).exits = []
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-18 18:33:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.worlds[1].swamp_patch_required = True
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 01:18:25 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.world.set_rules()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.world.create_items()
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld))
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 01:18:25 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world))
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def run_tests(self, access_pool):
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-10 19:54:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for exit in self.remove_exits:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            self.multiworld.get_entrance(exit, 1).connected_region = self.multiworld.get_region('Menu', 1)
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for location, access, *item_pool in access_pool:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            items = item_pool[0]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            all_except = item_pool[1] if len(item_pool) > 1 else None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            with self.subTest(location=location, access=access, items=items, all_except=all_except):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if all_except and len(all_except) > 0:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    items = self.multiworld.itempool[:]
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    items = [item for item in items if item.name not in all_except and not ("Bottle" in item.name and "AnyBottle" in all_except)]
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 01:18:25 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    items.extend(item_factory(item_pool[0], self.world))
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                else:
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 01:18:25 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    items = item_factory(items, self.world)
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                state = CollectionState(self.multiworld)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                state.reachable_regions[1].add(self.multiworld.get_region('Menu', 1))
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-10 19:54:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                for region_name in self.starting_regions:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    region = self.multiworld.get_region(region_name, 1)
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-10 19:54:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    state.reachable_regions[1].add(region)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    for exit in region.exits:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        if exit.connected_region is not None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                            state.blocked_connections[1].add(exit)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                for item in items:
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    item.classification = ItemClassification.progression
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-23 01:15:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    state.collect(item, prevent_sweep=True)  # prevent_sweep=True prevents running sweep_for_advancements() and picking up
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                state.sweep_for_advancements()             # key drop keys repeatedly
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-16 17:39:54 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-13 15:28:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                self.assertEqual(self.multiworld.get_location(location, 1).can_reach(state), access, f"failed {self.multiworld.get_location(location, 1)} with: {item_pool}")
							 |