OSDN Git Service

30376143be6ec3453e058c3afadcca03a73131e4
[hengbandforosx/hengbandosx.git] / src / object / lite-processor.cpp
1 #include "object/lite-processor.h"
2 #include "core/disturbance.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "game-option/disturbance-options.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "object-enchant/object-ego.h"
8 #include "sv-definition/sv-lite-types.h"
9 #include "system/object-type-definition.h"
10 #include "system/player-type-definition.h"
11 #include "view/display-messages.h"
12 #include "world/world.h"
13
14 /*!
15  * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
16  * / Handle burning fuel every 10 game turns
17  */
18 void reduce_lite_life(PlayerType* player_ptr)
19 {
20     ObjectType* o_ptr = &player_ptr->inventory_list[INVEN_LITE];
21     if (o_ptr->tval != ItemKindType::LITE)
22         return;
23
24     if (o_ptr->is_fixed_artifact() || (o_ptr->sval == SV_LITE_FEANOR) || (o_ptr->xtra4 <= 0))
25         return;
26
27     if (o_ptr->name2 == EGO_LITE_LONG) {
28         if (w_ptr->game_turn % (TURNS_PER_TICK * 2))
29             o_ptr->xtra4--;
30     } else
31         o_ptr->xtra4--;
32
33     notice_lite_change(player_ptr, o_ptr);
34 }
35
36 /*!
37  * @brief 寿命つき光源の警告メッセージ処理
38  * @param player_ptr プレイヤーへの参照ポインタ
39  * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
40  */
41 void notice_lite_change(PlayerType* player_ptr, ObjectType* o_ptr)
42 {
43     if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100))) {
44         player_ptr->window_flags |= (PW_EQUIP);
45     }
46
47     if (player_ptr->blind) {
48         if (o_ptr->xtra4 == 0)
49             o_ptr->xtra4++;
50     } else if (o_ptr->xtra4 == 0) {
51         disturb(player_ptr, false, true);
52         msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
53         player_ptr->update |= (PU_TORCH);
54         player_ptr->update |= (PU_BONUS);
55     } else if (o_ptr->name2 == EGO_LITE_LONG) {
56         if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
57             && (w_ptr->game_turn % (TURNS_PER_TICK * 2))) {
58             if (disturb_minor)
59                 disturb(player_ptr, false, true);
60             msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
61         }
62     } else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10))) {
63         if (disturb_minor)
64             disturb(player_ptr, false, true);
65         msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
66     }
67 }