OSDN Git Service

352e707de4942a819c33f116d71481ccd21398fb
[hengbandforosx/hengbandosx.git] / src / cmd-item / cmd-refill.c
1 #include "cmd-item/cmd-refill.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "floor/floor-object.h"
5 #include "inventory/inventory-object.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "object-enchant/object-ego.h"
8 #include "object-hook/hook-expendable.h"
9 #include "object/item-tester-hooker.h"
10 #include "object/item-use-flags.h"
11 #include "player/attack-defense-types.h"
12 #include "player/special-defense-types.h"
13 #include "status/action-setter.h"
14 #include "sv-definition/sv-lite-types.h"
15 #include "view/display-messages.h"
16 #include "object-enchant/tr-types.h"
17 #include "object/object-flags.h"
18 #include "util/bit-flags-calculator.h"
19
20 /*!
21  * @brief ランタンに燃料を加えるコマンドのメインルーチン
22  * Refill the players lamp (from the pack or floor)
23  * @return なし
24  */
25 static void do_cmd_refill_lamp(player_type *user_ptr)
26 {
27     OBJECT_IDX item;
28     object_type *o_ptr;
29     object_type *j_ptr;
30     item_tester_hook = item_tester_refill_lantern;
31     concptr q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
32     concptr s = _("油つぼがない。", "You have no flasks of oil.");
33     o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
34     if (!o_ptr)
35         return;
36
37     BIT_FLAGS flgs[TR_FLAG_SIZE], flgs2[TR_FLAG_SIZE];
38     object_flags(user_ptr, o_ptr, flgs);
39
40     take_turn(user_ptr, 50);
41     j_ptr = &user_ptr->inventory_list[INVEN_LITE];
42     object_flags(user_ptr, j_ptr, flgs2);
43     j_ptr->xtra4 += o_ptr->xtra4;
44     msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
45     if (has_flag(flgs, TR_DARK_SOURCE) && (j_ptr->xtra4 > 0)) {
46         j_ptr->xtra4 = 0;
47         msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
48     } else if (has_flag(flgs, TR_DARK_SOURCE) || has_flag(flgs2, TR_DARK_SOURCE)) {
49         j_ptr->xtra4 = 0;
50         msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
51     } else if (j_ptr->xtra4 >= FUEL_LAMP) {
52         j_ptr->xtra4 = FUEL_LAMP;
53         msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
54     }
55
56     vary_item(user_ptr, item, -1);
57     user_ptr->update |= PU_TORCH;
58 }
59
60 /*!
61  * @brief 松明を束ねるコマンドのメインルーチン
62  * Refuel the players torch (from the pack or floor)
63  * @return なし
64  */
65 static void do_cmd_refill_torch(player_type *user_ptr)
66 {
67     OBJECT_IDX item;
68     object_type *o_ptr;
69     object_type *j_ptr;
70     item_tester_hook = object_can_refill_torch;
71     concptr q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
72     concptr s = _("他に松明がない。", "You have no extra torches.");
73     o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
74     if (!o_ptr)
75         return;
76
77     BIT_FLAGS flgs[TR_FLAG_SIZE], flgs2[TR_FLAG_SIZE];
78     object_flags(user_ptr, o_ptr, flgs);
79
80     take_turn(user_ptr, 50);
81     j_ptr = &user_ptr->inventory_list[INVEN_LITE];
82     object_flags(user_ptr, j_ptr, flgs2);
83     j_ptr->xtra4 += o_ptr->xtra4 + 5;
84     msg_print(_("松明を結合した。", "You combine the torches."));
85     if (has_flag(flgs, TR_DARK_SOURCE) && (j_ptr->xtra4 > 0)) {
86         j_ptr->xtra4 = 0;
87         msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
88     } else if (has_flag(flgs, TR_DARK_SOURCE) || has_flag(flgs2, TR_DARK_SOURCE)) {
89         j_ptr->xtra4 = 0;
90         msg_print(_("しかし松明は全く光らない。", "Curiously, your torch doesn't light."));
91     } else if (j_ptr->xtra4 >= FUEL_TORCH) {
92         j_ptr->xtra4 = FUEL_TORCH;
93         msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
94     } else
95         msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
96
97     vary_item(user_ptr, item, -1);
98     user_ptr->update |= PU_TORCH;
99 }
100
101 /*!
102  * @brief 燃料を補充するコマンドのメインルーチン
103  * Refill the players lamp, or restock his torches
104  * @return なし
105  */
106 void do_cmd_refill(player_type *user_ptr)
107 {
108     object_type *o_ptr;
109     o_ptr = &user_ptr->inventory_list[INVEN_LITE];
110     if (user_ptr->special_defense & KATA_MUSOU)
111         set_action(user_ptr, ACTION_NONE);
112
113     if (o_ptr->tval != TV_LITE)
114         msg_print(_("光源を装備していない。", "You are not wielding a light."));
115     else if (o_ptr->sval == SV_LITE_LANTERN)
116         do_cmd_refill_lamp(user_ptr);
117     else if (o_ptr->sval == SV_LITE_TORCH)
118         do_cmd_refill_torch(user_ptr);
119     else
120         msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
121 }