forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ArchipelagoMW#9 from agilbert1412/StardewValley/5.…
…x.x-mod-rewrite Logic Mixins
- Loading branch information
Showing
50 changed files
with
1,450 additions
and
2,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,50 @@ | ||
from .cached_logic import profile_rule | ||
from .mine_logic import MineLogic | ||
from .received_logic import ReceivedLogic | ||
from .region_logic import RegionLogic | ||
from .skill_logic import SkillLogic | ||
from .tool_logic import ToolLogic | ||
from ..options import NumberOfMovementBuffs, NumberOfLuckBuffs | ||
from ..mods.logic.magic_logic import MagicLogic | ||
from ..mods.logic.skills_logic import ModSkillLogic | ||
from typing import Union | ||
|
||
from .base_logic import BaseLogicMixin, BaseLogic | ||
from .mine_logic import MineLogicMixin | ||
from .received_logic import ReceivedLogicMixin | ||
from .region_logic import RegionLogicMixin | ||
from .skill_logic import SkillLogicMixin | ||
from .tool_logic import ToolLogicMixin | ||
from ..mods.logic.magic_logic import MagicLogicMixin | ||
from ..stardew_rule import StardewRule | ||
from ..strings.ap_names.buff_names import Buff | ||
from ..strings.region_names import Region | ||
from ..strings.skill_names import Skill, ModSkill | ||
from ..strings.tool_names import ToolMaterial, Tool | ||
|
||
|
||
class AbilityLogic: | ||
player: int | ||
movement_buff_option: NumberOfMovementBuffs | ||
luck_buff_option: NumberOfLuckBuffs | ||
received: ReceivedLogic | ||
region: RegionLogic | ||
tool: ToolLogic | ||
skill: SkillLogic | ||
mine: MineLogic | ||
magic: MagicLogic | ||
mod_skill: ModSkillLogic | ||
class AbilityLogicMixin(BaseLogicMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.ability = AbilityLogic(*args, **kwargs) | ||
|
||
def __init__(self, player: int, movement_buff_option: NumberOfMovementBuffs, luck_buff_option: NumberOfLuckBuffs, received: ReceivedLogic, region: RegionLogic, tool: ToolLogic, | ||
skill: SkillLogic, mine: MineLogic): | ||
self.player = player | ||
self.movement_buff_option = movement_buff_option | ||
self.luck_buff_option = luck_buff_option | ||
self.received = received | ||
self.region = region | ||
self.tool = tool | ||
self.skill = skill | ||
self.mine = mine | ||
|
||
def set_magic(self, magic: MagicLogic, mod_skill: ModSkillLogic): | ||
self.magic = magic | ||
self.mod_skill = mod_skill | ||
|
||
class AbilityLogic(BaseLogic[Union[AbilityLogicMixin, RegionLogicMixin, ReceivedLogicMixin, ToolLogicMixin, SkillLogicMixin, MineLogicMixin, MagicLogicMixin]]): | ||
def can_mine_perfectly(self) -> StardewRule: | ||
return self.mine.can_progress_in_the_mines_from_floor(160) | ||
return self.logic.mine.can_progress_in_the_mines_from_floor(160) | ||
|
||
def can_mine_perfectly_in_the_skull_cavern(self) -> StardewRule: | ||
return (self.can_mine_perfectly() & | ||
self.region.can_reach(Region.skull_cavern)) | ||
return (self.logic.ability.can_mine_perfectly() & | ||
self.logic.region.can_reach(Region.skull_cavern)) | ||
|
||
def can_farm_perfectly(self) -> StardewRule: | ||
tool_rule = self.tool.has_tool(Tool.hoe, ToolMaterial.iridium) & self.tool.can_water(4) | ||
return tool_rule & self.skill.has_farming_level(10) | ||
tool_rule = self.logic.tool.has_tool(Tool.hoe, ToolMaterial.iridium) & self.logic.tool.can_water(4) | ||
return tool_rule & self.logic.skill.has_farming_level(10) | ||
|
||
def can_fish_perfectly(self) -> StardewRule: | ||
skill_rule = self.skill.has_level(Skill.fishing, 10) | ||
return skill_rule & self.tool.has_fishing_rod(4) | ||
skill_rule = self.logic.skill.has_level(Skill.fishing, 10) | ||
return skill_rule & self.logic.tool.has_fishing_rod(4) | ||
|
||
def can_chop_trees(self) -> StardewRule: | ||
return self.tool.has_tool(Tool.axe) & self.region.can_reach(Region.forest) | ||
return self.logic.tool.has_tool(Tool.axe) & self.logic.region.can_reach(Region.forest) | ||
|
||
def can_chop_perfectly(self) -> StardewRule: | ||
magic_rule = (self.magic.can_use_clear_debris_instead_of_tool_level(3)) & self.mod_skill.has_mod_level(ModSkill.magic, 10) | ||
tool_rule = self.tool.has_tool(Tool.axe, ToolMaterial.iridium) | ||
foraging_rule = self.skill.has_level(Skill.foraging, 10) | ||
region_rule = self.region.can_reach(Region.forest) | ||
magic_rule = (self.logic.magic.can_use_clear_debris_instead_of_tool_level(3)) & self.logic.mod.skill.has_mod_level(ModSkill.magic, 10) | ||
tool_rule = self.logic.tool.has_tool(Tool.axe, ToolMaterial.iridium) | ||
foraging_rule = self.logic.skill.has_level(Skill.foraging, 10) | ||
region_rule = self.logic.region.can_reach(Region.forest) | ||
return region_rule & ((tool_rule & foraging_rule) | magic_rule) | ||
|
||
def has_max_buffs(self) -> StardewRule: | ||
return self.received(Buff.movement, self.movement_buff_option.value) & self.received(Buff.luck, self.luck_buff_option.value) | ||
return self.logic.received(Buff.movement, self.options.movement_buff_number.value) & self.logic.received(Buff.luck, self.options.luck_buff_number.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
from typing import Union | ||
|
||
from Utils import cache_self1 | ||
from .cached_logic import CachedLogic | ||
from .has_logic import HasLogic, CachedRules | ||
from .received_logic import ReceivedLogic | ||
from .region_logic import RegionLogic | ||
from .base_logic import BaseLogic, BaseLogicMixin | ||
from .has_logic import HasLogicMixin | ||
from .received_logic import ReceivedLogicMixin | ||
from .region_logic import RegionLogicMixin | ||
from ..stardew_rule import StardewRule, True_, Or | ||
from ..strings.generic_names import Generic | ||
from ..strings.geode_names import Geode | ||
from ..strings.region_names import Region | ||
|
||
|
||
class ActionLogic(CachedLogic): | ||
received: ReceivedLogic | ||
has: HasLogic | ||
region: RegionLogic | ||
class ActionLogicMixin(BaseLogicMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.action = ActionLogic(*args, **kwargs) | ||
|
||
|
||
def __init__(self, player: int, cached_rules: CachedRules, received: ReceivedLogic, has: HasLogic, | ||
region: RegionLogic): | ||
super().__init__(player, cached_rules) | ||
self.received = received | ||
self.has = has | ||
self.region = region | ||
class ActionLogic(BaseLogic[Union[ActionLogicMixin, RegionLogicMixin, ReceivedLogicMixin, HasLogicMixin]]): | ||
|
||
def can_watch(self, channel: str = None): | ||
tv_rule = True_() | ||
if channel is None: | ||
return tv_rule | ||
return self.received(channel) & tv_rule | ||
return self.logic.received(channel) & tv_rule | ||
|
||
def can_pan(self) -> StardewRule: | ||
return self.received("Glittering Boulder Removed") & self.region.can_reach(Region.mountain) | ||
return self.logic.received("Glittering Boulder Removed") & self.logic.region.can_reach(Region.mountain) | ||
|
||
def can_pan_at(self, region: str) -> StardewRule: | ||
return self.region.can_reach(region) & self.can_pan() | ||
return self.logic.region.can_reach(region) & self.logic.action.can_pan() | ||
|
||
@cache_self1 | ||
def can_open_geode(self, geode: str) -> StardewRule: | ||
blacksmith_access = self.region.can_reach(Region.blacksmith) | ||
blacksmith_access = self.logic.region.can_reach(Region.blacksmith) | ||
geodes = [Geode.geode, Geode.frozen, Geode.magma, Geode.omni] | ||
if geode == Generic.any: | ||
return blacksmith_access & Or(*(self.has(geode_type) for geode_type in geodes)) | ||
return blacksmith_access & self.has(geode) | ||
return blacksmith_access & Or(*(self.logic.has(geode_type) for geode_type in geodes)) | ||
return blacksmith_access & self.logic.has(geode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
from .received_logic import ReceivedLogic | ||
from .region_logic import RegionLogic | ||
from typing import Union | ||
|
||
from .base_logic import BaseLogic, BaseLogicMixin | ||
from .received_logic import ReceivedLogicMixin | ||
from .region_logic import RegionLogicMixin | ||
from .. import options | ||
from ..options import ArcadeMachineLocations | ||
from ..stardew_rule import StardewRule, True_ | ||
from ..strings.region_names import Region | ||
|
||
|
||
class ArcadeLogic: | ||
player: int | ||
arcade_option: ArcadeMachineLocations | ||
received = ReceivedLogic | ||
region: RegionLogic | ||
class ArcadeLogicMixin(BaseLogicMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.arcade = ArcadeLogic(*args, **kwargs) | ||
|
||
|
||
def __init__(self, player: int, arcade_option: ArcadeMachineLocations, received: ReceivedLogic, region: RegionLogic): | ||
self.player = player | ||
self.arcade_option = arcade_option | ||
self.received = received | ||
self.region = region | ||
class ArcadeLogic(BaseLogic[Union[ArcadeLogicMixin, RegionLogicMixin, ReceivedLogicMixin]]): | ||
|
||
def has_jotpk_power_level(self, power_level: int) -> StardewRule: | ||
if self.arcade_option != options.ArcadeMachineLocations.option_full_shuffling: | ||
if self.options.arcade_machine_locations != options.ArcadeMachineLocations.option_full_shuffling: | ||
return True_() | ||
jotpk_buffs = ("JotPK: Progressive Boots", "JotPK: Progressive Gun", "JotPK: Progressive Ammo", "JotPK: Extra Life", "JotPK: Increased Drop Rate") | ||
return self.received(jotpk_buffs, power_level) | ||
return self.logic.received(jotpk_buffs, power_level) | ||
|
||
def has_junimo_kart_power_level(self, power_level: int) -> StardewRule: | ||
if self.arcade_option != options.ArcadeMachineLocations.option_full_shuffling: | ||
if self.options.arcade_machine_locations != options.ArcadeMachineLocations.option_full_shuffling: | ||
return True_() | ||
return self.received("Junimo Kart: Extra Life", power_level) | ||
return self.logic.received("Junimo Kart: Extra Life", power_level) | ||
|
||
def has_junimo_kart_max_level(self) -> StardewRule: | ||
play_rule = self.region.can_reach(Region.junimo_kart_3) | ||
if self.arcade_option != options.ArcadeMachineLocations.option_full_shuffling: | ||
play_rule = self.logic.region.can_reach(Region.junimo_kart_3) | ||
if self.options.arcade_machine_locations != options.ArcadeMachineLocations.option_full_shuffling: | ||
return play_rule | ||
return self.has_junimo_kart_power_level(8) | ||
return self.logic.arcade.has_junimo_kart_power_level(8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,53 @@ | ||
from typing import Union | ||
|
||
from .cached_logic import profile_rule | ||
from .has_logic import HasLogic | ||
from .time_logic import TimeLogic | ||
from .base_logic import BaseLogic, BaseLogicMixin | ||
from .has_logic import HasLogicMixin | ||
from .time_logic import TimeLogicMixin | ||
from ..stardew_rule import StardewRule | ||
from ..strings.crop_names import all_vegetables, all_fruits, Vegetable, Fruit | ||
from ..strings.generic_names import Generic | ||
from ..strings.machine_names import Machine | ||
|
||
|
||
class ArtisanLogic: | ||
player: int | ||
has: HasLogic | ||
time: TimeLogic | ||
class ArtisanLogicMixin(BaseLogicMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.artisan = ArtisanLogic(*args, **kwargs) | ||
|
||
def __init__(self, player: int, has: HasLogic, time: TimeLogic): | ||
self.player = player | ||
self.has = has | ||
self.time = time | ||
|
||
class ArtisanLogic(BaseLogic[Union[ArtisanLogicMixin, TimeLogicMixin, HasLogicMixin]]): | ||
|
||
def has_jelly(self) -> StardewRule: | ||
return self.can_preserves_jar(Fruit.any) | ||
return self.logic.artisan.can_preserves_jar(Fruit.any) | ||
|
||
def has_pickle(self) -> StardewRule: | ||
return self.can_preserves_jar(Vegetable.any) | ||
return self.logic.artisan.can_preserves_jar(Vegetable.any) | ||
|
||
def can_preserves_jar(self, item: str) -> StardewRule: | ||
machine_rule = self.has(Machine.preserves_jar) | ||
machine_rule = self.logic.has(Machine.preserves_jar) | ||
if item == Generic.any: | ||
return machine_rule | ||
if item == Fruit.any: | ||
return machine_rule & self.has(all_fruits, 1) | ||
return machine_rule & self.logic.has(all_fruits, 1) | ||
if item == Vegetable.any: | ||
return machine_rule & self.has(all_vegetables, 1) | ||
return machine_rule & self.has(item) | ||
return machine_rule & self.logic.has(all_vegetables, 1) | ||
return machine_rule & self.logic.has(item) | ||
|
||
def has_wine(self) -> StardewRule: | ||
return self.can_keg(Fruit.any) | ||
return self.logic.artisan.can_keg(Fruit.any) | ||
|
||
def has_juice(self) -> StardewRule: | ||
return self.can_keg(Vegetable.any) | ||
return self.logic.artisan.can_keg(Vegetable.any) | ||
|
||
def can_keg(self, item: str) -> StardewRule: | ||
machine_rule = self.has(Machine.keg) | ||
machine_rule = self.logic.has(Machine.keg) | ||
if item == Generic.any: | ||
return machine_rule | ||
if item == Fruit.any: | ||
return machine_rule & self.has(all_fruits, 1) | ||
return machine_rule & self.logic.has(all_fruits, 1) | ||
if item == Vegetable.any: | ||
return machine_rule & self.has(all_vegetables, 1) | ||
return machine_rule & self.has(item) | ||
return machine_rule & self.logic.has(all_vegetables, 1) | ||
return machine_rule & self.logic.has(item) | ||
|
||
def can_mayonnaise(self, item: str) -> StardewRule: | ||
return self.has(Machine.mayonnaise_machine) & self.has(item) | ||
return self.logic.has(Machine.mayonnaise_machine) & self.logic.has(item) |
Oops, something went wrong.