OSDN Git Service

762ef751b5bbd4e83ea166e2c0682107b8930f36
[hengbandforosx/hengbandosx.git] / src / player-status / player-stealth.cpp
1 #include "player-status/player-stealth.h"
2 #include "mind/mind-ninja.h"
3 #include "mutation/mutation-flag-types.h"
4 #include "player-base/player-race.h"
5 #include "player-info/class-info.h"
6 #include "player-info/equipment-info.h"
7 #include "player-info/mimic-info-table.h"
8 #include "player-info/race-types.h"
9 #include "player/player-personality.h"
10 #include "player/player-skill.h"
11 #include "player/player-status-flags.h"
12 #include "player/player-status.h"
13 #include "player/race-info-table.h"
14 #include "spell-realm/spells-hex.h"
15 #include "system/object-type-definition.h"
16 #include "system/player-type-definition.h"
17 #include "util/bit-flags-calculator.h"
18 #include "util/enum-converter.h"
19
20 PlayerStealth::PlayerStealth(player_type* player_ptr)
21     : PlayerStatusBase(player_ptr)
22 {
23 }
24
25 /*!
26  * @brief 隠密能力計算 - 種族
27  * @return 隠密能力の増分
28  * @details
29  * * 種族による加算
30  */
31 int16_t PlayerStealth::race_value()
32 {
33     return PlayerRace(this->player_ptr).get_info()->r_stl;
34 }
35
36 /*!
37  * @brief 隠密能力計算 - 性格
38  * @return 隠密能力の増分
39  * @details
40  * * 性格による加算
41  */
42 int16_t PlayerStealth::personality_value()
43 {
44     const player_personality *a_ptr = &personality_info[this->player_ptr->ppersonality];
45     return a_ptr->a_stl;
46 }
47
48 /*!
49  * @brief 隠密能力計算 - 職業(基礎値)
50  * @return 隠密能力の増分
51  * @details
52  * * 職業による加算
53  */
54 int16_t PlayerStealth::class_base_value()
55 {
56     const player_class_info *c_ptr = &class_info[enum2i(this->player_ptr->pclass)];
57     return c_ptr->c_stl + (c_ptr->x_stl * this->player_ptr->lev / 10);
58 }
59
60 /*!
61  * @brief 隠密能力計算 - 職業(追加分)
62  * @return 隠密能力の増分
63  * @details
64  * * 忍者がheavy_armorならば減算(-レベル/10)
65  * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
66  */
67 int16_t PlayerStealth::class_value()
68 {
69     ACTION_SKILL_POWER result = 0;
70
71     if (this->player_ptr->pclass == PlayerClassType::NINJA) {
72         if (heavy_armor(this->player_ptr)) {
73             result -= (this->player_ptr->lev) / 10;
74         } else if ((!this->player_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(this->player_ptr))
75             && (!this->player_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(this->player_ptr))) {
76             result += (this->player_ptr->lev) / 10;
77         }
78     }
79
80     return result;
81 }
82
83 /*!
84  * @brief 隠密能力計算 - 変異
85  * @return 隠密能力の増分
86  * @details
87  * * 変異MUT3_XTRA_NOISで減算(-3)
88  * * 変異MUT3_MOTIONで加算(+1)
89  */
90 int16_t PlayerStealth::mutation_value()
91 {
92     int16_t result = 0;
93     const auto &muta = this->player_ptr->muta;
94     if (muta.has(MUTA::XTRA_NOIS)) {
95         result -= 3;
96     }
97     if (muta.has(MUTA::MOTION)) {
98         result += 1;
99     }
100     return result;
101 }
102
103 /*!
104  * @brief 隠密能力計算 - 一時効果
105  * @return 隠密能力の増分
106  * @details
107  * * 呪術を唱えていると減算(-(詠唱数+1))
108  * * 狂戦士化で減算(-7)
109  * * 隠密の歌で加算(+999)
110  */
111 int16_t PlayerStealth::time_effect_value()
112 {
113     int16_t result = 0;
114     if (this->player_ptr->realm1 == REALM_HEX) {
115         SpellHex spell_hex(this->player_ptr);
116         if (spell_hex.is_spelling_any()) {
117             result -= spell_hex.get_casting_num() + 1;
118         }
119     }
120
121     if (is_shero(this->player_ptr)) {
122         result -= 7;
123     }
124
125     if (is_time_limit_stealth(this->player_ptr)) {
126         result += 999;
127     }
128
129     return result;
130 }
131
132 bool PlayerStealth::is_aggravated_s_fairy()
133 {
134     return player_aggravate_state(this->player_ptr) == AGGRAVATE_S_FAIRY;
135 }
136
137 /*!
138  * @brief 隠密能力計算 - 影フェアリー反感時の例外処理
139  * @return 修正後の隠密能力
140  * @details
141  * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
142  */
143 int16_t PlayerStealth::set_exception_value(int16_t value)
144 {
145     if (this->is_aggravated_s_fairy()) {
146         value = std::min<int16_t>(value - 3, (value + 2) / 2);
147     }
148     return value;
149 }
150
151 /*!
152  * @brief 隠密マイナスフラグ判定
153  * @return マイナスフラグの集合体
154  * @details
155  * * TR_STELATHがマイナスの要素に加え、種族影フェアリーかつ反感のとき種族にマイナスフラグを与える
156  */
157 BIT_FLAGS PlayerStealth::get_bad_flags()
158 {
159     BIT_FLAGS result = PlayerStatusBase::get_bad_flags();
160
161     if (this->is_aggravated_s_fairy())
162         set_bits(result, FLAG_CAUSE_RACE);
163
164     return result;
165 }
166
167 /*!
168  * @brief 隠密値の上限と下限の設定
169  * @details
170  * * 初期値1
171  * * 最大30、最低0に補正
172  */
173 void PlayerStealth::set_locals()
174 {
175     this->default_value = 1;
176     this->min_value = 0;
177     this->max_value = 30;
178     this->tr_flag = TR_STEALTH;
179     this->tr_bad_flag = TR_STEALTH;
180 }