Help with cleaning code.

From: S. Mead (meadsh@ECE.ORST.EDU)
Date: 02/07/98


Hello, I have added skills for each type of weapon and I have added a
value for it in .obj.  Then in do_wield I have a check against the
characters skill when he/she wields the weapon.

This is what I am using now, it is nasty and long but it works.
Careful, it may cause any C pros to cease up.  If there is anyone who
wants to take a moment to show me a slick shortcut to clean this up, I
would be very grateful, as I will most likely run into this situation
again.

This is the first if-structure.  I have 7(0-6) of them and each one is
the exact same structure.

Thanks!  Shaw <-Newbie Coder

>>>>>>>>>>>>>>>>>
snip!
>>>>>>>>>>>>>>>>>
 if (wtype == 0){
  if (GET_SKILL(ch, SKILL_SWORD) <= 0)
   send_to_char("You aren't sure which end to hold!\r\n", ch);
   else if (GET_SKILL(ch, SKILL_SWORD) <20)
    send_to_char("You take a shaky grip on the weapon.\r\n", ch);
    else if (GET_SKILL(ch, SKILL_SWORD) <60)
     send_to_char("You are skilled with this weapon.\r\n", ch);
     else if (GET_SKILL(ch, SKILL_SWORD) <90)
      send_to_char("You are an expert with this weapon.\r\n", ch);
      else if (GET_SKILL(ch, SKILL_SWORD) > 90)
       send_to_char("This weapon feels like part of you!\r\n", ch);}
.
.
.
.
 if (wtype == 6){
  if (GET_SKILL(ch, SKILL_STAFF) <= 0)
   send_to_char("You aren't sure which end to hold!\r\n", ch);
   else if (GET_SKILL(ch, SKILL_STAFF) <20)
    send_to_char("You take a shaky grip on the weapon.", ch);
    else if (GET_SKILL(ch, SKILL_STAFF) <60)
     send_to_char("You are skilled with this weapon.", ch);
     else if (GET_SKILL(ch, SKILL_STAFF) <90)
      send_to_char("You are an expert with this weapon.", ch);
      else if (GET_SKILL(ch, SKILL_STAFF) > 90)
       send_to_char("This weapon feels like part of you!", ch);}


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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