ID.ORG
LIB3/STD/BASIC/ID.ORG · 3.9 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#pragma save_binary
#include "parse_command.h"
inherit "/std/basic/print_object";
static string name, *alias, *adjectives, *plurals;
void create()
{
alias = ({ });
plurals = ({ });
adjectives = ({ });
name = "object";
}
void set_name( string str )
{
name = str;
}
string query_name()
{
return name;
}
string query_cap_name()
{
if( !name )
return "Someone";
return capitalize( name );
}
void set_aliases( string *str )
{
alias = str;
}
string *query_alias()
{
return alias;
}
void add_alias( mixed str )
{
if( pointerp( str ) )
alias += str;
else
alias += ({ str });
}
int remove_alias( string str )
{
int i;
if( (i = member_array( str, alias )) == -1 )
return 0;
alias = delete( alias, i, 1 );
return 1;
}
void set_plurals( string *str )
{
plurals = str;
}
string *query_plurals()
{
return plurals;
}
void add_plural( mixed str )
{
if( pointerp( str ) )
plurals += str;
else
plurals += ({ str });
}
int remove_plural( string str )
{
int i;
if( (i = member_array( str, plurals )) == -1 )
return 0;
plurals = delete( plurals, i, 1 );
return 1;
}
void set_adjectives( string *str )
{
adjectives = str;
}
string *query_adjectives()
{
return adjectives;
}
void add_adjective( mixed str )
{
if( pointerp( str ) )
adjectives += str;
else
adjectives += ({ str });
}
int remove_adjective( string str )
{
int i;
if( (i = member_array( str, adjectives )) == -1 )
return 0;
adjectives = delete( adjectives, i, 1 );
return 1;
}
/* *** Newstyle: Is this ever used? ***
void add_plurals(string *str) { plurals += str; }
*/
int id_plural( string str )
{
return( member_array( str, plurals ) != -1 );
}
int id( string str )
/* Do I answer to the name str? */
{
int i;
string s1, s2;
for(i=0;i<sizeof(adjectives);i++)
if(sscanf(str, "%s "+adjectives[i]+" %s", s1, s2) == 2)
str = replace(s1+s2, " ", " ");
else if(sscanf(str, "%s "+adjectives[i], s1) == 1)
str = s1[0..strlen(str)-2];
else if(sscanf(str, adjectives[i]+" %s", s1) == 1)
str = s1[1..strlen(str)-1];
return str == name ||
member_array(str, alias) != -1 ||
member_array(str, plurals) != -1 ;
}
/* *** This doesn't do anything. Wonder if it is used.. ***
int full_id(string str)
{
int loop;
for(loop = 0; loop < sizeof(adjectives); loop++) { }
return 0;
}
*/
string *parse_command_id_list()
{
return({ name }) +alias;
}
string *parse_command_plural_id_list()
{
return plurals;
}
string *parse_command_adjectiv_id_list()
{
return adjectives;
}
object query_parse_id( mixed *arr )
{
/* Where is P_THING defined ? And what is it ? */
/* And whats up with the numbers? */
if( arr[ P_THING ] == 0 )
return this_object();
if( arr[ P_THING ] < 0 )
{ /* specific object case */
arr[ P_THING ]++;
if( arr[ P_THING ] != 0 )
return 0;
arr[ P_THING ] = -10321;
return this_object();
}
arr[ P_THING ]--; /* lots of objects case */
if( arr[ P_THING ] != 0 )
return this_object();
arr[ P_THING ] = -10101;
return this_object();
}
object query_frac_parse_id( mixed *arr )
{
if( arr[ P_THING ] < 0 )
{
arr[ P_THING ]++;
if( arr[ P_THING ] != 0 )
return 0;
arr[ P_THING ] = -10235;
return 0;
}
if( arr[ P_THING ] == 0 )
if( (arr[ P_MAX_NUM ] * arr[ P_TOP ]) / arr[ P_BOT ] > arr[ P_CUR_NUM ]++ )
return this_object();
else
return 0;
if( (arr[ P_THING ] * arr[ P_TOP ]) / arr[ P_BOT ] > arr[ P_CUR_NUM ]++ )
return this_object();
return 0;
}
/* Have to wonder about this...
void attack_by(object ob) { ob->stop_fight(this_object()); }
*/
mixed * query_init_data()
{
return({ "name", name, "set_name/p/",
"alias", alias, "add_alias/p/",
"adjectives", adjectives, "add_adjective/p/",
"plurals", plurals, "add_plurals/p/" });
}