#include <artifacts.h>
#include <move_failures.h>
#define COST 50
#define LEVEL 100
#define SHAPING "crafts.pottery.forming.shaping"
#define SMITHING "crafts.smithing"
#define TURNING "crafts.carpentry.turning"
#define WHITTLING "crafts.carpentry.whittling"
inherit COMMAND_BASE;
inherit "/std/basic/cute_look";
int cmd( object* things) {
   int i, bonus;
   object form;
   mapping map;
 
   for ( i = 0; i < sizeof( things ); i++ ) {
      if ( !function_exists( "query_artifact_type", things[ i ] ) ) {
         write( "You cannot duplicate "+  things[ i ]->the_short() +".\n" );
         continue;
      }
      if ( (int)this_player()->query_specific_gp( "crafts" ) < COST ) {
         write( "You don't have enough guild points to duplicate "+
               things[ i ]->the_short() +".\n" );
         continue;
      }
      switch( (string)things[ i ]->query_artifact_type() ) {
       case "wand" :
         bonus = (int)this_player()->query_skill_bonus( TURNING );
         break;
       default :
         write( "Oops, something went wrong with "+ things[ i ]->the_short() +
               ".  Please contact a creator.\n" );
        continue;
      }
      if ( bonus < LEVEL ) {
         write( "Your skill is insufficient to make a form from "+
               things[ i ]->the_short() +".\n" );
         continue;
      }
      this_player()->adjust_gp( -COST );
      switch ( (string)things[ i ]->query_artifact_type() ) {
       case "wand" :
         form = clone_object( "/obj/weapon" );
         break;
      }
      map = (mapping)things[ i ]->query_static_auto_load();
      if ( !m_sizeof( map ) ) {
         map = (mapping)things[ i ]->int_query_static_auto_load();
         form->init_static_arg( map );
      } else
      form->init_static_arg( map[ "::" ] );
      map = (mapping)things[ i ]->query_dynamic_auto_load();
      form->init_dynamic_arg( map[ "::" ] );
      form->set_enchant( 0 );
      form->set_value_info( "artifact", 0 );
      if ( bonus < LEVEL + random( LEVEL ) )
         form->remove_property( "artifact form" );
      write( "You duplicate a form from "+ things[ i ]->the_short() +".\n" );
      if ( (int)form->move( this_player() ) != MOVE_OK )
         form->move( environment( this_player() ) );
   }
   return 1;
} /* cmd() */
mixed *query_pattern() {
   return ({ "<indirect:object:me>", (: cmd($1) :) });
} /* query_pattern() */