Files
Archipelago/worlds/stardew_valley/logic/source_logic.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

134 lines
5.2 KiB
Python

import functools
from typing import Any, Iterable
from .base_logic import BaseLogicMixin, BaseLogic
from .tailoring_logic import TailoringSource
from ..data.animal import IncubatorSource, OstrichIncubatorSource
from ..data.artisan import MachineSource
from ..data.fish_data import FishingSource
from ..data.game_item import GenericSource, Source, GameItem, CustomRuleSource, AllRegionsSource
from ..data.harvest import ForagingSource, FruitBatsSource, MushroomCaveSource, SeasonalForagingSource, \
HarvestCropSource, HarvestFruitTreeSource, ArtifactSpotSource
from ..data.monster_data import MonsterSource
from ..data.shop import ShopSource, MysteryBoxSource, ArtifactTroveSource, PrizeMachineSource, FishingTreasureChestSource, HatMouseSource
from ..strings.ap_names.ap_option_names import CustomLogicOptionName
from ..strings.skill_names import Skill
class SourceLogicMixin(BaseLogicMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.source = SourceLogic(*args, **kwargs)
class SourceLogic(BaseLogic):
def has_access_to_item(self, item: GameItem):
rules = []
if self.content.features.cropsanity.is_included(item):
unlock_rule = self.logic.received(item.name)
if CustomLogicOptionName.critical_free_samples in self.options.custom_logic:
return unlock_rule
rules.append(unlock_rule)
rules.append(self.logic.source.has_access_to_any(item.sources))
return self.logic.and_(*rules)
def has_access_to_any(self, sources: Iterable[Source]):
return self.logic.or_(*(self.logic.source.has_access_to(source) & self.logic.requirement.meet_all_requirements(source.other_requirements)
for source in sources))
@functools.singledispatchmethod
def has_access_to(self, source: Any):
raise ValueError(f"Sources of type{type(source)} have no rule registered.")
@has_access_to.register
def _(self, source: GenericSource):
return self.logic.region.can_reach_any(*source.regions) if source.regions else self.logic.true_
@has_access_to.register
def _(self, source: AllRegionsSource):
return self.logic.region.can_reach_all(*source.regions) if source.regions else self.logic.true_
@has_access_to.register
def _(self, source: CustomRuleSource):
return source.create_rule(self.logic)
@has_access_to.register
def _(self, source: ForagingSource):
return self.logic.harvesting.can_forage_from(source)
@has_access_to.register
def _(self, source: SeasonalForagingSource):
# Implementation could be different with some kind of "calendar shuffle"
return self.logic.harvesting.can_forage_from(source.as_foraging_source())
@has_access_to.register
def _(self, _: FruitBatsSource):
return self.logic.harvesting.can_harvest_from_fruit_bats
@has_access_to.register
def _(self, _: MushroomCaveSource):
return self.logic.harvesting.can_harvest_from_mushroom_cave
@has_access_to.register
def _(self, source: ShopSource):
return self.logic.money.can_shop_from(source)
@has_access_to.register
def _(self, source: HatMouseSource):
return self.logic.money.can_shop_from_hat_mouse(source)
@has_access_to.register
def _(self, source: HarvestFruitTreeSource):
return self.logic.harvesting.can_harvest_tree_from(source)
@has_access_to.register
def _(self, source: HarvestCropSource):
return self.logic.harvesting.can_harvest_crop_from(source)
@has_access_to.register
def _(self, source: IncubatorSource):
return self.logic.animal.can_incubate(source.egg_item)
@has_access_to.register
def _(self, source: OstrichIncubatorSource):
return self.logic.animal.can_ostrich_incubate(source.egg_item)
@has_access_to.register
def _(self, source: MachineSource):
return self.logic.artisan.can_produce_from(source)
@has_access_to.register
def _(self, source: MysteryBoxSource):
return self.logic.grind.can_grind_mystery_boxes(source.amount)
@has_access_to.register
def _(self, source: ArtifactTroveSource):
return self.logic.grind.can_grind_artifact_troves(source.amount)
@has_access_to.register
def _(self, source: PrizeMachineSource):
return self.logic.grind.can_grind_prize_tickets(source.amount)
@has_access_to.register
def _(self, source: FishingTreasureChestSource):
return self.logic.grind.can_grind_fishing_treasure_chests(source.amount)
@has_access_to.register
def _(self, source: ArtifactSpotSource):
return self.logic.grind.can_grind_artifact_spots(source.amount)
@has_access_to.register
def _(self, source: MonsterSource):
return self.logic.monster.can_kill_any(source.monsters, source.amount_tier)
@has_access_to.register
def _(self, source: TailoringSource):
return self.logic.tailoring.can_tailor(*source.tailoring_items)
@has_access_to.register
def _(self, source: FishingSource):
return self.logic.fishing.can_fish_at(source.region) & self.logic.skill.has_level(Skill.fishing, source.fishing_level) & self.logic.tool.has_fishing_rod(source.minimum_rod)