From bb635a596182adbbe9701e96d1631ca95fcdb7b6 Mon Sep 17 00:00:00 2001 From: PJ Beers Date: Thu, 11 Jul 2024 08:17:01 +0200 Subject: [PATCH] Features: Make FeatureSelector more robust This patch makes parsing options for a FeatureSelector more robust. First, it only compares selections with the keys of the FeatureSelector options dictionary, and second, it doesn't care whether developers have defined options lowercase or uppercase. In so doing, this fixes selecting a patron for the bloodhunter Order of the Profane Soul: The Bloodhunter Feature Selector for OtherwordlyPatron lists the options for the patron choices capitalised. However, the code in FeatureSelector expected them to be lowercased. Make the FeatureSelector not care about case. --- dungeonsheets/features/features.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dungeonsheets/features/features.py b/dungeonsheets/features/features.py index 399ddedd..74b50109 100644 --- a/dungeonsheets/features/features.py +++ b/dungeonsheets/features/features.py @@ -89,10 +89,12 @@ def __new__(t, owner, feature_choices=[]): new_feat.source = t.source new_feat.needs_implementation = True for selection in feature_choices: - if selection.lower() in t.options: - feat_class = t.options[selection.lower()] - if owner.has_feature(feat_class): - continue - new_feat = feat_class(owner=owner) - new_feat.source = t.source + for k in t.options.keys(): + if selection.lower() == k.lower(): + feat_class = t.options[k] + if owner.has_feature(feat_class): + continue + new_feat = feat_class(owner=owner) + new_feat.source = t.source + break return new_feat