From ce8d9ff6a98aa7561a2ece6efb039d65984c3289 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Sat, 12 Sep 2020 13:23:48 -0700 Subject: [PATCH] Report which linked option is badly formatted if possible. --- Mystery.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mystery.py b/Mystery.py index 6e519901..8a304ee3 100644 --- a/Mystery.py +++ b/Mystery.py @@ -252,8 +252,13 @@ def roll_settings(weights): if "linked_options" in weights: weights = weights.copy() # make sure we don't write back to other weights sets in same_settings for option_set in weights["linked_options"]: - if random.random() < (option_set["percentage"] / 100): - weights.update(option_set["options"]) + if "name" not in option_set: + raise ValueError("One of your linked options does not have a name.") + try: + if random.random() < (option_set["percentage"] / 100): + weights.update(option_set["options"]) + except Exception as e: + raise ValueError(f"Linked option {option_set['name']} is destroyed. Please fix your linked option.") from e ret.name = get_choice('name', weights) if ret.name: