1 #include "player-status/player-basic-statistics.h"
2 #include "core/player-redraw-types.h"
3 #include "core/window-redrawer.h"
4 #include "mutation/mutation-flag-types.h"
5 #include "object/object-flags.h"
6 #include "player-base/player-race.h"
7 #include "player-info/class-info.h"
8 #include "player-info/mimic-info-table.h"
9 #include "player/player-personality.h"
10 #include "player/player-status.h"
11 #include "player/race-info-table.h"
12 #include "player/special-defense-types.h"
13 #include "realm/realm-hex-numbers.h"
14 #include "spell-realm/spells-hex.h"
15 #include "system/player-type-definition.h"
16 #include "system/redrawing-flags-updater.h"
17 #include "util/bit-flags-calculator.h"
18 #include "util/enum-converter.h"
20 PlayerBasicStatistics::PlayerBasicStatistics(PlayerType *player_ptr)
21 : PlayerStatusBase(player_ptr)
31 int16_t PlayerBasicStatistics::modification_value()
33 return PlayerStatusBase::get_value();
38 * @return status_typeに対応するステータスの実値を返す
40 int16_t PlayerBasicStatistics::get_value()
43 return this->player_ptr->stat_index[(int)this->ability_type];
47 * @brief 基礎ステータス補正計算 - 種族
53 int16_t PlayerBasicStatistics::race_bonus()
55 return PlayerRace(this->player_ptr).get_info()->r_adj[this->ability_type];
59 * @brief ステータス補正計算 - 職業
65 int16_t PlayerBasicStatistics::class_bonus()
67 const player_class_info *c_ptr = &class_info[enum2i(this->player_ptr->pclass)];
68 return c_ptr->c_adj[this->ability_type];
72 * @brief ステータス補正計算 - 性格
78 int16_t PlayerBasicStatistics::personality_bonus()
80 const player_personality *a_ptr = &personality_info[this->player_ptr->ppersonality];
81 return a_ptr->a_adj[this->ability_type];
87 * * player_ptrのステータスを更新する
89 void PlayerBasicStatistics::update_value()
92 this->update_top_status();
93 this->update_use_status();
94 this->update_index_status();
100 * * player_ptrのステータス最大値を更新する
101 * * 更新対象はset_locals()で設定したstatus_typeで決定される
103 void PlayerBasicStatistics::update_top_status()
105 int status = (int)this->ability_type;
106 int top = modify_stat_value(this->player_ptr->stat_max[status], this->player_ptr->stat_add[status]);
108 if (this->player_ptr->stat_top[status] != top) {
109 this->player_ptr->stat_top[status] = (int16_t)top;
110 auto &rfu = RedrawingFlagsUpdater::get_instance();
111 rfu.set_flag(MainWindowRedrawingFlag::ABILITY_SCORE);
112 set_bits(this->player_ptr->window_flags, PW_PLAYER);
117 * @brief ステータス現在値更新の例外処理
118 * @param 通常処理されたステータスの値
119 * @returns 例外処理されたステータスの値
121 * * player_ptrのステータス現在値を更新する際の例外処理
122 * * 派生クラスでoverrideして使用する。
124 int16_t PlayerBasicStatistics::set_exception_use_status(int16_t value)
130 * @brief ステータス現在値更新処理
132 * * player_ptrのステータス現在値を更新する
133 * * 更新対象はset_locals()で設定したstatus_typeで決定される
135 void PlayerBasicStatistics::update_use_status()
137 int status = (int)this->ability_type;
138 int16_t use = modify_stat_value(this->player_ptr->stat_cur[status], this->player_ptr->stat_add[status]);
140 use = this->set_exception_use_status(use);
142 if (this->player_ptr->stat_use[status] != use) {
143 this->player_ptr->stat_use[status] = (int16_t)use;
144 auto &rfu = RedrawingFlagsUpdater::get_instance();
145 rfu.set_flag(MainWindowRedrawingFlag::ABILITY_SCORE);
146 set_bits(this->player_ptr->window_flags, PW_PLAYER);
151 * @brief ステータス内部値更新処理
153 * * player_ptrのステータス内部値を更新する
154 * * ステータス内部値は実際の数値処理に使われる0-37の整数値
155 * * 更新対象はset_locals()で設定したstatus_typeで決定される
157 void PlayerBasicStatistics::update_index_status()
159 int status = (int)this->ability_type;
161 if (this->player_ptr->stat_use[status] <= 18) {
162 index = (this->player_ptr->stat_use[status] - 3);
163 } else if (this->player_ptr->stat_use[status] <= 18 + 219) {
164 index = (15 + (this->player_ptr->stat_use[status] - 18) / 10);
169 if (this->player_ptr->stat_index[status] == index) {
173 this->player_ptr->stat_index[status] = (int16_t)index;
174 auto &rfu = RedrawingFlagsUpdater::get_instance();
176 StatusRedrawingFlag::MP,
177 StatusRedrawingFlag::SPELLS,
179 if (status == A_CON) {
180 rfu.set_flag(StatusRedrawingFlag::HP);
181 } else if (status == A_INT) {
182 if (mp_ptr->spell_stat == A_INT) {
183 rfu.set_flags(flags);
185 } else if (status == A_WIS) {
186 if (mp_ptr->spell_stat == A_WIS) {
187 rfu.set_flags(flags);
189 } else if (status == A_CHR) {
190 if (mp_ptr->spell_stat == A_CHR) {
191 rfu.set_flags(flags);
195 set_bits(this->player_ptr->window_flags, PW_PLAYER);