| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | # Copyright (c) 2022 FelicitusNeko | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # This software is released under the MIT License. | 
					
						
							|  |  |  | # https://opensource.org/licenses/MIT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  | from BaseClasses import MultiWorld, Region, Entrance | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | from .Locations import MeritousLocation, location_table | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | meritous_regions = ["Meridian", "Ataraxia", "Merodach", "Endgame"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def _generate_entrances(player: int, entrance_list: [str], parent: Region): | 
					
						
							|  |  |  |     return [Entrance(player, entrance, parent) for entrance in entrance_list] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def create_regions(world: MultiWorld, player: int): | 
					
						
							|  |  |  |     regions = ["First", "Second", "Third", "Last"] | 
					
						
							|  |  |  |     bosses = ["Meridian", "Ataraxia", "Merodach"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for x, name in enumerate(regions): | 
					
						
							|  |  |  |         fullname = f"{name} Quarter" | 
					
						
							|  |  |  |         insidename = fullname | 
					
						
							|  |  |  |         if x == 0: | 
					
						
							|  |  |  |             insidename = "Menu" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |         region = Region(insidename, player, world) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         for store in ["Alpha Cache", "Beta Cache", "Gamma Cache", "Reward Chest"]: | 
					
						
							|  |  |  |             for y in range(1, 7): | 
					
						
							|  |  |  |                 loc_name = f"{store} {(x * 6) + y}" | 
					
						
							|  |  |  |                 region.locations += [MeritousLocation(player, loc_name, location_table[loc_name], region)] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if x < 3: | 
					
						
							|  |  |  |             storage_loc = f"PSI Key Storage {x + 1}" | 
					
						
							|  |  |  |             region.locations += [MeritousLocation(player, storage_loc, location_table[storage_loc], region)] | 
					
						
							|  |  |  |             region.exits += _generate_entrances(player, [f"To {bosses[x]}"], region) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             locations_end_game = ["Place of Power", "The Last Place You'll Look"] | 
					
						
							|  |  |  |             region.locations += [ | 
					
						
							|  |  |  |                 MeritousLocation(player, loc_name, location_table[loc_name], region) | 
					
						
							|  |  |  |                 for loc_name in locations_end_game] | 
					
						
							|  |  |  |             region.exits += _generate_entrances(player, ["Back to the entrance", | 
					
						
							|  |  |  |                                                          "Back to the entrance with the Knife"], | 
					
						
							|  |  |  |                                                 region) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         world.regions += [region] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for x, boss in enumerate(bosses): | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |         boss_region = Region(boss, player, world) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         boss_region.locations += [ | 
					
						
							|  |  |  |             MeritousLocation(player, boss, location_table[boss], boss_region), | 
					
						
							|  |  |  |             MeritousLocation(player, f"{boss} Defeat", None, boss_region) | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |         boss_region.exits = _generate_entrances(player, [f"To {regions[x + 1]} Quarter"], boss_region) | 
					
						
							|  |  |  |         world.regions.append(boss_region) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |     region_final_boss = Region("Final Boss", player, world) | 
					
						
							| 
									
										
										
										
											2023-10-29 19:47:37 +01:00
										 |  |  |     region_final_boss.locations += [MeritousLocation( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         player, "Wervyn Anixil", None, region_final_boss)] | 
					
						
							|  |  |  |     world.regions.append(region_final_boss) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |     region_tfb = Region("True Final Boss", player, world) | 
					
						
							| 
									
										
										
										
											2023-10-29 19:47:37 +01:00
										 |  |  |     region_tfb.locations += [MeritousLocation( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         player, "Wervyn Anixil?", None, region_tfb)] | 
					
						
							|  |  |  |     world.regions.append(region_tfb) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     entrance_map = { | 
					
						
							|  |  |  |         "To Meridian": { | 
					
						
							|  |  |  |             "to": "Meridian", | 
					
						
							| 
									
										
										
										
											2022-05-27 19:52:14 -03:00
										 |  |  |             "rule": lambda state: state.has_group("PSI Keys", player, 1) and | 
					
						
							|  |  |  |                                   state.has_group("Important Artifacts", player, 1) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         }, | 
					
						
							|  |  |  |         "To Second Quarter": { | 
					
						
							|  |  |  |             "to": "Second Quarter", | 
					
						
							|  |  |  |             "rule": lambda state: state.has("Meridian Defeated", player) | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "To Ataraxia": { | 
					
						
							|  |  |  |             "to": "Ataraxia", | 
					
						
							| 
									
										
										
										
											2022-05-27 19:52:14 -03:00
										 |  |  |             "rule": lambda state: state.has_group("PSI Keys", player, 2) and | 
					
						
							|  |  |  |                                   state.has_group("Important Artifacts", player, 2) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         }, | 
					
						
							|  |  |  |         "To Third Quarter": { | 
					
						
							|  |  |  |             "to": "Third Quarter", | 
					
						
							|  |  |  |             "rule": lambda state: state.has("Ataraxia Defeated", player) | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "To Merodach": { | 
					
						
							|  |  |  |             "to": "Merodach", | 
					
						
							| 
									
										
										
										
											2022-05-27 19:52:14 -03:00
										 |  |  |             "rule": lambda state: state.has_group("PSI Keys", player, 3) and | 
					
						
							|  |  |  |                                   state.has_group("Important Artifacts", player, 3) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         }, | 
					
						
							|  |  |  |         "To Last Quarter": { | 
					
						
							|  |  |  |             "to": "Last Quarter", | 
					
						
							|  |  |  |             "rule": lambda state: state.has("Merodach Defeated", player) | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "Back to the entrance": { | 
					
						
							|  |  |  |             "to": "Final Boss", | 
					
						
							|  |  |  |             "rule": lambda state: state.has("Cursed Seal", player) | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "Back to the entrance with the Knife": { | 
					
						
							|  |  |  |             "to": "True Final Boss", | 
					
						
							|  |  |  |             "rule": lambda state: state.has_all(["Cursed Seal", "Agate Knife"], player) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for entrance in entrance_map: | 
					
						
							|  |  |  |         connection_data = entrance_map[entrance] | 
					
						
							|  |  |  |         connection = world.get_entrance(entrance, player) | 
					
						
							|  |  |  |         connection.access_rule = connection_data["rule"] | 
					
						
							|  |  |  |         connection.connect(world.get_region(connection_data["to"], player)) |