Files
Grinch-AP/worlds/stardew_valley/test/TestRegions.py
Jérémie Bolduc af7d0dbf37 Stardew Valley: implement new game (#1455)
* Stardew Valley Archipelago implementation

* fix breaking changes

* - Added and Updated Documentation for the game

* Removed fun

* Remove entire idea of step, due to possible inconsistency with the main AP core

* Commented out the desired steps, fix renaming after rebase

* Fixed wording

* tests now passes on 3.8

* run flake8

* remove dependency so apworld work again

* remove dependency for real

* - Fix Formatting in the Game Page
- Removed disabled Option Descriptions for Entrance Randomizer
- Improved Game Page's description of the Arcade Machine buffs
- Trimmed down the text on the Options page for Arcade Machines, so that it is smaller

* - Removed blankspace

* remove player field

* remove None check in options

* document the scripts

* fix pytest warning

* use importlib.resources.files

* fix

* add version requirement to importlib_resources

* remove __init__.py from data folder

* increment data version

* let the __init__.py for 3.9

* use sorted() instead of list()

* replace frozenset from fish_data with tuples

* remove dependency on pytest

* - Add a bit of text to the guide to tell them about how to redeem some received items

* - Added a comment about which mod version to use

* change single quotes for double quotes

* Minimum client version both ways

* Changed version number to be more specific. The mod will handle deciding

---------

Co-authored-by: Alex Gilbert <alexgilbert@yahoo.com>
2023-02-27 01:19:15 +01:00

47 lines
2.3 KiB
Python

import random
import sys
import unittest
from .. import StardewOptions, options
from ..regions import stardew_valley_regions, mandatory_connections, randomize_connections, RandomizationFlag
connections_by_name = {connection.name for connection in mandatory_connections}
regions_by_name = {region.name for region in stardew_valley_regions}
class TestRegions(unittest.TestCase):
def test_region_exits_lead_somewhere(self):
for region in stardew_valley_regions:
with self.subTest(region=region):
for exit in region.exits:
assert exit in connections_by_name, f"{region.name} is leading to {exit} but it does not exist."
def test_connection_lead_somewhere(self):
for connection in mandatory_connections:
with self.subTest(connection=connection):
assert connection.destination in regions_by_name, \
f"{connection.name} is leading to {connection.destination} but it does not exist."
class TestEntranceRando(unittest.TestCase):
def test_pelican_town_entrance_randomization(self):
for option, flag in [(options.EntranceRandomization.option_pelican_town, RandomizationFlag.PELICAN_TOWN),
(options.EntranceRandomization.option_non_progression, RandomizationFlag.NON_PROGRESSION)]:
with self.subTest(option=option, flag=flag):
seed = random.randrange(sys.maxsize)
rand = random.Random(seed)
world_options = StardewOptions({options.EntranceRandomization.internal_name: option})
_, randomized_connections = randomize_connections(rand, world_options)
for connection in mandatory_connections:
if flag in connection.flag:
assert connection.name in randomized_connections, \
f"Connection {connection.name} should be randomized but it is not in the output. Seed = {seed}"
assert connection.reverse in randomized_connections, \
f"Connection {connection.reverse} should be randomized but it is not in the output. Seed = {seed}"
assert len(set(randomized_connections.values())) == len(
randomized_connections.values()), f"Connections are duplicated in randomization. Seed = {seed}"