Git Product home page Git Product logo

Comments (3)

wsowens avatar wsowens commented on June 9, 2024

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.

wsowens avatar wsowens commented on June 9, 2024

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.

wsowens avatar wsowens commented on June 9, 2024

The location.Exit class now supports the CharFilter, I'm considering this issue closed.

from swampymud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.