From 6a91c861dccb6e441416532adf39ed7137db40f6 Mon Sep 17 00:00:00 2001 From: scribblecrumb Date: Mon, 2 Dec 2024 09:48:26 -0600 Subject: [PATCH 1/2] fix #3089 --- resources/dicts/events/new_cat/general.json | 4 ++-- scripts/utility.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/resources/dicts/events/new_cat/general.json b/resources/dicts/events/new_cat/general.json index b066ca6fb2..2d69c9ab01 100644 --- a/resources/dicts/events/new_cat/general.json +++ b/resources/dicts/events/new_cat/general.json @@ -597,7 +597,7 @@ "old_name", "clancat", "status:warrior", - "backstory:former_clancat_backstories" + "backstory:refugee1,guided4,retired_leader,ostracized_warrior,disgraced1,disgraced2,disgraced3,otherclan1,otherclan2,otherclan3,otherclan4" ] ], "other_clan": { @@ -619,7 +619,7 @@ "old_name", "clancat", "status:warrior", - "backstory:former_clancat_backstories" + "backstory:refugee1,guided4,retired_leader,ostracized_warrior,disgraced1,disgraced2,disgraced3,otherclan1,otherclan2,otherclan3,otherclan4" ] ], "injury": [ diff --git a/scripts/utility.py b/scripts/utility.py index 4b23472768..e19ad8826a 100644 --- a/scripts/utility.py +++ b/scripts/utility.py @@ -501,11 +501,18 @@ def create_new_cat_block( for _tag in attribute_list: match = re.match(r"backstory:(.+)", _tag) if match: - stor = [ - x for x in match.group(1).split(",") if x in BACKSTORIES["backstories"] - ] + bs_list = [x for x in match.group(1).split(",")] + stor = [] + for story in bs_list: + if story in BACKSTORIES["backstories"]: + stor.append(story) + elif story in BACKSTORIES["backstory_categories"]: + stor.extend(BACKSTORIES["backstory_categories"][story]) bs_override = True - chosen_backstory = choice(stor) + try: + chosen_backstory = choice(stor) + except IndexError: + print(f"given backstories: {_tag}") break # KITTEN THOUGHT From 26bdc034f668fa65ba4b1b87c96298abe066ceb9 Mon Sep 17 00:00:00 2001 From: scribblecrumb Date: Mon, 2 Dec 2024 09:50:28 -0600 Subject: [PATCH 2/2] remove try catch --- scripts/utility.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/utility.py b/scripts/utility.py index e19ad8826a..c392df4e3d 100644 --- a/scripts/utility.py +++ b/scripts/utility.py @@ -509,10 +509,6 @@ def create_new_cat_block( elif story in BACKSTORIES["backstory_categories"]: stor.extend(BACKSTORIES["backstory_categories"][story]) bs_override = True - try: - chosen_backstory = choice(stor) - except IndexError: - print(f"given backstories: {_tag}") break # KITTEN THOUGHT