Restore "random" option to weighted-settings (#1635)

* Restore "random" option to weighted-settings, adjust capitalization of hardcoded settings

* Set default value as "random" for Choice, TextChoice, and Toggle options with no default value
This commit is contained in:
Chris Wilson 2023-03-30 19:01:31 -04:00 committed by GitHub
parent d5b4a91a13
commit 1dc4e2b44b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -106,6 +106,9 @@ def create():
if sub_option_id == option.default:
this_option["defaultValue"] = sub_option_name
if not this_option["defaultValue"]:
this_option["defaultValue"] = "random"
elif issubclass(option, Options.Range):
game_options[option_name] = {
"type": "range",
@ -157,6 +160,14 @@ def create():
json.dump(player_settings, f, indent=2, separators=(',', ': '))
if not world.hidden and world.web.settings_page is True:
# Add the random option to Choice, TextChoice, and Toggle settings
for option in game_options.values():
if option["type"] == "select":
option["options"].append({"name": "Random", "value": "random"})
if not option["defaultValue"]:
option["defaultValue"] = "random"
weighted_settings["baseOptions"]["game"][game_name] = 0
weighted_settings["games"][game_name] = {}
weighted_settings["games"][game_name]["gameSettings"] = game_options

View File

@ -470,7 +470,17 @@ const buildWeightedSettingsDiv = (game, settings, gameItems, gameLocations) => {
const tr = document.createElement('tr');
const tdLeft = document.createElement('td');
tdLeft.classList.add('td-left');
tdLeft.innerText = option;
switch(option){
case 'random':
tdLeft.innerText = 'Random';
break;
case 'random-low':
tdLeft.innerText = "Random (Low)";
break;
case 'random-high':
tdLeft.innerText = "Random (High)";
break;
}
tr.appendChild(tdLeft);
const tdMiddle = document.createElement('td');