Options: add a way to get all option names (for selection menus or such)
This commit is contained in:
parent
230d9d993e
commit
3c1ac134f2
|
@ -1298,7 +1298,7 @@ class Spoiler():
|
||||||
for f_option, option in options.items():
|
for f_option, option in options.items():
|
||||||
res = getattr(self.world, f_option)[player]
|
res = getattr(self.world, f_option)[player]
|
||||||
displayname = getattr(option, "displayname", f_option)
|
displayname = getattr(option, "displayname", f_option)
|
||||||
outfile.write(f'{displayname + ":":33}{res.get_option_name()}\n')
|
outfile.write(f'{displayname + ":":33}{res.get_current_option_name()}\n')
|
||||||
|
|
||||||
if player in self.world.get_game_players("A Link to the Past"):
|
if player in self.world.get_game_players("A Link to the Past"):
|
||||||
for team in range(self.world.teams):
|
for team in range(self.world.teams):
|
||||||
|
|
17
Options.py
17
Options.py
|
@ -42,12 +42,15 @@ class Option(metaclass=AssembleOptions):
|
||||||
autodisplayname = False
|
autodisplayname = False
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"{self.__class__.__name__}({self.get_option_name()})"
|
return f"{self.__class__.__name__}({self.get_current_option_name()})"
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.value)
|
return hash(self.value)
|
||||||
|
|
||||||
def get_option_name(self) -> str:
|
def get_current_option_name(self) -> str:
|
||||||
|
return self.get_option_name(self.value)
|
||||||
|
|
||||||
|
def get_option_name(self, value: typing.Any) -> str:
|
||||||
if self.autodisplayname:
|
if self.autodisplayname:
|
||||||
return self.name_lookup[self.value].replace("_", " ").title()
|
return self.name_lookup[self.value].replace("_", " ").title()
|
||||||
else:
|
else:
|
||||||
|
@ -104,8 +107,8 @@ class Toggle(Option):
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return int(self.value)
|
return int(self.value)
|
||||||
|
|
||||||
def get_option_name(self):
|
def get_option_name(self, value):
|
||||||
return ["No", "Yes"][int(self.value)]
|
return ["No", "Yes"][int(value)]
|
||||||
|
|
||||||
class DefaultOnToggle(Toggle):
|
class DefaultOnToggle(Toggle):
|
||||||
default = 1
|
default = 1
|
||||||
|
@ -164,7 +167,7 @@ class Range(Option, int):
|
||||||
return cls(data)
|
return cls(data)
|
||||||
return cls.from_text(str(data))
|
return cls.from_text(str(data))
|
||||||
|
|
||||||
def get_option_name(self):
|
def get_option_name(self, value):
|
||||||
return str(self.value)
|
return str(self.value)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -201,8 +204,8 @@ class OptionDict(Option):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
||||||
|
|
||||||
def get_option_name(self):
|
def get_option_name(self, value):
|
||||||
return str(self.value)
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
local_objective = Toggle # local triforce pieces, local dungeon prizes etc.
|
local_objective = Toggle # local triforce pieces, local dungeon prizes etc.
|
||||||
|
|
|
@ -41,7 +41,7 @@ class MinecraftLogic(LogicMixin):
|
||||||
|
|
||||||
# Difficulty-dependent functions
|
# Difficulty-dependent functions
|
||||||
def _mc_combat_difficulty(self, player: int):
|
def _mc_combat_difficulty(self, player: int):
|
||||||
return self.world.combat_difficulty[player].get_option_name()
|
return self.world.combat_difficulty[player].get_current_option_name()
|
||||||
|
|
||||||
def _mc_can_adventure(self, player: int):
|
def _mc_can_adventure(self, player: int):
|
||||||
if self._mc_combat_difficulty(player) == 'easy':
|
if self._mc_combat_difficulty(player) == 'easy':
|
||||||
|
|
Loading…
Reference in New Issue