2025-04-08 12:37:45 -04:00
|
|
|
import typing
|
2024-11-29 14:41:26 -05:00
|
|
|
from functools import cached_property
|
2025-04-08 12:37:45 -04:00
|
|
|
from typing import Union
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
from Utils import cache_self1
|
|
|
|
from .base_logic import BaseLogic, BaseLogicMixin
|
|
|
|
from .has_logic import HasLogicMixin
|
|
|
|
from .received_logic import ReceivedLogicMixin
|
|
|
|
from .region_logic import RegionLogicMixin
|
2025-04-08 12:37:45 -04:00
|
|
|
from ..stardew_rule import StardewRule, true_
|
2024-03-15 15:05:14 +03:00
|
|
|
from ..strings.building_names import Building
|
2024-11-29 14:41:26 -05:00
|
|
|
from ..strings.region_names import Region
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
from .source_logic import SourceLogicMixin
|
|
|
|
else:
|
|
|
|
SourceLogicMixin = object
|
|
|
|
|
|
|
|
AUTO_BUILDING_BUILDINGS = {Building.shipping_bin, Building.pet_bowl, Building.farm_house}
|
Stardew Valley 6.x.x: The Content Update (#3478)
Focus of the Update: Compatibility with Stardew Valley 1.6 Released on March 19th 2024
This includes randomization for pretty much all of the new content, including but not limited to
- Raccoon Bundles
- Booksanity
- Skill Masteries
- New Recipes, Craftables, Fish, Maps, Farm Type, Festivals and Quests
This also includes a significant reorganisation of the code into "Content Packs", to allow for easier modularity of various game mechanics between the settings and the supported mods. This improves maintainability quite a bit.
In addition to that, a few **very** requested new features have been introduced, although they weren't the focus of this update
- Walnutsanity
- Player Buffs
- More customizability in settings, such as shorter special orders, ER without farmhouse
- New Remixed Bundles
2024-07-07 16:04:25 +03:00
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
class BuildingLogicMixin(BaseLogicMixin):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.building = BuildingLogic(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
class BuildingLogic(BaseLogic[Union[BuildingLogicMixin, RegionLogicMixin, ReceivedLogicMixin, HasLogicMixin, SourceLogicMixin]]):
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
@cache_self1
|
2025-04-08 12:37:45 -04:00
|
|
|
def can_build(self, building_name: str) -> StardewRule:
|
|
|
|
building = self.content.farm_buildings.get(building_name)
|
|
|
|
assert building is not None, f"Building {building_name} not found."
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
source_rule = self.logic.source.has_access_to_any(building.sources)
|
|
|
|
if not building.is_upgrade:
|
|
|
|
return source_rule
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
upgrade_rule = self.logic.building.has_building(building.upgrade_from)
|
|
|
|
return self.logic.and_(upgrade_rule, source_rule)
|
2024-11-29 14:41:26 -05:00
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
@cache_self1
|
2025-04-08 12:37:45 -04:00
|
|
|
def has_building(self, building_name: str) -> StardewRule:
|
|
|
|
building_progression = self.content.features.building_progression
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
if building_name in building_progression.starting_buildings:
|
|
|
|
return true_
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
if not building_progression.is_progressive:
|
|
|
|
return self.logic.building.can_build(building_name)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
# Those buildings are special. The mod auto-builds them when received, no need to go to Robin.
|
|
|
|
if building_name in AUTO_BUILDING_BUILDINGS:
|
|
|
|
return self.logic.received(Building.shipping_bin)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
carpenter_rule = self.logic.building.can_construct_buildings
|
|
|
|
item, count = building_progression.to_progressive_item(building_name)
|
|
|
|
return self.logic.received(item, count) & carpenter_rule
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
@cached_property
|
|
|
|
def can_construct_buildings(self) -> StardewRule:
|
|
|
|
return self.logic.region.can_reach(Region.carpenter)
|