Remove temporary solution "OptionSets" in favor of AutoWorld's Options

This commit is contained in:
Fabian Dill
2021-07-04 16:18:21 +02:00
parent 2530d28c9d
commit 7d5b20ccfc
13 changed files with 145 additions and 156 deletions

View File

@@ -9,6 +9,7 @@ from collections import Counter
import string
import ModuleUpdate
from worlds.alttp import Options as LttPOptions
from worlds.generic import PlandoItem, PlandoConnection
ModuleUpdate.update()
@@ -546,9 +547,7 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b
ret.startinventory = startitems
ret.start_hints = set(game_weights.get('start_hints', []))
if ret.game == "A Link to the Past":
roll_alttp_settings(ret, game_weights, plando_options)
elif ret.game in AutoWorldRegister.world_types:
if ret.game in AutoWorldRegister.world_types:
for option_name, option in AutoWorldRegister.world_types[ret.game].options.items():
if option_name in game_weights:
if issubclass(option, Options.OptionDict):
@@ -569,18 +568,14 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b
get_choice("exit", placement),
get_choice("direction", placement, "both")
))
elif ret.game == "A Link to the Past":
roll_alttp_settings(ret, game_weights, plando_options)
else:
raise Exception(f"Unsupported game {ret.game}")
return ret
def roll_alttp_settings(ret: argparse.Namespace, weights, plando_options):
for option_name, option in Options.alttp_options.items():
if option_name in weights:
setattr(ret, option_name, option.from_any(get_choice(option_name, weights)))
else:
setattr(ret, option_name, option(option.default))
glitches_required = get_choice('glitches_required', weights)
if glitches_required not in [None, 'none', 'no_logic', 'overworld_glitches', 'hybrid_major_glitches', 'minor_glitches']:
logging.warning("Only NMG, OWG, HMG and No Logic supported")
@@ -631,7 +626,7 @@ def roll_alttp_settings(ret: argparse.Namespace, weights, plando_options):
extra_pieces = get_choice('triforce_pieces_mode', weights, 'available')
ret.triforce_pieces_required = Options.TriforcePieces.from_any(get_choice('triforce_pieces_required', weights, 20))
ret.triforce_pieces_required = LttPOptions.TriforcePieces.from_any(get_choice('triforce_pieces_required', weights, 20))
# sum a percentage to required
if extra_pieces == 'percentage':
@@ -639,7 +634,7 @@ def roll_alttp_settings(ret: argparse.Namespace, weights, plando_options):
ret.triforce_pieces_available = int(round(ret.triforce_pieces_required * percentage, 0))
# vanilla mode (specify how many pieces are)
elif extra_pieces == 'available':
ret.triforce_pieces_available = Options.TriforcePieces.from_any(
ret.triforce_pieces_available = LttPOptions.TriforcePieces.from_any(
get_choice('triforce_pieces_available', weights, 30))
# required pieces + fixed extra
elif extra_pieces == 'extra':