OSDN Git Service

[Refactor] #40521 Separated inventory-slot-types.h from player-status.h
[hengband/hengband.git] / src / spell-kind / spells-curse-removal.c
1 #include "spell-kind/spells-curse-removal.h"
2 #include "inventory/inventory-slot-types.h"
3 #include "object-enchant/item-feeling.h"
4 #include "object-enchant/special-object-flags.h"
5 #include "object-enchant/trc-types.h"
6 #include "object-hook/hook-checker.h"
7 #include "system/object-type-definition.h"
8 #include "view/display-messages.h"
9
10 /*!
11  * @brief 装備の解呪処理 / Removes curses from items in inventory
12  * @param creature_ptr プレーヤーへの参照ポインタ
13  * @param all 軽い呪いまでの解除ならば0
14  * @return 解呪されたアイテムの数
15  * @details 永遠の呪いは解呪できない
16  */
17 static int exe_curse_removal(player_type *creature_ptr, int all)
18 {
19     int cnt = 0;
20     for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
21         object_type *o_ptr = &creature_ptr->inventory_list[i];
22         if (!o_ptr->k_idx)
23             continue;
24         if (!object_is_cursed(o_ptr))
25             continue;
26         if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE))
27             continue;
28         if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
29             o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
30             continue;
31         }
32
33         o_ptr->curse_flags = 0L;
34         o_ptr->ident |= IDENT_SENSE;
35         o_ptr->feeling = FEEL_NONE;
36
37         creature_ptr->update |= (PU_BONUS);
38         creature_ptr->window |= (PW_EQUIP);
39         cnt++;
40     }
41
42     if (cnt)
43         msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
44
45     return cnt;
46 }
47
48 /*!
49  * @brief 装備の軽い呪い解呪処理 /
50  * Remove most curses
51  * @param caster_ptr プレーヤーへの参照ポインタ
52  * @return 解呪に成功した装備数
53  */
54 int remove_curse(player_type *caster_ptr) { return exe_curse_removal(caster_ptr, FALSE); }
55
56 /*!
57  * @brief 装備の重い呪い解呪処理 /
58  * Remove all curses
59  * @return 解呪に成功した装備数
60  */
61 int remove_all_curse(player_type *caster_ptr) { return exe_curse_removal(caster_ptr, TRUE); }