| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | import csv | 
					
						
							|  |  |  | import enum | 
					
						
							|  |  |  | from dataclasses import dataclass | 
					
						
							|  |  |  | from random import Random | 
					
						
							|  |  |  | from typing import Optional, Dict, Protocol, List, FrozenSet | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | from . import data | 
					
						
							|  |  |  | from .options import StardewValleyOptions | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  | from .data.fish_data import legendary_fish, special_fish, all_fish | 
					
						
							|  |  |  | from .data.museum_data import all_museum_items | 
					
						
							|  |  |  | from .data.villagers_data import all_villagers | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | from .options import ExcludeGingerIsland, Friendsanity, ArcadeMachineLocations, SpecialOrderLocations, Cropsanity, Fishsanity, Museumsanity, FestivalLocations, SkillProgression, BuildingProgression, ToolProgression, ElevatorProgression, BackpackProgression | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  | from .strings.goal_names import Goal | 
					
						
							|  |  |  | from .strings.region_names import Region | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | LOCATION_CODE_OFFSET = 717000 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class LocationTags(enum.Enum): | 
					
						
							|  |  |  |     MANDATORY = enum.auto() | 
					
						
							|  |  |  |     BUNDLE = enum.auto() | 
					
						
							|  |  |  |     COMMUNITY_CENTER_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     CRAFTS_ROOM_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     PANTRY_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     FISH_TANK_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     BOILER_ROOM_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     BULLETIN_BOARD_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     VAULT_BUNDLE = enum.auto() | 
					
						
							|  |  |  |     COMMUNITY_CENTER_ROOM = enum.auto() | 
					
						
							|  |  |  |     BACKPACK = enum.auto() | 
					
						
							|  |  |  |     TOOL_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     HOE_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     PICKAXE_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     AXE_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     WATERING_CAN_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     TRASH_CAN_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     FISHING_ROD_UPGRADE = enum.auto() | 
					
						
							|  |  |  |     THE_MINES_TREASURE = enum.auto() | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     CROPSANITY = enum.auto() | 
					
						
							|  |  |  |     ELEVATOR = enum.auto() | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |     SKILL_LEVEL = enum.auto() | 
					
						
							|  |  |  |     FARMING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     FISHING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     FORAGING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     COMBAT_LEVEL = enum.auto() | 
					
						
							|  |  |  |     MINING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     BUILDING_BLUEPRINT = enum.auto() | 
					
						
							|  |  |  |     QUEST = enum.auto() | 
					
						
							|  |  |  |     ARCADE_MACHINE = enum.auto() | 
					
						
							|  |  |  |     ARCADE_MACHINE_VICTORY = enum.auto() | 
					
						
							|  |  |  |     JOTPK = enum.auto() | 
					
						
							|  |  |  |     JUNIMO_KART = enum.auto() | 
					
						
							|  |  |  |     HELP_WANTED = enum.auto() | 
					
						
							|  |  |  |     TRAVELING_MERCHANT = enum.auto() | 
					
						
							|  |  |  |     FISHSANITY = enum.auto() | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |     MUSEUM_MILESTONES = enum.auto() | 
					
						
							|  |  |  |     MUSEUM_DONATIONS = enum.auto() | 
					
						
							|  |  |  |     FRIENDSANITY = enum.auto() | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     FESTIVAL = enum.auto() | 
					
						
							|  |  |  |     FESTIVAL_HARD = enum.auto() | 
					
						
							|  |  |  |     SPECIAL_ORDER_BOARD = enum.auto() | 
					
						
							|  |  |  |     SPECIAL_ORDER_QI = enum.auto() | 
					
						
							|  |  |  |     GINGER_ISLAND = enum.auto() | 
					
						
							|  |  |  |     WALNUT_PURCHASE = enum.auto() | 
					
						
							|  |  |  |     # Skill Mods | 
					
						
							|  |  |  |     LUCK_LEVEL = enum.auto() | 
					
						
							|  |  |  |     BINNING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     COOKING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     SOCIALIZING_LEVEL = enum.auto() | 
					
						
							|  |  |  |     MAGIC_LEVEL = enum.auto() | 
					
						
							|  |  |  |     ARCHAEOLOGY_LEVEL = enum.auto() | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @dataclass(frozen=True) | 
					
						
							|  |  |  | class LocationData: | 
					
						
							|  |  |  |     code_without_offset: Optional[int] | 
					
						
							|  |  |  |     region: str | 
					
						
							|  |  |  |     name: str | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     mod_name: Optional[str] = None | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |     tags: FrozenSet[LocationTags] = frozenset() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @property | 
					
						
							|  |  |  |     def code(self) -> Optional[int]: | 
					
						
							|  |  |  |         return LOCATION_CODE_OFFSET + self.code_without_offset if self.code_without_offset is not None else None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class StardewLocationCollector(Protocol): | 
					
						
							|  |  |  |     def __call__(self, name: str, code: Optional[int], region: str) -> None: | 
					
						
							|  |  |  |         raise NotImplementedError | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def load_location_csv() -> List[LocationData]: | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         from importlib.resources import files | 
					
						
							|  |  |  |     except ImportError: | 
					
						
							|  |  |  |         from importlib_resources import files | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     with files(data).joinpath("locations.csv").open() as file: | 
					
						
							|  |  |  |         reader = csv.DictReader(file) | 
					
						
							|  |  |  |         return [LocationData(int(location["id"]) if location["id"] else None, | 
					
						
							|  |  |  |                              location["region"], | 
					
						
							|  |  |  |                              location["name"], | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |                              str(location["mod_name"]) if location["mod_name"] else None, | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |                              frozenset(LocationTags[group] | 
					
						
							|  |  |  |                                        for group in location["tags"].split(",") | 
					
						
							|  |  |  |                                        if group)) | 
					
						
							|  |  |  |                 for location in reader] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | events_locations = [ | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     LocationData(None, Region.farm_house, Goal.grandpa_evaluation), | 
					
						
							|  |  |  |     LocationData(None, Region.community_center, Goal.community_center), | 
					
						
							|  |  |  |     LocationData(None, Region.mines_floor_120, Goal.bottom_of_the_mines), | 
					
						
							|  |  |  |     LocationData(None, Region.skull_cavern_100, Goal.cryptic_note), | 
					
						
							|  |  |  |     LocationData(None, Region.farm, Goal.master_angler), | 
					
						
							|  |  |  |     LocationData(None, Region.museum, Goal.complete_museum), | 
					
						
							|  |  |  |     LocationData(None, Region.farm_house, Goal.full_house), | 
					
						
							|  |  |  |     LocationData(None, Region.island_west, Goal.greatest_walnut_hunter), | 
					
						
							|  |  |  |     LocationData(None, Region.qi_walnut_room, Goal.perfection), | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | all_locations = load_location_csv() + events_locations | 
					
						
							|  |  |  | location_table: Dict[str, LocationData] = {location.name: location for location in all_locations} | 
					
						
							|  |  |  | locations_by_tag: Dict[LocationTags, List[LocationData]] = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def initialize_groups(): | 
					
						
							|  |  |  |     for location in all_locations: | 
					
						
							|  |  |  |         for tag in location.tags: | 
					
						
							|  |  |  |             location_group = locations_by_tag.get(tag, list()) | 
					
						
							|  |  |  |             location_group.append(location) | 
					
						
							|  |  |  |             locations_by_tag[tag] = location_group | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | initialize_groups() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_cropsanity_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.cropsanity == Cropsanity.option_disabled: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cropsanity_locations = locations_by_tag[LocationTags.CROPSANITY] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     cropsanity_locations = filter_ginger_island(options, cropsanity_locations) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     randomized_locations.extend(cropsanity_locations) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | def extend_help_wanted_quests(randomized_locations: List[LocationData], desired_number_of_quests: int): | 
					
						
							|  |  |  |     for i in range(0, desired_number_of_quests): | 
					
						
							|  |  |  |         batch = i // 7 | 
					
						
							|  |  |  |         index_this_batch = i % 7 | 
					
						
							|  |  |  |         if index_this_batch < 4: | 
					
						
							|  |  |  |             randomized_locations.append( | 
					
						
							|  |  |  |                 location_table[f"Help Wanted: Item Delivery {(batch * 4) + index_this_batch + 1}"]) | 
					
						
							|  |  |  |         elif index_this_batch == 4: | 
					
						
							|  |  |  |             randomized_locations.append(location_table[f"Help Wanted: Fishing {batch + 1}"]) | 
					
						
							|  |  |  |         elif index_this_batch == 5: | 
					
						
							|  |  |  |             randomized_locations.append(location_table[f"Help Wanted: Slay Monsters {batch + 1}"]) | 
					
						
							|  |  |  |         elif index_this_batch == 6: | 
					
						
							|  |  |  |             randomized_locations.append(location_table[f"Help Wanted: Gathering {batch + 1}"]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_fishsanity_locations(randomized_locations: List[LocationData], options: StardewValleyOptions, random: Random): | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |     prefix = "Fishsanity: " | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if options.fishsanity == Fishsanity.option_none: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         return | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.fishsanity == Fishsanity.option_legendaries: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         randomized_locations.extend(location_table[f"{prefix}{legendary.name}"] for legendary in legendary_fish) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.fishsanity == Fishsanity.option_special: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         randomized_locations.extend(location_table[f"{prefix}{special.name}"] for special in special_fish) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.fishsanity == Fishsanity.option_randomized: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         fish_locations = [location_table[f"{prefix}{fish.name}"] for fish in all_fish if random.random() < 0.4] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         randomized_locations.extend(filter_ginger_island(options, fish_locations)) | 
					
						
							|  |  |  |     elif options.fishsanity == Fishsanity.option_all: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         fish_locations = [location_table[f"{prefix}{fish.name}"] for fish in all_fish] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         randomized_locations.extend(filter_ginger_island(options, fish_locations)) | 
					
						
							|  |  |  |     elif options.fishsanity == Fishsanity.option_exclude_legendaries: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         fish_locations = [location_table[f"{prefix}{fish.name}"] for fish in all_fish if fish not in legendary_fish] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         randomized_locations.extend(filter_ginger_island(options, fish_locations)) | 
					
						
							|  |  |  |     elif options.fishsanity == Fishsanity.option_exclude_hard_fish: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         fish_locations = [location_table[f"{prefix}{fish.name}"] for fish in all_fish if fish.difficulty < 80] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         randomized_locations.extend(filter_ginger_island(options, fish_locations)) | 
					
						
							|  |  |  |     elif options.fishsanity == Fishsanity.option_only_easy_fish: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         fish_locations = [location_table[f"{prefix}{fish.name}"] for fish in all_fish if fish.difficulty < 50] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         randomized_locations.extend(filter_ginger_island(options, fish_locations)) | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_museumsanity_locations(randomized_locations: List[LocationData], options: StardewValleyOptions, random: Random): | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |     prefix = "Museumsanity: " | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if options.museumsanity == Museumsanity.option_none: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         return | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.museumsanity == Museumsanity.option_milestones: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         randomized_locations.extend(locations_by_tag[LocationTags.MUSEUM_MILESTONES]) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.museumsanity == Museumsanity.option_randomized: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         randomized_locations.extend(location_table[f"{prefix}{museum_item.name}"] | 
					
						
							|  |  |  |                                     for museum_item in all_museum_items if random.random() < 0.4) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     elif options.museumsanity == Museumsanity.option_all: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         randomized_locations.extend(location_table[f"{prefix}{museum_item.name}"] for museum_item in all_museum_items) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_friendsanity_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.friendsanity == Friendsanity.option_none: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         return | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     exclude_leo = options.exclude_ginger_island == ExcludeGingerIsland.option_true | 
					
						
							|  |  |  |     exclude_non_bachelors = options.friendsanity == Friendsanity.option_bachelors | 
					
						
							|  |  |  |     exclude_locked_villagers = options.friendsanity == Friendsanity.option_starting_npcs or \ | 
					
						
							|  |  |  |                                options.friendsanity == Friendsanity.option_bachelors | 
					
						
							|  |  |  |     include_post_marriage_hearts = options.friendsanity == Friendsanity.option_all_with_marriage | 
					
						
							|  |  |  |     heart_size = options.friendsanity_heart_size | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |     for villager in all_villagers: | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |         if villager.mod_name not in options.mods and villager.mod_name is not None: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |             continue | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         if not villager.available and exclude_locked_villagers: | 
					
						
							|  |  |  |             continue | 
					
						
							|  |  |  |         if not villager.bachelor and exclude_non_bachelors: | 
					
						
							|  |  |  |             continue | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         if villager.name == "Leo" and exclude_leo: | 
					
						
							|  |  |  |             continue | 
					
						
							|  |  |  |         heart_cap = 8 if villager.bachelor else 10 | 
					
						
							|  |  |  |         if include_post_marriage_hearts and villager.bachelor: | 
					
						
							|  |  |  |             heart_cap = 14 | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |         for heart in range(1, 15): | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |             if heart > heart_cap: | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             if heart % heart_size == 0 or heart == heart_cap: | 
					
						
							| 
									
										
										
										
											2023-04-10 19:44:59 -04:00
										 |  |  |                 randomized_locations.append(location_table[f"Friendsanity: {villager.name} {heart} <3"]) | 
					
						
							|  |  |  |     if not exclude_non_bachelors: | 
					
						
							|  |  |  |         for heart in range(1, 6): | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |             if heart % heart_size == 0 or heart == 5: | 
					
						
							|  |  |  |                 randomized_locations.append(location_table[f"Friendsanity: Pet {heart} <3"]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_festival_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.festival_locations == FestivalLocations.option_disabled: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     festival_locations = locations_by_tag[LocationTags.FESTIVAL] | 
					
						
							|  |  |  |     randomized_locations.extend(festival_locations) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     extend_hard_festival_locations(randomized_locations, options) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_hard_festival_locations(randomized_locations, options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.festival_locations != FestivalLocations.option_hard: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     hard_festival_locations = locations_by_tag[LocationTags.FESTIVAL_HARD] | 
					
						
							|  |  |  |     randomized_locations.extend(hard_festival_locations) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_special_order_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.special_order_locations == SpecialOrderLocations.option_disabled: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     include_island = options.exclude_ginger_island == ExcludeGingerIsland.option_false | 
					
						
							|  |  |  |     board_locations = filter_disabled_locations(options, locations_by_tag[LocationTags.SPECIAL_ORDER_BOARD]) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     randomized_locations.extend(board_locations) | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if options.special_order_locations == SpecialOrderLocations.option_board_qi and include_island: | 
					
						
							|  |  |  |         include_arcade = options.arcade_machine_locations != ArcadeMachineLocations.option_disabled | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         qi_orders = [location for location in locations_by_tag[LocationTags.SPECIAL_ORDER_QI] if include_arcade or LocationTags.JUNIMO_KART not in location.tags] | 
					
						
							|  |  |  |         randomized_locations.extend(qi_orders) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_walnut_purchase_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.exclude_ginger_island == ExcludeGingerIsland.option_true: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  |     randomized_locations.append(location_table["Repair Ticket Machine"]) | 
					
						
							|  |  |  |     randomized_locations.append(location_table["Repair Boat Hull"]) | 
					
						
							|  |  |  |     randomized_locations.append(location_table["Repair Boat Anchor"]) | 
					
						
							|  |  |  |     randomized_locations.append(location_table["Open Professor Snail Cave"]) | 
					
						
							|  |  |  |     randomized_locations.append(location_table["Complete Island Field Office"]) | 
					
						
							|  |  |  |     randomized_locations.extend(locations_by_tag[LocationTags.WALNUT_PURCHASE]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_mandatory_locations(randomized_locations: List[LocationData], options): | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     mandatory_locations = [location for location in locations_by_tag[LocationTags.MANDATORY]] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     filtered_mandatory_locations = filter_disabled_locations(options, mandatory_locations) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     randomized_locations.extend(filtered_mandatory_locations) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_backpack_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.backpack_progression == BackpackProgression.option_vanilla: | 
					
						
							| 
									
										
										
										
											2023-07-24 19:52:15 -04:00
										 |  |  |         return | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     backpack_locations = [location for location in locations_by_tag[LocationTags.BACKPACK]] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     filtered_backpack_locations = filter_modded_locations(options, backpack_locations) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     randomized_locations.extend(filtered_backpack_locations) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def extend_elevator_locations(randomized_locations: List[LocationData], options: StardewValleyOptions): | 
					
						
							|  |  |  |     if options.elevator_progression == ElevatorProgression.option_vanilla: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         return | 
					
						
							|  |  |  |     elevator_locations = [location for location in locations_by_tag[LocationTags.ELEVATOR]] | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     filtered_elevator_locations = filter_modded_locations(options, elevator_locations) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     randomized_locations.extend(filtered_elevator_locations) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def create_locations(location_collector: StardewLocationCollector, | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |                      options: StardewValleyOptions, | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |                      random: Random): | 
					
						
							|  |  |  |     randomized_locations = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     extend_mandatory_locations(randomized_locations, options) | 
					
						
							|  |  |  |     extend_backpack_locations(randomized_locations, options) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if not options.tool_progression == ToolProgression.option_vanilla: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         randomized_locations.extend(locations_by_tag[LocationTags.TOOL_UPGRADE]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     extend_elevator_locations(randomized_locations, options) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if not options.skill_progression == SkillProgression.option_vanilla: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         for location in locations_by_tag[LocationTags.SKILL_LEVEL]: | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |             if location.mod_name is None or location.mod_name in options.mods: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |                 randomized_locations.append(location_table[location.name]) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if not options.building_progression == BuildingProgression.option_vanilla: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |         for location in locations_by_tag[LocationTags.BUILDING_BLUEPRINT]: | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |             if location.mod_name is None or location.mod_name in options.mods: | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |                 randomized_locations.append(location_table[location.name]) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if options.arcade_machine_locations != ArcadeMachineLocations.option_disabled: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         randomized_locations.extend(locations_by_tag[LocationTags.ARCADE_MACHINE_VICTORY]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     if options.arcade_machine_locations == ArcadeMachineLocations.option_full_shuffling: | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  |         randomized_locations.extend(locations_by_tag[LocationTags.ARCADE_MACHINE]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     extend_cropsanity_locations(randomized_locations, options) | 
					
						
							|  |  |  |     extend_help_wanted_quests(randomized_locations, options.help_wanted_locations.value) | 
					
						
							|  |  |  |     extend_fishsanity_locations(randomized_locations, options, random) | 
					
						
							|  |  |  |     extend_museumsanity_locations(randomized_locations, options, random) | 
					
						
							|  |  |  |     extend_friendsanity_locations(randomized_locations, options) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  |     extend_festival_locations(randomized_locations, options) | 
					
						
							|  |  |  |     extend_special_order_locations(randomized_locations, options) | 
					
						
							|  |  |  |     extend_walnut_purchase_locations(randomized_locations, options) | 
					
						
							| 
									
										
										
										
											2023-02-26 19:19:15 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for location_data in randomized_locations: | 
					
						
							|  |  |  |         location_collector(location_data.name, location_data.code, location_data.region) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def filter_ginger_island(options: StardewValleyOptions, locations: List[LocationData]) -> List[LocationData]: | 
					
						
							|  |  |  |     include_island = options.exclude_ginger_island == ExcludeGingerIsland.option_false | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     return [location for location in locations if include_island or LocationTags.GINGER_ISLAND not in location.tags] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def filter_modded_locations(options: StardewValleyOptions, locations: List[LocationData]) -> List[LocationData]: | 
					
						
							|  |  |  |     current_mod_names = options.mods | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     return [location for location in locations if location.mod_name is None or location.mod_name in current_mod_names] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 15:30:20 -05:00
										 |  |  | def filter_disabled_locations(options: StardewValleyOptions, locations: List[LocationData]) -> List[LocationData]: | 
					
						
							|  |  |  |     locations_first_pass = filter_ginger_island(options, locations) | 
					
						
							|  |  |  |     locations_second_pass = filter_modded_locations(options, locations_first_pass) | 
					
						
							| 
									
										
										
										
											2023-07-19 14:26:38 -04:00
										 |  |  |     return locations_second_pass |