20080516

Eventos - a little taste of what may be to come

Aside from fixing tons of bugs with various things, I've been working slowly on Eventos, which are events, as you might have guessed. I won't say much about them now because the design is still somewhat in flux. It's basically an observer pattern that will replace each character writing text to other characters' terminals, in favor of sending messages to them. This will hopefully be the infrastructure that ultimately enables mobprogs, oprogs, rprogs, and whatever other kinds of progs you can think of.

A sample:

<type commands for a list> say hi
You say, 'hi'

<type commands for a list>
a man says, 'What do you mean, "hi"???'

<type commands for a list> say wut
You say, 'wut'

<type commands for a list>
a man says, 'What do you mean, "wut"???'

Yes, this gets old real fast. But it demonstrates something. Assuming the man standing in the room isn't parsing the text, "You say, '[text]'"1, he must be getting the text being said some other way. Indeed, he's receiving a SayEvento with the saidText property properly set to the contents of the message.

For fun, here's the old code...

@room.bagMobsInRoom.msgToAllExcept(self, "\\\\r\\\\n#{self.shortDescription} says, '#{text}'", "You say, '#{text}'")

...and the new code.

@room.speakEvento(SayEvento.new(self, text))

More on this later, when it's completed.

1 I would sooner stab myself in the eye than design a feature like that.

0 comments:

Post a Comment