1 #include "spell-realm/spells-sorcery.h"
2 #include "core/asking-player.h"
3 #include "core/window-redrawer.h"
4 #include "flavor/flavor-describer.h"
5 #include "floor/floor-object.h"
6 #include "game-option/input-options.h"
7 #include "inventory/inventory-object.h"
8 #include "io/input-key-requester.h"
9 #include "object-hook/hook-expendable.h"
10 #include "object/item-use-flags.h"
11 #include "object/object-value.h"
12 #include "system/item-entity.h"
13 #include "system/player-type-definition.h"
14 #include "system/redrawing-flags-updater.h"
15 #include "term/z-form.h"
16 #include "view/display-messages.h"
19 * @brief アイテムの価値に応じた錬金術処理 /
20 * Turns an object into gold, gain some of its value in a shop
21 * @param player_ptr プレイヤーへの参照ポインタ
22 * @return 処理が実際に行われたらTRUEを返す
24 bool alchemy(PlayerType *player_ptr)
27 if (command_arg > 0) {
31 concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
32 concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
35 o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR));
41 if (o_ptr->number > 1) {
42 amt = get_quantity(std::nullopt, o_ptr->number);
48 ITEM_NUMBER old_number = o_ptr->number;
50 const auto item_name = describe_flavor(player_ptr, o_ptr, 0);
51 o_ptr->number = old_number;
54 if (confirm_destroy || (o_ptr->get_price() > 0)) {
55 char out_val[MAX_NLEN + 40];
56 strnfmt(out_val, sizeof(out_val), _("本当に%sを金に変えますか?", "Really turn %s to gold? "), item_name.data());
57 if (!get_check(out_val)) {
63 if (!can_player_destroy_object(player_ptr, o_ptr)) {
64 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), item_name.data());
68 PRICE price = object_value_real(o_ptr);
70 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), item_name.data());
71 vary_item(player_ptr, item, -amt);
85 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %d coins worth of gold."), item_name.data(), price);
86 player_ptr->au += price;
87 auto &rfu = RedrawingFlagsUpdater::get_instance();
88 rfu.set_flag(MainWindowRedrawingFlag::GOLD);
89 player_ptr->window_flags |= PW_PLAYER;
90 vary_item(player_ptr, item, -amt);