mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Stardew Valley: Move progressive tool options handling in features (#4374)
* create tool progression feature and unwrap option * replace option usage with calling feature * add comment explaining why some logic is a weird place * replace item creation logic with feature * self review and add unit tests * rename test cuz I named them too long * add a test for the trash can useful stuff cuz I thought there was a bug but turns out it works * self review again * remove price_multiplier, turns out it's unused during generation * damn it 3.11 why are you like this * use blacksmith region when checking vanilla tools * fix rule * move can mine using in tool logic * remove changes to performance test * properly set the option I guess * properly set options 2 * that's what happen when you code too late
This commit is contained in:
@@ -10,12 +10,11 @@ from .region_logic import RegionLogicMixin
|
||||
from .skill_logic import SkillLogicMixin
|
||||
from .tool_logic import ToolLogicMixin
|
||||
from .. import options
|
||||
from ..options import ToolProgression
|
||||
from ..stardew_rule import StardewRule, True_
|
||||
from ..strings.performance_names import Performance
|
||||
from ..strings.region_names import Region
|
||||
from ..strings.skill_names import Skill
|
||||
from ..strings.tool_names import Tool, ToolMaterial
|
||||
from ..strings.tool_names import ToolMaterial
|
||||
|
||||
|
||||
class MineLogicMixin(BaseLogicMixin):
|
||||
@@ -56,11 +55,12 @@ SkillLogicMixin, CookingLogicMixin]]):
|
||||
def can_progress_in_the_mines_from_floor(self, floor: int) -> StardewRule:
|
||||
tier = floor // 40
|
||||
rules = []
|
||||
|
||||
weapon_rule = self.logic.mine.get_weapon_rule_for_floor_tier(tier)
|
||||
rules.append(weapon_rule)
|
||||
|
||||
if self.options.tool_progression & ToolProgression.option_progressive:
|
||||
rules.append(self.logic.tool.has_tool(Tool.pickaxe, ToolMaterial.tiers[tier]))
|
||||
tool_rule = self.logic.tool.can_mine_using(ToolMaterial.tiers[tier])
|
||||
rules.append(tool_rule)
|
||||
|
||||
# No alternative for vanilla because we assume that you will grind the levels in the mines.
|
||||
if self.content.features.skill_progression.is_progressive:
|
||||
@@ -85,11 +85,12 @@ SkillLogicMixin, CookingLogicMixin]]):
|
||||
def can_progress_in_the_skull_cavern_from_floor(self, floor: int) -> StardewRule:
|
||||
tier = floor // 50
|
||||
rules = []
|
||||
|
||||
weapon_rule = self.logic.combat.has_great_weapon
|
||||
rules.append(weapon_rule)
|
||||
|
||||
if self.options.tool_progression & ToolProgression.option_progressive:
|
||||
rules.append(self.logic.received("Progressive Pickaxe", min(4, max(0, tier + 2))))
|
||||
tool_rule = self.logic.tool.can_mine_using(ToolMaterial.tiers[min(4, max(0, tier + 2))])
|
||||
rules.append(tool_rule)
|
||||
|
||||
# No alternative for vanilla because we assume that you will grind the levels in the mines.
|
||||
if self.content.features.skill_progression.is_progressive:
|
||||
|
||||
@@ -8,12 +8,11 @@ from .received_logic import ReceivedLogicMixin
|
||||
from .region_logic import RegionLogicMixin
|
||||
from .season_logic import SeasonLogicMixin
|
||||
from ..mods.logic.magic_logic import MagicLogicMixin
|
||||
from ..options import ToolProgression
|
||||
from ..stardew_rule import StardewRule, True_, False_
|
||||
from ..strings.ap_names.skill_level_names import ModSkillLevel
|
||||
from ..strings.region_names import Region
|
||||
from ..strings.region_names import Region, LogicRegion
|
||||
from ..strings.spells import MagicSpell
|
||||
from ..strings.tool_names import ToolMaterial, Tool
|
||||
from ..strings.tool_names import ToolMaterial, Tool, APTool
|
||||
|
||||
fishing_rod_prices = {
|
||||
3: 1800,
|
||||
@@ -57,10 +56,10 @@ class ToolLogic(BaseLogic[Union[ToolLogicMixin, HasLogicMixin, ReceivedLogicMixi
|
||||
if material == ToolMaterial.basic or tool == Tool.scythe:
|
||||
return True_()
|
||||
|
||||
if self.options.tool_progression & ToolProgression.option_progressive:
|
||||
if self.content.features.tool_progression.is_progressive:
|
||||
return self.logic.received(f"Progressive {tool}", tool_materials[material])
|
||||
|
||||
can_upgrade_rule = self.logic.has(f"{material} Bar") & self.logic.money.can_spend_at(Region.blacksmith, tool_upgrade_prices[material])
|
||||
can_upgrade_rule = self.logic.tool._can_purchase_upgrade(material)
|
||||
if tool == Tool.pan:
|
||||
has_base_pan = self.logic.received("Glittering Boulder Removed") & self.logic.region.can_reach(Region.mountain)
|
||||
if material == ToolMaterial.copper:
|
||||
@@ -69,6 +68,20 @@ class ToolLogic(BaseLogic[Union[ToolLogicMixin, HasLogicMixin, ReceivedLogicMixi
|
||||
|
||||
return can_upgrade_rule
|
||||
|
||||
@cache_self1
|
||||
def can_mine_using(self, material: str) -> StardewRule:
|
||||
if material == ToolMaterial.basic:
|
||||
return self.logic.true_
|
||||
|
||||
if self.content.features.tool_progression.is_progressive:
|
||||
return self.logic.received(APTool.pickaxe, tool_materials[material])
|
||||
else:
|
||||
return self.logic.tool._can_purchase_upgrade(material)
|
||||
|
||||
@cache_self1
|
||||
def _can_purchase_upgrade(self, material: str) -> StardewRule:
|
||||
return self.logic.region.can_reach(LogicRegion.blacksmith_upgrade(material))
|
||||
|
||||
def can_use_tool_at(self, tool: str, material: str, region: str) -> StardewRule:
|
||||
return self.has_tool(tool, material) & self.logic.region.can_reach(region)
|
||||
|
||||
@@ -76,8 +89,8 @@ class ToolLogic(BaseLogic[Union[ToolLogicMixin, HasLogicMixin, ReceivedLogicMixi
|
||||
def has_fishing_rod(self, level: int) -> StardewRule:
|
||||
assert 1 <= level <= 4, "Fishing rod 0 isn't real, it can't hurt you. Training is 1, Bamboo is 2, Fiberglass is 3 and Iridium is 4."
|
||||
|
||||
if self.options.tool_progression & ToolProgression.option_progressive:
|
||||
return self.logic.received(f"Progressive {Tool.fishing_rod}", level)
|
||||
if self.content.features.tool_progression.is_progressive:
|
||||
return self.logic.received(APTool.fishing_rod, level)
|
||||
|
||||
if level <= 2:
|
||||
# We assume you always have access to the Bamboo pole, because mod side there is a builtin way to get it back.
|
||||
|
||||
Reference in New Issue
Block a user