1 #include "cmd-item/cmd-refill.h"
2 #include "floor/floor-object.h"
3 #include "inventory/inventory-object.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "object-enchant/object-ego.h"
6 #include "object-enchant/tr-types.h"
7 #include "object-hook/hook-expendable.h"
8 #include "object/item-tester-hooker.h"
9 #include "object/item-use-flags.h"
10 #include "player-base/player-class.h"
11 #include "player-info/samurai-data-type.h"
12 #include "player-status/player-energy.h"
13 #include "player/attack-defense-types.h"
14 #include "player/special-defense-types.h"
15 #include "status/action-setter.h"
16 #include "sv-definition/sv-lite-types.h"
17 #include "system/item-entity.h"
18 #include "system/player-type-definition.h"
19 #include "system/redrawing-flags-updater.h"
20 #include "util/bit-flags-calculator.h"
21 #include "view/display-messages.h"
24 * @brief ランタンに燃料を加えるコマンドのメインルーチン
25 * Refill the players lamp (from the pack or floor)
27 static void do_cmd_refill_lamp(PlayerType *player_ptr)
32 constexpr auto q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
33 constexpr auto s = _("油つぼがない。", "You have no flasks of oil.");
34 o_ptr = choose_object(player_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(&ItemEntity::can_refill_lantern));
39 const auto flags = o_ptr->get_flags();
41 PlayerEnergy(player_ptr).set_player_turn_energy(50);
42 j_ptr = &player_ptr->inventory_list[INVEN_LITE];
43 const auto flags2 = j_ptr->get_flags();
44 j_ptr->fuel += o_ptr->fuel;
45 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
46 if (flags.has(TR_DARK_SOURCE) && (j_ptr->fuel > 0)) {
48 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
49 } else if (flags.has(TR_DARK_SOURCE) || flags2.has(TR_DARK_SOURCE)) {
51 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
52 } else if (j_ptr->fuel >= FUEL_LAMP) {
53 j_ptr->fuel = FUEL_LAMP;
54 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
57 vary_item(player_ptr, item, -1);
58 RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::TORCH);
62 * @brief 松明を束ねるコマンドのメインルーチン
63 * Refuel the players torch (from the pack or floor)
65 static void do_cmd_refill_torch(PlayerType *player_ptr)
70 constexpr auto q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
71 constexpr auto s = _("他に松明がない。", "You have no extra torches.");
72 o_ptr = choose_object(player_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(&ItemEntity::can_refill_torch));
77 const auto flags = o_ptr->get_flags();
79 PlayerEnergy(player_ptr).set_player_turn_energy(50);
80 j_ptr = &player_ptr->inventory_list[INVEN_LITE];
81 const auto flags2 = j_ptr->get_flags();
82 j_ptr->fuel += o_ptr->fuel + 5;
83 msg_print(_("松明を結合した。", "You combine the torches."));
84 if (flags.has(TR_DARK_SOURCE) && (j_ptr->fuel > 0)) {
86 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
87 } else if (flags.has(TR_DARK_SOURCE) || flags2.has(TR_DARK_SOURCE)) {
89 msg_print(_("しかし松明は全く光らない。", "Curiously, your torch doesn't light."));
90 } else if (j_ptr->fuel >= FUEL_TORCH) {
91 j_ptr->fuel = FUEL_TORCH;
92 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
94 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
97 vary_item(player_ptr, item, -1);
98 RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::TORCH);
102 * @brief 燃料を補充するコマンドのメインルーチン
103 * Refill the players lamp, or restock his torches
105 void do_cmd_refill(PlayerType *player_ptr)
107 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
108 const auto *o_ptr = &player_ptr->inventory_list[INVEN_LITE];
109 const auto &bi_key = o_ptr->bi_key;
110 if (bi_key.tval() != ItemKindType::LITE) {
111 msg_print(_("光源を装備していない。", "You are not wielding a light."));
112 } else if (bi_key.sval() == SV_LITE_LANTERN) {
113 do_cmd_refill_lamp(player_ptr);
114 } else if (bi_key.sval() == SV_LITE_TORCH) {
115 do_cmd_refill_torch(player_ptr);
117 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));