/* Original Code by Colton Fisher (with help) (with smaug codebase) August 3, 2005 */
/* Porting by Raven Nightshade

/* While a bit nasty, it works without problem. This snippet is from
... if I recall a Smaug snippet but I can't quite remember which. Anyhow,
the snippet has been ported to an LoP 1.39 format. However, I work with 
a modified 1.39 version. This snippet should fit in easy enough with
maybe a few minor problems. */

/* Have Fun! */



/* The below snippet does a couple of things, 1.) creates the do_grant 
command for Immortals to assign Nobility Ranks. 2.) Removes the original 
rank (default with smaug code Level/Class) and replaces it with a rank 
from the list below. If the player is new, the default rank is Serf.

The Snippet is meant for those LoP muds that run as an RPI. (Roleplay Intensive)



/* At the bottom of ac_wiz.c add this code */


CMDF ( do_grant )
{
    char arg1[MIL];
    char arg2[MIL];
    CHAR_DATA *victim;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
 

    if ( arg1[0] == '\0' || arg2[0] == '\0' || atoi(arg2) < 1 || atoi(arg2) > 20 )
    {
        send_to_char( "Syntax: grant <chararacter> <rank number (1-20)>\n\r",ch);
send_to_char( "&W       Male Nobility            Female Nobility\n\r", ch);
send_to_char( "&W __[Basic Citizen Ranks]__|__[Basic Citizen Ranks]__\n\r", ch);
send_to_char( "|1   :Serf                |1   :Serf                |\n\r", ch);
send_to_char( "|2   :Peasent             |2   :Peasent             |\n\r", ch);   
send_to_char( "|3   :Worker              |3   :Worker              |\n\r", ch);   
send_to_char( "|4   :Freeman             |4   :Freewoman           |\n\r", ch); 
send_to_char( "|5   :Squire              |5   :Squire              |\n\r", ch);     
send_to_char( "||_[Upper Citizen Ranks]_|||_[Upper Citizen Ranks]_||\n\r", ch);      
send_to_char( "|6   :Horseman            |6   :Horsewomen          |\n\r", ch);      
send_to_char( "|7   :Knight              |7   :Knight              |\n\r", ch);    
send_to_char( "|8   :Adept               |8   :Adept               |\n\r", ch);  
send_to_char( "|9   :Militia             |9   :Militia             |\n\r", ch);    
send_to_char( "|10  :Legend              |10  :Legend              |\n\r", ch);      
send_to_char( "||____[Lesser Rulers]____|||____[Lesser Rulers]____||\n\r", ch);   
send_to_char( "|11  :Lord                |11  :Lady                |\n\r", ch);   
send_to_char( "|12  :Viscount            |12  :Lady to the Viscount|\n\r", ch);      
send_to_char( "|13  :Baronet             |13  :Lady to the Baronet |\n\r", ch);     
send_to_char( "|14  :Count               |14  :Countess            |\n\r", ch);     
send_to_char( "|15  :Baron               |15  :Baroness            |\n\r", ch);      
send_to_char( "||____[Upper Rulers]_____|||____[Upper Rulers]_____||\n\r", ch);    
send_to_char( "|16  :Margrave            |16  :Marchioness         |\n\r", ch);    
send_to_char( "|17  :Duke                |17  :Duchess             |\n\r", ch);  
send_to_char( "|18  :Arch Duke           |18  :Arch Duchess        |\n\r", ch); 
send_to_char( "|19  :Prince              |19  :Princess            |\n\r", ch); 
send_to_char( "|20  :King                |20  :Queen               |\n\r", ch); 
send_to_char( "|_________________________|_________________________|\n\r", ch);

        return;
    }

    if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
    {
        send_to_char( "They must be present to be granted nobility.\n\r", ch );
        return;
    }

    if ( is_npc(victim) )
    {
	send_to_char("&WMobs can't have player nobility rankings.\n\r",ch);
	return;
    }

    victim->pcdata->noble = atoi(arg2);
    
	pager_printf( ch, "You adjust %s's rank in sociaty to the nobility level of %s!\n\r",victim->name, noble_rank_table[ch->pcdata->noble].title_of_rank[ch->sex]);
	pager_printf( victim, "%s sets your nobility level to %s!\n\r", ch->name, noble_rank_table[victim->pcdata->noble].title_of_rank[ch->sex]);
    
    return;
}     


/* In act_info.c below snprintf( buf, sizeof( buf ), "%*s%-15s %s%s%s%s%s%s%s&D%s%s\r\n", change,

	Class,

to

          noble_rank_table[wch->pcdata->noble].title_of_rank[wch->sex],


/* In mud.h in struct pc_data add */


   int noble;

/*with the other global variables add */

extern const struct noble_type _noble_table[MAX_NOBLE];
extern struct noble_type *noble_table[MAX_NOBLE];
extern  const   struct  noble_titles     noble_rank_table[];

struct noble_titles
{
    char *title_of_rank[3];
};


/* then define MAX_NOBLE with the other defines */


/* in save.c in void fwrite_char( CHAR_DATA * ch, FILE * fp ) add */



   fprintf( fp, "Noble        %d\n", ch->pcdata->noble ); 


/* and in fread_char in case n add */




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


/* at the bottom of tables.c add */

const struct noble_titles noble_rank_table[] =
{   
    {
         {"Serf ",   "Serf ",    "Serf "   }
    },
    {
         {"Serf ",   "Serf ",    "Serf "   }
    },
    {
         {"Peasent "    ,"Peasent "    ,"Peasent "      }
    },
    {
         {"Worker "     ,"Worker "    ,"Worker "     }
    },
    {
         {"Freeman "     ,"Freeman "    ,"Freewomen "     }
    },
    {
         {"Squire "  ,"Squire " ,"Squire "  }
    },
    {
         {"Horseman "      ,"Horseman "     ,"Horsewomen "      }
    },
    {
         {"Knight "  ,"Knight " ,"Knight "}
    },
    {
         {"Adept "  ,"Adept " ,"Adept "  }
    },
    {
         {"Militia "        ,"Milita "       ,"Militia "        }
    },
    {
         {"Legend "      ,"Legend "     ,"Legend "      }
    },
    {
         {"Lord "      ,"Lord "     , "Lady "     }
    },
    {
         { "Viscount " ,"Viscount " ,"Lady " }                
    }, 
    {
         { "Baronet " ,"Baronet " ,"Lady " }                
    },  
    {
         { "Count " ,"Count " ,"Countess "  }                
    },   
    {
         { "Baron " ,"Baron " ,"Baroness "  }                
    },   
    {
         { "Margrave " ,"Margrave " ,"Marchioness "  }                
    },
    {
         { "Duke " ,"Duke " ,"Duchess "  }                
    },
    {
         { "Arch Duke " ,"Arch Duke " ,"Duchess "  }                
    },
    {
         { "Prince " ,"Prince " ,"Princess "  }                
    },
    {
         { "King " ,"King " ,"Queen "  }                
    },
};