| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  | from BaseClasses import Item, MultiWorld, Tutorial | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | from Fill import fill_restrictive | 
					
						
							|  |  |  | from .Items import item_table, item_groups, MeritousItem | 
					
						
							|  |  |  | from .Locations import location_table, MeritousLocation | 
					
						
							|  |  |  | from .Options import meritous_options, cost_scales | 
					
						
							|  |  |  | from .Regions import create_regions | 
					
						
							|  |  |  | from .Rules import set_rules | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  | from ..AutoWorld import World, WebWorld | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | client_version = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  | class MeritousWeb(WebWorld): | 
					
						
							|  |  |  |     tutorials = [Tutorial( | 
					
						
							|  |  |  |         "Meritous Setup Tutorial", | 
					
						
							|  |  |  |         "A guide to setting up the Archipelago Meritous software on your computer.", | 
					
						
							|  |  |  |         "English", | 
					
						
							|  |  |  |         "setup_en.md", | 
					
						
							|  |  |  |         "setup/en", | 
					
						
							|  |  |  |         ["KewlioMZX"] | 
					
						
							|  |  |  |     )] | 
					
						
							| 
									
										
										
										
											2022-05-27 19:52:14 -03:00
										 |  |  |     theme = "ice" | 
					
						
							|  |  |  |     bug_report_page = "https://github.com/FelicitusNeko/meritous-ap/issues" | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | class MeritousWorld(World): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |         Meritous Gaiden is a procedurally generated bullet-hell dungeon crawl game. | 
					
						
							|  |  |  |         Five generations after the Orcus Dome incident, strange experiments conducted in a new | 
					
						
							|  |  |  |         structure on the moon are tearing at the very fabric of reality... | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     game: str = "Meritous" | 
					
						
							|  |  |  |     topology_present: False | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  |     web = MeritousWeb() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |     item_name_to_id = item_table | 
					
						
							|  |  |  |     location_name_to_id = location_table | 
					
						
							|  |  |  |     item_name_groups = item_groups | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     data_version = 2 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-08 11:16:36 +02:00
										 |  |  |     # NOTE: Remember to change this before this game goes live | 
					
						
							|  |  |  |     required_client_version = (0, 2, 4) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 16:46:59 -05:00
										 |  |  |     option_definitions = meritous_options | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self, world: MultiWorld, player: int): | 
					
						
							|  |  |  |         super(MeritousWorld, self).__init__(world, player) | 
					
						
							|  |  |  |         self.goal = 0 | 
					
						
							|  |  |  |         self.include_evolution_traps = False | 
					
						
							|  |  |  |         self.include_psi_keys = False | 
					
						
							|  |  |  |         self.item_cache_cost = 0 | 
					
						
							|  |  |  |         self.death_link = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @staticmethod | 
					
						
							|  |  |  |     def _is_progression(name): | 
					
						
							| 
									
										
										
										
											2022-05-27 19:52:14 -03:00
										 |  |  |         return "PSI Key" in name or name in [ | 
					
						
							|  |  |  |             "Cursed Seal", "Agate Knife", "Dodge Enhancer", | 
					
						
							|  |  |  |             "Shield Boost", "Metabolism", "Circuit Booster" | 
					
						
							|  |  |  |         ] | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							| 
									
										
										
										
											2022-06-14 11:05:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |         return MeritousItem(name, self._is_progression( | 
					
						
							|  |  |  |             name), item_table[name], self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_event(self, event: str): | 
					
						
							|  |  |  |         event = MeritousItem(event, True, None, self.player) | 
					
						
							|  |  |  |         event.type = "Victory" | 
					
						
							|  |  |  |         return event | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _create_item_in_quantities(self, name: str, qty: int) -> [Item]: | 
					
						
							|  |  |  |         return [self.create_item(name) for _ in range(0, qty)] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _make_crystals(self, qty: int) -> [MeritousItem]: | 
					
						
							|  |  |  |         crystal_pool = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for _ in range(0, qty): | 
					
						
							| 
									
										
										
										
											2022-06-14 11:05:28 -04:00
										 |  |  |             crystal_pool.append(self.create_filler()) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return crystal_pool | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-14 11:05:28 -04:00
										 |  |  |     def get_filler_item_name(self) -> str: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         rand_crystals = self.multiworld.random.randrange(0, 32) | 
					
						
							| 
									
										
										
										
											2022-06-14 11:05:28 -04:00
										 |  |  |         if rand_crystals < 16: | 
					
						
							|  |  |  |             return "Crystals x500" | 
					
						
							|  |  |  |         elif rand_crystals < 28: | 
					
						
							|  |  |  |             return "Crystals x1000" | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             return "Crystals x2000" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |     def generate_early(self): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.goal = self.multiworld.goal[self.player].value | 
					
						
							|  |  |  |         self.include_evolution_traps = self.multiworld.include_evolution_traps[self.player].value | 
					
						
							|  |  |  |         self.include_psi_keys = self.multiworld.include_psi_keys[self.player].value | 
					
						
							|  |  |  |         self.item_cache_cost = self.multiworld.item_cache_cost[self.player].value | 
					
						
							|  |  |  |         self.death_link = self.multiworld.death_link[self.player].value | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_regions(self): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         create_regions(self.multiworld, self.player) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_items(self): | 
					
						
							|  |  |  |         frequencies = [0, # Nothing [0] | 
					
						
							|  |  |  |                        25, 23, 22, # PSI Enhancements [1-3] | 
					
						
							|  |  |  |                        1, 1, 1, 1, 1, 1, 1, 1, 1, # Artifacts [4-12] | 
					
						
							|  |  |  |                        1, 1, 1, # PSI Keys [13-15] | 
					
						
							|  |  |  |                        0, 0, # Seal & Knife [16-17] | 
					
						
							|  |  |  |                        3] # Traps [18] | 
					
						
							|  |  |  |         location_count = len(location_table) - 2 | 
					
						
							|  |  |  |         item_pool = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not self.include_psi_keys: | 
					
						
							|  |  |  |             location_count -= 3 | 
					
						
							|  |  |  |             for i in range(3): | 
					
						
							|  |  |  |                 frequencies[i - 6] = 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not self.include_evolution_traps: | 
					
						
							|  |  |  |             frequencies[-1] = 0 | 
					
						
							|  |  |  |             location_count -= 3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for i, name in enumerate(item_table): | 
					
						
							|  |  |  |             if i < len(frequencies): | 
					
						
							|  |  |  |                 item_pool += self._create_item_in_quantities( | 
					
						
							|  |  |  |                     name, frequencies[i]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if len(item_pool) < location_count: | 
					
						
							|  |  |  |             item_pool += self._make_crystals(location_count - len(item_pool)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.itempool += item_pool | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def set_rules(self): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         set_rules(self.multiworld, self.player) | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def generate_basic(self): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.get_location("Place of Power", self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |             self.create_item("Cursed Seal")) | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.get_location("The Last Place You'll Look", self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |             self.create_item("Agate Knife")) | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.get_location("Wervyn Anixil", self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |             self.create_event("Victory")) | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         self.multiworld.get_location("Wervyn Anixil?", self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |             self.create_event("Full Victory")) | 
					
						
							|  |  |  |         for boss in ["Meridian", "Ataraxia", "Merodach"]: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             self.multiworld.get_location(f"{boss} Defeat", self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                 self.create_event(f"{boss} Defeated")) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not self.include_psi_keys: | 
					
						
							|  |  |  |             psi_keys = [] | 
					
						
							|  |  |  |             psi_key_storage = [] | 
					
						
							|  |  |  |             for i in range(0, 3): | 
					
						
							|  |  |  |                 psi_keys += [self.create_item(f"PSI Key {i + 1}")] | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |                 psi_key_storage += [self.multiworld.get_location( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                     f"PSI Key Storage {i + 1}", self.player)] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             fill_restrictive(self.multiworld, self.multiworld.get_all_state( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                 False), psi_key_storage, psi_keys) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not self.include_evolution_traps: | 
					
						
							|  |  |  |             for boss in ["Meridian", "Ataraxia", "Merodach"]: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |                 self.multiworld.get_location(boss, self.player).place_locked_item( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                     self.create_item("Evolution Trap")) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if self.goal == 0: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             self.multiworld.completion_condition[self.player] = lambda state: state.has_any( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                 ["Victory", "Full Victory"], self.player) | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             self.multiworld.completion_condition[self.player] = lambda state: state.has( | 
					
						
							| 
									
										
										
										
											2022-03-18 00:30:47 -03:00
										 |  |  |                 "Full Victory", self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def fill_slot_data(self) -> dict: | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             "goal": self.goal, | 
					
						
							|  |  |  |             "cost_scale": cost_scales[self.item_cache_cost], | 
					
						
							|  |  |  |             "death_link": self.death_link | 
					
						
							|  |  |  |         } |