/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/

/***************************************************************************
*       ROM 2.4 is copyright 1993-1996 Russ Taylor                         *
*       ROM has been brought to you by the ROM consortium                  *
*           Russ Taylor (rtaylor@efn.org)                                  *
*           Gabrielle Taylor                                               *
*           Brian Moore (zump@rom.org)                                     *
*       By using this code, you have agreed to follow the terms of the     *
*       ROM license, in the file Rom24/doc/rom.license                     *
***************************************************************************/

/***************************************************************************
*  Character traits written by the RotL staff Written in the summer of 02  *
*  All rights reserved for this code to Realm of the Lost code was mainly  *
*  done by me aka Pallock ( My email (Pallock2000@yahoo.com) ) but got     *
*  the idea for hair and eye color from Cuthbert which works with me on    *
*  Realm of the Lost which is located at 66.51.211.81 port 6969            *
***************************************************************************/



/*This is my second snippet released, char traits. Very simple to add and overall
a very nice code.*/

/* merc.h */

/* add these structs */
struct eye_type
{
     char *      ecolor;
};

struct hair_type
{
     char *      hcolor;
};

/*add these cons*/
#define CON_GET_ETRAIT               13
#define CON_GET_HTRAIT               14
#define CON_GET_FHEIGHT              15
#define CON_GET_IHEIGHT              16
#define CON_GET_WEIGHT               17

/*add these to pcdata*/
     int                       iheight;
     int                       fheight;
     int                       weight;

/*these to char data*/
    sh_int             etrait;
    sh_int             htrait;

/* in const.c */

/* char traits - eye color */
const   struct  eye_type       etrait_table      []           =
{
     { "NULL"   },
     { "red"    },
     { "blue"   },
     { "green"  },
     { "black"  },
     { "brown"  },
     { "purple" },
     { "grey"   },
     { "white"  },
     { "hazel"  },
};

/* char traits - hair color */
const   struct  hair_type      htrait_table      []           =
{
     { "NULL"   },
     { "red"    },
     { "blue"   },
     { "green"  },
     { "black"  },
     { "brown"  },
     { "purple" },
     { "grey"   },
     { "white"  },
     { "orange" },
     { "silver" },
     { "yellow" },
};

/* save.c */

/* in fwrite_char */
    fprintf( fp, "Etrait %d\n", ch->etrait              );
    fprintf( fp, "Htrait %d\n", ch->htrait              );
    fprintf( fp, "Fheight %d\n", ch->pcdata->fheight    );
    fprintf( fp, "Iheight %d\n", ch->pcdata->iheight    );
    fprintf( fp, "Weight %d\n", ch->pcdata->weight     );

/* in fread_char */

/*find case 'E' and add after*/

            KEY( "Etrait",        ch->etrait,               fread_number( fp ) );

/*after case 'F'*/

           KEY( "Fheight",      ch->pcdata->fheight,    fread_number( fp ) );

/*after case 'H'*/

            KEY( "Htrait",      ch->htrait,             fread_number( fp ) );

/*after case 'I'*/

            KEY( "Iheight",     ch->pcdata->iheight,    fread_number( fp ) );

/*after case 'W'*/

            KEY( "Weight",      ch->pcdata->weight,     fread_number( fp ) );

/*in handler.c */

int etrait_lookup (const char *ecolor)
 {
    int etrait;

    for ( etrait = 0; etrait_table[etrait].ecolor != NULL; etrait++)
    {
         if (LOWER(ecolor[0]) == LOWER(etrait_table[etrait].ecolor[0])
         &&  !str_prefix( ecolor,etrait_table[etrait].ecolor))
             return etrait;
    }

    return 0;
}

int htrait_lookup (const char *hcolor)
 {
    int htrait;

    for ( htrait = 0; htrait_table[htrait].hcolor != NULL; htrait++)
    {
         if (LOWER(hcolor[0]) == LOWER(htrait_table[htrait].hcolor[0])
         &&  !str_prefix( hcolor,htrait_table[htrait].hcolor))
             return htrait;
    }

    return 0;
}


/* and finally in comm.c */

/*at the top of nanny in your local functions add*/

int etrait_lookup args((const char *ecolor));
int htrait_lookup args((const char *hcolor));


/*void nanny*/

add int etrait,htrait,fheight,iheight,weight;

/*and right before....or anywhere you want it to be used...this is just where i have mine*/

        write_to_buffer(d,"\n\r",0);
        group_add(ch,"rom basics",FALSE);
        group_add(ch,class_table[ch->class].base_group,FALSE);


