[CODE] Race w/class restrictions

From: Ole Gjerde (gjerde@plains.nodak.edu)
Date: 10/20/96


This is my way of doing this.
It should be pretty obvious how it works.. I think.. :)
My parse_race is at the end.  It's basically the same as parse_class.

The LEGAL_CLASS rules are from AD&D.. (surprise, surprise :)

I only included the first part of CON_QCLASS. The rest should be the 
same as orig. circle.

The class menu it prints out is only the classes you are allowed to 
choose.

If you have any questions or suggestions, just send me email.
----------------------------------------------------
#define NUM_RACES         6 
#define NUM_CLASSES       8

somewhere:

const int LEGAL_CLASS[NUM_RACES][NUM_CLASSES] = {
/* MAG  CLE  THI  FIG  RAN  PAL  BAR  ASS  */
  { 1,   1,   1,   1,   1,   0,   1,   1},  /* ELF */
  { 1,   1,   1,   1,   1,   1,   0,   1},  /* HUMAN */
  { 0,   1,   1,   1,   0,   0,   0,   1},  /* DWARF */
  { 0,   1,   1,   1,   0,   0,   0,   1},  /* GNOME */
  { 0,   1,   1,   1,   0,   0,   0,   1},  /* HALFLING */
  { 1,   1,   1,   1,   1,   0,   1,   1}   /* HALF-ELF */
};


In interpreter.c:

[snip]
    default:
      SEND_TO_Q("That is not a sex..\r\n"
                "What IS your sex? ", d);
      return;
      break;
    }

    SEND_TO_Q(race_menu, d);
    SEND_TO_Q("\r\nRace: ", d);
    STATE(d) = CON_QRACE;
    break;

  case CON_QRACE:
    load_result = parse_race(*arg);
    if (load_result == RACE_UNDEFINED) {
      SEND_TO_Q("\r\nThat's not a race.\r\nRace: ", d);
      return;
    } else
      GET_RACE(d->character) = load_result;

    SEND_TO_Q("\r\nSelect a class:\r\n", d);
    buf1[0] = '\0';
    for( i = 0; i < NUM_CLASSES; i++)
        if (LEGAL_CLASS[(int)GET_RACE(d->character)][i])
            sprintf(buf1, "%s %s\r\n", buf1, my_class_menu[i]);

    SEND_TO_Q(buf1, d);      

    SEND_TO_Q("\r\nClass: ", d);
    STATE(d) = CON_QCLASS;
    break;

  case CON_QCLASS:
    load_result = parse_class(*arg);
    if (load_result == CLASS_UNDEFINED) {
      SEND_TO_Q("\r\nThat's not a class.\r\nClass: ", d);
      return;
    } else if(!LEGAL_CLASS[(int)GET_RACE(d->character)][load_result]) {
      sprintf(buf2, "\r\n%s's are not allowed to be %ss.\r\nClass: ", 
                     pc_race_types[(int)GET_RACE(d->character)], arg);
      SEND_TO_Q(buf2, d);
      return;
    } else
      GET_CLASS(d->character) = load_result; 
[snip]

--------------------------------------------------------------------

int parse_race(char arg)
{
  arg = LOWER(arg);

  switch (arg) {
  case 'e':
    return RACE_ELF;
    break;
  case 'h':
    return RACE_HUMAN;
    break;
  case 'd':
    return RACE_DWARF;
    break;
  case 'g':
    return RACE_GNOME;
    break;
  case 'a':
    return RACE_HALFLING;
    break;
  case 'l':
    return RACE_HALF_ELF;
    break;
  default:
    return CLASS_UNDEFINED;
    break;
  }
}                                

----
Ole Gjerde
Homepage: http://www.pconline.com/~gjerde
Email: gjerde@plains.nodak.edu, gjerde@pconline.com
Studying Computer Science at North Dakota State University
"Unix _IS_ user friendly... It's just selective about who its friends are."
                                                  -- Unknown/Nem Schlecht


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



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