forked from mirror/Archipelago
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.
93 lines
2.4 KiB
Python
93 lines
2.4 KiB
Python
import enum
|
|
from abc import ABC
|
|
from dataclasses import dataclass, field
|
|
from types import MappingProxyType
|
|
from typing import Iterable, ClassVar, Mapping, Callable, TYPE_CHECKING
|
|
|
|
from ..stardew_rule.protocol import StardewRule
|
|
|
|
if TYPE_CHECKING:
|
|
from ..logic.logic import StardewLogic
|
|
|
|
DEFAULT_REQUIREMENT_TAGS = MappingProxyType({})
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Requirement(ABC):
|
|
...
|
|
|
|
|
|
class ItemTag(enum.Enum):
|
|
CROPSANITY_SEED = enum.auto()
|
|
CROPSANITY = enum.auto()
|
|
FISH = enum.auto()
|
|
FRUIT = enum.auto()
|
|
VEGETABLE = enum.auto()
|
|
EDIBLE_MUSHROOM = enum.auto()
|
|
BOOK = enum.auto()
|
|
BOOK_POWER = enum.auto()
|
|
BOOK_SKILL = enum.auto()
|
|
HAT = enum.auto()
|
|
FORAGE = enum.auto()
|
|
COOKING = enum.auto()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Source(ABC):
|
|
add_tags: ClassVar[tuple[ItemTag]] = ()
|
|
|
|
other_requirements: tuple[Requirement, ...] = field(kw_only=True, default=())
|
|
|
|
@property
|
|
def requirement_tags(self) -> Mapping[str, tuple[ItemTag, ...]]:
|
|
return DEFAULT_REQUIREMENT_TAGS
|
|
|
|
@property
|
|
def all_requirements(self) -> Iterable[Requirement]:
|
|
"""Returns all requirements that are not directly part of the source."""
|
|
return self.other_requirements
|
|
|
|
|
|
@dataclass(frozen=True, kw_only=True)
|
|
class GenericSource(Source):
|
|
regions: tuple[str, ...] = ()
|
|
"""No region means it's available everywhere."""
|
|
|
|
|
|
@dataclass(frozen=True, kw_only=True)
|
|
class AllRegionsSource(Source):
|
|
regions: tuple[str, ...] = ()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class CustomRuleSource(Source):
|
|
"""Hopefully once everything is migrated to sources, we won't need these custom logic anymore."""
|
|
create_rule: "Callable[[StardewLogic], StardewRule]"
|
|
|
|
|
|
class Tag(Source):
|
|
"""Not a real source, just a way to add tags to an item. Will be removed from the item sources during unpacking."""
|
|
tag: tuple[ItemTag, ...]
|
|
|
|
def __init__(self, *tag: ItemTag):
|
|
self.tag = tag # noqa
|
|
|
|
@property
|
|
def add_tags(self):
|
|
return self.tag
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class GameItem:
|
|
name: str
|
|
sources: list[Source] = field(default_factory=list)
|
|
tags: set[ItemTag] = field(default_factory=set)
|
|
|
|
def add_sources(self, sources: Iterable[Source]):
|
|
self.sources.extend(source for source in sources if type(source) is not Tag)
|
|
for source in sources:
|
|
self.add_tags(source.add_tags)
|
|
|
|
def add_tags(self, tags: Iterable[ItemTag]):
|
|
self.tags.update(tags)
|