mirror of
				https://github.com/MarioSpore/Grinch-AP.git
				synced 2025-10-21 20:21:32 -06:00 
			
		
		
		
	Core: Add support for non dictionary iterables for Region.add_exits (#1698)
				
					
				
			* Core: Add support for non dictionary iterables for `Region.add_exits` * some cleanup and duplicate code removal * add unit test for non dict iterable * use more consistent naming * sometimes i just make stuff harder on myself :)
This commit is contained in:
		| @@ -19,6 +19,7 @@ class TestHelpers(unittest.TestCase): | ||||
|         regions: Dict[str, str] = { | ||||
|             "TestRegion1": "I'm an apple", | ||||
|             "TestRegion2": "I'm a banana", | ||||
|             "TestRegion3": "Empty Region", | ||||
|         } | ||||
|  | ||||
|         locations: Dict[str, Dict[str, Optional[int]]] = { | ||||
| @@ -38,6 +39,10 @@ class TestHelpers(unittest.TestCase): | ||||
|             "TestRegion2": {"TestRegion1": None}, | ||||
|         } | ||||
|          | ||||
|         reg_exit_set: Dict[str, set[str]] = { | ||||
|             "TestRegion1": {"TestRegion3"} | ||||
|         } | ||||
|          | ||||
|         exit_rules: Dict[str, Callable[[CollectionState], bool]] = { | ||||
|             "TestRegion1": lambda state: state.has("test_item", self.player) | ||||
|         } | ||||
| @@ -68,3 +73,10 @@ class TestHelpers(unittest.TestCase): | ||||
|                         entrance_name = exit_name if exit_name else f"{parent} -> {exit_reg}" | ||||
|                         self.assertEqual(exit_rules[exit_reg], | ||||
|                                          self.multiworld.get_entrance(entrance_name, self.player).access_rule) | ||||
|              | ||||
|             for region in reg_exit_set: | ||||
|                 current_region = self.multiworld.get_region(region, self.player) | ||||
|                 current_region.add_exits(reg_exit_set[region]) | ||||
|                 exit_names = {_exit.name for _exit in current_region.exits} | ||||
|                 for reg_exit in reg_exit_set[region]: | ||||
|                     self.assertTrue(f"{region} -> {reg_exit}" in exit_names, f"{region} -> {reg_exit} not in {exit_names}") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Aaron Wagener
					Aaron Wagener