| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  | from typing import Dict, List, Set, Tuple, TextIO, Union | 
					
						
							|  |  |  | from BaseClasses import Item, MultiWorld, Tutorial, ItemClassification | 
					
						
							| 
									
										
										
										
											2023-03-08 20:05:30 +01:00
										 |  |  | from .Items import get_item_names_per_category | 
					
						
							|  |  |  | from .Items import item_table, starter_melee_weapons, starter_spells, filler_items, starter_progression_items | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  | from .Locations import get_location_datas, EventId | 
					
						
							| 
									
										
										
										
											2022-02-04 21:53:47 +01:00
										 |  |  | from .Options import is_option_enabled, get_option_value, timespinner_options | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  | from .PreCalculatedWeights import PreCalculatedWeights | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  | from .Regions import create_regions_and_locations | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  | from worlds.AutoWorld import World, WebWorld | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 22:39:39 +02:00
										 |  |  | class TimespinnerWebWorld(WebWorld): | 
					
						
							|  |  |  |     theme = "ice" | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  |     setup = Tutorial( | 
					
						
							|  |  |  |         "Multiworld Setup Guide", | 
					
						
							|  |  |  |         "A guide to setting up the Timespinner randomizer connected to an Archipelago Multiworld", | 
					
						
							|  |  |  |         "English", | 
					
						
							|  |  |  |         "setup_en.md", | 
					
						
							|  |  |  |         "setup/en", | 
					
						
							|  |  |  |         ["Jarno"] | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setup_de = Tutorial( | 
					
						
							|  |  |  |         setup.tutorial_name, | 
					
						
							|  |  |  |         setup.description, | 
					
						
							|  |  |  |         "Deutsch", | 
					
						
							|  |  |  |         "setup_de.md", | 
					
						
							| 
									
										
										
										
											2022-06-25 00:29:25 +02:00
										 |  |  |         "setup/de", | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  |         ["Grrmo", "Fynxes", "Blaze0168"] | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tutorials = [setup, setup_de] | 
					
						
							| 
									
										
										
										
											2022-02-19 17:43:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | class TimespinnerWorld(World): | 
					
						
							| 
									
										
										
										
											2021-09-30 19:51:07 +02:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Timespinner is a beautiful metroidvania inspired by classic 90s action-platformers. | 
					
						
							|  |  |  |     Travel back in time to change fate itself. Join timekeeper Lunais on her quest for revenge against the empire that killed her family. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 16:46:59 -05:00
										 |  |  |     option_definitions = timespinner_options | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  |     game = "Timespinner" | 
					
						
							|  |  |  |     topology_present = True | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |     data_version = 11 | 
					
						
							| 
									
										
										
										
											2022-04-01 22:39:39 +02:00
										 |  |  |     web = TimespinnerWebWorld() | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |     required_client_version = (0, 3, 7) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     item_name_to_id = {name: data.code for name, data in item_table.items()} | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     location_name_to_id = {location.name: location.code for location in get_location_datas(None, None, None)} | 
					
						
							| 
									
										
										
										
											2021-09-30 19:51:07 +02:00
										 |  |  |     item_name_groups = get_item_names_per_category() | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |     precalculated_weights: PreCalculatedWeights | 
					
						
							| 
									
										
										
										
											2021-12-11 21:05:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self, world: MultiWorld, player: int): | 
					
						
							|  |  |  |         super().__init__(world, player) | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |         self.precalculated_weights = PreCalculatedWeights(world, player) | 
					
						
							| 
									
										
										
										
											2021-12-11 21:05:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def generate_early(self) -> None: | 
					
						
							| 
									
										
										
										
											2021-12-14 14:04:34 +01:00
										 |  |  |         # in generate_early the start_inventory isnt copied over to precollected_items yet, so we can still modify the options directly | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         if self.multiworld.start_inventory[self.player].value.pop('Meyef', 0) > 0: | 
					
						
							|  |  |  |             self.multiworld.StartWithMeyef[self.player].value = self.multiworld.StartWithMeyef[self.player].option_true | 
					
						
							|  |  |  |         if self.multiworld.start_inventory[self.player].value.pop('Talaria Attachment', 0) > 0: | 
					
						
							|  |  |  |             self.multiworld.QuickSeed[self.player].value = self.multiworld.QuickSeed[self.player].option_true | 
					
						
							|  |  |  |         if self.multiworld.start_inventory[self.player].value.pop('Jewelry Box', 0) > 0: | 
					
						
							|  |  |  |             self.multiworld.StartWithJewelryBox[self.player].value = self.multiworld.StartWithJewelryBox[self.player].option_true | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def create_regions(self) -> None:  | 
					
						
							|  |  |  |         create_regions_and_locations(self.multiworld, self.player, self.precalculated_weights) | 
					
						
							| 
									
										
										
										
											2021-09-30 19:51:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def create_items(self) -> None:  | 
					
						
							|  |  |  |         self.create_and_assign_event_items() | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         excluded_items: Set[str] = self.get_excluded_items() | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         self.assign_starter_items(excluded_items) | 
					
						
							| 
									
										
										
										
											2023-03-08 20:05:30 +01:00
										 |  |  |         self.place_first_progression_item(excluded_items) | 
					
						
							| 
									
										
										
										
											2021-09-30 19:51:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         self.multiworld.itempool += self.get_item_pool(excluded_items) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def set_rules(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |         final_boss: str | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         if self.is_option_enabled("DadPercent"): | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |             final_boss = "Killed Emperor" | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             final_boss = "Killed Nightmare" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.multiworld.completion_condition[self.player] = lambda state: state.has(final_boss, self.player)  | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 12:37:06 +02:00
										 |  |  |     def fill_slot_data(self) -> Dict[str, object]: | 
					
						
							|  |  |  |         slot_data: Dict[str, object] = {} | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |         ap_specific_settings: Set[str] = {"RisingTidesOverrides", "TrapChance"} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  |         for option_name in timespinner_options: | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |             if (option_name not in ap_specific_settings): | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |                 slot_data[option_name] = self.get_option_value(option_name) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-30 19:51:07 +02:00
										 |  |  |         slot_data["StinkyMaw"] = True | 
					
						
							|  |  |  |         slot_data["ProgressiveVerticalMovement"] = False | 
					
						
							|  |  |  |         slot_data["ProgressiveKeycards"] = False | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         slot_data["PersonalItems"] = self.get_personal_items() | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |         slot_data["PyramidKeysGate"] = self.precalculated_weights.pyramid_keys_unlock | 
					
						
							|  |  |  |         slot_data["PresentGate"] = self.precalculated_weights.present_key_unlock | 
					
						
							|  |  |  |         slot_data["PastGate"] = self.precalculated_weights.past_key_unlock | 
					
						
							|  |  |  |         slot_data["TimeGate"] = self.precalculated_weights.time_key_unlock | 
					
						
							|  |  |  |         slot_data["Basement"] = int(self.precalculated_weights.flood_basement) + \ | 
					
						
							|  |  |  |                                 int(self.precalculated_weights.flood_basement_high) | 
					
						
							|  |  |  |         slot_data["Xarion"] = self.precalculated_weights.flood_xarion | 
					
						
							|  |  |  |         slot_data["Maw"] = self.precalculated_weights.flood_maw | 
					
						
							|  |  |  |         slot_data["PyramidShaft"] = self.precalculated_weights.flood_pyramid_shaft | 
					
						
							|  |  |  |         slot_data["BackPyramid"] = self.precalculated_weights.flood_pyramid_back | 
					
						
							|  |  |  |         slot_data["CastleMoat"] = self.precalculated_weights.flood_moat | 
					
						
							|  |  |  |         slot_data["CastleCourtyard"] = self.precalculated_weights.flood_courtyard | 
					
						
							|  |  |  |         slot_data["LakeDesolation"] = self.precalculated_weights.flood_lake_desolation | 
					
						
							|  |  |  |         slot_data["DryLakeSerene"] = self.precalculated_weights.dry_lake_serene | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return slot_data | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def write_spoiler_header(self, spoiler_handle: TextIO) -> None: | 
					
						
							|  |  |  |         if self.is_option_enabled("UnchainedKeys"): | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |             spoiler_handle.write(f'Modern Warp Beacon unlock:       {self.precalculated_weights.present_key_unlock}\n') | 
					
						
							|  |  |  |             spoiler_handle.write(f'Timeworn Warp Beacon unlock:     {self.precalculated_weights.past_key_unlock}\n') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |             if self.is_option_enabled("EnterSandman"): | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |                 spoiler_handle.write(f'Mysterious Warp Beacon unlock:   {self.precalculated_weights.time_key_unlock}\n') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             spoiler_handle.write(f'Twin Pyramid Keys unlock:        {self.precalculated_weights.pyramid_keys_unlock}\n') | 
					
						
							|  |  |  |         | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         if self.is_option_enabled("RisingTides"): | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  |             flooded_areas: List[str] = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_basement: | 
					
						
							|  |  |  |                 if self.precalculated_weights.flood_basement_high: | 
					
						
							|  |  |  |                     flooded_areas.append("Castle Basement") | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     flooded_areas.append("Castle Basement (Savepoint available)") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_xarion: | 
					
						
							|  |  |  |                 flooded_areas.append("Xarion (boss)") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_maw: | 
					
						
							|  |  |  |                 flooded_areas.append("Maw (caves + boss)") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_pyramid_shaft: | 
					
						
							|  |  |  |                 flooded_areas.append("Ancient Pyramid Shaft") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_pyramid_back: | 
					
						
							|  |  |  |                 flooded_areas.append("Sandman\\Nightmare (boss)") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_moat: | 
					
						
							|  |  |  |                 flooded_areas.append("Castle Ramparts Moat") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_courtyard: | 
					
						
							|  |  |  |                 flooded_areas.append("Castle Courtyard") | 
					
						
							|  |  |  |             if self.precalculated_weights.flood_lake_desolation: | 
					
						
							|  |  |  |                 flooded_areas.append("Lake Desolation") | 
					
						
							| 
									
										
										
										
											2023-03-04 16:31:44 +01:00
										 |  |  |             if not self.precalculated_weights.dry_lake_serene: | 
					
						
							|  |  |  |                 flooded_areas.append("Lake Serene") | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if len(flooded_areas) == 0: | 
					
						
							|  |  |  |                 flooded_areas_string: str = "None" | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 flooded_areas_string: str = ", ".join(flooded_areas) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             spoiler_handle.write(f'Flooded Areas:                   {flooded_areas_string}\n') | 
					
						
							| 
									
										
										
										
											2021-12-11 21:05:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							|  |  |  |         data = item_table[name] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if data.useful: | 
					
						
							|  |  |  |             classification = ItemClassification.useful | 
					
						
							|  |  |  |         elif data.progression: | 
					
						
							|  |  |  |             classification = ItemClassification.progression | 
					
						
							|  |  |  |         elif data.trap: | 
					
						
							|  |  |  |             classification = ItemClassification.trap | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |             classification = ItemClassification.filler | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |         item = Item(name, classification, data.code, self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not item.advancement: | 
					
						
							|  |  |  |             return item | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (name == 'Tablet' or name == 'Library Keycard V') and not self.is_option_enabled("DownloadableItems"): | 
					
						
							|  |  |  |             item.classification = ItemClassification.filler | 
					
						
							|  |  |  |         elif name == 'Oculus Ring' and not self.is_option_enabled("EyeSpy"): | 
					
						
							|  |  |  |             item.classification = ItemClassification.filler | 
					
						
							|  |  |  |         elif (name == 'Kobo' or name == 'Merchant Crow') and not self.is_option_enabled("GyreArchives"): | 
					
						
							|  |  |  |             item.classification = ItemClassification.filler | 
					
						
							|  |  |  |         elif name in {"Timeworn Warp Beacon", "Modern Warp Beacon", "Mysterious Warp Beacon"} \ | 
					
						
							|  |  |  |                 and not self.is_option_enabled("UnchainedKeys"): | 
					
						
							|  |  |  |             item.classification = ItemClassification.filler | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         return item | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def get_filler_item_name(self) -> str: | 
					
						
							|  |  |  |         trap_chance: int = self.get_option_value("TrapChance") | 
					
						
							|  |  |  |         enabled_traps: List[str] = self.get_option_value("Traps") | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         if self.multiworld.random.random() < (trap_chance / 100) and enabled_traps: | 
					
						
							|  |  |  |             return self.multiworld.random.choice(enabled_traps) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             return self.multiworld.random.choice(filler_items)  | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def get_excluded_items(self) -> Set[str]: | 
					
						
							|  |  |  |         excluded_items: Set[str] = set() | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         if self.is_option_enabled("StartWithJewelryBox"): | 
					
						
							|  |  |  |             excluded_items.add('Jewelry Box') | 
					
						
							|  |  |  |         if self.is_option_enabled("StartWithMeyef"): | 
					
						
							|  |  |  |             excluded_items.add('Meyef') | 
					
						
							|  |  |  |         if self.is_option_enabled("QuickSeed"): | 
					
						
							|  |  |  |             excluded_items.add('Talaria Attachment') | 
					
						
							| 
									
										
										
										
											2021-12-12 23:43:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         if self.is_option_enabled("UnchainedKeys"): | 
					
						
							|  |  |  |             excluded_items.add('Twin Pyramid Key') | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |             if not self.is_option_enabled("EnterSandman"): | 
					
						
							|  |  |  |                 excluded_items.add('Mysterious Warp Beacon') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             excluded_items.add('Timeworn Warp Beacon') | 
					
						
							|  |  |  |             excluded_items.add('Modern Warp Beacon') | 
					
						
							|  |  |  |             excluded_items.add('Mysterious Warp Beacon') | 
					
						
							| 
									
										
										
										
											2021-09-25 02:31:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         for item in self.multiworld.precollected_items[self.player]: | 
					
						
							|  |  |  |             if item.name not in self.item_name_groups['UseItem']: | 
					
						
							|  |  |  |                 excluded_items.add(item.name) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         return excluded_items | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def assign_starter_items(self, excluded_items: Set[str]) -> None: | 
					
						
							|  |  |  |         non_local_items: Set[str] = self.multiworld.non_local_items[self.player].value | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         local_starter_melee_weapons = tuple(item for item in starter_melee_weapons if item not in non_local_items) | 
					
						
							|  |  |  |         if not local_starter_melee_weapons: | 
					
						
							|  |  |  |             if 'Plasma Orb' in non_local_items: | 
					
						
							|  |  |  |                 raise Exception("Atleast one melee orb must be local") | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 local_starter_melee_weapons = ('Plasma Orb',) | 
					
						
							| 
									
										
										
										
											2021-09-25 02:31:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         local_starter_spells = tuple(item for item in starter_spells if item not in non_local_items) | 
					
						
							|  |  |  |         if not local_starter_spells: | 
					
						
							|  |  |  |             if 'Lightwall' in non_local_items: | 
					
						
							|  |  |  |                 raise Exception("Atleast one spell must be local") | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 local_starter_spells = ('Lightwall',) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         self.assign_starter_item(excluded_items, 'Tutorial: Yo Momma 1', local_starter_melee_weapons) | 
					
						
							|  |  |  |         self.assign_starter_item(excluded_items, 'Tutorial: Yo Momma 2', local_starter_spells) | 
					
						
							| 
									
										
										
										
											2021-09-25 02:31:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def assign_starter_item(self, excluded_items: Set[str], location: str, item_list: Tuple[str, ...]) -> None: | 
					
						
							|  |  |  |         item_name = self.multiworld.random.choice(item_list) | 
					
						
							| 
									
										
										
										
											2023-02-19 21:22:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 20:05:30 +01:00
										 |  |  |         self.place_locked_item(excluded_items, location, item_name) | 
					
						
							| 
									
										
										
										
											2021-10-10 13:05:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 20:05:30 +01:00
										 |  |  |     def place_first_progression_item(self, excluded_items: Set[str]) -> None: | 
					
						
							|  |  |  |         if self.is_option_enabled("QuickSeed") or self.is_option_enabled("Inverted") \ | 
					
						
							|  |  |  |                 or self.precalculated_weights.flood_lake_desolation: | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for item in self.multiworld.precollected_items[self.player]: | 
					
						
							|  |  |  |             if item.name in starter_progression_items and not item.name in excluded_items: | 
					
						
							|  |  |  |                 return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local_starter_progression_items = tuple( | 
					
						
							|  |  |  |             item for item in starter_progression_items  | 
					
						
							|  |  |  |                 if item not in excluded_items and item not in self.multiworld.non_local_items[self.player].value) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not local_starter_progression_items: | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         progression_item = self.multiworld.random.choice(local_starter_progression_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.multiworld.local_early_items[self.player][progression_item] = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def place_locked_item(self, excluded_items: Set[str], location: str, item: str) -> None: | 
					
						
							|  |  |  |         excluded_items.add(item) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         item = self.create_item(item) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         self.multiworld.get_location(location, self.player).place_locked_item(item) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def get_item_pool(self, excluded_items: Set[str]) -> List[Item]: | 
					
						
							|  |  |  |         pool: List[Item] = [] | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         for name, data in item_table.items(): | 
					
						
							|  |  |  |             if name not in excluded_items: | 
					
						
							|  |  |  |                 for _ in range(data.count): | 
					
						
							|  |  |  |                     item = self.create_item(name) | 
					
						
							|  |  |  |                     pool.append(item) | 
					
						
							| 
									
										
										
										
											2021-09-25 02:31:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         for _ in range(len(self.multiworld.get_unfilled_locations(self.player)) - len(pool)): | 
					
						
							|  |  |  |             item = self.create_item(self.get_filler_item_name()) | 
					
						
							|  |  |  |             pool.append(item) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         return pool | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def create_and_assign_event_items(self) -> None: | 
					
						
							|  |  |  |         for location in self.multiworld.get_locations(self.player): | 
					
						
							|  |  |  |             if location.address == EventId: | 
					
						
							|  |  |  |                 item = Item(location.name, ItemClassification.progression, EventId, self.player) | 
					
						
							|  |  |  |                 location.place_locked_item(item) | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def get_personal_items(self) -> Dict[int, int]: | 
					
						
							|  |  |  |         personal_items: Dict[int, int] = {} | 
					
						
							| 
									
										
										
										
											2021-09-25 02:31:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         for location in self.multiworld.get_locations(self.player): | 
					
						
							|  |  |  |             if location.address and location.item and location.item.code and location.item.player == self.player: | 
					
						
							|  |  |  |                 personal_items[location.address] = location.item.code | 
					
						
							| 
									
										
										
										
											2021-09-24 04:07:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |         return personal_items | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     def is_option_enabled(self, option: str) -> bool: | 
					
						
							|  |  |  |         return is_option_enabled(self.multiworld, self.player, option) | 
					
						
							| 
									
										
										
										
											2022-06-22 20:31:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 08:16:05 +01:00
										 |  |  |     def get_option_value(self, option: str) -> Union[int, Dict, List]: | 
					
						
							|  |  |  |         return get_option_value(self.multiworld, self.player, option) |