mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-04-04 16:53:40 -07:00
Major Content update for Stardew Valley ### Features - New BundleRandomization Value: Meme Bundles - Over 100 custom bundles, designed to be jokes, references, trolls, etc - New Setting: Bundles Per Room modifier - New Setting: Backpack Size - New Setting: Secretsanity - Checks for triggering easter eggs and secrets - New Setting: Moviesanity - Checks for watching movies and sharing snacks with Villagers - New Setting: Eatsanity - Checks for eating items - New Setting: Hatsanity - Checks for wearing Hats - New Setting: Start Without - Allows you to select any combination of various "starting" items, that you will actually not start with. Notably, tools, backpack slots, Day5 unlocks, etc. - New Setting: Allowed Filler Items - Allows you to customize the filler items you'll get - New Setting: Endgame Locations - Checks for various expensive endgame tasks and purchases - New Shipsanity value: Crops and Fish - New Settings: Jojapocalypse and settings to customize it - Bundle Plando: Replaced with BundleWhitelist and BundleBlacklist, for more customization freedom - Added a couple of Host.yaml settings to help hosts allow or ban specific difficult settings that could cause problems if the people don't know what they are signing up for. Plus a truckload of improvements on the mod side, not seen in this PR. ### Removed features - Integration for Stardew Valley Expanded. It is simply disabled, the code is all still there, but I'm extremely tired of providing tech support for it, plus Stardew Valley 1.7 was announced and that will break it again, so I'm done. When a maintainer steps up, it can be re-enabled.
99 lines
5.6 KiB
Python
99 lines
5.6 KiB
Python
from Utils import cache_self1
|
|
from .base_logic import BaseLogicMixin, BaseLogic
|
|
from .. import options
|
|
from ..data.craftable_data import CraftingRecipe, all_crafting_recipes, all_crafting_recipes_by_name
|
|
from ..data.recipe_source import CutsceneSource, ShopTradeSource, ArchipelagoSource, LogicSource, SpecialOrderSource, \
|
|
FestivalShopSource, QuestSource, StarterSource, ShopSource, SkillSource, MasterySource, FriendshipSource, SkillCraftsanitySource, ShopWithKnownRecipeSource
|
|
from ..options import Craftsanity, SpecialOrderLocations
|
|
from ..stardew_rule import StardewRule, True_, False_
|
|
from ..strings.region_names import Region
|
|
|
|
|
|
class CraftingLogicMixin(BaseLogicMixin):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.crafting = CraftingLogic(*args, **kwargs)
|
|
|
|
|
|
class CraftingLogic(BaseLogic):
|
|
@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):
|
|
if self.options.quest_locations.has_no_story_quests():
|
|
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)
|
|
if isinstance(recipe.source, (StarterSource, ShopTradeSource, ShopSource, SkillCraftsanitySource)):
|
|
return self.logic.crafting.received_recipe(recipe.item)
|
|
if isinstance(recipe.source, SpecialOrderSource) and self.options.special_order_locations & SpecialOrderLocations.option_board:
|
|
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, ShopWithKnownRecipeSource):
|
|
return self.knows_recipe(all_crafting_recipes_by_name[recipe.source.recipe_required]) & self.logic.money.can_spend_at(recipe.source.region, recipe.source.price)
|
|
if isinstance(recipe.source, ShopSource):
|
|
return self.logic.money.can_spend_at(recipe.source.region, recipe.source.price)
|
|
if isinstance(recipe.source, SkillCraftsanitySource):
|
|
return self.logic.skill.has_level(recipe.source.skill, recipe.source.level) & self.logic.skill.can_earn_level(recipe.source.skill,
|
|
recipe.source.level)
|
|
if isinstance(recipe.source, SkillSource):
|
|
return self.logic.skill.has_level(recipe.source.skill, recipe.source.level)
|
|
if isinstance(recipe.source, MasterySource):
|
|
return self.logic.skill.has_mastery(recipe.source.skill)
|
|
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):
|
|
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)
|
|
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")
|
|
|
|
def can_have_crafted_recipes(self, number: int) -> StardewRule:
|
|
if number <= 0:
|
|
return self.logic.true_
|
|
recipe_rules = []
|
|
for recipe in all_crafting_recipes:
|
|
if recipe.content_pack is not None and not self.content.are_all_enabled(recipe.content_pack):
|
|
continue
|
|
recipe_rules.append(self.can_craft(recipe))
|
|
number = min(len(recipe_rules), number)
|
|
return self.logic.count(number, *recipe_rules)
|