1 #include "spell-realm/spells-sorcery.h"
2 #include "core/asking-player.h"
3 #include "core/player-redraw-types.h"
4 #include "core/window-redrawer.h"
5 #include "flavor/flavor-describer.h"
6 #include "floor/floor-object.h"
7 #include "game-option/input-options.h"
8 #include "inventory/inventory-object.h"
9 #include "io/input-key-requester.h"
10 #include "object-hook/hook-expendable.h"
11 #include "object/item-use-flags.h"
12 #include "object/object-value.h"
13 #include "system/object-type-definition.h"
14 #include "view/display-messages.h"
17 * @brief アイテムの価値に応じた錬金術処理 /
18 * Turns an object into gold, gain some of its value in a shop
19 * @param caster_ptr プレーヤーへの参照ポインタ
20 * @return 処理が実際に行われたらTRUEを返す
22 bool alchemy(player_type *caster_ptr)
28 concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
29 concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
32 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
37 if (o_ptr->number > 1) {
38 amt = get_quantity(NULL, o_ptr->number);
43 ITEM_NUMBER old_number = o_ptr->number;
45 GAME_TEXT o_name[MAX_NLEN];
46 describe_flavor(caster_ptr, o_name, o_ptr, 0);
47 o_ptr->number = old_number;
50 if (confirm_destroy || (object_value(caster_ptr, o_ptr) > 0)) {
51 char out_val[MAX_NLEN + 40];
52 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
53 if (!get_check(out_val))
58 if (!can_player_destroy_object(caster_ptr, o_ptr)) {
59 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
63 PRICE price = object_value_real(caster_ptr, o_ptr);
65 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
66 vary_item(caster_ptr, item, -amt);
77 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
79 caster_ptr->au += price;
80 caster_ptr->redraw |= PR_GOLD;
81 caster_ptr->window |= PW_PLAYER;
82 vary_item(caster_ptr, item, -amt);