Skip to content

Commit

Permalink
mark some items easy in grinding logic so blueprints buildings can be…
Browse files Browse the repository at this point in the history
… in more early spheres
  • Loading branch information
Jouramie committed Dec 1, 2024
1 parent 53b4ff9 commit 32ba7ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
6 changes: 3 additions & 3 deletions worlds/stardew_valley/logic/building_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

if typing.TYPE_CHECKING:
from .source_logic import SourceLogicMixin

assert SourceLogicMixin
else:
SourceLogicMixin = object


class BuildingLogicMixin(BaseLogicMixin):
Expand All @@ -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:
Expand Down
37 changes: 29 additions & 8 deletions worlds/stardew_valley/logic/grind_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand All @@ -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)
Expand All @@ -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)
8 changes: 4 additions & 4 deletions worlds/stardew_valley/logic/money_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 32ba7ad

Please sign in to comment.