本文整理汇总了C++中object::add_money方法的典型用法代码示例。如果您正苦于以下问题:C++ object::add_money方法的具体用法?C++ object::add_money怎么用?C++ object::add_money使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::add_money方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_buy
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: remove_affix_from_target
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: do_sell
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.");
}
}