示例#1
0
void do_buy(object player, object what) {
   string name;
   int value;

   value = what->query_value();

   if ((will_buy < 1) || (value < 1)) {
      write(capitalize(this_object()->query_name()) + " will not buy that.\n");
      return;
   }

   name = what->base_name();

   if (!what->move(this_object())) {
      write("You can not sell that.\n");
      return;
   }

   player->targeted_action("$N $vsell $t $o for " + value + " ducats.", 
      this_object(), what);
   what->query_environment()->remove_object(what);
   what->destruct();

   if (!member_map(name, stored_items)) {
      stored_items[name] = 1;
   } else {
      stored_items[name] = stored_items[name] + 1;
   }

   player->add_money("ducat", value);
}
示例#2
0
文件: smith.c 项目: sirdude/gurbalib
void remove_affix_from_target(string affixable, object target,
      int coins, object client) {
   busy_right_now = TRUE;
   client->add_money("ducat", -coins);
   target->move(this_object());
   client->simple_action("$N $voffer $p payment and $p stuff to the smith.",
      client);
   client->simple_action("The smith takes $p payment and $p your stuff " +
      "and gets to work. He pulls out a giant hammer...", client);
   call_out("clunk1", 2, affixable, target, coins, client);
}
示例#3
0
void do_sell(object player, string what) {
   string *objs;
   object obj;
   int i, found, value;

   objs = map_indices(stored_items);

   found = 0;
   for (i = 0; i < sizeof(objs); i++) {

      obj = clone_object(objs[i]);
      if (obj) {
	 obj->move(this_object());
	 obj->setup();

         /* Found the object */
	 if (obj->query_id() == what && found != 1) {
            value = obj->query_value();

            if (stored_items[objs[i]] < 1) {
               /* Skip here, out of stock... */
            } else {
               if (value <= player->query_total_money() ) {
                  this_object()->other_action(this_object(),
                     "$N $vgive $t $o", player, obj);
                  value = -1 * value;
                  player->add_money("ducat", value);
	          obj->move(player);
                  stored_items[objs[i]] = stored_items[objs[i]] - 1;
                  found = 1;
                  return;
               } else {
                  write("You do not have enough money for that.\n");
	          obj->query_environment()->remove_object(obj);
	          obj->destruct();
                  return;
               }
            }
         } else {
	    obj->query_environment()->remove_object(obj);
	    obj->destruct();
	 }
      }
   }

   if (found == 0) {
      player->message("That item is out of stock.");
   }
}