| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  | from typing import Dict, List, NamedTuple, Optional, TYPE_CHECKING | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  | from BaseClasses import MultiWorld, Region, Entrance | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  | from .Locations import RLLocation, location_table, get_locations_by_category | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  | if TYPE_CHECKING: | 
					
						
							|  |  |  |     from . import RLWorld | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | class RLRegionData(NamedTuple): | 
					
						
							|  |  |  |     locations: Optional[List[str]] | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  |     region_exits: Optional[List[str]] | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  | def create_regions(world: "RLWorld"): | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     regions: Dict[str, RLRegionData] = { | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  |         "Menu":              RLRegionData(None, ["Castle Hamson"]), | 
					
						
							|  |  |  |         "The Manor":         RLRegionData([],   []), | 
					
						
							|  |  |  |         "Castle Hamson":     RLRegionData([],   ["Forest Abkhazia", "The Maya", "Land of Darkness", | 
					
						
							|  |  |  |                                                  "The Fountain Room", "The Manor"]), | 
					
						
							|  |  |  |         "Forest Abkhazia":   RLRegionData([],   []), | 
					
						
							|  |  |  |         "The Maya":          RLRegionData([],   []), | 
					
						
							|  |  |  |         "Land of Darkness":  RLRegionData([],   []), | 
					
						
							|  |  |  |         "The Fountain Room": RLRegionData([],   None), | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  |     # Artificially stagger diary spheres for progression. | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     for diary in range(0, 25): | 
					
						
							|  |  |  |         region: str | 
					
						
							|  |  |  |         if 0 <= diary < 6: | 
					
						
							|  |  |  |             region = "Castle Hamson" | 
					
						
							|  |  |  |         elif 6 <= diary < 12: | 
					
						
							|  |  |  |             region = "Forest Abkhazia" | 
					
						
							|  |  |  |         elif 12 <= diary < 18: | 
					
						
							|  |  |  |             region = "The Maya" | 
					
						
							|  |  |  |         elif 18 <= diary < 24: | 
					
						
							|  |  |  |             region = "Land of Darkness" | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             region = "The Fountain Room" | 
					
						
							|  |  |  |         regions[region].locations.append(f"Diary {diary + 1}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Manor & Special | 
					
						
							|  |  |  |     for manor in get_locations_by_category("Manor").keys(): | 
					
						
							|  |  |  |         regions["The Manor"].locations.append(manor) | 
					
						
							|  |  |  |     for special in get_locations_by_category("Special").keys(): | 
					
						
							|  |  |  |         regions["Castle Hamson"].locations.append(special) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Boss Rewards | 
					
						
							|  |  |  |     regions["Castle Hamson"].locations.append("Castle Hamson Boss Reward") | 
					
						
							|  |  |  |     regions["Forest Abkhazia"].locations.append("Forest Abkhazia Boss Reward") | 
					
						
							|  |  |  |     regions["The Maya"].locations.append("The Maya Boss Reward") | 
					
						
							|  |  |  |     regions["Land of Darkness"].locations.append("Land of Darkness Boss Reward") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Events | 
					
						
							|  |  |  |     regions["Castle Hamson"].locations.append("Castle Hamson Boss Room") | 
					
						
							|  |  |  |     regions["Forest Abkhazia"].locations.append("Forest Abkhazia Boss Room") | 
					
						
							|  |  |  |     regions["The Maya"].locations.append("The Maya Boss Room") | 
					
						
							|  |  |  |     regions["Land of Darkness"].locations.append("Land of Darkness Boss Room") | 
					
						
							|  |  |  |     regions["The Fountain Room"].locations.append("Fountain Room") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Chests | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  |     chests = int(world.options.chests_per_zone) | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     for i in range(0, chests): | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  |         if world.options.universal_chests: | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |             regions["Castle Hamson"].locations.append(f"Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Forest Abkhazia"].locations.append(f"Chest {i + 1 + chests}") | 
					
						
							|  |  |  |             regions["The Maya"].locations.append(f"Chest {i + 1 + (chests * 2)}") | 
					
						
							|  |  |  |             regions["Land of Darkness"].locations.append(f"Chest {i + 1 + (chests * 3)}") | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             regions["Castle Hamson"].locations.append(f"Castle Hamson - Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Forest Abkhazia"].locations.append(f"Forest Abkhazia - Chest {i + 1}") | 
					
						
							|  |  |  |             regions["The Maya"].locations.append(f"The Maya - Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Land of Darkness"].locations.append(f"Land of Darkness - Chest {i + 1}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Fairy Chests | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  |     chests = int(world.options.fairy_chests_per_zone) | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     for i in range(0, chests): | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  |         if world.options.universal_fairy_chests: | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |             regions["Castle Hamson"].locations.append(f"Fairy Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Forest Abkhazia"].locations.append(f"Fairy Chest {i + 1 + chests}") | 
					
						
							|  |  |  |             regions["The Maya"].locations.append(f"Fairy Chest {i + 1 + (chests * 2)}") | 
					
						
							|  |  |  |             regions["Land of Darkness"].locations.append(f"Fairy Chest {i + 1 + (chests * 3)}") | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             regions["Castle Hamson"].locations.append(f"Castle Hamson - Fairy Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Forest Abkhazia"].locations.append(f"Forest Abkhazia - Fairy Chest {i + 1}") | 
					
						
							|  |  |  |             regions["The Maya"].locations.append(f"The Maya - Fairy Chest {i + 1}") | 
					
						
							|  |  |  |             regions["Land of Darkness"].locations.append(f"Land of Darkness - Fairy Chest {i + 1}") | 
					
						
							| 
									
										
										
										
											2022-01-03 18:12:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Set up the regions correctly. | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |     for name, data in regions.items(): | 
					
						
							| 
									
										
										
										
											2024-09-08 11:50:08 -05:00
										 |  |  |         world.multiworld.regions.append(create_region(world.multiworld, world.player, name, data)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     world.get_entrance("Castle Hamson").connect(world.get_region("Castle Hamson")) | 
					
						
							|  |  |  |     world.get_entrance("The Manor").connect(world.get_region("The Manor")) | 
					
						
							|  |  |  |     world.get_entrance("Forest Abkhazia").connect(world.get_region("Forest Abkhazia")) | 
					
						
							|  |  |  |     world.get_entrance("The Maya").connect(world.get_region("The Maya")) | 
					
						
							|  |  |  |     world.get_entrance("Land of Darkness").connect(world.get_region("Land of Darkness")) | 
					
						
							|  |  |  |     world.get_entrance("The Fountain Room").connect(world.get_region("The Fountain Room")) | 
					
						
							| 
									
										
										
										
											2022-01-03 18:12:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  | def create_region(multiworld: MultiWorld, player: int, name: str, data: RLRegionData): | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |     region = Region(name, player, multiworld) | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  |     if data.locations: | 
					
						
							|  |  |  |         for loc_name in data.locations: | 
					
						
							| 
									
										
										
										
											2022-10-29 22:15:06 -05:00
										 |  |  |             loc_data = location_table.get(loc_name) | 
					
						
							| 
									
										
										
										
											2022-12-06 20:49:55 -06:00
										 |  |  |             location = RLLocation(player, loc_name, loc_data.code if loc_data else None, region) | 
					
						
							|  |  |  |             region.locations.append(location) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if data.region_exits: | 
					
						
							|  |  |  |         for exit in data.region_exits: | 
					
						
							|  |  |  |             entrance = Entrance(player, exit, region) | 
					
						
							|  |  |  |             region.exits.append(entrance) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return region |