gurba-0.40/
gurba-0.40/bin/
gurba-0.40/lib/
gurba-0.40/lib/cmds/guild/fighter/
gurba-0.40/lib/cmds/monster/
gurba-0.40/lib/cmds/race/catfolk/
gurba-0.40/lib/cmds/race/dwarf/
gurba-0.40/lib/cmds/verb/
gurba-0.40/lib/daemons/data/
gurba-0.40/lib/data/boards/
gurba-0.40/lib/data/messages/
gurba-0.40/lib/data/players/
gurba-0.40/lib/design/
gurba-0.40/lib/domains/gurba/
gurba-0.40/lib/domains/gurba/guilds/fighter/
gurba-0.40/lib/domains/gurba/monsters/
gurba-0.40/lib/domains/gurba/objects/armor/
gurba-0.40/lib/domains/gurba/objects/clothing/
gurba-0.40/lib/domains/gurba/objects/weapons/
gurba-0.40/lib/domains/gurba/vendors/
gurba-0.40/lib/kernel/cmds/admin/
gurba-0.40/lib/kernel/daemons/
gurba-0.40/lib/kernel/include/
gurba-0.40/lib/kernel/lib/
gurba-0.40/lib/kernel/net/
gurba-0.40/lib/kernel/sys/
gurba-0.40/lib/logs/
gurba-0.40/lib/pub/
gurba-0.40/lib/std/modules/languages/
gurba-0.40/lib/std/races/
gurba-0.40/lib/std/races/monsters/
gurba-0.40/lib/wiz/fudge/
gurba-0.40/lib/wiz/spud/
gurba-0.40/src/host/beos/
gurba-0.40/src/host/pc/res/
gurba-0.40/src/kfun/
gurba-0.40/src/lpc/
gurba-0.40/src/parser/
gurba-0.40/tmp/
#include <type.h>

