forked from mirror/Archipelago
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.
72 lines
3.3 KiB
Python
72 lines
3.3 KiB
Python
from functools import cached_property
|
|
from typing import Iterable, Union, Hashable
|
|
|
|
from Utils import cache_self1
|
|
from .base_logic import BaseLogicMixin, BaseLogic
|
|
from .time_logic import MAX_MONTHS
|
|
from ..data import monster_data
|
|
from ..data.fish_data import ginger_island_river
|
|
from ..stardew_rule import StardewRule
|
|
from ..strings.generic_names import Generic
|
|
from ..strings.region_names import Region
|
|
|
|
|
|
class MonsterLogicMixin(BaseLogicMixin):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.monster = MonsterLogic(*args, **kwargs)
|
|
|
|
|
|
class MonsterLogic(BaseLogic):
|
|
|
|
@cached_property
|
|
def all_monsters_by_name(self):
|
|
return monster_data.all_monsters_by_name_given_content_packs(self.content.registered_packs)
|
|
|
|
@cached_property
|
|
def all_monsters_by_category(self):
|
|
return monster_data.all_monsters_by_category_given_content_packs(self.content.registered_packs)
|
|
|
|
def can_kill(self, monster: Union[str, monster_data.StardewMonster], amount_tier: int = 0) -> StardewRule:
|
|
if amount_tier <= 0:
|
|
amount_tier = 0
|
|
time_rule = self.logic.time.has_lived_months(amount_tier)
|
|
|
|
if isinstance(monster, str):
|
|
if monster == Generic.any:
|
|
return self.logic.monster.can_kill_any(self.all_monsters_by_name.values()) & time_rule
|
|
|
|
monster = self.all_monsters_by_name[monster]
|
|
region_rule = self.logic.region.can_reach_any(*monster.locations)
|
|
combat_rule = self.logic.combat.can_fight_at_level(monster.difficulty)
|
|
|
|
return region_rule & combat_rule & time_rule
|
|
|
|
@cache_self1
|
|
def can_kill_many(self, monster: Union[str, monster_data.StardewMonster]) -> StardewRule:
|
|
return self.logic.monster.can_kill(monster, MAX_MONTHS / 3)
|
|
|
|
@cache_self1
|
|
def can_kill_max(self, monster: Union[str, monster_data.StardewMonster]) -> StardewRule:
|
|
return self.logic.monster.can_kill(monster, MAX_MONTHS)
|
|
|
|
# Should be cached
|
|
def can_kill_any(self, monsters: (Iterable[Union[str, monster_data.StardewMonster]], Hashable), amount_tier: int = 0) -> StardewRule:
|
|
return self.logic.or_(*(self.logic.monster.can_kill(monster, amount_tier) for monster in monsters))
|
|
|
|
# Should be cached
|
|
def can_kill_all(self, monsters: (Iterable[Union[str, monster_data.StardewMonster]], Hashable), amount_tier: int = 0) -> StardewRule:
|
|
return self.logic.and_(*(self.logic.monster.can_kill(monster, amount_tier) for monster in monsters))
|
|
|
|
def can_complete_all_monster_slaying_goals(self) -> StardewRule:
|
|
rules = [self.logic.time.has_lived_max_months]
|
|
exclude_island = not self.content.is_enabled(ginger_island_river)
|
|
island_regions = [Region.volcano_floor_5, Region.volcano_floor_10, Region.island_west, Region.dangerous_skull_cavern]
|
|
for category in self.all_monsters_by_category:
|
|
if exclude_island and all(all(location in island_regions for location in monster.locations)
|
|
for monster in self.all_monsters_by_category[category]):
|
|
continue
|
|
rules.append(self.logic.monster.can_kill_any(self.all_monsters_by_category[category]))
|
|
|
|
return self.logic.and_(*rules)
|