sell.c

gurba-0.40/lib/cmds/player/sell.c · 959 B

From the archive gurba.tgz

Download the archive   « Back to the archive contents

/* Created by Fudge */

void main( string str ) {
  object *objs;
  object obj;
  int i;

  if( str == "" ) {
    write( "Sell what?" );
    return;
  }

  obj = this_player()->find_object( str ); 
  if( obj != 0 ) {
    /* Found the item */

    objs = this_environment()->query_inventory();
    for( i = 0; i < sizeof( objs ); i++ ) {
      if( objs[i]->is_vendor() == 1 ) {
	/* Found the shopkeeper */
	
	if( obj->is_worn() ) {
	  this_player()->do_remove( obj );
	  this_player()->targetted_action( obj->query_remove_message(), 0, obj );
	}
	
	if( obj->is_wielded() ) {
	  this_player()->do_unwield( obj );
	  this_player()->targetted_action( obj->query_unwield_message(), 0, obj );
	}
	
	if( obj->is_undroppable() ) {
	  this_player()->targetted_action( "$N $vare unable to let go of $o.", 0, obj ); 
    return;
	} 
	
	objs[i]->do_buy( this_player(), obj );
	return;
	
      }
    }
    write( "Sell to who?" );
  }
  write( "You don't have that." );
}

Site Stats

Snippets: 1791
Codebases: 571