Adding Classes, can it get easier?

From: Rasdan (rasdan@PEAK.ORG)
Date: 11/19/97


The answer is YES!

Here is a small, and quite easy change, to make adding classes to
CircleMUD even easier than it already is:


First off, you will need to remove the code for parse_class and
find_class_bitvector and replace it with this:

struct class_selection_data {
  char arg;
  int class;
} class_selection[] = {
  {     '1'     , CLASS_MAGIC_USER      },
  {     '2'     , CLASS_CLERIC          },
  {     '3'     , CLASS_THIEF           },
  {     '4'     , CLASS_WARRIOR         },
  {     '\n'    , CLASS_UNDEFINED       }};

int parse_class(char arg)
{
  int i;

  arg = LOWER(arg);

  for (i = 0; class_selection[i].arg != '\n'; i++)
    if (arg == class_selection[i].arg)
      return (class_selection[i].class);

  return CLASS_UNDEFINED;
}

long find_class_bitvector(char arg)
{
  int i;

  arg = LOWER(arg);

  for (i = 0; class_selection[i].arg != '\n'; i++)
    if (arg == class_selection[i].arg)
      return (1 << class_selection[i].class);

  return 0;
}

With that small change, all that needs to be added to the class selection
menu is an entry into a structure, and an entry into into class_menu.
Can't get any easier than that :P.

Rasdan




                                  /   \
        _                 )      ((   ))     (
       (@)               /|\      ))_((     /|\                 _
       |-|`\            / | \    (/\|/\)   / | \               (@)
       | | ------------/--|-voV---\`|'/--Vov-|--\--------------|-|
       |-|                  '^`   (o o)  '^`                   | |
       | |  James C. Thomas Jr.   `\Y/'  Founder of Finality   |-|
       |-|                 rasdan@finality.com                 | |
       | |                  finality.com 4000                  |-|
       |_|_____________________________________________________| |
       (@)       l   /\ /         ( (       \ /\   l         `\|-|
                 l /   V           \ \       V   \ l           (@)
                 l/                _) )_          \I
                                   `\ /'
                                     `


     +------------------------------------------------------------+
     | 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