| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  | from argparse import Namespace | 
					
						
							| 
									
										
										
										
											2023-02-26 19:13:24 -06:00
										 |  |  | from typing import Type, Tuple | 
					
						
							| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | from BaseClasses import MultiWorld, CollectionState | 
					
						
							| 
									
										
										
										
											2023-02-26 19:13:24 -06:00
										 |  |  | from worlds.AutoWorld import call_all, World | 
					
						
							| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-26 19:13:24 -06:00
										 |  |  | gen_steps = ("generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill") | 
					
						
							| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-26 19:13:24 -06:00
										 |  |  | def setup_solo_multiworld(world_type: Type[World], steps: Tuple[str, ...] = gen_steps) -> MultiWorld: | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Creates a multiworld with a single player of `world_type`, sets default options, and calls provided gen steps. | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     :param world_type: Type of the world to generate a multiworld for | 
					
						
							|  |  |  |     :param steps: The gen steps that should be called on the generated multiworld before returning. Default calls | 
					
						
							|  |  |  |     steps through pre_fill | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |     multiworld = MultiWorld(1) | 
					
						
							|  |  |  |     multiworld.game[1] = world_type.game | 
					
						
							|  |  |  |     multiworld.player_name = {1: "Tester"} | 
					
						
							|  |  |  |     multiworld.set_seed() | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     multiworld.state = CollectionState(multiworld) | 
					
						
							| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  |     args = Namespace() | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     for name, option in world_type.options_dataclass.type_hints.items(): | 
					
						
							| 
									
										
										
										
											2021-10-21 20:23:13 +02:00
										 |  |  |         setattr(args, name, {1: option.from_any(option.default)}) | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |     multiworld.set_options(args) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:13:24 -06:00
										 |  |  |     for step in steps: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         call_all(multiworld, step) | 
					
						
							|  |  |  |     return multiworld |