-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make FeatureSelector more robust (fixes patron for Order of the Profane Soul) #167
Open
PJBrs
wants to merge
1
commit into
canismarko:master
Choose a base branch
from
PJBrs:bloodhunter-patron-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just to add the other solution: diff --git a/dungeonsheets/features/features.py b/dungeonsheets/features/features.py
index 399dded..74b5010 100644
--- a/dungeonsheets/features/features.py
+++ b/dungeonsheets/features/features.py
@@ -89,10 +89,12 @@ class FeatureSelector(Feature):
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 This way, it doesn't matter whether the options in a FeatureSelector are capitalised or lowercase. But don't let that refrain you from merging this PR! |
canismarko
requested changes
Aug 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer the alternate fix that changes the matching.
PJBrs
force-pushed
the
bloodhunter-patron-fix
branch
from
August 23, 2024 12:08
35731b7
to
bb635a5
Compare
Switched to the alternative fix! |
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.
PJBrs
force-pushed
the
bloodhunter-patron-fix
branch
from
November 29, 2024 19:30
bb635a5
to
6c2a2cd
Compare
PJBrs
changed the title
bloodhunter: Fix patron for Order of the Profane Soul
Make FeatureSelector more robust (fixes Fix patron for Order of the Profane Soul)
Nov 29, 2024
PJBrs
changed the title
Make FeatureSelector more robust (fixes Fix patron for Order of the Profane Soul)
Make FeatureSelector more robust (fixes patron for Order of the Profane Soul)
Nov 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Bloodhunter Feature Selector for OtherwordlyPatron lists the options for the patron choices capitalised. However, the code in FeatureSelector expects them to be lowercased. Make the options lowercase.
An alternative, more robust fix might have been to change some stuff over here:
dungeon-sheets/dungeonsheets/features/features.py
Line 92 in 5e07e38
So, the user's selection in feature_choices is lowered, but it is not checked against a lowered t.options in FeatureSelector. Then again, I think it only should check against the keys of t.options in FeatureSelector... Anyway, that's all academic for now, this patch just fixes #134
Usually, I'd have added c868575 as well, which is a good way to test this fix, but this time I decided to err on the side of caution :-)