/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
/* inherited by the common rooms in the domains */
inherit "/std/room";
string  dom_name;

string  query_dom()
{
    return dom_name;
}
void    set_dom( string str )
{
    dom_name = str;
}

void    init()
{
    ::init();
    add_action( "do_list", "list" );
    add_action( "add_creator", "add" );
    add_action( "delete_creator", "del*ete" );
    add_action( "set_project", "pro*ject" );
}

int     do_list( string arg )
{
    string *domains, mast, s, *ppl;
    mapping members;
    int     i, j;

    if( arg == "all" )
	domains = get_dir( "/d/" );
    else
	if( !arg )
	    domains = ({ dom_name });
	else
	{
	    notify_fail( "Usage: list\n       list all\n" );
	    return 0;
	}

    if( sizeof( domains ) > 1 )
	write( "All domains:\n" );
    else
	write( "This domain:\n" );
    s = "";
    for( i = 0; i < sizeof( domains ); i++ )
    {
	mast = "/d/" + domains[ i ] + "/master";
	members = (mapping)mast->query_members();
	if( !members )
	    members = ([ ]);
	printf( "%8s has %2d members and is owned by %s.\n", domains[ i ],
		m_sizeof( members ), capitalize( (string)mast->query_lord() ) );
	ppl = m_indices( members );
	for( j = 0; j < sizeof( ppl ); j++ )
	    s += sprintf( "%s : %-*=s", capitalize( ppl[ j ] ),
			  (int)this_player()->query_cols(), members[ ppl[ j ] ] + ".\n" );
	s += "\n\n";
    }
    this_player()->set_finish_func( 0 );
    this_player()->more_string( s );
    return 1;
}

int     add_creator( string arg )
{
    string  mast;

    if( !arg )
    {
	notify_fail( "Usage: add <creator>\n" );
	return 0;
    }
    arg = (string)this_player()->expand_nickname( arg );
    mast = "/d/" + dom_name + "/master";
    if( (string)mast->query_lord() != geteuid( this_player() ) )
    {
	notify_fail( "You are not the Lord of this Domain.\n" );
	return 0;
    }
    if( !mast->add_member( arg ) )
    {
	notify_fail( capitalize( arg ) + " is already a member of " + dom_name + ".\n" );
	return 0;
    }
    write( "Creator " + capitalize( arg ) + " now added to " + dom_name + ".\n" );
    return 1;
}

int     delete_creator( string arg )
{
    string  mast;

    if( !arg )
    {
	notify_fail( "Usage: delete <creator>\n" );
	return 0;
    }
    arg = (string)this_player()->expand_nickname( arg );
    mast = "d/" + dom_name + "/master";
    if( (string)mast->query_lord() != geteuid( this_player() ) )
    {
	notify_fail( "You are not the Lord of this Domain.\n" );
	return 0;
    }
    if( !mast->remove_member( arg ) )
    {
	notify_fail( capitalize( arg ) + " is not a member of " + dom_name + ".\n" );
	return 0;
    }
    write( "Member " + capitalize( arg ) + " removed from " + dom_name + ".\n" );
    return 1;
}

int     set_project( string str )
{
    string  name, project, mast;

    if( sscanf( str, "%s %s", name, project ) != 2 )
    {
	notify_fail( "Usage: project <creator> <project>\n" );
	return 0;
    }
    mast = "d/" + dom_name + "/master";
    if( (string)mast->query_lord() != geteuid( this_player() ) )
    {
	notify_fail( "You are not the lord of this domain.\n" );
	return 0;
    }
    name = (string)this_player()->expand_nickname( name );
    if( !mast->set_project( name, project ) )
    {
	notify_fail( capitalize( name ) + " is not a member of this domain.\n" );
	return 0;
    }
    write( capitalize( name ) + "'s project set to : " + project + ".\n" );
    return 1;
}