| 
									
										
										
										
											2021-06-29 03:49:29 +02:00
										 |  |  | import importlib | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
										
										
											2021-02-26 21:03:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-21 20:17:24 +01:00
										 |  |  | __all__ = {"lookup_any_item_id_to_name", | 
					
						
							| 
									
										
										
										
											2021-02-26 21:03:16 +01:00
										 |  |  |            "lookup_any_location_id_to_name", | 
					
						
							| 
									
										
										
										
											2021-11-19 19:44:34 +01:00
										 |  |  |            "network_data_package", | 
					
						
							|  |  |  |            "AutoWorldRegister"} | 
					
						
							| 
									
										
										
										
											2021-02-21 20:17:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-29 03:49:29 +02:00
										 |  |  | # import all submodules to trigger AutoWorldRegister | 
					
						
							|  |  |  | for file in os.scandir(os.path.dirname(__file__)): | 
					
						
							|  |  |  |     if file.is_dir(): | 
					
						
							| 
									
										
										
										
											2021-07-12 18:05:46 +02:00
										 |  |  |         importlib.import_module(f".{file.name}", "worlds") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .AutoWorld import AutoWorldRegister | 
					
						
							|  |  |  | lookup_any_item_id_to_name = {} | 
					
						
							|  |  |  | lookup_any_location_id_to_name = {} | 
					
						
							|  |  |  | games = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for world_name, world in AutoWorldRegister.world_types.items(): | 
					
						
							|  |  |  |     games[world_name] = { | 
					
						
							|  |  |  |         "item_name_to_id" : world.item_name_to_id, | 
					
						
							|  |  |  |         "location_name_to_id": world.location_name_to_id, | 
					
						
							|  |  |  |         "version": world.data_version, | 
					
						
							|  |  |  |         # seems clients don't actually want this. Keeping it here in case someone changes their mind. | 
					
						
							|  |  |  |         # "item_name_groups": {name: tuple(items) for name, items in world.item_name_groups.items()} | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     lookup_any_item_id_to_name.update(world.item_id_to_name) | 
					
						
							|  |  |  |     lookup_any_location_id_to_name.update(world.location_id_to_name) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | network_data_package = { | 
					
						
							| 
									
										
										
										
											2021-07-14 10:02:39 +02:00
										 |  |  |     "version": sum(world.data_version for world in AutoWorldRegister.world_types.values()), | 
					
						
							| 
									
										
										
										
											2021-07-12 18:05:46 +02:00
										 |  |  |     "games": games, | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-08-22 04:22:34 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Set entire datapackage to version 0 if any of them are set to 0 | 
					
						
							|  |  |  | if any(not world.data_version for world in AutoWorldRegister.world_types.values()): | 
					
						
							|  |  |  |     network_data_package["version"] = 0 | 
					
						
							| 
									
										
										
										
											2021-09-26 09:10:27 +02:00
										 |  |  |     import logging | 
					
						
							|  |  |  |     logging.warning("Datapackage is in custom mode.") |