Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Advice on Perl OO program structure (MUD)

by hv (Prior)
on Jun 24, 2006 at 11:07 UTC ( [id://557376]=note: print w/replies, xml ) Need Help??


in reply to Advice on Perl OO program structure (MUD)

I agree with Joost that this is a perfectly reasonable start.

You'll want to consider various things for getting further from here:

  • class structure: you almost certainly want a base class for monsters/people. One important question is whether the characters controlled by players are "just another monster" or a separate class - I favour the first approach, since it means that (for example) it is easy to let players be any sort of creature, and automatically adopt the limitations and capabilities of that creature. However the second approach gives you flexibilities in other ways - you don't have to consider how arbitrary monsters level up, and it's much easier to retain game balance with player-specific tweaks.
  • class structure: you'll probably want a base class for locations. If you want consistent physics and large-area effects such as weather, you'll need to know the size of each location and take some care to ensure that things fit together consistently; if not, you can get away with not much more than a description and a list of exits.
  • class structure: you'll probably want a base class for items, that gives underlying support for things like weight/size and value.
  • namespace: as the number of classes starts to expand, the danger increases that you'll use a classname that clashes with one already in use on CPAN or in the perl core. I'd suggest from the start picking a name for the MUD and putting all your classes under that namespace, like "YourMudName::Peasant".
  • communication: you'll soon want to consider what is required to support multiple users (without which you only have an UD :) - each time something occurs that should result in a message, you need somehow to know who is in range to be informed about it: you need in some sense a list of observers of each location. If you can find a nice generalised way to handle that, it would probably be a great help in debugging - you could have (for example) a global monitor that observed everything, that wrote all such messages to a log file.

Hope this helps some,

Hugo

  • Comment on Re: Advice on Perl OO program structure (MUD)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://557376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found