/* Slist written by Sirius [o0Sirius0o@hotmail.com]
* Add this to act_info.c, this was written for Rom2.4
* Some of the for loops levels for (level = 1 ;level <= 101;level++)
* may have to be changed depending on your Max Mortal Level.
*/
void do_slist(CHAR_DATA *ch,char *argument) {
char arg1[MIL],group[MSL];
int skill,class = 0,cl = 0;
int sn = 0,col = 0,level = 0, sp,gr;
int skCount = 0,spCount = 0, class_name = 0, gn = 0;
bool found = FALSE;
argument = one_argument(argument,arg1);

    if (arg1[0] == '\0') {
        printf_to_char(ch,"Enter the name of the spell or class.\n\r");
        return;
    }
        if (((skill = skill_lookup(arg1)) == -1) && (cl = class_lookup(arg1)) == -1) {
        printf_to_char(ch,"That is not a valid class or skill.\n\r");
        return;
    }

    if (((skill = skill_lookup(arg1)) == -1) && (cl = class_lookup(arg1)) != -1) {
      for (class_name = 0; class_name < MAX_CLASS; class_name++) {
          if (!str_cmp(arg1, class_table[class_name].name))
            break;
      }
      if (class_name == MAX_CLASS) {
        send_to_char( "Please spell out the full class name.\n\r",ch);
        return;
      } else {
          printf_to_char(ch,"{CAviable skill/spells for the class{c: {W%s{x\n\r", class_table[cl].name);
          printf_to_char(ch,"{cSpells{W:{x\n\r");
          for (level = 1 ;level <= 101;level++) {
              for (sn = 0; sn < MAX_SKILL; sn++) {
                  if (skill_table[sn].skill_level[cl] > 100)
                      continue;
                  if (skill_table[sn].skill_level[cl] != level)
                      continue;
                  if (skill_table[sn].spell_fun == spell_null)
                      continue;
                  printf_to_char(ch, "{B[{C%3d{B] {W%-18s{x",
                  level,
                  skill_table[sn].name);
                  spCount++;
                  if (++col % 3 == 0)
                      send_to_char("\n\r",ch);
              }
          }
          send_to_char("\n\r",ch); col = 0;
          printf_to_char(ch, "{CTotal spells found{g: {W%d{x\n\r",spCount);
          printf_to_char(ch, "{cSkills{W:{x\n\r");
          for (level = 1 ;level <= 101;level++) {
              for (sn = 0; sn < MAX_SKILL; sn++) {
                  if (skill_table[sn].skill_level[cl] > 100)
                      continue;
                  if (skill_table[sn].skill_level[cl] != level)
                      continue;
                  if (skill_table[sn].spell_fun != spell_null)
                      continue;
                  printf_to_char(ch, "{B[{C%3d{B] {W%-18s{x",
                  level,
                  skill_table[sn].name);
                  skCount++;
                  if (++col % 3 == 0)
                      send_to_char("\n\r",ch);
              }
          }
          send_to_char("\n\r",ch);
          printf_to_char(ch, "{cBase Group{W: {W%s{x\n\r",class_table[cl].base_group);
          gn = 0; col = 0; level = 1;
          gn = group_lookup(class_table[class].base_group);
          printf_to_char(ch, "{CSkills included with {W%s{x.{x\n\r",class_table[cl].base_group);
              for (sn = 0; sn < MAX_IN_GROUP; sn++) {
                  if (group_table[gn].spells[sn] == NULL)
                      continue;
                  printf_to_char(ch,"{W%-18s{x",group_table[gn].spells[sn]);
                  if (++col % 3 == 0)
                      send_to_char("\n\r",ch);
              }
          send_to_char("\n\r",ch);
          printf_to_char(ch, "{cDefault Group{W: {W%s{x\n\r",class_table[cl].default_group);
          gn = 0; col = 0; level = 1;
          gn = group_lookup(class_table[cl].default_group);
          printf_to_char(ch, "{CSkills included with {W%s{x.{x\n\r",class_table[cl].default_group);
              for (sn = 0; sn < MAX_IN_GROUP; sn++) {
                  if (group_table[gn].spells[sn] == NULL)
                      continue;
                  printf_to_char(ch,"{W%-18s{x",group_table[gn].spells[sn]);
                  if (++col % 3 == 0)
                      send_to_char("\n\r",ch);
              }
          send_to_char("\n\r",ch);
          printf_to_char(ch, "{CTotal skills found{g: {W%d{x\n\r",skCount);
          printf_to_char(ch, "{WTotal skills/spells found: {B%d{x\n\r",(spCount + skCount));
          return;
      }
    }
    if (((skill = skill_lookup(arg1)) != -1) && (cl = class_lookup(arg1)) == -1) {
        for (gr = 1; gr < MAX_GROUP; gr++) {
          if (group_table[gr].name == NULL) {
            continue;
          }
          for (sp = 0; sp < MAX_IN_GROUP; sp++) {
            if (group_table[gr].spells[sp] == NULL) {
              continue;
            }
            if(group_table[gr].spells[sp] == skill_table[skill].name) {
              found = TRUE;
              sprintf(group,"%s",capitalize(group_table[gr].name));
              break;
            }
          }
        }
        printf_to_char(ch,"{CSettings for skill/spell{c: {W%s{x\n\r",skill_table[skill].name);
        if (found)
          printf_to_char(ch,"{CIn the group: {W%s{C.{x\n\r",group);
        else
          printf_to_char(ch,"{CIn the group: {WUnknown{C!{x\n\r");
        send_to_char("{cClass       Level Gain Wait-Time Min-Mana Rating{x\n\r",ch);
        send_to_char("{W----------- ----- ---- --------- -------- ------{x\n\r",ch);
        for (class = 0;class < MAX_CLASS;class++) {
        if (skill_table[skill].skill_level[class] > 100)
            continue;
        printf_to_char(ch,"{G%-11s {g%5d %4d %9d %8d %6d\n\r",
        class_table[class].name,
        skill_table[skill].skill_level[class],
        skill_table[skill].rating[class],
        skill_table[skill].beats,
        skill_table[skill].min_mana,
        skill_table[skill].rating[class]);
        }
        return;
    }
}
