mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-05-27 14:09:57 -07:00
Stardew Valley: Refactor buildings to use content packs (#4239)
* create building data object and rename ItemSource to Source to be more generic # Conflicts: # worlds/stardew_valley/content/game_content.py # Conflicts: # worlds/stardew_valley/data/artisan.py # worlds/stardew_valley/data/game_item.py # worlds/stardew_valley/data/harvest.py # worlds/stardew_valley/data/shop.py * remove compound sources, replace by other requirements which already handle this usecase * add coops to content packs * add building progression in game features * add shippping bin to starting building; remove has_house * replace config check with feature * add other buildings in content packs * not passing * tests passes, unbelievable * use newly create methods more * use new assets to ease readability * self review * fix flake8 maybe * properly split rule for mapping cave systems * fix tractor garage name * self review * add upgrade_from to farm house buldings * don't override building name variable in logic * remove has_group from buildings * mark some items easy in grinding logic so blueprints buildings can be in more early spheres * move stuff around to maybe avoid future conflicts cuz I have like 10 PRs opened right now * remove price_multiplier, turns out it's unused during generation * disable shop source for mapping cave systems * bunch of code review changes * add petbowl and farmhouse to autobuilding * set min easy items to 300 * fix farm type
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .game_item import ItemSource
|
||||
from .game_item import Source
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MachineSource(ItemSource):
|
||||
class MachineSource(Source):
|
||||
item: str # this should be optional (worm bin)
|
||||
machine: str
|
||||
# seasons
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from dataclasses import dataclass, field
|
||||
from functools import cached_property
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from .game_item import Source
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Building:
|
||||
name: str
|
||||
sources: Tuple[Source, ...] = field(kw_only=True)
|
||||
upgrade_from: Optional[str] = field(default=None, kw_only=True)
|
||||
|
||||
@cached_property
|
||||
def is_upgrade(self) -> bool:
|
||||
return self.upgrade_from is not None
|
||||
@@ -27,7 +27,7 @@ class ItemTag(enum.Enum):
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ItemSource(ABC):
|
||||
class Source(ABC):
|
||||
add_tags: ClassVar[Tuple[ItemTag]] = ()
|
||||
|
||||
other_requirements: Tuple[Requirement, ...] = field(kw_only=True, default_factory=tuple)
|
||||
@@ -38,23 +38,18 @@ class ItemSource(ABC):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class GenericSource(ItemSource):
|
||||
class GenericSource(Source):
|
||||
regions: Tuple[str, ...] = ()
|
||||
"""No region means it's available everywhere."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CustomRuleSource(ItemSource):
|
||||
class CustomRuleSource(Source):
|
||||
"""Hopefully once everything is migrated to sources, we won't need these custom logic anymore."""
|
||||
create_rule: Callable[[Any], StardewRule]
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class CompoundSource(ItemSource):
|
||||
sources: Tuple[ItemSource, ...] = ()
|
||||
|
||||
|
||||
class Tag(ItemSource):
|
||||
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, ...]
|
||||
|
||||
@@ -69,10 +64,10 @@ class Tag(ItemSource):
|
||||
@dataclass(frozen=True)
|
||||
class GameItem:
|
||||
name: str
|
||||
sources: List[ItemSource] = field(default_factory=list)
|
||||
sources: List[Source] = field(default_factory=list)
|
||||
tags: Set[ItemTag] = field(default_factory=set)
|
||||
|
||||
def add_sources(self, sources: Iterable[ItemSource]):
|
||||
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)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Tuple, Sequence, Mapping
|
||||
|
||||
from .game_item import ItemSource, ItemTag
|
||||
from .game_item import Source, ItemTag
|
||||
from ..strings.season_names import Season
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ForagingSource(ItemSource):
|
||||
class ForagingSource(Source):
|
||||
regions: Tuple[str, ...]
|
||||
seasons: Tuple[str, ...] = Season.all
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class SeasonalForagingSource(ItemSource):
|
||||
class SeasonalForagingSource(Source):
|
||||
season: str
|
||||
days: Sequence[int]
|
||||
regions: Tuple[str, ...]
|
||||
@@ -22,17 +22,17 @@ class SeasonalForagingSource(ItemSource):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class FruitBatsSource(ItemSource):
|
||||
class FruitBatsSource(Source):
|
||||
...
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MushroomCaveSource(ItemSource):
|
||||
class MushroomCaveSource(Source):
|
||||
...
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class HarvestFruitTreeSource(ItemSource):
|
||||
class HarvestFruitTreeSource(Source):
|
||||
add_tags = (ItemTag.CROPSANITY,)
|
||||
|
||||
sapling: str
|
||||
@@ -46,7 +46,7 @@ class HarvestFruitTreeSource(ItemSource):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class HarvestCropSource(ItemSource):
|
||||
class HarvestCropSource(Source):
|
||||
add_tags = (ItemTag.CROPSANITY,)
|
||||
|
||||
seed: str
|
||||
@@ -61,5 +61,5 @@ class HarvestCropSource(ItemSource):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ArtifactSpotSource(ItemSource):
|
||||
class ArtifactSpotSource(Source):
|
||||
amount: int
|
||||
|
||||
@@ -509,6 +509,7 @@ id,name,classification,groups,mod_name
|
||||
561,Fishing Bar Size Bonus,filler,PLAYER_BUFF,
|
||||
562,Quality Bonus,filler,PLAYER_BUFF,
|
||||
563,Glow Bonus,filler,PLAYER_BUFF,
|
||||
564,Pet Bowl,progression,BUILDING,
|
||||
4001,Burnt Trap,trap,TRAP,
|
||||
4002,Darkness Trap,trap,TRAP,
|
||||
4003,Frozen Trap,trap,TRAP,
|
||||
|
||||
|
@@ -21,6 +21,11 @@ class SkillRequirement(Requirement):
|
||||
level: int
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RegionRequirement(Requirement):
|
||||
region: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SeasonRequirement(Requirement):
|
||||
season: str
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Tuple, Optional
|
||||
|
||||
from .game_item import ItemSource
|
||||
from .game_item import Source
|
||||
from ..strings.season_names import Season
|
||||
|
||||
ItemPrice = Tuple[int, str]
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ShopSource(ItemSource):
|
||||
class ShopSource(Source):
|
||||
shop_region: str
|
||||
money_price: Optional[int] = None
|
||||
items_price: Optional[Tuple[ItemPrice, ...]] = None
|
||||
@@ -20,20 +20,20 @@ class ShopSource(ItemSource):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MysteryBoxSource(ItemSource):
|
||||
class MysteryBoxSource(Source):
|
||||
amount: int
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ArtifactTroveSource(ItemSource):
|
||||
class ArtifactTroveSource(Source):
|
||||
amount: int
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class PrizeMachineSource(ItemSource):
|
||||
class PrizeMachineSource(Source):
|
||||
amount: int
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class FishingTreasureChestSource(ItemSource):
|
||||
class FishingTreasureChestSource(Source):
|
||||
amount: int
|
||||
|
||||
Reference in New Issue
Block a user