in reply to Module Organization

If this is intended to be uploaded to CPAN, this PAUSE page has details under the heading Register your namespace!

Regardless of whether this is for CPAN or just personal use, I would strongly recommend you do a design first. I foresee you drowning in a sea of Roleplay::* modules for every type of creature, weapon, armour, potion, spell, etc.

Also give some thought to the long term. Even if your Players are only slaughtering Goblins this week, they'll probably want to move on to Trolls, Dragons and so on.

The project sounds like fun - enjoy!

-- Ken

Replies are listed 'Best First'.
Re^2: Module Organization
by Dwood (Acolyte) on Oct 13, 2010 at 08:42 UTC
    Heh, I was actually thinking about it, which is why I was wondering about the design of the MUD.... I don't want to have Roleplay::Goblin, Dragon, Witch, Knight etc etc, and since I'm really new to Perl I don't want to do too much that I can't use later

    I don't seem to be capable of finding information on OOP in perl that either I can understand or doesn't repeat the same stuff over and over again as other tutorials, it's all usually just barebones tutorials or outdated from 1990's... *looks in tutorial section again*

    I've been working with matrices lately in perl as well so I may wish to use a graphics system for tiling at some point. Would you be willing to help me get started by taking looks at my code and offering suggestions? Also, thanks, I hope to make this fairly fun! :P

      I noticed your "I'm still really new to Perl ..." so I'm guessing a CPAN contribution wasn't really what you were looking at. This makes the answer to "Is it okay for me to have an empty namespace (Roleplay) and go straight for Roleplay::Player or Roleplay::Goblin?" a more straightforward YES!

      You can have these:

      /path/to/perl/mods/Roleplay/Player.pm /path/to/perl/mods/Roleplay/Goblin.pm

      without needing to have this:

      /path/to/perl/mods/Roleplay.pm

      You may still want a top-level Roleplay class but it's not a requirement of Perl.

      In terms of tutorials, I'd suggest going to Perldoc and looking under GETTING HELP - Tutorials. perlboot, perltoot, perltooc and perlbot are all directly related to Perl OO programming. perlfaq2 - Obtaining and Learning about Perl lists many resources you'll probably find useful. Scrolling down a bit further, you'll see Reference Manual which links to a large amount of documentation including OO topics such as perlmod and perlobj. I recommend you bookmark Perldoc and refer to it often.

      Regarding graphics, take a look at CPAN. The Graphics and User Interfaces sections should probably be your first ports of call.

      You can post your code to, ask questions of and seek advice from PerlMonks at any time. Perlmonks FAQ describes how to do these things. In general, a clearly written question with examples of what you've already tried (including appropriate output, particularly error messages) will be far better received than a "it didn't work" or "please write this for me" type posting.

      -- Ken

      This layout -- Roleplay::Goblin -- will break down very quickly. Consider the Monster Manual, for example. Then the Fiend Folio. Then the Monster Manual 2. Then custom monsters from modules... And you've already got a couple thousand .pm files in a single directory. Not fun to edit or maintain.

      You want to abstract it more. MyRPG::NPC or something. Then it can have basic attributes like hit points, damage taken, and alignment; and roles (see Moose for ideas there) for things like "magic (spell list)," "flight," "healing," et cetera. NPCs could then be built from configuration which would be much easier to maintain, write, and generate on the fly.

        So you think Roleplay::NPC would be sufficient? I'll do a few characters as objects just to get the game going as well as get used to perl objects- i'll move on afterwards.