From 664e90840ed04d004ee0107801afc89ee1031741 Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:59:59 -0500 Subject: [PATCH 1/5] fix text dict handling --- Options.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Options.py b/Options.py index ecde6275f1ea..f8fcab3fa1c7 100644 --- a/Options.py +++ b/Options.py @@ -974,6 +974,9 @@ def from_any(cls, data: PlandoTextsFromAnyType) -> Self: at = text.get("at", None) if at is not None: given_text = text.get("text", []) + if isinstance(given_text, dict): + given_text = random.choices(list(given_text.keys()), + weights=list(given_text.values()), k=1) if isinstance(given_text, str): given_text = [given_text] texts.append(PlandoText( From ff682c4ea29f934c8d3615c0c4c5eabbebcd2f82 Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:01:57 -0500 Subject: [PATCH 2/5] at as well --- Options.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Options.py b/Options.py index f8fcab3fa1c7..94faaad09bad 100644 --- a/Options.py +++ b/Options.py @@ -973,6 +973,9 @@ def from_any(cls, data: PlandoTextsFromAnyType) -> Self: if random.random() < float(text.get("percentage", 100)/100): at = text.get("at", None) if at is not None: + if isinstance(at, dict): + at = random.choices(list(at.keys()), + weights=list(at.values()), k=1) given_text = text.get("text", []) if isinstance(given_text, dict): given_text = random.choices(list(given_text.keys()), From e1e55ddf18d02c92183ec9b7d26ef0ea51e9d312 Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:04:25 -0500 Subject: [PATCH 3/5] fix lttp --- worlds/alttp/Options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worlds/alttp/Options.py b/worlds/alttp/Options.py index 20dd18038a14..bd87cbf2c3ea 100644 --- a/worlds/alttp/Options.py +++ b/worlds/alttp/Options.py @@ -728,7 +728,7 @@ class ALttPPlandoConnections(PlandoConnections): entrances = set([connection[0] for connection in ( *default_connections, *default_dungeon_connections, *inverted_default_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, *inverted_default_dungeon_connections)]) From e0e598d771dd0f3e48a8a7fcc0bdacd92e25cf8c Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:46:29 -0500 Subject: [PATCH 4/5] needs to be a str --- Options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Options.py b/Options.py index 94faaad09bad..be70dd264971 100644 --- a/Options.py +++ b/Options.py @@ -975,7 +975,7 @@ def from_any(cls, data: PlandoTextsFromAnyType) -> Self: if at is not None: if isinstance(at, dict): at = random.choices(list(at.keys()), - weights=list(at.values()), k=1) + weights=list(at.values()), k=1)[0] given_text = text.get("text", []) if isinstance(given_text, dict): given_text = random.choices(list(given_text.keys()), From f6a385ec4eb8845d2ef823371983fc97f1ee94f8 Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:00:40 -0500 Subject: [PATCH 5/5] handle errors --- Options.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Options.py b/Options.py index be70dd264971..b79714635d9e 100644 --- a/Options.py +++ b/Options.py @@ -974,12 +974,18 @@ def from_any(cls, data: PlandoTextsFromAnyType) -> Self: at = text.get("at", None) if at is not None: if isinstance(at, dict): - at = random.choices(list(at.keys()), - weights=list(at.values()), k=1)[0] + 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", []) if isinstance(given_text, dict): - given_text = random.choices(list(given_text.keys()), - weights=list(given_text.values()), k=1) + 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): given_text = [given_text] texts.append(PlandoText( @@ -987,6 +993,8 @@ def from_any(cls, data: PlandoTextsFromAnyType) -> Self: given_text, text.get("percentage", 100) )) + else: + raise OptionError("\"at\" must be a valid string or weighted list of strings!") elif isinstance(text, PlandoText): if random.random() < float(text.percentage/100): texts.append(text)