| 
									
										
										
										
											2025-07-28 00:53:04 -04:00
										 |  |  | from typing import TYPE_CHECKING | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  | from BaseClasses import Region | 
					
						
							| 
									
										
										
										
											2025-07-28 00:53:04 -04:00
										 |  |  | from .Rules import access_rules_dict, interpret_rule | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-03 13:39:32 -04:00
										 |  |  | from ..generic.Rules import add_rule | 
					
						
							| 
									
										
										
										
											2025-07-28 23:12:47 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 00:53:04 -04:00
										 |  |  | if TYPE_CHECKING: | 
					
						
							| 
									
										
										
										
											2025-07-28 23:12:47 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 00:53:04 -04:00
										 |  |  |     from . import GrinchWorld | 
					
						
							| 
									
										
										
										
											2025-07-25 16:24:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-25 19:33:51 -04:00
										 |  |  | mainareas_list = [ | 
					
						
							|  |  |  |     "Whoville", | 
					
						
							|  |  |  |     "Who Forest", | 
					
						
							|  |  |  |     "Who Dump", | 
					
						
							|  |  |  |     "Who Lake" | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | subareas_list = [ | 
					
						
							|  |  |  |     "Post Office", | 
					
						
							|  |  |  |     "City Hall", | 
					
						
							|  |  |  |     "Countdown to X-Mas Tower", | 
					
						
							|  |  |  |     "Ski Resort", | 
					
						
							|  |  |  |     "Civic Center", | 
					
						
							|  |  |  |     "Minefield", | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  |     "Power Plant", | 
					
						
							|  |  |  |     "Generator Building", | 
					
						
							| 
									
										
										
										
											2025-07-25 19:33:51 -04:00
										 |  |  |     "Submarine World", | 
					
						
							|  |  |  |     "Scout's Hut", | 
					
						
							|  |  |  |     "North Shore", | 
					
						
							|  |  |  |     "Mayor's Villa", | 
					
						
							|  |  |  |     "Sleigh Room" | 
					
						
							|  |  |  | ] | 
					
						
							| 
									
										
										
										
											2025-07-25 16:24:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-25 19:33:51 -04:00
										 |  |  | supadow_list = [ | 
					
						
							|  |  |  |     "Spin N' Win Supadow", | 
					
						
							|  |  |  |     "Dankamania Supadow", | 
					
						
							| 
									
										
										
										
											2025-08-03 19:43:54 -04:00
										 |  |  |     "The Copter Race Contest Supadow", | 
					
						
							|  |  |  |     "Bike Race" | 
					
						
							| 
									
										
										
										
											2025-07-25 19:33:51 -04:00
										 |  |  | ] | 
					
						
							| 
									
										
										
										
											2025-07-26 00:30:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  | def create_regions(world: "GrinchWorld"): | 
					
						
							|  |  |  |     for mainarea in mainareas_list: | 
					
						
							|  |  |  |         #Each area in mainarea, create a region for the given player | 
					
						
							|  |  |  |         world.multiworld.regions.append(Region(mainarea, world.player, world.multiworld)) | 
					
						
							|  |  |  |     for subarea in subareas_list: | 
					
						
							|  |  |  |         #Each area in subarea, create a region for the given player | 
					
						
							|  |  |  |         world.multiworld.regions.append(Region(subarea, world.player, world.multiworld)) | 
					
						
							|  |  |  |     for supadow in supadow_list: | 
					
						
							|  |  |  |         #Each area in supadow, create a region for the given player | 
					
						
							|  |  |  |         world.multiworld.regions.append(Region(supadow, world.player, world.multiworld)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def grinchconnect(world: "GrinchWorld", current_region_name: str, connected_region_name: str): | 
					
						
							|  |  |  |     current_region = world.get_region(current_region_name) | 
					
						
							|  |  |  |     connected_region = world.get_region(connected_region_name) | 
					
						
							| 
									
										
										
										
											2025-07-28 23:12:47 -04:00
										 |  |  |     required_items: list[list[str]] = access_rules_dict[connected_region.name] | 
					
						
							| 
									
										
										
										
											2025-08-03 13:39:32 -04:00
										 |  |  |     rule_list = interpret_rule(required_items, world.player) | 
					
						
							|  |  |  |     # Goes from current to connected | 
					
						
							|  |  |  |     current_region.connect(connected_region) | 
					
						
							|  |  |  |     # Goes from connected to current | 
					
						
							|  |  |  |     connected_region.connect(current_region) | 
					
						
							|  |  |  |     for access_rule in rule_list: | 
					
						
							| 
									
										
										
										
											2025-08-03 14:37:52 -04:00
										 |  |  |         for region_entrance in current_region.entrances: | 
					
						
							|  |  |  |             if region_entrance.connected_region.name == current_region_name and \ | 
					
						
							|  |  |  |                 region_entrance.parent_region.name == connected_region_name: | 
					
						
							|  |  |  |                 add_rule(region_entrance, access_rule) | 
					
						
							|  |  |  |         for region_entrance in connected_region.entrances: | 
					
						
							|  |  |  |             if region_entrance.connected_region.name == connected_region_name and \ | 
					
						
							|  |  |  |                     region_entrance.parent_region.name == current_region_name: | 
					
						
							|  |  |  |                 add_rule(region_entrance, access_rule) | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-03 18:40:12 -04:00
										 |  |  | #What regions are connected to each other | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  | def connect_regions(world: "GrinchWorld"): | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Whoville") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Who Forest") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Who Dump") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Who Lake") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Sleigh Room") | 
					
						
							| 
									
										
										
										
											2025-08-03 13:39:32 -04:00
										 |  |  |     grinchconnect(world, "Mount Crumpit", "Spin N' Win Supadow") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "Dankamania Supadow") | 
					
						
							|  |  |  |     grinchconnect(world, "Mount Crumpit", "The Copter Race Contest Supadow") | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  |     grinchconnect(world, "Whoville", "Post Office") | 
					
						
							|  |  |  |     grinchconnect(world, "Whoville", "City Hall") | 
					
						
							| 
									
										
										
										
											2025-07-28 00:53:04 -04:00
										 |  |  |     grinchconnect(world, "Whoville", "Countdown to X-Mas Clock Tower") | 
					
						
							| 
									
										
										
										
											2025-07-26 20:51:05 -04:00
										 |  |  |     grinchconnect(world, "Who Forest", "Ski Resort") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Forest", "Civic Center") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Dump", "Minefield") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Dump", "Power Plant") | 
					
						
							|  |  |  |     grinchconnect(world, "Power Plant", "Generator Building") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Lake", "Submarine World") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Lake", "Scout's Hut") | 
					
						
							|  |  |  |     grinchconnect(world, "Who Lake", "North Shore") | 
					
						
							|  |  |  |     grinchconnect(world, "North Shore", "Mayor's Villa") |