NEWBIE: Code, C question. [Part 2]

From: Fionn Colvin (fcolvin@metz.une.edu.au)
Date: 05/12/96


Hi all,
       Ok, I changed my percent line to:

percent = (100 * current) / total

ass suggested by Jeremy. However now when I do a score, again with str: 17
dex: 25 and con: 12 I get

str: below average  dex: below average  con: below average.

Con should be below average, but dex should be supreme and str good. Any 
ideas?


char *see_good(int current, int total)
{
  int percent;
  static char word[256];

  if ((total == 200) && (current < 0))
    current = 100 - current;

  if (total < 1)
    total = 1;

  percent = (current * 100) / total;

  if (percent < 1)
    percent = 1;

  if (percent >= 100)
    strcpy(word, "supreme");
  else if (percent >= 90)
    strcpy(word, "excellent");
  else if (percent >= 80)
    strcpy(word, "very good");
  else if (percent >= 70)
    strcpy(word, "good");
  else if (percent >= 60)
    strcpy(word, "above average");
  else if (percent >= 50)
    strcpy(word, "average");
  else if (percent >= 40)
    strcpy(word, "below average");
  else if (percent >= 30)
    strcpy(word, "fair");
  else if (percent >= 20)
    strcpy(word, "poor");
  else if (percent >= 10)
    strcpy(word, "bad");
  else
    strcpy(word, "pathetic");

  return (word);
}



ACMD(do_score)
{
/*  struct time_info_data playing_time;
    struct time_info_data real_time_passed(time_t t2, time_t t1); */

  sprintf(buf, " Name: %s\r\n", GET_NAME(ch));
  
  sprintf(buf, "%s Title: %s\r\n", buf, GET_TITLE(ch));
  
  sprintf(buf, "%s\r\n", buf);
  
  sprintf(buf, "%s Race: %s\r\n", buf, RACE_ABBR(ch));
  
  sprintf(buf, "%s Level: %d		      Class: %s\r\n",
          buf, GET_LEVEL(ch), CLASS_ABBR(ch));
  
  sprintf(buf, "%s Hit Points: %d(%d)	      Mana: %d(%d)       Moves: %d(%d)\r\n",
          buf, GET_HIT(ch), GET_MAX_HIT(ch), GET_MANA(ch), GET_MAX_MANA(ch),
          GET_MOVE(ch), GET_MAX_MOVE(ch));
  
  sprintf(buf, "%s Age: %d years old.	      Height: %d''	   Weight: %d lbs\r\n", 
          buf, GET_AGE(ch), GET_HEIGHT(ch), GET_WEIGHT(ch));
  
  sprintf(buf, "%s Str: %s/%d		      Dex: %s		   Con: %s\r\n",
          buf, see_good(GET_STR(ch), 25), GET_ADD(ch), see_good(GET_DEX(ch), 25), see_good(GET_CON(ch), 25));
  
  sprintf(buf, "%s Int: %d  		      Wis: %d		   Cha: %d\r\n",
          buf, GET_INT(ch), GET_WIS(ch), GET_CHA(ch));

  sprintf(buf, "%s AC: %d   		      Hit Roll: %d   	   Damage Roll: %d\r\n",
          buf, GET_AC(ch), GET_HITROLL(ch), GET_DAMROLL(ch));


Thanks in advance

Fionn



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