mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Stardew Valley 6.x.x: The Content Update (#3478)
Focus of the Update: Compatibility with Stardew Valley 1.6 Released on March 19th 2024 This includes randomization for pretty much all of the new content, including but not limited to - Raccoon Bundles - Booksanity - Skill Masteries - New Recipes, Craftables, Fish, Maps, Farm Type, Festivals and Quests This also includes a significant reorganisation of the code into "Content Packs", to allow for easier modularity of various game mechanics between the settings and the supported mods. This improves maintainability quite a bit. In addition to that, a few **very** requested new features have been introduced, although they weren't the focus of this update - Walnutsanity - Player Buffs - More customizability in settings, such as shorter special orders, ER without farmhouse - New Remixed Bundles
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from .base_logic import BaseLogic
|
||||
from ..stardew_rule import StardewRule, And, Or, Has, Count
|
||||
from ..stardew_rule import StardewRule, And, Or, Has, Count, true_, false_
|
||||
|
||||
|
||||
class HasLogicMixin(BaseLogic[None]):
|
||||
true_ = true_
|
||||
false_ = false_
|
||||
|
||||
# Should be cached
|
||||
def has(self, item: str) -> StardewRule:
|
||||
return Has(item, self.registry.item_rules)
|
||||
@@ -10,12 +13,12 @@ class HasLogicMixin(BaseLogic[None]):
|
||||
def has_all(self, *items: str):
|
||||
assert items, "Can't have all of no items."
|
||||
|
||||
return And(*(self.has(item) for item in items))
|
||||
return self.logic.and_(*(self.has(item) for item in items))
|
||||
|
||||
def has_any(self, *items: str):
|
||||
assert items, "Can't have any of no items."
|
||||
|
||||
return Or(*(self.has(item) for item in items))
|
||||
return self.logic.or_(*(self.has(item) for item in items))
|
||||
|
||||
def has_n(self, *items: str, count: int):
|
||||
return self.count(count, *(self.has(item) for item in items))
|
||||
@@ -24,6 +27,16 @@ class HasLogicMixin(BaseLogic[None]):
|
||||
def count(count: int, *rules: StardewRule) -> StardewRule:
|
||||
assert rules, "Can't create a Count conditions without rules"
|
||||
assert len(rules) >= count, "Count need at least as many rules as the count"
|
||||
assert count > 0, "Count can't be negative"
|
||||
|
||||
count -= sum(r is true_ for r in rules)
|
||||
rules = list(r for r in rules if r is not true_)
|
||||
|
||||
if count <= 0:
|
||||
return true_
|
||||
|
||||
if len(rules) == 1:
|
||||
return rules[0]
|
||||
|
||||
if count == 1:
|
||||
return Or(*rules)
|
||||
@@ -31,4 +44,22 @@ class HasLogicMixin(BaseLogic[None]):
|
||||
if count == len(rules):
|
||||
return And(*rules)
|
||||
|
||||
return Count(list(rules), count)
|
||||
return Count(rules, count)
|
||||
|
||||
@staticmethod
|
||||
def and_(*rules: StardewRule) -> StardewRule:
|
||||
assert rules, "Can't create a And conditions without rules"
|
||||
|
||||
if len(rules) == 1:
|
||||
return rules[0]
|
||||
|
||||
return And(*rules)
|
||||
|
||||
@staticmethod
|
||||
def or_(*rules: StardewRule) -> StardewRule:
|
||||
assert rules, "Can't create a Or conditions without rules"
|
||||
|
||||
if len(rules) == 1:
|
||||
return rules[0]
|
||||
|
||||
return Or(*rules)
|
||||
|
||||
Reference in New Issue
Block a user