2025-04-08 12:37:45 -04:00
|
|
|
import itertools
|
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
2024-07-07 16:04:25 +03:00
|
|
|
import logging
|
2023-07-19 14:26:38 -04:00
|
|
|
import os
|
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
2024-07-07 16:04:25 +03:00
|
|
|
import threading
|
2023-10-28 00:18:33 +02:00
|
|
|
import unittest
|
2024-03-15 15:05:14 +03:00
|
|
|
from contextlib import contextmanager
|
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
2024-07-07 16:04:25 +03:00
|
|
|
from typing import Dict, ClassVar, Iterable, Tuple, Optional, List, Union, Any
|
2023-02-26 19:19:15 -05:00
|
|
|
|
2024-12-08 21:00:30 -05:00
|
|
|
from BaseClasses import MultiWorld, CollectionState, get_seed, Location, Item
|
2024-03-15 15:05:14 +03:00
|
|
|
from test.bases import WorldTestBase
|
2023-07-30 13:17:12 -05:00
|
|
|
from test.general import gen_steps, setup_solo_multiworld as setup_base_solo_multiworld
|
|
|
|
from worlds.AutoWorld import call_all
|
2024-03-15 15:05:14 +03:00
|
|
|
from .assertion import RuleAssertMixin
|
2024-12-08 21:00:30 -05:00
|
|
|
from .options.utils import fill_namespace_with_default, parse_class_option_keys, fill_dataclass_with_default
|
2025-04-08 12:37:45 -04:00
|
|
|
from .. import StardewValleyWorld, StardewItem, StardewRule
|
|
|
|
from ..logic.time_logic import MONTH_COEFFICIENT
|
2024-12-08 21:00:30 -05:00
|
|
|
from ..options import StardewValleyOption
|
2023-02-26 19:19:15 -05: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
2024-07-07 16:04:25 +03:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
DEFAULT_TEST_SEED = get_seed()
|
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
2024-07-07 16:04:25 +03:00
|
|
|
logger.info(f"Default Test Seed: {DEFAULT_TEST_SEED}")
|
2023-02-26 19:19:15 -05:00
|
|
|
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
class SVTestCase(unittest.TestCase):
|
|
|
|
# Set False to not skip some 'extra' tests
|
|
|
|
skip_base_tests: bool = True
|
|
|
|
# Set False to run tests that take long
|
|
|
|
skip_long_tests: bool = True
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls) -> None:
|
|
|
|
super().setUpClass()
|
|
|
|
base_tests_key = "base"
|
|
|
|
if base_tests_key in os.environ:
|
|
|
|
cls.skip_base_tests = not bool(os.environ[base_tests_key])
|
|
|
|
long_tests_key = "long"
|
|
|
|
if long_tests_key in os.environ:
|
|
|
|
cls.skip_long_tests = not bool(os.environ[long_tests_key])
|
|
|
|
|
|
|
|
@contextmanager
|
|
|
|
def solo_world_sub_test(self, msg: Optional[str] = None,
|
|
|
|
/,
|
|
|
|
world_options: Optional[Dict[Union[str, StardewValleyOption], Any]] = None,
|
|
|
|
*,
|
|
|
|
seed=DEFAULT_TEST_SEED,
|
|
|
|
world_caching=True,
|
|
|
|
**kwargs) -> Tuple[MultiWorld, StardewValleyWorld]:
|
|
|
|
if msg is not None:
|
|
|
|
msg += " "
|
|
|
|
else:
|
|
|
|
msg = ""
|
|
|
|
msg += f"[Seed = {seed}]"
|
|
|
|
|
|
|
|
with self.subTest(msg, **kwargs):
|
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
2024-07-07 16:04:25 +03:00
|
|
|
with solo_multiworld(world_options, seed=seed, world_caching=world_caching) as (multiworld, world):
|
|
|
|
yield multiworld, world
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
class SVTestBase(RuleAssertMixin, WorldTestBase, SVTestCase):
|
|
|
|
game = "Stardew Valley"
|
|
|
|
world: StardewValleyWorld
|
|
|
|
player: ClassVar[int] = 1
|
|
|
|
|
|
|
|
seed = DEFAULT_TEST_SEED
|
|
|
|
|
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
2024-07-07 16:04:25 +03:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls) -> None:
|
|
|
|
if cls is SVTestBase:
|
|
|
|
raise unittest.SkipTest("No running tests on SVTestBase import.")
|
|
|
|
|
|
|
|
super().setUpClass()
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
def world_setup(self, *args, **kwargs):
|
|
|
|
self.options = parse_class_option_keys(self.options)
|
|
|
|
|
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
2024-07-07 16:04:25 +03:00
|
|
|
self.multiworld = setup_solo_multiworld(self.options, seed=self.seed)
|
|
|
|
self.multiworld.lock.acquire()
|
|
|
|
world = self.multiworld.worlds[self.player]
|
|
|
|
|
|
|
|
self.original_state = self.multiworld.state.copy()
|
|
|
|
self.original_itempool = self.multiworld.itempool.copy()
|
|
|
|
self.unfilled_locations = self.multiworld.get_unfilled_locations(1)
|
2024-03-15 15:05:14 +03:00
|
|
|
if self.constructed:
|
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
2024-07-07 16:04:25 +03:00
|
|
|
self.world = world # noqa
|
|
|
|
|
|
|
|
def tearDown(self) -> None:
|
|
|
|
self.multiworld.state = self.original_state
|
|
|
|
self.multiworld.itempool = self.original_itempool
|
|
|
|
for location in self.unfilled_locations:
|
|
|
|
location.item = None
|
|
|
|
|
|
|
|
self.multiworld.lock.release()
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
@property
|
|
|
|
def run_default_tests(self) -> bool:
|
|
|
|
if self.skip_base_tests:
|
|
|
|
return False
|
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
2024-07-07 16:04:25 +03:00
|
|
|
return super().run_default_tests
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
def collect_months(self, months: int) -> None:
|
|
|
|
real_total_prog_items = self.world.total_progression_items
|
|
|
|
percent = months * MONTH_COEFFICIENT
|
|
|
|
self.collect("Stardrop", real_total_prog_items * 100 // percent)
|
|
|
|
self.world.total_progression_items = real_total_prog_items
|
|
|
|
|
2024-09-18 01:03:33 +03:00
|
|
|
def collect_lots_of_money(self, percent: float = 0.25):
|
2024-11-29 19:46:35 -05:00
|
|
|
self.collect("Shipping Bin")
|
|
|
|
real_total_prog_items = self.world.total_progression_items
|
2024-09-18 01:03:33 +03:00
|
|
|
required_prog_items = int(round(real_total_prog_items * percent))
|
2024-11-29 19:46:35 -05:00
|
|
|
self.collect("Stardrop", required_prog_items)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
def collect_all_the_money(self):
|
2024-11-29 19:46:35 -05:00
|
|
|
self.collect_lots_of_money(0.95)
|
2024-03-15 15:05:14 +03: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
2024-07-07 16:04:25 +03:00
|
|
|
def collect_everything(self):
|
|
|
|
non_event_items = [item for item in self.multiworld.get_items() if item.code]
|
|
|
|
for item in non_event_items:
|
|
|
|
self.multiworld.state.collect(item)
|
|
|
|
|
|
|
|
def collect_all_except(self, item_to_not_collect: str):
|
2024-11-29 19:46:35 -05:00
|
|
|
non_event_items = [item for item in self.multiworld.get_items() if item.code]
|
|
|
|
for item in non_event_items:
|
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
2024-07-07 16:04:25 +03:00
|
|
|
if item.name != item_to_not_collect:
|
|
|
|
self.multiworld.state.collect(item)
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
def get_real_locations(self) -> List[Location]:
|
2024-04-14 13:37:48 -05:00
|
|
|
return [location for location in self.multiworld.get_locations(self.player) if location.address is not None]
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
def get_real_location_names(self) -> List[str]:
|
2024-04-14 13:37:48 -05:00
|
|
|
return [location.name for location in self.get_real_locations()]
|
2024-03-15 15:05:14 +03: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
2024-07-07 16:04:25 +03:00
|
|
|
def collect(self, item: Union[str, Item, Iterable[Item]], count: int = 1) -> Union[None, Item, List[Item]]:
|
|
|
|
assert count > 0
|
2024-11-29 19:46:35 -05: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
2024-07-07 16:04:25 +03:00
|
|
|
if not isinstance(item, str):
|
|
|
|
super().collect(item)
|
|
|
|
return
|
2024-11-29 19:46:35 -05: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
2024-07-07 16:04:25 +03:00
|
|
|
if count == 1:
|
|
|
|
item = self.create_item(item)
|
|
|
|
self.multiworld.state.collect(item)
|
|
|
|
return item
|
2024-11-29 19:46:35 -05: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
2024-07-07 16:04:25 +03:00
|
|
|
items = []
|
|
|
|
for i in range(count):
|
|
|
|
item = self.create_item(item)
|
|
|
|
self.multiworld.state.collect(item)
|
|
|
|
items.append(item)
|
2024-11-29 19:46:35 -05: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
2024-07-07 16:04:25 +03:00
|
|
|
return items
|
|
|
|
|
|
|
|
def create_item(self, item: str) -> StardewItem:
|
2024-11-29 19:46:35 -05:00
|
|
|
return self.world.create_item(item)
|
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
2024-07-07 16:04:25 +03:00
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
def get_all_created_items(self) -> list[str]:
|
|
|
|
return [item.name for item in itertools.chain(self.multiworld.get_items(), self.multiworld.precollected_items[self.player])]
|
|
|
|
|
2024-09-08 12:46:58 -04:00
|
|
|
def remove_one_by_name(self, item: str) -> None:
|
|
|
|
self.remove(self.create_item(item))
|
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
def reset_collection_state(self) -> None:
|
2024-09-08 12:46:58 -04:00
|
|
|
self.multiworld.state = self.original_state.copy()
|
|
|
|
|
2025-04-08 12:37:45 -04:00
|
|
|
def assert_rule_true(self, rule: StardewRule, state: CollectionState | None = None) -> None:
|
|
|
|
if state is None:
|
|
|
|
state = self.multiworld.state
|
|
|
|
super().assert_rule_true(rule, state)
|
|
|
|
|
|
|
|
def assert_rule_false(self, rule: StardewRule, state: CollectionState | None = None) -> None:
|
|
|
|
if state is None:
|
|
|
|
state = self.multiworld.state
|
|
|
|
super().assert_rule_false(rule, state)
|
|
|
|
|
|
|
|
def assert_can_reach_location(self, location: Location | str, state: CollectionState | None = None) -> None:
|
|
|
|
if state is None:
|
|
|
|
state = self.multiworld.state
|
|
|
|
super().assert_can_reach_location(location, state)
|
|
|
|
|
|
|
|
def assert_cannot_reach_location(self, location: Location | str, state: CollectionState | None = None) -> None:
|
|
|
|
if state is None:
|
|
|
|
state = self.multiworld.state
|
|
|
|
super().assert_cannot_reach_location(location, state)
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2023-04-10 19:44:59 -04:00
|
|
|
pre_generated_worlds = {}
|
|
|
|
|
|
|
|
|
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
2024-07-07 16:04:25 +03:00
|
|
|
@contextmanager
|
|
|
|
def solo_multiworld(world_options: Optional[Dict[Union[str, StardewValleyOption], Any]] = None,
|
|
|
|
*,
|
|
|
|
seed=DEFAULT_TEST_SEED,
|
|
|
|
world_caching=True) -> Tuple[MultiWorld, StardewValleyWorld]:
|
|
|
|
if not world_caching:
|
|
|
|
multiworld = setup_solo_multiworld(world_options, seed, _cache={})
|
|
|
|
yield multiworld, multiworld.worlds[1]
|
|
|
|
else:
|
|
|
|
multiworld = setup_solo_multiworld(world_options, seed)
|
|
|
|
multiworld.lock.acquire()
|
|
|
|
world = multiworld.worlds[1]
|
|
|
|
|
|
|
|
original_state = multiworld.state.copy()
|
|
|
|
original_itempool = multiworld.itempool.copy()
|
|
|
|
unfilled_locations = multiworld.get_unfilled_locations(1)
|
|
|
|
|
|
|
|
yield multiworld, world
|
|
|
|
|
|
|
|
multiworld.state = original_state
|
|
|
|
multiworld.itempool = original_itempool
|
|
|
|
for location in unfilled_locations:
|
|
|
|
location.item = None
|
|
|
|
|
|
|
|
multiworld.lock.release()
|
|
|
|
|
|
|
|
|
2023-04-10 19:44:59 -04:00
|
|
|
# Mostly a copy of test.general.setup_solo_multiworld, I just don't want to change the core.
|
2024-03-15 15:05:14 +03:00
|
|
|
def setup_solo_multiworld(test_options: Optional[Dict[Union[str, StardewValleyOption], str]] = None,
|
|
|
|
seed=DEFAULT_TEST_SEED,
|
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
2024-07-07 16:04:25 +03:00
|
|
|
_cache: Dict[frozenset, MultiWorld] = {}, # noqa
|
2024-03-15 15:05:14 +03:00
|
|
|
_steps=gen_steps) -> MultiWorld:
|
|
|
|
test_options = parse_class_option_keys(test_options)
|
2023-04-10 19:44:59 -04:00
|
|
|
|
|
|
|
# Yes I reuse the worlds generated between tests, its speeds the execution by a couple seconds
|
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
2024-07-07 16:04:25 +03:00
|
|
|
# If the simple dict caching ends up taking too much memory, we could replace it with some kind of lru cache.
|
2024-03-15 15:05:14 +03:00
|
|
|
should_cache = "start_inventory" not in test_options
|
|
|
|
if should_cache:
|
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
2024-07-07 16:04:25 +03:00
|
|
|
frozen_options = frozenset(test_options.items()).union({("seed", seed)})
|
|
|
|
cached_multi_world = search_world_cache(_cache, frozen_options)
|
|
|
|
if cached_multi_world:
|
|
|
|
print(f"Using cached solo multi world [Seed = {cached_multi_world.seed}] [Cache size = {len(_cache)}]")
|
2024-03-15 15:05:14 +03:00
|
|
|
return cached_multi_world
|
2023-04-10 19:44:59 -04:00
|
|
|
|
2024-03-10 12:47:45 -05:00
|
|
|
multiworld = setup_base_solo_multiworld(StardewValleyWorld, (), seed=seed)
|
2023-07-19 14:26:38 -04:00
|
|
|
# print(f"Seed: {multiworld.seed}") # Uncomment to print the seed for every test
|
2024-03-15 15:05:14 +03:00
|
|
|
|
2024-12-08 21:00:30 -05:00
|
|
|
args = fill_namespace_with_default(test_options)
|
2023-04-10 19:44:59 -04:00
|
|
|
multiworld.set_options(args)
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
if "start_inventory" in test_options:
|
|
|
|
for item, amount in test_options["start_inventory"].items():
|
|
|
|
for _ in range(amount):
|
|
|
|
multiworld.push_precollected(multiworld.create_item(item, 1))
|
|
|
|
|
|
|
|
for step in _steps:
|
2023-04-10 19:44:59 -04:00
|
|
|
call_all(multiworld, step)
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
if should_cache:
|
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
2024-07-07 16:04:25 +03:00
|
|
|
add_to_world_cache(_cache, frozen_options, multiworld) # noqa
|
|
|
|
|
|
|
|
# Lock is needed for multi-threading tests
|
|
|
|
setattr(multiworld, "lock", threading.Lock())
|
2024-03-15 15:05:14 +03:00
|
|
|
|
|
|
|
return multiworld
|
|
|
|
|
|
|
|
|
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
2024-07-07 16:04:25 +03:00
|
|
|
def search_world_cache(cache: Dict[frozenset, MultiWorld], frozen_options: frozenset) -> Optional[MultiWorld]:
|
|
|
|
try:
|
|
|
|
return cache[frozen_options]
|
|
|
|
except KeyError:
|
|
|
|
for cached_options, multi_world in cache.items():
|
|
|
|
if frozen_options.issubset(cached_options):
|
|
|
|
return multi_world
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def add_to_world_cache(cache: Dict[frozenset, MultiWorld], frozen_options: frozenset, multi_world: MultiWorld) -> None:
|
|
|
|
# We could complete the key with all the default options, but that does not seem to improve performances.
|
|
|
|
cache[frozen_options] = multi_world
|
|
|
|
|
|
|
|
|
2024-03-15 15:05:14 +03:00
|
|
|
def setup_multiworld(test_options: Iterable[Dict[str, int]] = None, seed=None) -> MultiWorld: # noqa
|
|
|
|
if test_options is None:
|
|
|
|
test_options = []
|
|
|
|
|
|
|
|
multiworld = MultiWorld(len(test_options))
|
|
|
|
multiworld.player_name = {}
|
|
|
|
multiworld.set_seed(seed)
|
|
|
|
multiworld.state = CollectionState(multiworld)
|
|
|
|
for i in range(1, len(test_options) + 1):
|
|
|
|
multiworld.game[i] = StardewValleyWorld.game
|
|
|
|
multiworld.player_name.update({i: f"Tester{i}"})
|
2024-12-08 21:00:30 -05:00
|
|
|
args = fill_namespace_with_default(test_options)
|
2024-07-26 05:33:14 -04:00
|
|
|
multiworld.set_options(args)
|
|
|
|
|
|
|
|
for step in gen_steps:
|
|
|
|
call_all(multiworld, step)
|
|
|
|
|
|
|
|
return multiworld
|