OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / src / spell-kind / spells-curse-removal.cpp
1 #include "spell-kind/spells-curse-removal.h"
2 #include "core/window-redrawer.h"
3 #include "inventory/inventory-slot-types.h"
4 #include "object-enchant/item-feeling.h"
5 #include "object-enchant/special-object-flags.h"
6 #include "object-enchant/trc-types.h"
7 #include "system/item-entity.h"
8 #include "system/player-type-definition.h"
9 #include "system/redrawing-flags-updater.h"
10 #include "view/display-messages.h"
11
12 /*!
13  * @brief 装備の解呪処理 / Removes curses from items in inventory
14  * @param player_ptr プレイヤーへの参照ポインタ
15  * @param all 軽い呪いまでの解除ならば0
16  * @return 解呪されたアイテムの数
17  * @details 永遠の呪いは解呪できない
18  */
19 static int exe_curse_removal(PlayerType *player_ptr, int all)
20 {
21     auto count = 0;
22     auto &rfu = RedrawingFlagsUpdater::get_instance();
23     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
24         auto *o_ptr = &player_ptr->inventory_list[i];
25         if (!o_ptr->is_valid() || !o_ptr->is_cursed()) {
26             continue;
27         }
28
29         if (!all && o_ptr->curse_flags.has(CurseTraitType::HEAVY_CURSE)) {
30             continue;
31         }
32
33         if (o_ptr->curse_flags.has(CurseTraitType::PERMA_CURSE)) {
34             o_ptr->curse_flags &= { CurseTraitType::CURSED, CurseTraitType::HEAVY_CURSE, CurseTraitType::PERMA_CURSE };
35             continue;
36         }
37
38         o_ptr->curse_flags.clear();
39         o_ptr->ident |= IDENT_SENSE;
40         o_ptr->feeling = FEEL_NONE;
41         rfu.set_flag(StatusRedrawingFlag::BONUS);
42         player_ptr->window_flags |= (PW_EQUIPMENT);
43         count++;
44     }
45
46     if (count > 0) {
47         msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
48     }
49
50     return count;
51 }
52
53 /*!
54  * @brief 装備の軽い呪い解呪処理 /
55  * Remove most curses
56  * @param player_ptr プレイヤーへの参照ポインタ
57  * @return 解呪に成功した装備数
58  */
59 int remove_curse(PlayerType *player_ptr)
60 {
61     return exe_curse_removal(player_ptr, false);
62 }
63
64 /*!
65  * @brief 装備の重い呪い解呪処理 /
66  * Remove all curses
67  * @return 解呪に成功した装備数
68  */
69 int remove_all_curse(PlayerType *player_ptr)
70 {
71     return exe_curse_removal(player_ptr, true);
72 }