2025-04-20 10:17:22 -04:00
|
|
|
import typing
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
from .base_logic import BaseLogicMixin, BaseLogic
|
2025-04-20 10:17:22 -04:00
|
|
|
from ..stardew_rule import StardewRule
|
2024-03-15 15:05:14 +03:00
|
|
|
from ..strings.building_names import Building
|
|
|
|
from ..strings.forageable_names import Forageable
|
2025-04-20 10:17:22 -04:00
|
|
|
from ..strings.machine_names import Machine
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
class AnimalLogicMixin(BaseLogicMixin):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.animal = AnimalLogic(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2025-04-23 11:31:08 -04:00
|
|
|
class AnimalLogic(BaseLogic):
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-20 10:17:22 -04:00
|
|
|
def can_incubate(self, egg_item: str) -> StardewRule:
|
|
|
|
return self.logic.building.has_building(Building.coop) & self.logic.has(egg_item)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-20 10:17:22 -04:00
|
|
|
def can_ostrich_incubate(self, egg_item: str) -> StardewRule:
|
|
|
|
return self.logic.building.has_building(Building.barn) & self.logic.has(Machine.ostrich_incubator) & self.logic.has(egg_item)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-20 10:17:22 -04:00
|
|
|
def has_animal(self, animal_name: str) -> StardewRule:
|
|
|
|
animal = self.content.animals.get(animal_name)
|
|
|
|
assert animal is not None, f"Animal {animal_name} not found."
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-20 10:17:22 -04:00
|
|
|
return self.logic.source.has_access_to_any(animal.sources) & self.logic.building.has_building(animal.required_building)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-20 10:17:22 -04:00
|
|
|
def has_happy_animal(self, animal_name: str) -> StardewRule:
|
|
|
|
return self.logic.animal.has_animal(animal_name) & self.logic.has(Forageable.hay)
|