varargs string *compose_message( object who, string msg, object target, mixed *objs) {
  string *words;
  string us;
  string them;
  string others;
  int punc;
  int i;
  int objnum;

  words = explode( msg, " " );
  us = "";
  them = "";
  others = "";
  for( i = 0; i < sizeof( words ); i++ ) {
    if( words[i] == "" )
      continue;

    if( words[i][0] == '$' && strlen( words[i] ) >=2 ) {

      if( words[i][strlen(words[i])-1] == '.' ||
     words[i][strlen(words[i])-1] == ',' ||
     words[i][strlen(words[i])-1] == '!' ||
     words[i][strlen(words[i])-1] == '?' ) {
   punc = words[i][strlen(words[i])-1];
   words[i] = words[i][..strlen(words[i])-2];
      } else {
   punc = 0;
      }
      
      switch( words[i][1] ) {
      case 'N':
   if( who->is_living() ) {
     if( who->query_proper_name() == 0 ) {
       us += "you ";
       them += "the " + who->query_id() + " ";
       others += "the " + who->query_id() + " ";
     } else {
       us += "you ";
       them += who->query_proper_name() + " ";
       others += who->query_proper_name() + " ";
     }
   } else {
     us += "you ";
     them += "the " + who->query_id() + " ";
     others += "the " + who->query_id() + " ";
   }
   break;
      case 'n':
   us += "you ";
   them += who->query_gender_pronoun() + " ";
   others += who->query_gender_pronoun() + " ";
   break;
      case 'p':
   us += "your ";
   them += who->query_gender_possessive() + " ";
   others += who->query_gender_possessive() + " ";
   break;
      case 'v':
   if( strlen( words[i] ) < 3 )
     break;
   us += words[i][2..] + " ";
   if( words[i][2..] == "are" ) {
     them += "is ";
     others += "is ";
   } else if( words[i][2..] == "say:" ) {
     them += "says: ";
     others += "says: ";
   } else if( words[i][2..] == "ask:" ) {
     them += "asks: ";
     others += "asks: ";
   } else if( words[i][2..] == "remark:" ) {
     them += "remarks: ";
     others += "remarks: ";
   } else if( words[i][2..] == "mumble:" ) {
     them += "mumble: ";
     others += "mumble: ";
   } else if( words[i][2..] == "shout:" ) {
     them += "shouts: ";
     others += "shouts: ";
   } else if( words[i][2..] == "ponder:" ) {
     them += "ponders: ";
     others += "ponders: ";
   } else if( words[i][2..] == "whisper:" ) {
     them += "whispers: ";
     others += "whispers: ";
   } else if( words[i][2..] == "exclaim:" ) {
     them += "exclaims: ";
     others += "exclaims: ";
   } else if( words[i][2..] == "mutter:" ) {
     them += "mutters: ";
     others += "mutters: ";
   } else if( words[i][2..] == "say" ) {
     them += "says ";
     others += "says ";
   } else if( words[i][strlen(words[i])-1] == 'o' ) {
     them += words[i][2..] + "es ";
     others += words[i][2..] + "es ";
   } else if( words[i][strlen(words[i])-1] == 'h' &&
         words[i][strlen(words[i])-2] != 'g' ) {
     them += words[i][2..] + "es ";
     others += words[i][2..] + "es ";
   } else if( words[i][strlen(words[i])-1] == 'y' ) {
     them += words[i][2..strlen(words[i])-2] + "ies ";
     others += words[i][2..strlen(words[i])-2] + "ies ";
   } else if( words[i][strlen(words[i])-1] == 's' ) {
     them += words[i][2..] + "es ";
     others += words[i][2..] + "es ";
   } else {
     them += words[i][2..] + "s ";
     others += words[i][2..] + "s ";
   }
   break;
      case 'T':
   if( who == target ) {
     /* Doing something to ourselves. */
     us += "yourself ";
     them += who->query_gender_reflexive() + " ";
     others += who->query_gender_reflexive() + " ";
   } else {
     if( target->is_living() ) {
       if( target->query_proper_name() == 0 ) {
         us += "the " + target->query_id() + " ";
         them += "you ";
         others += "the " + target->query_id() + " ";
       } else {
         us += target->query_proper_name() + " ";
         them += "you ";
         others += target->query_proper_name() + " ";
       }
     } else {
       us += "the " + target->query_id() + " ";
       them += "you " + target->query_id() + " ";
       others += "the " + target->query_id() + " ";
     }
   }
   break;
      case 't':
   if( who == target ) {
     /* Doing something to ourselves. */
     us += "yourself ";
     them += who->query_gender_reflexive() + " ";
     others += who->query_gender_reflexive() + " ";
   } else {
     if( target->is_living() ) {
       if( target->query_proper_name() == 0 ) {
         us += "the " + target->query_id() + " ";
         them += "you ";
         others += "the " + target->query_id() + " ";
       } else {
         us += target->query_proper_name() + " ";
         them += "you ";
         others += target->query_proper_name() + " ";
       }
     } else {
       us += "the " + target->query_id() + " ";
       them += "you " + target->query_id() + " ";
       others += "the " + target->query_id() + " ";
     }
   }
   break;
      case 'o':
   if( strlen( words[i] ) > 2 && words[i][2] >= '0' && words[i][2] <= '9' ) {
     objnum = words[i][2] - '0';
   } else {
     objnum = 0;
   }  
   if( objs == 0 || objs[objnum] == 0 )
     break;
   if( typeof( objs[objnum] ) == T_STRING ) {
     us += objs[objnum] + " ";
     them += objs[objnum] + " ";
     others += objs[objnum] + " ";
   } else {
     us += "the " + objs[objnum]->query_id() + " ";
     them += "the " + objs[objnum]->query_id() + " ";
     others += "the " + objs[objnum]->query_id() + " ";
   }
     
   break;
      }
      if( punc != 0 ) {
   us[strlen(us)-1] = punc;
   them[strlen(them)-1] = punc;
   others[strlen(others)-1] = punc;
   us += " ";
   them += " ";
   others += " ";
      }
    } else {
      us += words[i] + " ";
      them += words[i] + " ";
      others += words[i] + " ";
    }
  }
  if( us[strlen(us)-1] == ' ' ) {
    /* We need to strip the final space. */
    us = us[..strlen(us)-2];
    them = them[..strlen(them)-2];
    others = others[..strlen(others)-2];
  }
  
  return( ({ us, them, others }) );
}


varargs void simple_action( string msg, mixed objs...) {
  string *result;
  result = compose_message( this_player(), msg, 0, objs );
  this_environment()->tell_room( this_object(), result[2] );
  write( capitalize( result[0] ) );
}

varargs targetted_action( string msg, object target, mixed objs...) {
  string *result;

  result = compose_message( this_player(), msg, target, objs );
  this_environment()->tell_room( this_player(), result[2], target );
  this_object()->message( capitalize( result[0] ) );
  if( target != 0 && target->is_living() && target != this_player() ) {
    target->message( capitalize( result[1] ) );
    target->outside_message( capitalize( result[1] ) );
  }
}

varargs other_action( object who, string msg, object target, mixed objs...) {
  string *result;

  result = compose_message( who, msg, target, objs );
  if( this_object()->query_environment() == 0 )
    return;
  this_object()->query_environment()->tell_room( who, result[2], target );
  /*  who->write( capitalize( result[0] ) ); */
  if( target != 0 && target->is_living() && target != who ) {
    target->message( capitalize( result[1] ) );
  }
}