Files
Archipelago/worlds/stardew_valley/content/unpacking.py
agilbert1412 1de91fab67 Stardew Valley: 7.x.x - The Jojapocalypse Update (#5432)
Major Content update for Stardew Valley

### Features
- New BundleRandomization Value: Meme Bundles - Over 100 custom bundles, designed to be jokes, references, trolls, etc
- New Setting: Bundles Per Room modifier
- New Setting: Backpack Size
- New Setting: Secretsanity - Checks for triggering easter eggs and secrets
- New Setting: Moviesanity - Checks for watching movies and sharing snacks with Villagers
- New Setting: Eatsanity - Checks for eating items
- New Setting: Hatsanity - Checks for wearing Hats
- New Setting: Start Without - Allows you to select any combination of various "starting" items, that you will actually not start with. Notably, tools, backpack slots, Day5 unlocks, etc.
- New Setting: Allowed Filler Items - Allows you to customize the filler items you'll get
- New Setting: Endgame Locations - Checks for various expensive endgame tasks and purchases
- New Shipsanity value: Crops and Fish
- New Settings: Jojapocalypse and settings to customize it
- Bundle Plando: Replaced with BundleWhitelist and BundleBlacklist, for more customization freedom
- Added a couple of Host.yaml settings to help hosts allow or ban specific difficult settings that could cause problems if the people don't know what they are signing up for.

Plus a truckload of improvements on the mod side, not seen in this PR.

### Removed features
- Integration for Stardew Valley Expanded. It is simply disabled, the code is all still there, but I'm extremely tired of providing tech support for it, plus Stardew Valley 1.7 was announced and that will break it again, so I'm done. When a maintainer steps up, it can be re-enabled.
2026-02-15 18:02:21 +01:00

102 lines
3.4 KiB
Python

from __future__ import annotations
from graphlib import TopologicalSorter
from typing import Iterable, Mapping, Callable
from .game_content import StardewContent, ContentPack, StardewFeatures
from .vanilla.base import base_game as base_game_content_pack
from ..data.game_item import Source
def unpack_content(features: StardewFeatures, packs: Iterable[ContentPack]) -> StardewContent:
# Base game is always registered first.
content = StardewContent(features)
packs_to_finalize = [base_game_content_pack]
register_pack(content, base_game_content_pack)
# Content packs are added in order based on their dependencies
sorter = TopologicalSorter()
packs_by_name = {p.name: p for p in packs}
# Build the dependency graph
for name, pack in packs_by_name.items():
sorter.add(name,
*pack.dependencies,
*(wd for wd in pack.weak_dependencies if wd in packs_by_name))
# Graph is traversed in BFS
sorter.prepare()
while sorter.is_active():
# Packs get shuffled in TopologicalSorter, most likely due to hash seeding.
for pack_name in sorted(sorter.get_ready()):
pack = packs_by_name[pack_name]
register_pack(content, pack)
sorter.done(pack_name)
packs_to_finalize.append(pack)
prune_inaccessible_items(content)
for pack in packs_to_finalize:
pack.finalize_hook(content)
# Maybe items without source should be removed at some point
return content
def register_pack(content: StardewContent, pack: ContentPack):
# register regions
# register entrances
register_sources_and_call_hook(content, pack.harvest_sources, pack.harvest_source_hook)
register_sources_and_call_hook(content, pack.shop_sources, pack.shop_source_hook)
register_sources_and_call_hook(content, pack.crafting_sources, pack.crafting_hook)
register_sources_and_call_hook(content, pack.artisan_good_sources, pack.artisan_good_hook)
for fish in pack.fishes:
content.fishes[fish.name] = fish
pack.fish_hook(content)
for villager in pack.villagers:
content.villagers[villager.name] = villager
pack.villager_hook(content)
for building in pack.farm_buildings:
content.farm_buildings[building.name] = building
pack.farm_building_hook(content)
for animal in pack.animals:
content.animals[animal.name] = animal
pack.animal_hook(content)
for skill in pack.skills:
content.skills[skill.name] = skill
pack.skill_hook(content)
for hat, sources in pack.hat_sources.items():
item = content.source_item(hat.clarified_name, *sources)
# Some sources may be filtered out. We don't want to register a hat without source.
if item.sources:
content.hats[hat.name] = hat
pack.hat_source_hook(content)
# register_quests
# ...
content.registered_packs.add(pack.name)
def register_sources_and_call_hook(content: StardewContent,
sources_by_item_name: Mapping[str, Iterable[Source]],
hook: Callable[[StardewContent], None]):
for item_name, sources in sources_by_item_name.items():
content.source_item(item_name, *sources)
hook(content)
def prune_inaccessible_items(content: StardewContent):
for item in list(content.game_items.values()):
if not item.sources:
content.game_items.pop(item.name)