-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Options: support "random" and variations for OptionSet with defined valid_keys #4418
base: main
Are you sure you want to change the base?
Conversation
raise Exception( | ||
f"{random_range[0]}-{random_range[1]} is outside allowed range " | ||
f"0-{len(choice_list)} for option {self.__name__} for player {player_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make more sense to just modify the chosen range instead of raising an exception because unlike normal random range the only way to find the "allowed range" is to hit this exception
Co-authored-by: qwint <[email protected]>
|
||
def __init__(self, value: typing.Iterable[str]): | ||
def __init__(self, value: typing.Iterable[str], random_str: str = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
is not a string
Really makes me wish we found a way already to actually put location groups and item groups in valid_keys Pretty cool tho |
Oh, just realized something |
What is this fixing or adding?
Adds support for
random
,random-low
,random-high
,random-mid
, andrandom-range-x-y
to OptionSet. The behavior is defined as follows.random
is a random number of random itemsrandom-low
,random-high
, andrandom-mid
is a random number (weighted towards the argument) of random itemsrandom-range-x-y
is a random number between x and y of random items. This also supportsrandom-range-low
and similar variants.Only OptionSets that define valid keys (and thus, could appear on WebHost) can utilize this behavior. No WebHost behavior has been changed for now. Item/LocationSets are supported.
How was this tested?
Manually by providing a number of possible values to several OptionSet options in core. No automated testing has been added.
If this makes graphical changes, please attach screenshots.