OSDN Git Service

[Fix] #40514 effect_player_lite() と effect_player_dark() 内の盲目判定バグ修正. / Fixed blind...
[hengband/hengband.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
17 /*!
18  * @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
19  * Refill the players lamp (from the pack or floor)
20  * @return \82È\82µ
21  */
22 static void do_cmd_refill_lamp(player_type *user_ptr)
23 {
24     OBJECT_IDX item;
25     object_type *o_ptr;
26     object_type *j_ptr;
27     item_tester_hook = item_tester_refill_lantern;
28     concptr q = _("\82Ç\82Ì\96û\82Â\82Ú\82©\82ç\92\8d\82¬\82Ü\82·\82©? ", "Refill with which flask? ");
29     concptr s = _("\96û\82Â\82Ú\82ª\82È\82¢\81B", "You have no flasks of oil.");
30     o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
31     if (!o_ptr)
32         return;
33
34     take_turn(user_ptr, 50);
35     j_ptr = &user_ptr->inventory_list[INVEN_LITE];
36     j_ptr->xtra4 += o_ptr->xtra4;
37     msg_print(_("\83\89\83\93\83v\82É\96û\82ð\92\8d\82¢\82¾\81B", "You fuel your lamp."));
38     if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) {
39         j_ptr->xtra4 = 0;
40         msg_print(_("\83\89\83\93\83v\82ª\8fÁ\82¦\82Ä\82µ\82Ü\82Á\82½\81I", "Your lamp has gone out!"));
41     } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) {
42         j_ptr->xtra4 = 0;
43         msg_print(_("\82µ\82©\82µ\83\89\83\93\83v\82Í\91S\82­\8cõ\82ç\82È\82¢\81B", "Curiously, your lamp doesn't light."));
44     } else if (j_ptr->xtra4 >= FUEL_LAMP) {
45         j_ptr->xtra4 = FUEL_LAMP;
46         msg_print(_("\83\89\83\93\83v\82Ì\96û\82Í\88ê\94t\82¾\81B", "Your lamp is full."));
47     }
48
49     vary_item(user_ptr, item, -1);
50     user_ptr->update |= PU_TORCH;
51 }
52
53 /*!
54  * @brief \8f¼\96¾\82ð\91©\82Ë\82é\83R\83}\83\93\83h\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93
55  * Refuel the players torch (from the pack or floor)
56  * @return \82È\82µ
57  */
58 static void do_cmd_refill_torch(player_type *creature_ptr)
59 {
60     OBJECT_IDX item;
61     object_type *o_ptr;
62     object_type *j_ptr;
63     item_tester_hook = object_can_refill_torch;
64     concptr q = _("\82Ç\82Ì\8f¼\96¾\82Å\96¾\82©\82è\82ð\8b­\82ß\82Ü\82·\82©? ", "Refuel with which torch? ");
65     concptr s = _("\91¼\82É\8f¼\96¾\82ª\82È\82¢\81B", "You have no extra torches.");
66     o_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
67     if (!o_ptr)
68         return;
69
70     take_turn(creature_ptr, 50);
71     j_ptr = &creature_ptr->inventory_list[INVEN_LITE];
72     j_ptr->xtra4 += o_ptr->xtra4 + 5;
73     msg_print(_("\8f¼\96¾\82ð\8c\8b\8d\87\82µ\82½\81B", "You combine the torches."));
74     if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) {
75         j_ptr->xtra4 = 0;
76         msg_print(_("\8f¼\96¾\82ª\8fÁ\82¦\82Ä\82µ\82Ü\82Á\82½\81I", "Your torch has gone out!"));
77     } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) {
78         j_ptr->xtra4 = 0;
79         msg_print(_("\82µ\82©\82µ\8f¼\96¾\82Í\91S\82­\8cõ\82ç\82È\82¢\81B", "Curiously, your torch doesn't light."));
80     } else if (j_ptr->xtra4 >= FUEL_TORCH) {
81         j_ptr->xtra4 = FUEL_TORCH;
82         msg_print(_("\8f¼\96¾\82Ì\8eõ\96½\82Í\8f\\95ª\82¾\81B", "Your torch is fully fueled."));
83     } else
84         msg_print(_("\8f¼\96¾\82Í\82¢\82Á\82»\82¤\96¾\82é\82­\8bP\82¢\82½\81B", "Your torch glows more brightly."));
85
86     vary_item(creature_ptr, item, -1);
87     creature_ptr->update |= PU_TORCH;
88 }
89
90 /*!
91  * @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
92  * Refill the players lamp, or restock his torches
93  * @return \82È\82µ
94  */
95 void do_cmd_refill(player_type *creature_ptr)
96 {
97     object_type *o_ptr;
98     o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
99     if (creature_ptr->special_defense & KATA_MUSOU)
100         set_action(creature_ptr, ACTION_NONE);
101
102     if (o_ptr->tval != TV_LITE)
103         msg_print(_("\8cõ\8c¹\82ð\91\95\94õ\82µ\82Ä\82¢\82È\82¢\81B", "You are not wielding a light."));
104     else if (o_ptr->sval == SV_LITE_LANTERN)
105         do_cmd_refill_lamp(creature_ptr);
106     else if (o_ptr->sval == SV_LITE_TORCH)
107         do_cmd_refill_torch(creature_ptr);
108     else
109         msg_print(_("\82±\82Ì\8cõ\8c¹\82Í\8eõ\96½\82ð\89\84\82Î\82¹\82È\82¢\81B", "Your light cannot be refilled."));
110 }