/*
 * By request of Jawzith before I wiped the phpBB board, a command to increase stats for QP. Written for Ack games
 * but should easily drop into any Diku-derived game with minimal work.
 * Fixed string matching, oops :) Added clarification to a few things too, thanks Koron.
 *
 * Feel free to modify this code to suit your needs, and if you have a great improvement I wouldn't mind if you
 * shared it with me either, if you're so inclined :D. All I ask is to give me credit for the code if you do
 * choose to use it.
 *
 * --Kline (Matt Goff)
 */

void do_statraise(CHAR_DATA *ch, char *argument)
{
 int cost = 5;
 int statcap = 25;
 char buf[MSL];

 /* Note, you'll need to edit your stat tables in const.c
  * to give bonuses past 25 for each stat, based on whatever
  * limit you set in this function --Kline
  */

 if( IS_NPC(ch) ) /* Not on mobs */
  return;

 if( argument[0] == '\0' ) /* No arg supplied, show the syntax */
 {
  send_to_char("Syntax is: statraise <str/int/wis/dex/con>\n\r",ch);
  return;
 }
 if( !str_prefix(argument,"str") ) /* Matches on 's', 'st', 'str' */
 {
  if( ch->pcdata->max_str >= statcap )
  {
   sprintf(buf,"You can not raise your Str any further. The limit is %d.\n\r",statcap);
   send_to_char(buf,ch);
   return;
  }
  cost *= ch->pcdata->max_str; /* Take base cost (5) mult by current value */
  if( ch->quest_points < cost )
  {
   sprintf(buf,"It costs %d QP to raise your Str, but you only have %d.\n\r",cost,ch->quest_points);
   send_to_char(buf,ch);
   return;
  }
  ch->pcdata->max_str++; /* Raise the actual cap */
  ch->pcdata->perm_str++; /* Give them a free stat train */
  ch->quest_points -= cost;
  sprintf(buf,"You have spent %d QP to raise your Str! It is now %d and you have %d QP remaining.\n\r",cost,ch->pcdata->max_str,ch->quest_points);
  send_to_char(buf,ch);
  return;
 }
 else if( !str_prefix(argument,"int") ) /* Matches on 'i', 'in', 'int' */
 {
  if( ch->pcdata->max_int >= statcap )
  {
   sprintf(buf,"You can not raise your Int any further. The limit is %d.\n\r",statcap);
   send_to_char(buf,ch);
   return;
  }
  cost *= ch->pcdata->max_int; /* Take base cost (5) mult by current value */
  if( ch->quest_points < cost )
  {
   sprintf(buf,"It costs %d QP to raise your Int, but you only have %d.\n\r",cost,ch->quest_points);
   send_to_char(buf,ch);
   return;
  }
  ch->pcdata->max_int++; /* Raise the actual cap */
  ch->pcdata->perm_int++; /* Give them a free stat train */
  ch->quest_points -= cost;
  sprintf(buf,"You have spent %d QP to raise your Int! It is now %d and you have %d QP remaining.\n\r",cost,ch->pcdata->max_int,ch->quest_points);
  send_to_char(buf,ch);
  return;
 }
 else if( !str_prefix(argument,"wis") ) /* Matches on 'w', 'wi', 'wis' */
 {
  if( ch->pcdata->max_wis >= statcap )
  {
   sprintf(buf,"You can not raise your Wis any further. The limit is %d.\n\r",statcap);
   send_to_char(buf,ch);
   return;
  }
  cost *= ch->pcdata->max_wis; /* Take base cost (5) mult by current value */
  if( ch->quest_points < cost )
  {
   sprintf(buf,"It costs %d QP to raise your Wis, but you only have %d.\n\r",cost,ch->quest_points);
   send_to_char(buf,ch);
   return;
  }
  ch->pcdata->max_wis++; /* Raise the actual cap */
  ch->pcdata->perm_wis++; /* Give them a free stat train */
  ch->quest_points -= cost;
  sprintf(buf,"You have spent %d QP to raise your Wis! It is now %d and you have %d QP remaining.\n\r",cost,ch->pcdata->max_wis,ch->quest_points);
  send_to_char(buf,ch);
  return;
 }
 else if( !str_prefix(argument,"dex") ) /* Matches on 'd', 'de', 'dex' */
 {
  if( ch->pcdata->max_dex >= statcap )
  {
   sprintf(buf,"You can not raise your Dex any further. The limit is %d.\n\r",statcap);
   send_to_char(buf,ch);
   return;
  }
  cost *= ch->pcdata->max_dex; /* Take base cost (5) mult by current value */
  if( ch->quest_points < cost )
  {
   sprintf(buf,"It costs %d QP to raise your Dex, but you only have %d.\n\r",cost,ch->quest_points);
   send_to_char(buf,ch);
   return;
  }
  ch->pcdata->max_dex++; /* Raise the actual cap */
  ch->pcdata->perm_dex++; /* Give them a free stat train */
  ch->quest_points -= cost;
  sprintf(buf,"You have spent %d QP to raise your Dex! It is now %d and you have %d QP remaining.\n\r",cost,ch->pcdata->max_dex,ch->quest_points);
  send_to_char(buf,ch);
  return;
 }
 else if( !str_prefix(argument,"con") ) /* Matches on 'c', 'co', 'con' */
 {
  if( ch->pcdata->max_con >= statcap )
  {
   sprintf(buf,"You can not raise your Con any further. The limit is %d.\n\r",statcap);
   send_to_char(buf,ch);
   return;
  }
  cost *= ch->pcdata->max_con; /* Take base cost (5) mult by current value */
  if( ch->quest_points < cost )
  {
   sprintf(buf,"It costs %d QP to raise your Con, but you only have %d.\n\r",cost,ch->quest_points);
   send_to_char(buf,ch);
   return;
  }
  ch->pcdata->max_con++; /* Raise the actual cap */
  ch->pcdata->perm_con++; /* Give them a free stat train */
  ch->quest_points -= cost;
  sprintf(buf,"You have spent %d QP to raise your Con! It is now %d and you have %d QP remaining.\n\r",cost,ch->pcdata->max_con,ch->quest_points);
  send_to_char(buf,ch);
  return;
 }
 else /* Invalid argument, display syntax */
 {
  send_to_char("Syntax is: statraise <str/int/wis/dex/con>\n\r",ch);
  return;
 }
}