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,4 +1,4 @@
|
||||
from typing import Union, List
|
||||
from typing import Union, Iterable
|
||||
from unittest import TestCase
|
||||
|
||||
from BaseClasses import MultiWorld
|
||||
@@ -7,9 +7,11 @@ from ...mods.mod_data import ModNames
|
||||
|
||||
|
||||
class ModAssertMixin(TestCase):
|
||||
def assert_stray_mod_items(self, chosen_mods: Union[List[str], str], multiworld: MultiWorld):
|
||||
def assert_stray_mod_items(self, chosen_mods: Union[Iterable[str], str], multiworld: MultiWorld):
|
||||
if isinstance(chosen_mods, str):
|
||||
chosen_mods = [chosen_mods]
|
||||
else:
|
||||
chosen_mods = list(chosen_mods)
|
||||
|
||||
if ModNames.jasper in chosen_mods:
|
||||
# Jasper is a weird case because it shares NPC w/ SVE...
|
||||
|
||||
@@ -63,8 +63,12 @@ class OptionAssertMixin(TestCase):
|
||||
all_item_names = set(get_all_item_names(multiworld))
|
||||
all_location_names = set(get_all_location_names(multiworld))
|
||||
all_cropsanity_item_names = {item_name for item_name in all_item_names if Group.CROPSANITY in item_table[item_name].groups}
|
||||
all_cropsanity_location_names = {location_name for location_name in all_location_names if LocationTags.CROPSANITY in location_table[location_name].tags}
|
||||
self.assertEqual(len(all_cropsanity_item_names), len(all_cropsanity_location_names))
|
||||
all_cropsanity_location_names = {location_name
|
||||
for location_name in all_location_names
|
||||
if LocationTags.CROPSANITY in location_table[location_name].tags
|
||||
# Qi Beans do not have an item
|
||||
and location_name != "Harvest Qi Fruit"}
|
||||
self.assertEqual(len(all_cropsanity_item_names) + 1, len(all_cropsanity_location_names))
|
||||
|
||||
def assert_all_rarecrows_exist(self, multiworld: MultiWorld):
|
||||
all_item_names = set(get_all_item_names(multiworld))
|
||||
|
||||
@@ -1,17 +1,49 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from BaseClasses import CollectionState
|
||||
from .rule_explain import explain
|
||||
from ...stardew_rule import StardewRule, false_, MISSING_ITEM
|
||||
from BaseClasses import CollectionState, Location
|
||||
from ...stardew_rule import StardewRule, false_, MISSING_ITEM, Reach
|
||||
from ...stardew_rule.rule_explain import explain
|
||||
|
||||
|
||||
class RuleAssertMixin(TestCase):
|
||||
def assert_rule_true(self, rule: StardewRule, state: CollectionState):
|
||||
self.assertTrue(rule(state), explain(rule, state))
|
||||
expl = explain(rule, state)
|
||||
try:
|
||||
self.assertTrue(rule(state), expl)
|
||||
except KeyError as e:
|
||||
raise AssertionError(f"Error while checking rule {rule}: {e}"
|
||||
f"\nExplanation: {expl}")
|
||||
|
||||
def assert_rule_false(self, rule: StardewRule, state: CollectionState):
|
||||
self.assertFalse(rule(state), explain(rule, state, expected=False))
|
||||
expl = explain(rule, state, expected=False)
|
||||
try:
|
||||
self.assertFalse(rule(state), expl)
|
||||
except KeyError as e:
|
||||
raise AssertionError(f"Error while checking rule {rule}: {e}"
|
||||
f"\nExplanation: {expl}")
|
||||
|
||||
def assert_rule_can_be_resolved(self, rule: StardewRule, complete_state: CollectionState):
|
||||
self.assertNotIn(MISSING_ITEM, repr(rule))
|
||||
self.assertTrue(rule is false_ or rule(complete_state), explain(rule, complete_state))
|
||||
expl = explain(rule, complete_state)
|
||||
try:
|
||||
self.assertNotIn(MISSING_ITEM, repr(rule))
|
||||
self.assertTrue(rule is false_ or rule(complete_state), expl)
|
||||
except KeyError as e:
|
||||
raise AssertionError(f"Error while checking rule {rule}: {e}"
|
||||
f"\nExplanation: {expl}")
|
||||
|
||||
def assert_reach_location_true(self, location: Location, state: CollectionState):
|
||||
expl = explain(Reach(location.name, "Location", 1), state)
|
||||
try:
|
||||
can_reach = location.can_reach(state)
|
||||
self.assertTrue(can_reach, expl)
|
||||
except KeyError as e:
|
||||
raise AssertionError(f"Error while checking location {location.name}: {e}"
|
||||
f"\nExplanation: {expl}")
|
||||
|
||||
def assert_reach_location_false(self, location: Location, state: CollectionState):
|
||||
expl = explain(Reach(location.name, "Location", 1), state, expected=False)
|
||||
try:
|
||||
self.assertFalse(location.can_reach(state), expl)
|
||||
except KeyError as e:
|
||||
raise AssertionError(f"Error while checking location {location.name}: {e}"
|
||||
f"\nExplanation: {expl}")
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from functools import cached_property, singledispatch
|
||||
from typing import Iterable
|
||||
|
||||
from BaseClasses import CollectionState
|
||||
from worlds.generic.Rules import CollectionRule
|
||||
from ...stardew_rule import StardewRule, AggregatingStardewRule, Count, Has, TotalReceived, Received, Reach
|
||||
|
||||
max_explanation_depth = 10
|
||||
|
||||
|
||||
@dataclass
|
||||
class RuleExplanation:
|
||||
rule: StardewRule
|
||||
state: CollectionState
|
||||
expected: bool
|
||||
sub_rules: Iterable[StardewRule] = field(default_factory=list)
|
||||
|
||||
def summary(self, depth=0):
|
||||
return " " * depth + f"{str(self.rule)} -> {self.result}"
|
||||
|
||||
def __str__(self, depth=0):
|
||||
if not self.sub_rules or depth >= max_explanation_depth:
|
||||
return self.summary(depth)
|
||||
|
||||
return self.summary(depth) + "\n" + "\n".join(RuleExplanation.__str__(i, depth + 1)
|
||||
if i.result is not self.expected else i.summary(depth + 1)
|
||||
for i in sorted(self.explained_sub_rules, key=lambda x: x.result))
|
||||
|
||||
def __repr__(self, depth=0):
|
||||
if not self.sub_rules or depth >= max_explanation_depth:
|
||||
return self.summary(depth)
|
||||
|
||||
return self.summary(depth) + "\n" + "\n".join(RuleExplanation.__repr__(i, depth + 1)
|
||||
for i in sorted(self.explained_sub_rules, key=lambda x: x.result))
|
||||
|
||||
@cached_property
|
||||
def result(self):
|
||||
return self.rule(self.state)
|
||||
|
||||
@cached_property
|
||||
def explained_sub_rules(self):
|
||||
return [_explain(i, self.state, self.expected) for i in self.sub_rules]
|
||||
|
||||
|
||||
def explain(rule: CollectionRule, state: CollectionState, expected: bool = True) -> RuleExplanation:
|
||||
if isinstance(rule, StardewRule):
|
||||
return _explain(rule, state, expected)
|
||||
else:
|
||||
return f"Value of rule {str(rule)} was not {str(expected)} in {str(state)}" # noqa
|
||||
|
||||
|
||||
@singledispatch
|
||||
def _explain(rule: StardewRule, state: CollectionState, expected: bool) -> RuleExplanation:
|
||||
return RuleExplanation(rule, state, expected)
|
||||
|
||||
|
||||
@_explain.register
|
||||
def _(rule: AggregatingStardewRule, state: CollectionState, expected: bool) -> RuleExplanation:
|
||||
return RuleExplanation(rule, state, expected, rule.original_rules)
|
||||
|
||||
|
||||
@_explain.register
|
||||
def _(rule: Count, state: CollectionState, expected: bool) -> RuleExplanation:
|
||||
return RuleExplanation(rule, state, expected, rule.rules)
|
||||
|
||||
|
||||
@_explain.register
|
||||
def _(rule: Has, state: CollectionState, expected: bool) -> RuleExplanation:
|
||||
return RuleExplanation(rule, state, expected, [rule.other_rules[rule.item]])
|
||||
|
||||
|
||||
@_explain.register
|
||||
def _(rule: TotalReceived, state: CollectionState, expected=True) -> RuleExplanation:
|
||||
return RuleExplanation(rule, state, expected, [Received(i, rule.player, 1) for i in rule.items])
|
||||
|
||||
|
||||
@_explain.register
|
||||
def _(rule: Reach, state: CollectionState, expected=True) -> RuleExplanation:
|
||||
access_rules = None
|
||||
if rule.resolution_hint == 'Location':
|
||||
spot = state.multiworld.get_location(rule.spot, rule.player)
|
||||
|
||||
if isinstance(spot.access_rule, StardewRule):
|
||||
access_rules = [spot.access_rule, Reach(spot.parent_region.name, "Region", rule.player)]
|
||||
|
||||
elif rule.resolution_hint == 'Entrance':
|
||||
spot = state.multiworld.get_entrance(rule.spot, rule.player)
|
||||
|
||||
if isinstance(spot.access_rule, StardewRule):
|
||||
access_rules = [spot.access_rule, Reach(spot.parent_region.name, "Region", rule.player)]
|
||||
|
||||
else:
|
||||
spot = state.multiworld.get_region(rule.spot, rule.player)
|
||||
access_rules = [*(Reach(e.name, "Entrance", rule.player) for e in spot.entrances)]
|
||||
|
||||
if not access_rules:
|
||||
return RuleExplanation(rule, state, expected)
|
||||
|
||||
return RuleExplanation(rule, state, expected, access_rules)
|
||||
@@ -53,7 +53,7 @@ class WorldAssertMixin(RuleAssertMixin, TestCase):
|
||||
|
||||
def assert_can_reach_everything(self, multiworld: MultiWorld):
|
||||
for location in multiworld.get_locations():
|
||||
self.assert_rule_true(location.access_rule, multiworld.state)
|
||||
self.assert_reach_location_true(location, multiworld.state)
|
||||
|
||||
def assert_basic_checks(self, multiworld: MultiWorld):
|
||||
self.assert_same_number_items_locations(multiworld)
|
||||
|
||||
Reference in New Issue
Block a user