Files
Grinch-AP/worlds/stardew_valley/test/checks/option_checks.py
agilbert1412 62657df3fb Stardew Valley: 4.x.x - The Ginger Update (#1931)
## What is this fixing or adding?
Major content update for Stardew Valley

## How was this tested?
One large-scale public Beta on the archipelago server, plus several smaller private asyncs and test runs

You can go to https://github.com/agilbert1412/StardewArchipelago/releases to grab the mod (latest 4.x.x version), the supported mods and the apworld, to test this PR

## New Features:
- Festival Checks [Easy mode or Hard Mode]
- Special Orders [Both Board and Qi]
- Willy's Boat
- Ginger Island Parrots
- TV Channels
- Trap Items [Available in various difficulty levels]
- Entrance Randomizer: Buildings and Chaos
- New Fishsanity options: Exclude Legendaries, Exclude Hard fish, Only easy fish
- Resource Pack overhaul [Resource packs are now more enjoyable and varied]
- Goal: Greatest Walnut Hunter [Find every single Golden Walnut]
- Goal: Perfection [Achieve Perfection]
- Option: Profit Margin [Multiplier over all earnings]
- Option: Friendsanity Heart Size [Reduce clutter from friendsanity hearts]
- Option: Exclude Ginger Island - will exclude many locations and items to generate a playthrough that does not go to the island
- Mod Support [Curated list of mods]

## New Contributors:
@Witchybun for the mod support

---------

Co-authored-by: Witchybun <embenham05@gmail.com>
Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
2023-07-19 20:26:38 +02:00

91 lines
3.8 KiB
Python

from typing import Union
from BaseClasses import MultiWorld
from .world_checks import get_all_item_names, get_all_location_names
from .. import SVTestBase
from ... import StardewValleyWorld, options, item_table, Group, location_table
from ...locations import LocationTags
from ...strings.ap_names.transport_names import Transportation
def get_stardew_world(multiworld: MultiWorld) -> Union[StardewValleyWorld, None]:
for world_key in multiworld.worlds:
world = multiworld.worlds[world_key]
if isinstance(world, StardewValleyWorld):
return world
return None
def is_setting(multiworld: MultiWorld, setting_name: str, setting_value: int) -> bool:
stardew_world = get_stardew_world(multiworld)
if not stardew_world:
return False
current_value = stardew_world.options[setting_name]
return current_value == setting_value
def is_not_setting(multiworld: MultiWorld, setting_name: str, setting_value: int) -> bool:
return not is_setting(multiworld, setting_name, setting_value)
def assert_is_setting(tester: SVTestBase, multiworld: MultiWorld, setting_name: str, setting_value: int) -> bool:
stardew_world = get_stardew_world(multiworld)
if not stardew_world:
return False
current_value = stardew_world.options[setting_name]
tester.assertEqual(current_value, setting_value)
def assert_can_reach_island(tester: SVTestBase, multiworld: MultiWorld):
all_item_names = get_all_item_names(multiworld)
tester.assertIn(Transportation.boat_repair, all_item_names)
tester.assertIn(Transportation.island_obelisk, all_item_names)
def assert_cannot_reach_island(tester: SVTestBase, multiworld: MultiWorld):
all_item_names = get_all_item_names(multiworld)
tester.assertNotIn(Transportation.boat_repair, all_item_names)
tester.assertNotIn(Transportation.island_obelisk, all_item_names)
def assert_can_reach_island_if_should(tester: SVTestBase, multiworld: MultiWorld):
include_island = is_setting(multiworld, options.ExcludeGingerIsland.internal_name, options.ExcludeGingerIsland.option_false)
if include_island:
assert_can_reach_island(tester, multiworld)
else:
assert_cannot_reach_island(tester, multiworld)
def assert_cropsanity_same_number_items_and_locations(tester: SVTestBase, multiworld: MultiWorld):
is_cropsanity = is_setting(multiworld, options.Cropsanity.internal_name, options.Cropsanity.option_shuffled)
if not is_cropsanity:
return
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}
tester.assertEqual(len(all_cropsanity_item_names), len(all_cropsanity_location_names))
def assert_all_rarecrows_exist(tester: SVTestBase, multiworld: MultiWorld):
all_item_names = set(get_all_item_names(multiworld))
for rarecrow_number in range(1, 9):
tester.assertIn(f"Rarecrow #{rarecrow_number}", all_item_names)
def assert_has_deluxe_scarecrow_recipe(tester: SVTestBase, multiworld: MultiWorld):
all_item_names = set(get_all_item_names(multiworld))
tester.assertIn(f"Deluxe Scarecrow Recipe", all_item_names)
def assert_festivals_give_access_to_deluxe_scarecrow(tester: SVTestBase, multiworld: MultiWorld):
has_festivals = is_not_setting(multiworld, options.FestivalLocations.internal_name, options.FestivalLocations.option_disabled)
if not has_festivals:
return
assert_all_rarecrows_exist(tester, multiworld)
assert_has_deluxe_scarecrow_recipe(tester, multiworld)