OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / src / spell-realm / spells-arcane.cpp
1 #include "spell-realm/spells-arcane.h"
2 #include "inventory/inventory-slot-types.h"
3 #include "object/tval-types.h"
4 #include "sv-definition/sv-lite-types.h"
5 #include "system/item-entity.h"
6 #include "system/player-type-definition.h"
7 #include "system/redrawing-flags-updater.h"
8 #include "view/display-messages.h"
9
10 /*!
11  * @brief 寿命つき光源の燃素追加処理 /
12  * Charge a lite (torch or latern)
13  */
14 void phlogiston(PlayerType *player_ptr)
15 {
16     short max_flog = 0;
17     auto *o_ptr = &player_ptr->inventory_list[INVEN_LITE];
18     const auto &bi_key = o_ptr->bi_key;
19     if (bi_key == BaseitemKey(ItemKindType::LITE, SV_LITE_LANTERN)) {
20         max_flog = FUEL_LAMP;
21     } else if (bi_key == BaseitemKey(ItemKindType::LITE, SV_LITE_TORCH)) {
22         max_flog = FUEL_TORCH;
23     } else {
24         msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
25         return;
26     }
27
28     if (o_ptr->fuel >= max_flog) {
29         msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
30         return;
31     }
32
33     o_ptr->fuel += max_flog / 2;
34     msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light."));
35     if (o_ptr->fuel >= max_flog) {
36         o_ptr->fuel = max_flog;
37         msg_print(_("照明用アイテムは満タンになった。", "Your light is full."));
38     }
39
40     RedrawingFlagsUpdater::get_instance().set_flag(StatusRedrawingFlag::TORCH);
41 }