1 #include "player-status/player-basic-statistics.h"
2 #include "core/window-redrawer.h"
3 #include "mutation/mutation-flag-types.h"
4 #include "object/object-flags.h"
5 #include "player-base/player-race.h"
6 #include "player-info/class-info.h"
7 #include "player-info/mimic-info-table.h"
8 #include "player/player-personality.h"
9 #include "player/player-status.h"
10 #include "player/race-info-table.h"
11 #include "player/special-defense-types.h"
12 #include "realm/realm-hex-numbers.h"
13 #include "spell-realm/spells-hex.h"
14 #include "system/player-type-definition.h"
15 #include "system/redrawing-flags-updater.h"
16 #include "util/bit-flags-calculator.h"
17 #include "util/enum-converter.h"
19 PlayerBasicStatistics::PlayerBasicStatistics(PlayerType *player_ptr)
20 : PlayerStatusBase(player_ptr)
30 int16_t PlayerBasicStatistics::modification_value()
32 return PlayerStatusBase::get_value();
37 * @return status_typeに対応するステータスの実値を返す
39 int16_t PlayerBasicStatistics::get_value()
42 return this->player_ptr->stat_index[(int)this->ability_type];
46 * @brief 基礎ステータス補正計算 - 種族
52 int16_t PlayerBasicStatistics::race_bonus()
54 return PlayerRace(this->player_ptr).get_info()->r_adj[this->ability_type];
58 * @brief ステータス補正計算 - 職業
64 int16_t PlayerBasicStatistics::class_bonus()
66 const player_class_info *c_ptr = &class_info[enum2i(this->player_ptr->pclass)];
67 return c_ptr->c_adj[this->ability_type];
71 * @brief ステータス補正計算 - 性格
77 int16_t PlayerBasicStatistics::personality_bonus()
79 const player_personality *a_ptr = &personality_info[this->player_ptr->ppersonality];
80 return a_ptr->a_adj[this->ability_type];
86 * * player_ptrのステータスを更新する
88 void PlayerBasicStatistics::update_value()
91 this->update_top_status();
92 this->update_use_status();
93 this->update_index_status();
99 * * player_ptrのステータス最大値を更新する
100 * * 更新対象はset_locals()で設定したstatus_typeで決定される
102 void PlayerBasicStatistics::update_top_status()
104 int status = (int)this->ability_type;
105 int top = modify_stat_value(this->player_ptr->stat_max[status], this->player_ptr->stat_add[status]);
107 if (this->player_ptr->stat_top[status] != top) {
108 this->player_ptr->stat_top[status] = (int16_t)top;
109 auto &rfu = RedrawingFlagsUpdater::get_instance();
110 rfu.set_flag(MainWindowRedrawingFlag::ABILITY_SCORE);
111 rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
116 * @brief ステータス現在値更新の例外処理
117 * @param 通常処理されたステータスの値
118 * @returns 例外処理されたステータスの値
120 * * player_ptrのステータス現在値を更新する際の例外処理
121 * * 派生クラスでoverrideして使用する。
123 int16_t PlayerBasicStatistics::set_exception_use_status(int16_t value)
129 * @brief ステータス現在値更新処理
131 * * player_ptrのステータス現在値を更新する
132 * * 更新対象はset_locals()で設定したstatus_typeで決定される
134 void PlayerBasicStatistics::update_use_status()
136 int status = (int)this->ability_type;
137 int16_t use = modify_stat_value(this->player_ptr->stat_cur[status], this->player_ptr->stat_add[status]);
139 use = this->set_exception_use_status(use);
141 if (this->player_ptr->stat_use[status] != use) {
142 this->player_ptr->stat_use[status] = (int16_t)use;
143 auto &rfu = RedrawingFlagsUpdater::get_instance();
144 rfu.set_flag(MainWindowRedrawingFlag::ABILITY_SCORE);
145 rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
150 * @brief ステータス内部値更新処理
152 * * player_ptrのステータス内部値を更新する
153 * * ステータス内部値は実際の数値処理に使われる0-37の整数値
154 * * 更新対象はset_locals()で設定したstatus_typeで決定される
156 void PlayerBasicStatistics::update_index_status()
158 int status = (int)this->ability_type;
160 if (this->player_ptr->stat_use[status] <= 18) {
161 index = (this->player_ptr->stat_use[status] - 3);
162 } else if (this->player_ptr->stat_use[status] <= 18 + 219) {
163 index = (15 + (this->player_ptr->stat_use[status] - 18) / 10);
168 if (this->player_ptr->stat_index[status] == index) {
172 this->player_ptr->stat_index[status] = (int16_t)index;
173 auto &rfu = RedrawingFlagsUpdater::get_instance();
174 static constexpr auto flags = {
175 StatusRecalculatingFlag::MP,
176 StatusRecalculatingFlag::SPELLS,
178 if (status == A_CON) {
179 rfu.set_flag(StatusRecalculatingFlag::HP);
180 } else if (status == A_INT) {
181 if (mp_ptr->spell_stat == A_INT) {
182 rfu.set_flags(flags);
184 } else if (status == A_WIS) {
185 if (mp_ptr->spell_stat == A_WIS) {
186 rfu.set_flags(flags);
188 } else if (status == A_CHR) {
189 if (mp_ptr->spell_stat == A_CHR) {
190 rfu.set_flags(flags);
194 rfu.set_flag(SubWindowRedrawingFlag::PLAYER);