mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
14
Options.py
14
Options.py
@@ -973,7 +973,19 @@ class PlandoTexts(Option[typing.List[PlandoText]], VerifyKeys):
|
|||||||
if random.random() < float(text.get("percentage", 100)/100):
|
if random.random() < float(text.get("percentage", 100)/100):
|
||||||
at = text.get("at", None)
|
at = text.get("at", None)
|
||||||
if at is not None:
|
if at is not None:
|
||||||
|
if isinstance(at, dict):
|
||||||
|
if at:
|
||||||
|
at = random.choices(list(at.keys()),
|
||||||
|
weights=list(at.values()), k=1)[0]
|
||||||
|
else:
|
||||||
|
raise OptionError("\"at\" must be a valid string or weighted list of strings!")
|
||||||
given_text = text.get("text", [])
|
given_text = text.get("text", [])
|
||||||
|
if isinstance(given_text, dict):
|
||||||
|
if not given_text:
|
||||||
|
given_text = []
|
||||||
|
else:
|
||||||
|
given_text = random.choices(list(given_text.keys()),
|
||||||
|
weights=list(given_text.values()), k=1)
|
||||||
if isinstance(given_text, str):
|
if isinstance(given_text, str):
|
||||||
given_text = [given_text]
|
given_text = [given_text]
|
||||||
texts.append(PlandoText(
|
texts.append(PlandoText(
|
||||||
@@ -981,6 +993,8 @@ class PlandoTexts(Option[typing.List[PlandoText]], VerifyKeys):
|
|||||||
given_text,
|
given_text,
|
||||||
text.get("percentage", 100)
|
text.get("percentage", 100)
|
||||||
))
|
))
|
||||||
|
else:
|
||||||
|
raise OptionError("\"at\" must be a valid string or weighted list of strings!")
|
||||||
elif isinstance(text, PlandoText):
|
elif isinstance(text, PlandoText):
|
||||||
if random.random() < float(text.percentage/100):
|
if random.random() < float(text.percentage/100):
|
||||||
texts.append(text)
|
texts.append(text)
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ class ALttPPlandoConnections(PlandoConnections):
|
|||||||
entrances = set([connection[0] for connection in (
|
entrances = set([connection[0] for connection in (
|
||||||
*default_connections, *default_dungeon_connections, *inverted_default_connections,
|
*default_connections, *default_dungeon_connections, *inverted_default_connections,
|
||||||
*inverted_default_dungeon_connections)])
|
*inverted_default_dungeon_connections)])
|
||||||
exits = set([connection[1] for connection in (
|
exits = set([connection[0] for connection in (
|
||||||
*default_connections, *default_dungeon_connections, *inverted_default_connections,
|
*default_connections, *default_dungeon_connections, *inverted_default_connections,
|
||||||
*inverted_default_dungeon_connections)])
|
*inverted_default_dungeon_connections)])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user