Skip to content

Commit

Permalink
ArchipelagoMW#2143: switch from SpecialRange to NamedRange
Browse files Browse the repository at this point in the history
  • Loading branch information
el-u committed Nov 16, 2023
1 parent 000c1b2 commit de0fed3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion WebHostLib/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_html_doc(option_type: type(Options.Option)) -> str:
continue

option = world.options_dataclass.type_hints[option_name].from_any(option_value)
if isinstance(option, Options.SpecialRange) and isinstance(option_value, str):
if isinstance(option, Options.NamedRange) and isinstance(option_value, str):
assert option_value in option.special_range_names, \
f"Invalid preset value '{option_value}' for '{option_name}' in '{preset_name}'. " \
f"Expected {option.special_range_names.keys()} or {option.range_start}-{option.range_end}."
Expand Down
4 changes: 2 additions & 2 deletions docs/world api.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ the options and the values are the values to be set for that option. These prese

Note: The values must be a non-aliased value for the option type and can only include the following option types:

- If you have a `Range`/`SpecialRange` option, the value should be an `int` between the `range_start` and `range_end`
- If you have a `Range`/`NamedRange` option, the value should be an `int` between the `range_start` and `range_end`
values.
- If you have a `SpecialRange` option, the value can alternatively be a `str` that is one of the
- If you have a `NamedRange` option, the value can alternatively be a `str` that is one of the
`special_range_names` keys.
- If you have a `Choice` option, the value should be a `str` that is one of the `option_<name>` values.
- If you have a `Toggle`/`DefaultOnToggle` option, the value should be a `bool`.
Expand Down
8 changes: 4 additions & 4 deletions test/webhost/test_option_presets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from worlds import AutoWorldRegister
from Options import Choice, SpecialRange, Toggle, Range
from Options import Choice, NamedRange, Toggle, Range


class TestOptionPresets(unittest.TestCase):
Expand All @@ -14,7 +14,7 @@ def test_option_presets_have_valid_options(self):
with self.subTest(game=game_name, preset=preset_name, option=option_name):
try:
option = world_type.options_dataclass.type_hints[option_name].from_any(option_value)
supported_types = [Choice, Toggle, Range, SpecialRange]
supported_types = [Choice, Toggle, Range, NamedRange]
if not any([issubclass(option.__class__, t) for t in supported_types]):
self.fail(f"'{option_name}' in preset '{preset_name}' for game '{game_name}' "
f"is not a supported type for webhost. "
Expand Down Expand Up @@ -46,8 +46,8 @@ def test_option_preset_values_are_explicitly_defined(self):

# Check for from_text resolving to a different value. ("random" is allowed though.)
if option_value != "random" and isinstance(option_value, str):
# Allow special named values for SpecialRange option presets.
if isinstance(option, SpecialRange):
# Allow special named values for NamedRange option presets.
if isinstance(option, NamedRange):
self.assertTrue(
option_value in option.special_range_names,
f"Invalid preset '{option_name}': '{option_value}' in preset '{preset_name}' "
Expand Down

0 comments on commit de0fed3

Please sign in to comment.