Skip to content

Commit

Permalink
Features: Make FeatureSelector more robust
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PJBrs committed Aug 24, 2024
1 parent 1f24caa commit ce7ed4f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dungeonsheets/features/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ce7ed4f

Please sign in to comment.