It seems like I'm overengineering the backend somewhat - surely I should just jump in and write usage code instead of worrying about exactly how events are going to be implemented? After the last few times I've tried to write this kind of thing, I know how fundamental it is to have a completely solid abstraction that you don't have to "tweak" to make it do what you want for each individual item.
I'm firmly of the belief that in this case, the object-oriented structure is absolutely the best way to achieve the kind of code-reuse I'm looking for - no matter how "Enterprise Hello World" it seems at first glance.
I quickly wrote in another vital feature: the ability to "skip" certain event handlers. Sure, lever-pulling might be a type of touch event, but you might not want to hear about how it feels smooth and cold to the touch when you've just triggered some major event - like the walls crashing down. Here's the implementation:
It's a relatively minor change code-wise, but it'll allow for a lot of flexibility in future. The output:
Working Lever was touched!
Working Lever was pulled!
Working Lever was lever-pulled!
Electrified Lever was touched!
ZAP!
You hit the forcefield around the lever!
Forcefield Lever was forcefield-lever-pulled!
The next "minor" thing to think about is multiple inheritance: I want to make sure that my system works correctly when an event is a type of more than one other super-event. I can't think of any particularly good examples right now - maybe hacking into a restricted computer terminal is a type of TechnologyInteraction
to implement the skill-checks, but with the StealthRequired
mixin to make sure that if you get noticed, the crap will hit the fan. Mainly, I want to solidify my understanding of how the method-resolution order will work; whether interrupts and ignores will be processed successfully and so on.
The next "major" points of focus are actions which don't have a single object as their target. For instance, "put the X in the Y" will require interactions between two objects, and "look around" won't require interactions with any. This is also likely the point where I start considering how the event handlers actually work - right now I'm just writing print statements to prove we can get to arbitrary code points, but when testing this out I'm going to start mocking up Player
and Environment
abstractions.