OSDN Git Service

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