Re: Some input needed

From: Brian Gray (mandy@NETCOM.COM)
Date: 08/23/97


On Sat, 23 Aug 1997, Daniel Koepke wrote:
> I think more apt would be to move the do_xxx() functions into the character
> class (eg., player and mobiles), and the actual interpreter into either
> the character or descriptor class.  This way you do:
>
>   // stupid little example
>   void character_class::example(char *str)
>   {
>      do_say(str,0,0);
>   }
>
> where do_say is part of the "character_class".  This way, mobiles like
> Puff and things still have access to the do_xxx() functions, and you
> eliminate some overhead by keeping the command interpreter away from
> the mobile/general character class (I suppose player_class::interpreter).
> Sound good? :)

Well, placing the do_xxx() functions in global space kind of defeats the
idea of encapsulation.  You had it right to begin with: place them in the
character class, which is a subclass both to players and mobs.  Just make
them virtual in case there are subtle implementation differences that
need accounting for.  In some cases, like socials, it may even be cool to
abstract them out further to a Thing class from which is inherited
Objects and Characters.

The more I think about it, the more I'm convinced that the interpreter
must be a member of the descriptor class, and should use RTTI to
determine whether or not a command is defined for the attached subclass
of Thing.  If it is, just call the function and rely on polymorphism to
select the correct function for the object on which it is acting.

 -- Brian


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST