diff --git a/Options.py b/Options.py index da2723d42a67..d9ddfc2e2fdb 100644 --- a/Options.py +++ b/Options.py @@ -955,14 +955,6 @@ def as_dict(self, *option_names: str, casing: str = "snake") -> typing.Dict[str, raise ValueError(f"{option_name} not found in {tuple(type(self).type_hints)}") return option_results - def get_value(self, option_name: str) -> typing.Any: - """ - Returns the value of a given option - - :param option_name: names of the option to return the value of - """ - return getattr(self, option_name).value - class LocalItems(ItemSet): """Forces these items to be in their native world.""" diff --git a/worlds/stardew_valley/test/checks/goal_checks.py b/worlds/stardew_valley/test/checks/goal_checks.py index e1059fe2d641..d0f06a6caafa 100644 --- a/worlds/stardew_valley/test/checks/goal_checks.py +++ b/worlds/stardew_valley/test/checks/goal_checks.py @@ -1,11 +1,11 @@ from BaseClasses import MultiWorld -from .option_checks import is_setting, assert_is_setting +from .option_checks import get_stardew_options from ... import options from .. import SVTestBase def is_goal(multiworld: MultiWorld, goal: int) -> bool: - return is_setting(multiworld, options.Goal.internal_name, goal) + return get_stardew_options(multiworld).goal.value == goal def is_bottom_mines(multiworld: MultiWorld) -> bool: @@ -33,7 +33,7 @@ def is_not_perfection(multiworld: MultiWorld) -> bool: def assert_ginger_island_is_included(tester: SVTestBase, multiworld: MultiWorld): - assert_is_setting(tester, multiworld, options.ExcludeGingerIsland.internal_name, options.ExcludeGingerIsland.option_false) + tester.assertEqual(get_stardew_options(multiworld).exclude_ginger_island, options.ExcludeGingerIsland.option_false) def assert_walnut_hunter_world_is_valid(tester: SVTestBase, multiworld: MultiWorld): diff --git a/worlds/stardew_valley/test/checks/option_checks.py b/worlds/stardew_valley/test/checks/option_checks.py index 06a97b8a256f..ce8e552461e3 100644 --- a/worlds/stardew_valley/test/checks/option_checks.py +++ b/worlds/stardew_valley/test/checks/option_checks.py @@ -1,5 +1,3 @@ -from typing import Union - from BaseClasses import MultiWorld from .world_checks import get_all_item_names, get_all_location_names from .. import SVTestBase @@ -8,32 +6,16 @@ from ...strings.ap_names.transport_names import Transportation -def get_stardew_world(multiworld: MultiWorld) -> Union[StardewValleyWorld, None]: +def get_stardew_world(multiworld: MultiWorld) -> StardewValleyWorld: 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.get_value(setting_name) - return current_value == setting_value - + raise ValueError("no stardew world in this multiworld") -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.get_value(setting_name) - tester.assertEqual(current_value, setting_value) +def get_stardew_options(multiworld: MultiWorld) -> options.StardewValleyOptions: + return get_stardew_world(multiworld).options def assert_can_reach_island(tester: SVTestBase, multiworld: MultiWorld): @@ -49,7 +31,8 @@ def assert_cannot_reach_island(tester: SVTestBase, multiworld: MultiWorld): def assert_can_reach_island_if_should(tester: SVTestBase, multiworld: MultiWorld): - include_island = is_setting(multiworld, options.ExcludeGingerIsland.internal_name, options.ExcludeGingerIsland.option_false) + stardew_options = get_stardew_options(multiworld) + include_island = stardew_options.exclude_ginger_island.value == options.ExcludeGingerIsland.option_false if include_island: assert_can_reach_island(tester, multiworld) else: @@ -57,7 +40,7 @@ def assert_can_reach_island_if_should(tester: SVTestBase, multiworld: 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) + is_cropsanity = get_stardew_options(multiworld).cropsanity.value == options.Cropsanity.option_shuffled if not is_cropsanity: return @@ -80,11 +63,10 @@ def assert_has_deluxe_scarecrow_recipe(tester: SVTestBase, multiworld: MultiWorl 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) + stardew_options = get_stardew_options(multiworld) + has_festivals = stardew_options.festival_locations.value != options.FestivalLocations.option_disabled if not has_festivals: return assert_all_rarecrows_exist(tester, multiworld) assert_has_deluxe_scarecrow_recipe(tester, multiworld) - -