/
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/
#include "money.h"
inherit "/std/room";

void    init()
{
    ::init();
    add_action( "change", "ch*ange" );
}

int     change( string str )
{
    string  s1, type;
    object *obs, cont, ob;
    mixed  *values, *change_arr;
    int     val, mon, i;

    notify_fail( "CHange is not a well beast.\n" );
    notify_fail( "Syntax: " + query_verb() + " <money> into <type>\n" +
		 "       Eg: change 10 brass coins into copper\n" );
    if( !str || ((sscanf( str, "%s into %s", s1, type ) != 2) &&
		 (sscanf( str, "%s to %s", s1, type ) != 2)) )
	return 0;
    cont = clone_object( "/std/container" );
    obs = find_match( s1, this_player() );
    for( i = 0; i < sizeof( obs ); i++ )
	if( obs[ i ]->query_property( "money" ) )
	{
	    mon = 1;
	    obs[ i ]->move( cont );
	}
    if( !mon )
    {
	notify_fail( "I can only change money.  Sorry.\n" );
	cont->dest_me();
	return 0;
    }
    values = (mixed *)MONEY_HAND->query_values();
    if( (i = member_array( type, values )) == -1 )
    {
	notify_fail( "It would be nice if you changed to an existing money type.\n" );
	cont->dest_me();
	return 0;
    }
    ob = present( MONEY_ALIAS, cont );
    val = (int)ob->query_value() * 93 / 100;
    if( val < values[ i + 1 ] )
    {
	notify_fail( "This is not even worth one " + type + " coin, I cannot change " +
		     "to that!\n" );
	ob->move( this_player() );
	cont->dest_me();
	return 0;
    }
    this_player()->adjust_money( val / values[ i + 1 ], type );
    change_arr = MONEY_HAND->create_money_array( val % values[ i + 1 ] );
    write( "Ok, changed " + MONEY_HAND->money_string( ob->query_money_array() ) +
	   " into " + (val / values[ i + 1 ]) + " " + type + " coins.\n" );
    for( i = 0; i < sizeof( change_arr ); i += 2 )
	this_player()->adjust_money( change_arr[ i + 1 ], change_arr[ i ] );
    if( sizeof( change_arr ) )
	write( "You were returned " + MONEY_HAND->money_string( change_arr ) + " as excess coinage.\n" );
    ob->dest_me();
    cont->dest_me();
    return 1;
}