| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | from Utils import cache_self1 | 
					
						
							|  |  |  | from .base_logic import BaseLogicMixin, BaseLogic | 
					
						
							|  |  |  | from .. import options | 
					
						
							| 
									
										
										
										
											2025-03-22 15:29:16 -04:00
										 |  |  | from ..data.craftable_data import CraftingRecipe | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | from ..data.recipe_source import CutsceneSource, ShopTradeSource, ArchipelagoSource, LogicSource, SpecialOrderSource, \ | 
					
						
							| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  |     FestivalShopSource, QuestSource, StarterSource, ShopSource, SkillSource, MasterySource, FriendshipSource, SkillCraftsanitySource | 
					
						
							| 
									
										
										
										
											2025-03-22 15:29:16 -04:00
										 |  |  | from ..options import Craftsanity, SpecialOrderLocations | 
					
						
							| 
									
										
										
											
												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
										 |  |  | from ..stardew_rule import StardewRule, True_, False_ | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | from ..strings.region_names import Region | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CraftingLogicMixin(BaseLogicMixin): | 
					
						
							|  |  |  |     def __init__(self, *args, **kwargs): | 
					
						
							|  |  |  |         super().__init__(*args, **kwargs) | 
					
						
							|  |  |  |         self.crafting = CraftingLogic(*args, **kwargs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-23 11:31:08 -04:00
										 |  |  | class CraftingLogic(BaseLogic): | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |     @cache_self1 | 
					
						
							|  |  |  |     def can_craft(self, recipe: CraftingRecipe = None) -> StardewRule: | 
					
						
							|  |  |  |         if recipe is None: | 
					
						
							|  |  |  |             return True_() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         learn_rule = self.logic.crafting.knows_recipe(recipe) | 
					
						
							|  |  |  |         ingredients_rule = self.logic.has_all(*recipe.ingredients) | 
					
						
							|  |  |  |         return learn_rule & ingredients_rule | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @cache_self1 | 
					
						
							|  |  |  |     def knows_recipe(self, recipe: CraftingRecipe) -> StardewRule: | 
					
						
							|  |  |  |         if isinstance(recipe.source, ArchipelagoSource): | 
					
						
							|  |  |  |             return self.logic.received_all(*recipe.source.ap_item) | 
					
						
							|  |  |  |         if isinstance(recipe.source, FestivalShopSource): | 
					
						
							|  |  |  |             if self.options.festival_locations == options.FestivalLocations.option_disabled: | 
					
						
							|  |  |  |                 return self.logic.crafting.can_learn_recipe(recipe) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 return self.logic.crafting.received_recipe(recipe.item) | 
					
						
							|  |  |  |         if isinstance(recipe.source, QuestSource): | 
					
						
							| 
									
										
										
										
											2025-03-10 18:39:35 +03:00
										 |  |  |             if self.options.quest_locations.has_no_story_quests(): | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |                 return self.logic.crafting.can_learn_recipe(recipe) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 return self.logic.crafting.received_recipe(recipe.item) | 
					
						
							|  |  |  |         if self.options.craftsanity == Craftsanity.option_none: | 
					
						
							|  |  |  |             return self.logic.crafting.can_learn_recipe(recipe) | 
					
						
							| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  |         if isinstance(recipe.source, (StarterSource, ShopTradeSource, ShopSource, SkillCraftsanitySource)): | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |             return self.logic.crafting.received_recipe(recipe.item) | 
					
						
							| 
									
										
										
											
												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
										 |  |  |         if isinstance(recipe.source, SpecialOrderSource) and self.options.special_order_locations & SpecialOrderLocations.option_board: | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |             return self.logic.crafting.received_recipe(recipe.item) | 
					
						
							|  |  |  |         return self.logic.crafting.can_learn_recipe(recipe) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @cache_self1 | 
					
						
							|  |  |  |     def can_learn_recipe(self, recipe: CraftingRecipe) -> StardewRule: | 
					
						
							|  |  |  |         if isinstance(recipe.source, StarterSource): | 
					
						
							|  |  |  |             return True_() | 
					
						
							|  |  |  |         if isinstance(recipe.source, ArchipelagoSource): | 
					
						
							|  |  |  |             return self.logic.received_all(*recipe.source.ap_item) | 
					
						
							|  |  |  |         if isinstance(recipe.source, ShopTradeSource): | 
					
						
							|  |  |  |             return self.logic.money.can_trade_at(recipe.source.region, recipe.source.currency, recipe.source.price) | 
					
						
							|  |  |  |         if isinstance(recipe.source, ShopSource): | 
					
						
							|  |  |  |             return self.logic.money.can_spend_at(recipe.source.region, recipe.source.price) | 
					
						
							| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  |         if isinstance(recipe.source, SkillCraftsanitySource): | 
					
						
							| 
									
										
										
										
											2025-03-22 15:29:16 -04:00
										 |  |  |             return self.logic.skill.has_level(recipe.source.skill, recipe.source.level) & self.logic.skill.can_earn_level(recipe.source.skill, | 
					
						
							|  |  |  |                                                                                                                           recipe.source.level) | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |         if isinstance(recipe.source, SkillSource): | 
					
						
							|  |  |  |             return self.logic.skill.has_level(recipe.source.skill, recipe.source.level) | 
					
						
							| 
									
										
										
											
												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
										 |  |  |         if isinstance(recipe.source, MasterySource): | 
					
						
							|  |  |  |             return self.logic.skill.has_mastery(recipe.source.skill) | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |         if isinstance(recipe.source, CutsceneSource): | 
					
						
							|  |  |  |             return self.logic.region.can_reach(recipe.source.region) & self.logic.relationship.has_hearts(recipe.source.friend, recipe.source.hearts) | 
					
						
							|  |  |  |         if isinstance(recipe.source, FriendshipSource): | 
					
						
							|  |  |  |             return self.logic.relationship.has_hearts(recipe.source.friend, recipe.source.hearts) | 
					
						
							|  |  |  |         if isinstance(recipe.source, QuestSource): | 
					
						
							|  |  |  |             return self.logic.quest.can_complete_quest(recipe.source.quest) | 
					
						
							|  |  |  |         if isinstance(recipe.source, SpecialOrderSource): | 
					
						
							| 
									
										
										
											
												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
										 |  |  |             if self.options.special_order_locations & SpecialOrderLocations.option_board: | 
					
						
							|  |  |  |                 return self.logic.crafting.received_recipe(recipe.item) | 
					
						
							|  |  |  |             return self.logic.special_order.can_complete_special_order(recipe.source.special_order) | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |         if isinstance(recipe.source, LogicSource): | 
					
						
							|  |  |  |             if recipe.source.logic_rule == "Cellar": | 
					
						
							|  |  |  |                 return self.logic.region.can_reach(Region.cellar) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return False_() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @cache_self1 | 
					
						
							|  |  |  |     def received_recipe(self, item_name: str): | 
					
						
							|  |  |  |         return self.logic.received(f"{item_name} Recipe") |