/*add this*/

       write_to_buffer(d,"Please select your characters eye color:\n\r  ",0);
       send_to_desc("\n\r",d);
       send_to_desc("[ red blue green black brown purple grey white hazel ]\n\r",d);
        write_to_buffer(d,"\n\r",0);
        write_to_buffer(d,"What is your characters eye color? ",0);
        d->connected = CON_GET_ETRAIT;
        break;

case CON_GET_ETRAIT:
        one_argument(argument,arg);

        if (!strcmp(arg,"help"))
        {
            argument = one_argument(argument,arg);
            if (argument[0] == '\0')
                do_help(ch,"etrait");
            else
                do_help(ch,argument);
                write_to_buffer(d,"What is your characters eye color? ",0);
            break;
        }
        etrait = etrait_lookup(argument);

        if ( etrait == 0 )
        {
            write_to_buffer(d,"That is not a valid eye color.\n\r",0);
            write_to_buffer(d,"The following eye colors are available:\n\r",0);
            write_to_buffer(d,"\n\r",0);
      send_to_desc("[ red blue green black brown purple grey white hazel ]\n\r",d);
            write_to_buffer(d,
                "What is your characters eye color?",0);
            break;
         }

        ch->etrait = etrait;

        write_to_buffer(d,"\n\r",0);

       write_to_buffer(d,"Please select your characters hair color:\n\r  ",0);
       send_to_desc("\n\r",d);
       send_to_desc("[ red blue green black brown purple grey white orange silver yellow ]\n\r",d);
        write_to_buffer(d,"\n\r",0);
        write_to_buffer(d,"What is your characters hair color? ",0);
        d->connected = CON_GET_HTRAIT;
        break;

case CON_GET_HTRAIT:
        one_argument(argument,arg);

        if (!strcmp(arg,"help"))
        {
            argument = one_argument(argument,arg);
            if (argument[0] == '\0')
                do_help(ch,"htrait");
            else
                do_help(ch,argument);
                write_to_buffer(d,"What is your characters hair color? ",0);
            break;
        }
        htrait = htrait_lookup(argument);

        if ( htrait == 0 )
        {
            write_to_buffer(d,"That is not a valid hair color.\n\r",0);
            write_to_buffer(d,"The following hair colors are available:\n\r",0);
            write_to_buffer(d,"\n\r",0);
      send_to_desc("[ red blue green black brown purple grey white orange silver yellow ]\n\r",d);
            write_to_buffer(d,
                "What is your characters hair color?",0);
            break;
         }

        ch->htrait = htrait;

        write_to_buffer(d,"\n\r",0);
        write_to_buffer(d,"What is your characters height in feet? ",0);
        d->connected = CON_GET_FHEIGHT;
        break;

case CON_GET_FHEIGHT:

        fheight = atoi(argument);


        if ( (fheight = atoi(argument)) <= 0 || fheight > 25 )
        {
             write_to_buffer(d,"Invalid height in feet, choose a reasonable value.\n\r",0);
             write_to_buffer(d,"\n\r",0);
             write_to_buffer(d,"Height is limited from 1 to 25.\n\r",0);
             break;

        }

        ch->pcdata->fheight = fheight;

        write_to_buffer(d,"\n\r",0);
        write_to_buffer(d,"What is your characters height in inches? ",0);
        d->connected = CON_GET_IHEIGHT;
        break;

case CON_GET_IHEIGHT:

        iheight = atoi(argument);


        if ( (iheight = atoi(argument)) <= 0 || iheight > 11 )
        {
             write_to_buffer(d,"Invalid height in inches, choose a reasonable value.\n\r",0);
             write_to_buffer(d,"\n\r",0);
             write_to_buffer(d,"Height in inches is limited from 1 to 11.\n\r",0);
             break;

        }

        ch->pcdata->iheight = iheight;

        write_to_buffer(d,"\n\r",0);
        write_to_buffer(d,"What is your characters weight? ",0);
        d->connected = CON_GET_WEIGHT;
        break;

case CON_GET_WEIGHT:

        weight = atoi(argument);


        if ( (weight = atoi(argument)) <= 50 || weight > 1000 )
        {
             write_to_buffer(d,"Invalid weight, choose a reasonable weight.\n\r",0);
             write_to_buffer(d,"\n\r",0);
             write_to_buffer(d,"Weight is limited from 50 to 1000.\n\r",0);
             break;

        }

        ch->pcdata->weight = weight;


/* that should be it...all i ask for is a little credit...its not easy being a newbie
 * and im sure one day you will put snippets out and want to be credited yourself.
 * if you have any problems with this code please email me at pallock2000@yahoo.com
 * and i will help you the best i can.
 */


/* If you want to use these with some info function i.e. score or whois
 * you would use etrait_type[ch->etrait].ecolor for eyes and
 * htrait_type[ch->htrait].hcolor the rest are just ch->pcdata->blah
 * like i said this is pretty simple and self explanitory.
 */