 9ac921380f
			
		
	
	9ac921380f
	
	
	
		
			
			* 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
		
			
				
	
	
		
			77 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import enum
 | |
| from abc import ABC
 | |
| from dataclasses import dataclass, field
 | |
| from types import MappingProxyType
 | |
| from typing import List, Iterable, Set, ClassVar, Tuple, Mapping, Callable, Any
 | |
| 
 | |
| from ..stardew_rule.protocol import StardewRule
 | |
| 
 | |
| 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()
 | |
| 
 | |
| 
 | |
| @dataclass(frozen=True)
 | |
| class Source(ABC):
 | |
|     add_tags: ClassVar[Tuple[ItemTag]] = ()
 | |
| 
 | |
|     other_requirements: Tuple[Requirement, ...] = field(kw_only=True, default_factory=tuple)
 | |
| 
 | |
|     @property
 | |
|     def requirement_tags(self) -> Mapping[str, Tuple[ItemTag, ...]]:
 | |
|         return DEFAULT_REQUIREMENT_TAGS
 | |
| 
 | |
| 
 | |
| @dataclass(frozen=True, kw_only=True)
 | |
| class GenericSource(Source):
 | |
|     regions: Tuple[str, ...] = ()
 | |
|     """No region means it's available everywhere."""
 | |
| 
 | |
| 
 | |
| @dataclass(frozen=True)
 | |
| class CustomRuleSource(Source):
 | |
|     """Hopefully once everything is migrated to sources, we won't need these custom logic anymore."""
 | |
|     create_rule: Callable[[Any], 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)
 |