1 #include "inventory/recharge-processor.h"
2 #include "core/disturbance.h"
3 #include "core/window-redrawer.h"
4 #include "flavor/flavor-describer.h"
5 #include "flavor/object-flavor-types.h"
6 #include "hpmp/hp-mp-regenerator.h"
7 #include "inventory/inventory-slot-types.h"
8 #include "object/tval-types.h"
9 #include "system/baseitem-info.h"
10 #include "system/floor-type-definition.h"
11 #include "system/item-entity.h"
12 #include "system/player-type-definition.h"
13 #include "util/quarks.h"
14 #include "util/string-processor.h"
15 #include "view/display-messages.h"
19 * !!を刻んだ魔道具の時間経過による再充填を知らせる処理 /
20 * If player has inscribed the object with "!!", let him know when it's recharged. -LM-
21 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
23 static void recharged_notice(PlayerType *player_ptr, ItemEntity *o_ptr)
25 if (!o_ptr->inscription) {
29 concptr s = angband_strchr(quark_str(o_ptr->inscription), '!');
32 GAME_TEXT o_name[MAX_NLEN];
33 describe_flavor(player_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
35 msg_format("%sは再充填された。", o_name);
37 if (o_ptr->number > 1) {
38 msg_format("Your %s are recharged.", o_name);
40 msg_format("Your %s is recharged.", o_name);
43 disturb(player_ptr, false, false);
47 s = angband_strchr(s + 1, '!');
52 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
53 * / Handle recharging objects once every 10 game turns
55 void recharge_magic_items(PlayerType *player_ptr)
60 for (changed = false, i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
61 auto *o_ptr = &player_ptr->inventory_list[i];
66 if (o_ptr->timeout > 0) {
68 if (!o_ptr->timeout) {
69 recharged_notice(player_ptr, o_ptr);
76 player_ptr->window_flags |= (PW_EQUIP);
81 * Recharge rods. Rods now use timeout to control charging status,
82 * and each charging rod in a stack decreases the stack's timeout by
85 for (changed = false, i = 0; i < INVEN_PACK; i++) {
86 auto *o_ptr = &player_ptr->inventory_list[i];
87 auto *k_ptr = &baseitems_info[o_ptr->bi_id];
92 if ((o_ptr->bi_key.tval() == ItemKindType::ROD) && (o_ptr->timeout)) {
93 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
94 if (temp > o_ptr->number) {
95 temp = (TIME_EFFECT)o_ptr->number;
98 o_ptr->timeout -= temp;
99 if (o_ptr->timeout < 0) {
103 if (!(o_ptr->timeout)) {
104 recharged_notice(player_ptr, o_ptr);
106 } else if (o_ptr->timeout % k_ptr->pval) {
113 player_ptr->window_flags |= (PW_INVEN);
117 for (i = 1; i < player_ptr->current_floor_ptr->o_max; i++) {
118 auto *o_ptr = &player_ptr->current_floor_ptr->o_list[i];
119 if (!o_ptr->is_valid()) {
123 if ((o_ptr->bi_key.tval() == ItemKindType::ROD) && (o_ptr->timeout)) {
124 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
125 if (o_ptr->timeout < 0) {