| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | import typing | 
					
						
							|  |  |  | from ..generic.Rules import add_rule | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  | from .Regions import v6areas | 
					
						
							| 
									
										
										
										
											2022-02-04 21:22:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  | def _has_trinket_range(state, player, start, end) -> bool: | 
					
						
							|  |  |  |     for i in range(start, end): | 
					
						
							|  |  |  |         if not state.has("Trinket " + str(i + 1).zfill(2), player): | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  |             return False | 
					
						
							|  |  |  |     return True | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 21:34:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  | def set_rules(multiworld, options, player, area_connections: typing.Dict[int, int], area_cost_map: typing.Dict[int, int]): | 
					
						
							| 
									
										
										
										
											2022-02-04 21:22:26 +01:00
										 |  |  |     areashuffle = list(range(len(v6areas))) | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     if options.area_rando: | 
					
						
							|  |  |  |         multiworld.random.shuffle(areashuffle) | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  |     area_connections.update({(index + 1): (value + 1) for index, value in enumerate(areashuffle)}) | 
					
						
							|  |  |  |     area_connections.update({0: 0}) | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     if options.area_cost: | 
					
						
							|  |  |  |         multiworld.random.shuffle(areashuffle) | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  |     area_cost_map.update({(index + 1): (value + 1) for index, value in enumerate(areashuffle)}) | 
					
						
							|  |  |  |     area_cost_map.update({0: 0}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     menu_region = multiworld.get_region("Menu", player) | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  |     for i in range(1, 5): | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |         target_region = multiworld.get_region(v6areas[area_connections[i] - 1], player) | 
					
						
							|  |  |  |         menu_region.connect(connecting_region=target_region, | 
					
						
							|  |  |  |                             rule=lambda state, i=i: _has_trinket_range(state, player, | 
					
						
							|  |  |  |                                                                        options.door_cost * (area_cost_map[i] - 1), | 
					
						
							|  |  |  |                                                                        options.door_cost * area_cost_map[i])) | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Special Rule for V | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     add_rule(multiworld.get_location("V", player), lambda state: state.can_reach("Laboratory", 'Region', player) and | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  |                                                             state.can_reach("The Tower", 'Region', player) and | 
					
						
							|  |  |  |                                                             state.can_reach("Space Station 2", 'Region', player) and | 
					
						
							|  |  |  |                                                             state.can_reach("Warp Zone", 'Region', player)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Special Rule for NPC Trinket | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     add_rule(multiworld.get_location("NPC Trinket", player), | 
					
						
							| 
									
										
										
										
											2022-03-26 10:16:28 +01:00
										 |  |  |              lambda state: state.can_reach("Laboratory", 'Region', player) or | 
					
						
							|  |  |  |                            (state.can_reach("The Tower", 'Region', player) and | 
					
						
							|  |  |  |                             state.can_reach("Space Station 2", 'Region', player) and | 
					
						
							|  |  |  |                             state.can_reach("Warp Zone", 'Region', player))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-16 13:38:19 +01:00
										 |  |  |     multiworld.completion_condition[player] = lambda state: state.can_reach("V", 'Location', player) |