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 constexpr auto q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
32 constexpr auto s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
34 auto *o_ptr = choose_object(player_ptr, &i_idx, q, s, (USE_INVEN | USE_FLOOR));
40 if (o_ptr->number > 1) {
41 amt = input_quantity(o_ptr->number);
47 const auto old_number = o_ptr->number;
49 const auto item_name = describe_flavor(player_ptr, o_ptr, 0);
50 o_ptr->number = old_number;
53 if (confirm_destroy || (o_ptr->get_price() > 0)) {
54 char out_val[MAX_NLEN + 40];
55 strnfmt(out_val, sizeof(out_val), _("本当に%sを金に変えますか?", "Really turn %s to gold? "), item_name.data());
56 if (!input_check(out_val)) {
62 if (!can_player_destroy_object(o_ptr)) {
63 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), item_name.data());
67 auto price = object_value_real(o_ptr);
69 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), item_name.data());
70 vary_item(player_ptr, i_idx, -amt);
84 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %d coins worth of gold."), item_name.data(), price);
85 player_ptr->au += price;
86 auto &rfu = RedrawingFlagsUpdater::get_instance();
87 rfu.set_flag(MainWindowRedrawingFlag::GOLD);
88 rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
89 vary_item(player_ptr, i_idx, -amt);