2022-10-01 15:24:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from typing import List, Set, Dict, Tuple, Optional, Callable
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from BaseClasses import MultiWorld, Region, Entrance, Location
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from .Locations import LocationData
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .Options import get_option_value, MissionOrder
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from .MissionTables import MissionInfo, mission_orders, vanilla_mission_req_table, alt_final_mission_locations, \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    MissionPools, vanilla_shuffle_order
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .PoolFilter import filter_missions
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PROPHECY_CHAIN_MISSION_COUNT = 4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								VANILLA_SHUFFLED_FIRST_PROPHECY_MISSION = 21
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def create_regions(multiworld: MultiWorld, player: int, locations: Tuple[LocationData, ...], location_cache: List[Location])\
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        -> Tuple[Dict[str, MissionInfo], int, str]:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    locations_per_region = get_locations_per_region(locations)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mission_order_type = get_option_value(multiworld, player, "mission_order")
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mission_order = mission_orders[mission_order_type]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mission_pools = filter_missions(multiworld, player)
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    regions = [create_region(multiworld, player, locations_per_region, location_cache, "Menu")]
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    names: Dict[str, int] = {}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if mission_order_type == MissionOrder.option_vanilla:
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Generating all regions and locations
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for region_name in vanilla_mission_req_table.keys():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            regions.append(create_region(multiworld, player, locations_per_region, location_cache, region_name))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        multiworld.regions += regions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Menu', 'Liberation Day'),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Liberation Day', 'The Outlaws',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Liberation Day", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'The Outlaws', 'Zero Hour',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat The Outlaws", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Zero Hour', 'Evacuation',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Zero Hour", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Evacuation', 'Outbreak',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Evacuation", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Outbreak", "Safe Haven",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 7) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Outbreak", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Outbreak", "Haven's Fall",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 7) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Outbreak", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Zero Hour', 'Smash and Grab',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Zero Hour", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Smash and Grab', 'The Dig',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 8) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Smash and Grab", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'The Dig', 'The Moebius Factor',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 11) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat The Dig", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'The Moebius Factor', 'Supernova',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 14) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat The Moebius Factor", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Supernova', 'Maw of the Void',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Supernova", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Zero Hour', "Devil's Playground",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 4) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Zero Hour", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Devil's Playground", 'Welcome to the Jungle',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Devil's Playground", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Welcome to the Jungle", 'Breakout',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 8) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Welcome to the Jungle", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Welcome to the Jungle", 'Ghost of a Chance',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 8) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Welcome to the Jungle", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, "Zero Hour", 'The Great Train Robbery',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                lambda state: state._sc2wol_cleared_missions(multiworld, player, 6) and
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              state.has("Beat Zero Hour", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'The Great Train Robbery', 'Cutthroat',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat The Great Train Robbery", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Cutthroat', 'Engine of Destruction',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Cutthroat", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Engine of Destruction', 'Media Blitz',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Engine of Destruction", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Media Blitz', 'Piercing the Shroud',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Media Blitz", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'The Dig', 'Whispers of Doom',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat The Dig", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Whispers of Doom', 'A Sinister Turn',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Whispers of Doom", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'A Sinister Turn', 'Echoes of the Future',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat A Sinister Turn", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Echoes of the Future', 'In Utter Darkness',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Echoes of the Future", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Maw of the Void', 'Gates of Hell',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Maw of the Void", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Gates of Hell', 'Belly of the Beast',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Gates of Hell", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Gates of Hell', 'Shatter the Sky',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has("Beat Gates of Hell", player)),
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        connect(multiworld, player, names, 'Gates of Hell', 'All-In',
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                lambda state: state.has('Beat Gates of Hell', player) and (
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        state.has('Beat Shatter the Sky', player) or state.has('Beat Belly of the Beast', player)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return vanilla_mission_req_table, 29, 'All-In: Victory'
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missions = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        remove_prophecy = mission_order_type == 1 and not get_option_value(multiworld, player, "shuffle_protoss")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        final_mission = mission_pools[MissionPools.FINAL][0]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Determining if missions must be removed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mission_pool_size = sum(len(mission_pool) for mission_pool in mission_pools.values())
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        removals = len(mission_order) - mission_pool_size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Removing entire Prophecy chain on vanilla shuffled when not shuffling protoss
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if remove_prophecy:
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            removals -= PROPHECY_CHAIN_MISSION_COUNT
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # Initial fill out of mission list and marking all-in mission
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for mission in mission_order:
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            # Removing extra missions if mission pool is too small
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            # Also handle lower removal priority than Prophecy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if 0 < mission.removal_priority <= removals or mission.category == 'Prophecy' and remove_prophecy \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    or (remove_prophecy and mission_order_type == MissionOrder.option_vanilla_shuffled
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        and mission.removal_priority > vanilla_shuffle_order[
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                            VANILLA_SHUFFLED_FIRST_PROPHECY_MISSION].removal_priority
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        and 0 < mission.removal_priority <= removals + PROPHECY_CHAIN_MISSION_COUNT):
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                missions.append(None)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            elif mission.type == MissionPools.FINAL:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                missions.append(final_mission)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                missions.append(mission.type)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        no_build_slots = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        easy_slots = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        medium_slots = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        hard_slots = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Search through missions to find slots needed to fill
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for i in range(len(missions)):
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if missions[i] is None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if missions[i] == MissionPools.STARTER:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                no_build_slots.append(i)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            elif missions[i] == MissionPools.EASY:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                easy_slots.append(i)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            elif missions[i] == MissionPools.MEDIUM:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                medium_slots.append(i)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            elif missions[i] == MissionPools.HARD:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                hard_slots.append(i)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Add no_build missions to the pool and fill in no_build slots
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missions_to_add = mission_pools[MissionPools.STARTER]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if len(no_build_slots) > len(missions_to_add):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            raise Exception("There are no valid No-Build missions.  Please exclude fewer missions.")
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for slot in no_build_slots:
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            filler = multiworld.random.randint(0, len(missions_to_add) - 1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            missions[slot] = missions_to_add.pop(filler)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Add easy missions into pool and fill in easy slots
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missions_to_add = missions_to_add + mission_pools[MissionPools.EASY]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if len(easy_slots) > len(missions_to_add):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            raise Exception("There are not enough Easy missions to fill the campaign.  Please exclude fewer missions.")
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for slot in easy_slots:
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            filler = multiworld.random.randint(0, len(missions_to_add) - 1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            missions[slot] = missions_to_add.pop(filler)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Add medium missions into pool and fill in medium slots
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missions_to_add = missions_to_add + mission_pools[MissionPools.MEDIUM]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if len(medium_slots) > len(missions_to_add):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            raise Exception("There are not enough Easy and Medium missions to fill the campaign.  Please exclude fewer missions.")
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for slot in medium_slots:
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            filler = multiworld.random.randint(0, len(missions_to_add) - 1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            missions[slot] = missions_to_add.pop(filler)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Add hard missions into pool and fill in hard slots
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missions_to_add = missions_to_add + mission_pools[MissionPools.HARD]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if len(hard_slots) > len(missions_to_add):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            raise Exception("There are not enough missions to fill the campaign.  Please exclude fewer missions.")
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for slot in hard_slots:
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            filler = multiworld.random.randint(0, len(missions_to_add) - 1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            missions[slot] = missions_to_add.pop(filler)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # Generating regions and locations from selected missions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for region_name in missions:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            regions.append(create_region(multiworld, player, locations_per_region, location_cache, region_name))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        multiworld.regions += regions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Mapping original mission slots to shifted mission slots when missions are removed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        slot_map = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        slot_offset = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for position, mission in enumerate(missions):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            slot_map.append(position - slot_offset + 1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if mission is None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                slot_offset += 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # Loop through missions to create requirements table and connect regions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # TODO: Handle 'and' connections
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mission_req_table = {}
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        def build_connection_rule(mission_names: List[str], missions_req: int) -> Callable:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if len(mission_names) > 1:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                return lambda state: state.has_all({f"Beat {name}" for name in mission_names}, player) and \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                     state._sc2wol_cleared_missions(multiworld, player, missions_req)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                return lambda state: state.has(f"Beat {mission_names[0]}", player) and \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                     state._sc2wol_cleared_missions(multiworld, player, missions_req)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for i, mission in enumerate(missions):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if mission is None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            connections = []
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            all_connections = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            for connection in mission_order[i].connect_to:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if connection == -1:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                while missions[connection] is None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    connection -= 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                all_connections.append(missions[connection])
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for connection in mission_order[i].connect_to:
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                required_mission = missions[connection]
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                if connection == -1:
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    connect(multiworld, player, names, "Menu", mission)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                else:
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    if required_mission is None and not mission_order[i].completion_critical:  # Drop non-critical null slots
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    while required_mission is None:  # Substituting null slot with prior slot
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        connection -= 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        required_mission = missions[connection]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    required_missions = [required_mission] if mission_order[i].or_requirements else all_connections
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    connect(multiworld, player, names, required_mission, mission,
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                            build_connection_rule(required_missions, mission_order[i].number))
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    connections.append(slot_map[connection])
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            mission_req_table.update({mission: MissionInfo(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                vanilla_mission_req_table[mission].id, connections, mission_order[i].category,
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                number=mission_order[i].number,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                completion_critical=mission_order[i].completion_critical,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                or_requirements=mission_order[i].or_requirements)})
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 13:28:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        final_mission_id = vanilla_mission_req_table[final_mission].id
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # Changing the completion condition for alternate final missions into an event
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if final_mission != 'All-In':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            final_location = alt_final_mission_locations[final_mission]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            # Final location should be near the end of the cache
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            for i in range(len(location_cache) - 1, -1, -1):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if location_cache[i].name == final_location:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    location_cache[i].locked = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    location_cache[i].event = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    location_cache[i].address = None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    break
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            final_location = 'All-In: Victory'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return mission_req_table, final_mission_id, final_location
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-20 20:47:16 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def create_location(player: int, location_data: LocationData, region: Region,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    location_cache: List[Location]) -> Location:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    location = Location(player, location_data.name, location_data.code, region)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    location.access_rule = location_data.rule
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if id is None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        location.event = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        location.locked = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    location_cache.append(location)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return location
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def create_region(multiworld: MultiWorld, player: int, locations_per_region: Dict[str, List[LocationData]],
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-20 20:47:16 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  location_cache: List[Location], name: str) -> Region:
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    region = Region(name, player, multiworld)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if name in locations_per_region:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for location_data in locations_per_region[name]:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            location = create_location(player, location_data, region, location_cache)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            region.locations.append(location)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return region
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-20 20:47:16 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def connect(world: MultiWorld, player: int, used_names: Dict[str, int], source: str, target: str,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            rule: Optional[Callable] = None):
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    sourceRegion = world.get_region(source, player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    targetRegion = world.get_region(target, player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if target not in used_names:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        used_names[target] = 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        name = target
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        used_names[target] += 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        name = target + (' ' * used_names[target])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    connection = Entrance(player, name, sourceRegion)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if rule:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        connection.access_rule = rule
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    sourceRegion.exits.append(connection)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    connection.connect(targetRegion)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def get_locations_per_region(locations: Tuple[LocationData, ...]) -> Dict[str, List[LocationData]]:
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-20 20:47:16 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    per_region: Dict[str, List[LocationData]] = {}
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for location in locations:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        per_region.setdefault(location.region, []).append(location)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return per_region
							 |