OSDN Git Service

To be more idiomatic, drop "was" from English message for death of dragon centipedes.
[hengband/hengband.git] / src / spell-realm / spells-sorcery.c
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"
15
16 /*!
17  * @brief アイテムの価値に応じた錬金術処理 /
18  * Turns an object into gold, gain some of its value in a shop
19  * @param caster_ptr プレーヤーへの参照ポインタ
20  * @return 処理が実際に行われたらTRUEを返す
21  */
22 bool alchemy(player_type *caster_ptr)
23 {
24     bool force = FALSE;
25     if (command_arg > 0)
26         force = TRUE;
27
28     concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
29     concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
30     OBJECT_IDX item;
31     object_type *o_ptr;
32     o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
33     if (!o_ptr)
34         return FALSE;
35
36     int amt = 1;
37     if (o_ptr->number > 1) {
38         amt = get_quantity(NULL, o_ptr->number);
39         if (amt <= 0)
40             return FALSE;
41     }
42
43     ITEM_NUMBER old_number = o_ptr->number;
44     o_ptr->number = amt;
45     GAME_TEXT o_name[MAX_NLEN];
46     describe_flavor(caster_ptr, o_name, o_ptr, 0);
47     o_ptr->number = old_number;
48
49     if (!force) {
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))
54                 return FALSE;
55         }
56     }
57
58     if (!can_player_destroy_object(caster_ptr, o_ptr)) {
59         msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
60         return FALSE;
61     }
62
63     PRICE price = object_value_real(caster_ptr, o_ptr);
64     if (price <= 0) {
65         msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
66         vary_item(caster_ptr, item, -amt);
67         return TRUE;
68     }
69
70     price /= 3;
71
72     if (amt > 1)
73         price *= amt;
74
75     if (price > 30000)
76         price = 30000;
77     msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
78
79     caster_ptr->au += price;
80     caster_ptr->redraw |= PR_GOLD;
81     caster_ptr->window |= PW_PLAYER;
82     vary_item(caster_ptr, item, -amt);
83     return TRUE;
84 }