 9b22458f44
			
		
	
	9b22458f44
	
	
	
		
			
			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
		
			
				
	
	
		
			94 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from typing import Union
 | |
| 
 | |
| from .base_logic import BaseLogic, BaseLogicMixin
 | |
| from .has_logic import HasLogicMixin
 | |
| from .time_logic import TimeLogicMixin
 | |
| from ..data.artisan import MachineSource
 | |
| from ..data.game_item import ItemTag
 | |
| from ..stardew_rule import StardewRule
 | |
| from ..strings.artisan_good_names import ArtisanGood
 | |
| from ..strings.crop_names import Vegetable, Fruit
 | |
| from ..strings.fish_names import Fish, all_fish
 | |
| from ..strings.forageable_names import Mushroom
 | |
| from ..strings.generic_names import Generic
 | |
| from ..strings.machine_names import Machine
 | |
| 
 | |
| 
 | |
| class ArtisanLogicMixin(BaseLogicMixin):
 | |
|     def __init__(self, *args, **kwargs):
 | |
|         super().__init__(*args, **kwargs)
 | |
|         self.artisan = ArtisanLogic(*args, **kwargs)
 | |
| 
 | |
| 
 | |
| class ArtisanLogic(BaseLogic[Union[ArtisanLogicMixin, TimeLogicMixin, HasLogicMixin]]):
 | |
|     def initialize_rules(self):
 | |
|         # TODO remove this one too once fish are converted to sources
 | |
|         self.registry.artisan_good_rules.update({ArtisanGood.specific_smoked_fish(fish): self.can_smoke(fish) for fish in all_fish})
 | |
|         self.registry.artisan_good_rules.update({ArtisanGood.specific_bait(fish): self.can_bait(fish) for fish in all_fish})
 | |
| 
 | |
|     def has_jelly(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_preserves_jar(Fruit.any)
 | |
| 
 | |
|     def has_pickle(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_preserves_jar(Vegetable.any)
 | |
| 
 | |
|     def has_smoked_fish(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_smoke(Fish.any)
 | |
| 
 | |
|     def has_targeted_bait(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_bait(Fish.any)
 | |
| 
 | |
|     def has_dried_fruits(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_dehydrate(Fruit.any)
 | |
| 
 | |
|     def has_dried_mushrooms(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_dehydrate(Mushroom.any_edible)
 | |
| 
 | |
|     def has_raisins(self) -> StardewRule:
 | |
|         return self.logic.artisan.can_dehydrate(Fruit.grape)
 | |
| 
 | |
|     def can_produce_from(self, source: MachineSource) -> StardewRule:
 | |
|         return self.logic.has(source.item) & self.logic.has(source.machine)
 | |
| 
 | |
|     def can_preserves_jar(self, item: str) -> StardewRule:
 | |
|         machine_rule = self.logic.has(Machine.preserves_jar)
 | |
|         if item == Generic.any:
 | |
|             return machine_rule
 | |
|         if item == Fruit.any:
 | |
|             return machine_rule & self.logic.has_any(*(fruit.name for fruit in self.content.find_tagged_items(ItemTag.FRUIT)))
 | |
|         if item == Vegetable.any:
 | |
|             return machine_rule & self.logic.has_any(*(vege.name for vege in self.content.find_tagged_items(ItemTag.VEGETABLE)))
 | |
|         return machine_rule & self.logic.has(item)
 | |
| 
 | |
|     def can_keg(self, item: str) -> StardewRule:
 | |
|         machine_rule = self.logic.has(Machine.keg)
 | |
|         if item == Generic.any:
 | |
|             return machine_rule
 | |
|         if item == Fruit.any:
 | |
|             return machine_rule & self.logic.has_any(*(fruit.name for fruit in self.content.find_tagged_items(ItemTag.FRUIT)))
 | |
|         if item == Vegetable.any:
 | |
|             return machine_rule & self.logic.has_any(*(vege.name for vege in self.content.find_tagged_items(ItemTag.VEGETABLE)))
 | |
|         return machine_rule & self.logic.has(item)
 | |
| 
 | |
|     def can_mayonnaise(self, item: str) -> StardewRule:
 | |
|         return self.logic.has(Machine.mayonnaise_machine) & self.logic.has(item)
 | |
| 
 | |
|     def can_smoke(self, item: str) -> StardewRule:
 | |
|         machine_rule = self.logic.has(Machine.fish_smoker)
 | |
|         return machine_rule & self.logic.has(item)
 | |
| 
 | |
|     def can_bait(self, item: str) -> StardewRule:
 | |
|         machine_rule = self.logic.has(Machine.bait_maker)
 | |
|         return machine_rule & self.logic.has(item)
 | |
| 
 | |
|     def can_dehydrate(self, item: str) -> StardewRule:
 | |
|         machine_rule = self.logic.has(Machine.dehydrator)
 | |
|         if item == Generic.any:
 | |
|             return machine_rule
 | |
|         if item == Fruit.any:
 | |
|             # Grapes make raisins
 | |
|             return machine_rule & self.logic.has_any(*(fruit.name for fruit in self.content.find_tagged_items(ItemTag.FRUIT) if fruit.name != Fruit.grape))
 | |
|         if item == Mushroom.any_edible:
 | |
|             return machine_rule & self.logic.has_any(*(mushroom.name for mushroom in self.content.find_tagged_items(ItemTag.EDIBLE_MUSHROOM)))
 | |
|         return machine_rule & self.logic.has(item)
 |