Comments (3)
I've implemented this feature on the branch class-filter.
Here's a test:
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:
Testing: salty_spitoon
steve False
gandalf False
bill False
sabrina False
rich piana True
Default Character False
Magical False
Wizard False
Witch False
Brute True
Testing: no_brutes_allowed
steve True
gandalf True
bill True
sabrina True
rich piana False
Default Character True
Magical True
Wizard True
Witch True
Brute False
Testing: magic_users_club
steve False
gandalf True
bill True
sabrina True
rich piana False
Default Character False
Magical True
Wizard True
Witch True
Brute False
Testing: we're fine with wizards, we just hate bill
steve True
gandalf True
bill False
sabrina True
rich piana True
Default Character True
Magical True
Wizard True
Witch True
Brute True
from swampymud.
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.
from swampymud.
The location.Exit class now supports the CharFilter, I'm considering this issue closed.
from swampymud.
Related Issues (20)
- Update DESIGN.md once setting is decided HOT 1
- fix the StocString class HOT 4
- Remove any tabs used in user-directed output HOT 1
- Update cmd_look in character.py to also list players in current location
- Add Class checking to items HOT 1
- Rewrite the EquipTarget class to less memory intensive
- Update cmd_look HOT 4
- Should we change cmd_walk to be cmd_go? HOT 2
- Use the "@property" decorator to make certain attributes readonly HOT 1
- Implement cmd_drop in the Character class HOT 1
- Implement class checking for Exits in Character.py HOT 1
- Add describe() methods to all of the classes in the sandbox
- Add a Color module HOT 3
- Switch mudimport to use YAML HOT 1
- Add a login system that allows users to regain control of a character after logging out
- Convert all commands to new-style commands HOT 2
- Write unit tests for each module HOT 2
- Add a recursive 'find' method HOT 1
- Bug: [ERROR] Unhandled exception in client_connected_cb
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swampymud.