-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add a "CharacterFilter" class #32
Labels
enhancement
New feature or request
Comments
I've implemented this feature on the branch class-filter. from character import *
class Magical(Character):
pass
class Brute(Character):
pass
class Wizard(Magical):
pass
class Witch(Magical):
pass
steve = Character()
steve.set_name("steve")
gandalf = Wizard()
gandalf.set_name("gandalf")
bill = Wizard()
bill.set_name("bill")
sabrina = Witch()
sabrina.set_name("sabrina")
rich_piana = Brute()
rich_piana.set_name("rich piana")
filters = {
"salty_spitoon" : CharFilter(True, [Brute]),
"no_brutes_allowed" : CharFilter(False, [Brute]),
"magic_users_club" : CharFilter(True, [Magical]),
"we're fine with wizards, we just hate bill" : CharFilter(False, [bill])
}
for name, filter in filters.items():
print("Testing: %s" % name)
for thing in [steve, gandalf, bill, sabrina, rich_piana, Character, Magical, Wizard, Witch, Brute]:
print(str(thing).strip(), filter.allows(thing), sep="\t") Results:
|
Now we must rewrite this part of the Exit class, and add this to the item class. After with do the latter, #27 will be effectively solved. |
The location.Exit class now supports the CharFilter, I'm considering this issue closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now, the Exit class has a lot of specialized code to deal with allowing certain CharacterClasses in, and keeping certain CharacterClasses out.
In the interest of abstraction, we should abstract this code out into a new class,
CharacterFilter
. We could then painlessly reuse this functionality for items and entities later. This would solve Issue #27 as well.The text was updated successfully, but these errors were encountered: