OSDN Git Service

Merge pull request #934 from sikabane-works/feature/add-doxygen-artifact
[hengbandforosx/hengbandosx.git] / src / mspell / improper-mspell-remover.cpp
1 #include "mspell/improper-mspell-remover.h"
2 #include "game-option/birth-options.h"
3 #include "monster-race/monster-race.h"
4 #include "monster-race/race-flags2.h"
5 #include "monster/smart-learn-types.h"
6 #include "mspell/element-resistance-checker.h"
7 #include "mspell/high-resistance-checker.h"
8 #include "mspell/smart-mspell-util.h"
9 #include "system/floor-type-definition.h"
10 #include "system/monster-race-definition.h"
11 #include "system/monster-type-definition.h"
12 #include "system/player-type-definition.h"
13
14 static void add_cheat_remove_flags(player_type *target_ptr, msr_type *msr_ptr)
15 {
16     if (!smart_cheat)
17         return;
18
19     add_cheat_remove_flags_element(target_ptr, msr_ptr);
20     add_cheat_remove_flags_others(target_ptr, msr_ptr);
21 }
22
23 /*!
24  * @brief モンスターの魔法一覧から戦術的に適さない魔法を除外する /
25  * Remove the "bad" spells from a spell list
26  * @param m_idx モンスターの構造体参照ポインタ
27  * @param f4p モンスター魔法のフラグリスト1
28  * @param f5p モンスター魔法のフラグリスト2
29  * @param f6p モンスター魔法のフラグリスト3
30  * @return なし
31  */
32 void remove_bad_spells(MONSTER_IDX m_idx, player_type *target_ptr, EnumClassFlagGroup<RF_ABILITY> &ability_flags)
33 {
34     msr_type tmp_msr;
35     msr_type *msr_ptr = initialize_msr_type(target_ptr, &tmp_msr, m_idx, ability_flags);
36     if (msr_ptr->r_ptr->flags2 & RF2_STUPID)
37         return;
38
39     if (!smart_cheat && !smart_learn)
40         return;
41
42     monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
43     if (smart_learn) {
44         /* 時々学習情報を忘れる */
45         if (randint0(100) < 1)
46             m_ptr->smart.clear();
47
48         msr_ptr->smart = m_ptr->smart;
49     }
50
51     add_cheat_remove_flags(target_ptr, msr_ptr);
52     if (msr_ptr->smart.none())
53         return;
54
55     check_element_resistance(msr_ptr);
56     check_high_resistances(target_ptr, msr_ptr);
57     ability_flags = msr_ptr->ability_flags;
58 }