From 32ba7ad507baa4076a8fca816765cfbfb6495843 Mon Sep 17 00:00:00 2001 From: Jouramie Date: Sun, 1 Dec 2024 17:54:14 -0500 Subject: [PATCH] mark some items easy in grinding logic so blueprints buildings can be in more early spheres --- worlds/stardew_valley/logic/building_logic.py | 6 +-- worlds/stardew_valley/logic/grind_logic.py | 37 +++++++++++++++---- worlds/stardew_valley/logic/money_logic.py | 8 ++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/worlds/stardew_valley/logic/building_logic.py b/worlds/stardew_valley/logic/building_logic.py index a0016ad73ec8..9bc0b2229cf7 100644 --- a/worlds/stardew_valley/logic/building_logic.py +++ b/worlds/stardew_valley/logic/building_logic.py @@ -13,8 +13,8 @@ if typing.TYPE_CHECKING: from .source_logic import SourceLogicMixin - - assert SourceLogicMixin +else: + SourceLogicMixin = object class BuildingLogicMixin(BaseLogicMixin): @@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs): self.building = BuildingLogic(*args, **kwargs) -class BuildingLogic(BaseLogic[Union[BuildingLogicMixin, RegionLogicMixin, ReceivedLogicMixin, HasLogicMixin, 'SourceLogicMixin']]): +class BuildingLogic(BaseLogic[Union[BuildingLogicMixin, RegionLogicMixin, ReceivedLogicMixin, HasLogicMixin, SourceLogicMixin]]): @cache_self1 def can_build(self, building_name: str) -> StardewRule: diff --git a/worlds/stardew_valley/logic/grind_logic.py b/worlds/stardew_valley/logic/grind_logic.py index 997300ae7a54..61d54c632d5d 100644 --- a/worlds/stardew_valley/logic/grind_logic.py +++ b/worlds/stardew_valley/logic/grind_logic.py @@ -13,6 +13,7 @@ from ..strings.currency_names import Currency from ..strings.fish_names import WaterChest from ..strings.geode_names import Geode +from ..strings.material_names import Material from ..strings.region_names import Region from ..strings.tool_names import Tool @@ -21,9 +22,14 @@ else: ToolLogicMixin = object -MIN_ITEMS = 10 -MAX_ITEMS = 999 -PERCENT_REQUIRED_FOR_MAX_ITEM = 24 +MIN_MEDIUM_ITEMS = 10 +MAX_MEDIUM_ITEMS = 999 +PERCENT_REQUIRED_FOR_MAX_MEDIUM_ITEM = 24 + +EASY_ITEMS = {Material.wood, Material.stone, Material.fiber, Material.sap} +MIN_EASY_ITEMS = 500 +MAX_EASY_ITEMS = 2997 +PERCENT_REQUIRED_FOR_MAX_EASY_ITEM = 6 class GrindLogicMixin(BaseLogicMixin): @@ -43,7 +49,7 @@ def can_grind_mystery_boxes(self, quantity: int) -> StardewRule: # Assuming one box per day, but halved because we don't know how many months have passed before Mr. Qi's Plane Ride. time_rule = self.logic.time.has_lived_months(quantity // 14) return self.logic.and_(opening_rule, mystery_box_rule, - book_of_mysteries_rule, time_rule,) + book_of_mysteries_rule, time_rule, ) def can_grind_artifact_troves(self, quantity: int) -> StardewRule: opening_rule = self.logic.region.can_reach(Region.blacksmith) @@ -67,11 +73,26 @@ def can_grind_artifact_spots(self, quantity: int) -> StardewRule: # Assuming twelve per month if the player does not grind it. self.logic.time.has_lived_months(quantity // 12)) + def can_grind_item(self, quantity: int, item: str | None = None) -> StardewRule: + if item in EASY_ITEMS: + return self.logic.grind.can_grind_easy_item(quantity) + else: + return self.logic.grind.can_grind_medium_item(quantity) + + @cache_self1 + def can_grind_medium_item(self, quantity: int) -> StardewRule: + if quantity <= MIN_MEDIUM_ITEMS: + return self.logic.true_ + + quantity = min(quantity, MAX_MEDIUM_ITEMS) + price = max(1, quantity * PERCENT_REQUIRED_FOR_MAX_MEDIUM_ITEM // MAX_MEDIUM_ITEMS) + return HasProgressionPercent(self.player, price) + @cache_self1 - def can_grind_item(self, quantity: int) -> StardewRule: - if quantity <= MIN_ITEMS: + def can_grind_easy_item(self, quantity: int) -> StardewRule: + if quantity <= MIN_EASY_ITEMS: return self.logic.true_ - quantity = min(quantity, MAX_ITEMS) - price = max(1, quantity * PERCENT_REQUIRED_FOR_MAX_ITEM // MAX_ITEMS) + quantity = min(quantity, MAX_EASY_ITEMS) + price = max(1, quantity * PERCENT_REQUIRED_FOR_MAX_EASY_ITEM // MAX_EASY_ITEMS) return HasProgressionPercent(self.player, price) diff --git a/worlds/stardew_valley/logic/money_logic.py b/worlds/stardew_valley/logic/money_logic.py index 85370273c987..e272436fd8b9 100644 --- a/worlds/stardew_valley/logic/money_logic.py +++ b/worlds/stardew_valley/logic/money_logic.py @@ -17,8 +17,8 @@ if typing.TYPE_CHECKING: from .shipping_logic import ShippingLogicMixin - - assert ShippingLogicMixin +else: + ShippingLogicMixin = object qi_gem_rewards = ("100 Qi Gems", "50 Qi Gems", "40 Qi Gems", "35 Qi Gems", "25 Qi Gems", "20 Qi Gems", "15 Qi Gems", "10 Qi Gems") @@ -31,7 +31,7 @@ def __init__(self, *args, **kwargs): class MoneyLogic(BaseLogic[Union[RegionLogicMixin, MoneyLogicMixin, TimeLogicMixin, RegionLogicMixin, ReceivedLogicMixin, HasLogicMixin, SeasonLogicMixin, -GrindLogicMixin, 'ShippingLogicMixin']]): +GrindLogicMixin, ShippingLogicMixin]]): @cache_self1 def can_have_earned_total(self, amount: int) -> StardewRule: @@ -80,7 +80,7 @@ def can_shop_from(self, source: ShopSource) -> StardewRule: item_rules = [] if source.items_price is not None: for price, item in source.items_price: - item_rules.append(self.logic.has(item) & self.logic.grind.can_grind_item(price)) + item_rules.append(self.logic.has(item) & self.logic.grind.can_grind_item(price, item)) region_rule = self.logic.region.can_reach(source.shop_region)