Skip to content

Commit

Permalink
add test to make sure worlds are actually completable for given options
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouramie committed Mar 2, 2023
1 parent 27983d2 commit 41b39de
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions worlds/stardew_valley/test/TestOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from BaseClasses import ItemClassification
from BaseClasses import ItemClassification, MultiWorld
from Options import SpecialRange
from worlds.stardew_valley import StardewItem
from . import setup_solo_multiworld
Expand All @@ -13,24 +13,33 @@
TOOLS = {"Hoe", "Pickaxe", "Axe", "Watering Can", "Trash Can", "Fishing Rod"}


def assert_can_win(multi_world: MultiWorld):
for item in multi_world.get_items():
multi_world.state.collect(item)

assert multi_world.find_item("Victory", 1).can_reach(multi_world.state)


@pytest.mark.parametrize("option, value", [(option, value)
for option in stardew_valley_option_classes
if issubclass(option, SpecialRange)
for value in option.special_range_names])
def test_given_special_range_when_generate_then_can_generate(option: (SpecialRange, StardewOption), value):
def test_given_special_range_when_generate_then_can_win(option: (SpecialRange, StardewOption), value):
multi_world = setup_solo_multiworld({option.internal_name: option.special_range_names[value]})

assert StardewItem("Victory", ItemClassification.progression, None, 1) in multi_world.get_items()
assert_can_win(multi_world)


@pytest.mark.parametrize("option, value", [(option, value)
for option in stardew_valley_option_classes
if option.options
for value in option.options])
def test_given_choice_when_generate_then_can_generate(option, value):
def test_given_choice_when_generate_then_can_win(option, value):
multi_world = setup_solo_multiworld({option.internal_name: option.options[value]})

assert StardewItem("Victory", ItemClassification.progression, None, 1) in multi_world.get_items()
assert_can_win(multi_world)


class TestGoal:
Expand Down

0 comments on commit 41b39de

Please sign in to comment.