| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | # Regions are areas in your game that you travel to. | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | from typing import Dict, List, TYPE_CHECKING | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | from BaseClasses import Entrance, Region | 
					
						
							|  |  |  | from . import locations | 
					
						
							|  |  |  | from .events import create_all_events | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | if TYPE_CHECKING: | 
					
						
							|  |  |  |     from . import NoitaWorld | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | def create_locations(world: "NoitaWorld", region: Region) -> None: | 
					
						
							|  |  |  |     locs = locations.location_region_mapping.get(region.name, {}) | 
					
						
							|  |  |  |     for location_name, location_data in locs.items(): | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  |         location_type = location_data.ltype | 
					
						
							|  |  |  |         flag = location_data.flag | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 06:02:14 -04:00
										 |  |  |         is_orb_allowed = location_type == "Orb" and flag <= world.options.orbs_as_checks | 
					
						
							|  |  |  |         is_boss_allowed = location_type == "Boss" and flag <= world.options.bosses_as_checks | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  |         amount = 0 | 
					
						
							|  |  |  |         if flag == locations.LocationFlag.none or is_orb_allowed or is_boss_allowed: | 
					
						
							|  |  |  |             amount = 1 | 
					
						
							| 
									
										
										
										
											2024-05-02 06:02:14 -04:00
										 |  |  |         elif location_type == "Chest" and flag <= world.options.path_option: | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  |             amount = world.options.hidden_chests.value | 
					
						
							| 
									
										
										
										
											2024-05-02 06:02:14 -04:00
										 |  |  |         elif location_type == "Pedestal" and flag <= world.options.path_option: | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  |             amount = world.options.pedestal_checks.value | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  |         region.add_locations(locations.make_location_range(location_name, location_data.id, amount), | 
					
						
							|  |  |  |                              locations.NoitaLocation) | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Creates a new Region with the locations found in `location_region_mapping` and adds them to the world. | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | def create_region(world: "NoitaWorld", region_name: str) -> Region: | 
					
						
							|  |  |  |     new_region = Region(region_name, world.player, world.multiworld) | 
					
						
							|  |  |  |     create_locations(world, new_region) | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  |     return new_region | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | def create_regions(world: "NoitaWorld") -> Dict[str, Region]: | 
					
						
							|  |  |  |     return {name: create_region(world, name) for name in noita_regions} | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # An "Entrance" is really just a connection between two regions | 
					
						
							| 
									
										
										
										
											2024-04-13 19:21:20 -04:00
										 |  |  | def create_entrance(player: int, source: str, destination: str, regions: Dict[str, Region]) -> Entrance: | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  |     entrance = Entrance(player, f"From {source} To {destination}", regions[source]) | 
					
						
							|  |  |  |     entrance.connect(regions[destination]) | 
					
						
							|  |  |  |     return entrance | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Creates connections based on our access mapping in `noita_connections`. | 
					
						
							|  |  |  | def create_connections(player: int, regions: Dict[str, Region]) -> None: | 
					
						
							|  |  |  |     for source, destinations in noita_connections.items(): | 
					
						
							|  |  |  |         new_entrances = [create_entrance(player, source, destination, regions) for destination in destinations] | 
					
						
							|  |  |  |         regions[source].exits = new_entrances | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Creates all regions and connections. Called from NoitaWorld. | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  | def create_all_regions_and_connections(world: "NoitaWorld") -> None: | 
					
						
							|  |  |  |     created_regions = create_regions(world) | 
					
						
							|  |  |  |     create_connections(world.player, created_regions) | 
					
						
							|  |  |  |     create_all_events(world, created_regions) | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-19 15:31:45 -05:00
										 |  |  |     world.multiworld.regions += created_regions.values() | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Oh, what a tangled web we weave | 
					
						
							|  |  |  | # Notes to create artificial spheres: | 
					
						
							|  |  |  | # - Shaft is excluded to disconnect Mines from the Snowy Depths | 
					
						
							|  |  |  | # - Lukki Lair is disconnected from The Vault | 
					
						
							|  |  |  | # - Overgrown Cavern is connected to the Underground Jungle instead of the Desert due to similar difficulty | 
					
						
							|  |  |  | # - Powerplant is disconnected from the Sandcave due to difficulty and sphere creation | 
					
						
							|  |  |  | # - Snow Chasm is disconnected from the Snowy Wasteland | 
					
						
							|  |  |  | # - Pyramid is connected to the Hiisi Base instead of the Desert due to similar difficulty | 
					
						
							|  |  |  | # - Frozen Vault is connected to the Vault instead of the Snowy Wasteland due to similar difficulty | 
					
						
							| 
									
										
										
										
											2024-04-18 12:34:57 -04:00
										 |  |  | # - Lake is connected to The Laboratory, since the bosses are hard without specific set-ups (which means late game) | 
					
						
							| 
									
										
										
										
											2023-06-05 13:32:33 -04:00
										 |  |  | # - Snowy Depths connects to Lava Lake orb since you need digging for it, so fairly early is acceptable | 
					
						
							| 
									
										
										
										
											2023-07-18 22:51:01 -04:00
										 |  |  | # - Ancient Laboratory is connected to the Coal Pits, so that Ylialkemisti isn't sphere 1 | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  | noita_connections: Dict[str, List[str]] = { | 
					
						
							|  |  |  |     "Menu": ["Forest"], | 
					
						
							|  |  |  |     "Forest": ["Mines", "Floating Island", "Desert", "Snowy Wasteland"], | 
					
						
							|  |  |  |     "Frozen Vault": ["The Vault"], | 
					
						
							|  |  |  |     "Overgrown Cavern": ["Sandcave"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Mines": ["Collapsed Mines", "Coal Pits Holy Mountain", "Lava Lake"], | 
					
						
							|  |  |  |     "Lava Lake": ["Abyss Orb Room"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Coal Pits Holy Mountain": ["Coal Pits"], | 
					
						
							|  |  |  |     "Coal Pits": ["Fungal Caverns", "Snowy Depths Holy Mountain", "Ancient Laboratory"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Snowy Depths Holy Mountain": ["Snowy Depths"], | 
					
						
							|  |  |  |     "Snowy Depths": ["Hiisi Base Holy Mountain", "Magical Temple", "Below Lava Lake"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Hiisi Base Holy Mountain": ["Hiisi Base"], | 
					
						
							|  |  |  |     "Hiisi Base": ["Secret Shop", "Pyramid", "Underground Jungle Holy Mountain"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Underground Jungle Holy Mountain": ["Underground Jungle"], | 
					
						
							| 
									
										
										
										
											2024-04-18 12:34:57 -04:00
										 |  |  |     "Underground Jungle": ["Dragoncave", "Overgrown Cavern", "Vault Holy Mountain", "Lukki Lair", "Snow Chasm", "West Meat Realm"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Vault Holy Mountain": ["The Vault"], | 
					
						
							|  |  |  |     "The Vault": ["Frozen Vault", "Temple of the Art Holy Mountain"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Temple of the Art Holy Mountain": ["Temple of the Art"], | 
					
						
							|  |  |  |     "Temple of the Art": ["Laboratory Holy Mountain", "The Tower", "Wizards' Den"], | 
					
						
							|  |  |  |     "Wizards' Den": ["Powerplant"], | 
					
						
							| 
									
										
										
										
											2024-04-18 12:54:03 -04:00
										 |  |  |     "Powerplant": ["Meat Realm"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ### | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  |     "Laboratory Holy Mountain": ["The Laboratory"], | 
					
						
							| 
									
										
										
										
											2024-04-18 12:34:57 -04:00
										 |  |  |     "The Laboratory": ["The Work", "Friend Cave", "The Work (Hell)", "Lake", "The Sky"], | 
					
						
							| 
									
										
										
										
											2023-04-19 20:21:56 -07:00
										 |  |  |     ### | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-28 16:27:57 -04:00
										 |  |  | noita_regions: List[str] = sorted(set(noita_connections.keys()).union(*noita_connections.values())) |