OSDN Git Service

[MISC] cmd-item/cmd-refill.c 内の player_type 変数名を統一. / Unified player_type variable...
[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 \83\89\83\93\83^\83\93\82É\94R\97¿\82ð\89Á\82¦\82é\83R\83}\83\93\83h\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93
22  * Refill the players lamp (from the pack or floor)
23  * @return \82È\82µ
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 = _("\82Ç\82Ì\96û\82Â\82Ú\82©\82ç\92\8d\82¬\82Ü\82·\82©? ", "Refill with which flask? ");
32     concptr s = _("\96û\82Â\82Ú\82ª\82È\82¢\81B", "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(_("\83\89\83\93\83v\82É\96û\82ð\92\8d\82¢\82¾\81B", "You fuel your lamp."));
45     if (has_flag(flgs, TR_DARK_SOURCE) && (j_ptr->xtra4 > 0)) {
46         j_ptr->xtra4 = 0;
47         msg_print(_("\83\89\83\93\83v\82ª\8fÁ\82¦\82Ä\82µ\82Ü\82Á\82½\81I", "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(_("\82µ\82©\82µ\83\89\83\93\83v\82Í\91S\82­\8cõ\82ç\82È\82¢\81B", "Curiously, your lamp doesn't light."));
51     } else if (j_ptr->xtra4 >= FUEL_LAMP) {
52         j_ptr->xtra4 = FUEL_LAMP;
53         msg_print(_("\83\89\83\93\83v\82Ì\96û\82Í\88ê\94t\82¾\81B", "Your lamp is full."));
54     }
55
56     vary_item(user_ptr, item, -1);
57     user_ptr->update |= PU_TORCH;
58 }
59
60 /*!
61  * @brief \8f¼\96¾\82ð\91©\82Ë\82é\83R\83}\83\93\83h\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93
62  * Refuel the players torch (from the pack or floor)
63  * @return \82È\82µ
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 = _("\82Ç\82Ì\8f¼\96¾\82Å\96¾\82©\82è\82ð\8b­\82ß\82Ü\82·\82©? ", "Refuel with which torch? ");
72     concptr s = _("\91¼\82É\8f¼\96¾\82ª\82È\82¢\81B", "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(_("\8f¼\96¾\82ð\8c\8b\8d\87\82µ\82½\81B", "You combine the torches."));
85     if (has_flag(flgs, TR_DARK_SOURCE) && (j_ptr->xtra4 > 0)) {
86         j_ptr->xtra4 = 0;
87         msg_print(_("\8f¼\96¾\82ª\8fÁ\82¦\82Ä\82µ\82Ü\82Á\82½\81I", "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(_("\82µ\82©\82µ\8f¼\96¾\82Í\91S\82­\8cõ\82ç\82È\82¢\81B", "Curiously, your torch doesn't light."));
91     } else if (j_ptr->xtra4 >= FUEL_TORCH) {
92         j_ptr->xtra4 = FUEL_TORCH;
93         msg_print(_("\8f¼\96¾\82Ì\8eõ\96½\82Í\8f\\95ª\82¾\81B", "Your torch is fully fueled."));
94     } else
95         msg_print(_("\8f¼\96¾\82Í\82¢\82Á\82»\82¤\96¾\82é\82­\8bP\82¢\82½\81B", "Your torch glows more brightly."));
96
97     vary_item(user_ptr, item, -1);
98     user_ptr->update |= PU_TORCH;
99 }
100
101 /*!
102  * @brief \94R\97¿\82ð\95â\8f[\82·\82é\83R\83}\83\93\83h\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93
103  * Refill the players lamp, or restock his torches
104  * @return \82È\82µ
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(_("\8cõ\8c¹\82ð\91\95\94õ\82µ\82Ä\82¢\82È\82¢\81B", "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(_("\82±\82Ì\8cõ\8c¹\82Í\8eõ\96½\82ð\89\84\82Î\82¹\82È\82¢\81B", "Your light cannot be refilled."));
121 }