A while back I made a rule-based text adventure game engine in Python, inspired by Nelson's Inform 7 and also this presentation. My rule system didn't solve for specificity; it simply took the first rule which applied, so hopefully you define the rules in the correct order.
Decorators can go a long way for pretending Python has a metaprogramming facility!
(I made the engine so that I could experiment with a continuation-like object which saves the entire world state. Example at http://tep.mit.edu:8888/game/continuations )
Here's the obligatory Cloak of Darkness: https://github.com/kmill/textadv/blob/master/games/cloak.py
Decorators can go a long way for pretending Python has a metaprogramming facility!
(I made the engine so that I could experiment with a continuation-like object which saves the entire world state. Example at http://tep.mit.edu:8888/game/continuations )