2 * @brief プレイヤーの耐性と能力値を表示する
6 * ここにこれ以上関数を引っ越してくるのは禁止。何ならここから更に分割していく
9 #include "display-player-stat-info.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "mutation/mutation-flag-types.h"
12 #include "object-enchant/tr-types.h"
13 #include "object/object-flags.h"
14 #include "player-base/player-race.h"
15 #include "player-info/class-info.h"
16 #include "player-info/mimic-info-table.h"
17 #include "player/permanent-resistances.h"
18 #include "player/player-personality.h"
19 #include "player/player-status-table.h"
20 #include "player/player-status.h"
21 #include "system/object-type-definition.h"
22 #include "system/player-type-definition.h"
23 #include "term/screen-processor.h"
24 #include "term/term-color-types.h"
25 #include "util/bit-flags-calculator.h"
28 * @brief プレイヤーのパラメータ基礎値 (腕力等)を18以下になるようにして返す
29 * @param player_ptr プレイヤーへの参照ポインタ
30 * @param stat_num 能力値番号
32 * @details 最大が18になるのはD&D由来
34 static int calc_basic_stat(player_type *player_ptr, int stat_num)
37 if ((player_ptr->stat_max[stat_num] > 18) && (player_ptr->stat_top[stat_num] > 18))
38 e_adj = (player_ptr->stat_top[stat_num] - player_ptr->stat_max[stat_num]) / 10;
40 if ((player_ptr->stat_max[stat_num] <= 18) && (player_ptr->stat_top[stat_num] <= 18))
41 e_adj = player_ptr->stat_top[stat_num] - player_ptr->stat_max[stat_num];
43 if ((player_ptr->stat_max[stat_num] <= 18) && (player_ptr->stat_top[stat_num] > 18))
44 e_adj = (player_ptr->stat_top[stat_num] - 18) / 10 - player_ptr->stat_max[stat_num] + 18;
46 if ((player_ptr->stat_max[stat_num] > 18) && (player_ptr->stat_top[stat_num] <= 18))
47 e_adj = player_ptr->stat_top[stat_num] - (player_ptr->stat_max[stat_num] - 19) / 10 - 19;
53 * @brief 特殊な種族の時、腕力等の基礎パラメータを変動させる
54 * @param player_ptr プレイヤーへの参照ポインタ
55 * @param stat_num 能力値番号
58 static int compensate_special_race(player_type *player_ptr, int stat_num)
60 if (!PlayerRace(player_ptr).equals(PlayerRaceType::ENT))
67 if (player_ptr->lev > 25)
69 if (player_ptr->lev > 40)
71 if (player_ptr->lev > 45)
75 if (player_ptr->lev > 25)
77 if (player_ptr->lev > 40)
79 if (player_ptr->lev > 45)
88 * @brief 能力値名を(もし一時的減少なら'x'を付けて)表示する
89 * @param player_ptr プレイヤーへの参照ポインタ
90 * @param stat_num 能力値番号
94 static void display_basic_stat_name(player_type *player_ptr, int stat_num, int row, int stat_col)
96 if (player_ptr->stat_cur[stat_num] < player_ptr->stat_max[stat_num])
97 c_put_str(TERM_WHITE, stat_names_reduced[stat_num], row + stat_num + 1, stat_col + 1);
99 c_put_str(TERM_WHITE, stat_names[stat_num], row + stat_num + 1, stat_col + 1);
103 * @brief 能力値を、基本・種族補正・職業補正・性格補正・装備補正・合計・現在 (一時的減少のみ) の順で表示する
104 * @param player_ptr プレイヤーへの参照ポインタ
105 * @param stat_num 能力値番号
106 * @param r_adj 補正後の基礎パラメータ
112 static void display_basic_stat_value(player_type *player_ptr, int stat_num, int r_adj, int e_adj, int row, int stat_col, char *buf)
114 (void)sprintf(buf, "%3d", r_adj);
115 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 13);
117 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[stat_num]);
118 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 16);
120 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[stat_num]);
121 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 19);
123 (void)sprintf(buf, "%3d", (int)e_adj);
124 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 22);
126 cnv_stat(player_ptr->stat_top[stat_num], buf);
127 c_put_str(TERM_L_GREEN, buf, row + stat_num + 1, stat_col + 26);
129 if (player_ptr->stat_use[stat_num] < player_ptr->stat_top[stat_num]) {
130 cnv_stat(player_ptr->stat_use[stat_num], buf);
131 c_put_str(TERM_YELLOW, buf, row + stat_num + 1, stat_col + 33);
136 * @brief 能力値を補正しつつ表示する
137 * @param player_ptr プレイヤーへの参照ポインタ
141 static void process_stats(player_type *player_ptr, int row, int stat_col)
144 for (int i = 0; i < A_MAX; i++) {
145 int r_adj = player_ptr->mimic_form ? mimic_info[player_ptr->mimic_form].r_adj[i] : rp_ptr->r_adj[i];
146 int e_adj = calc_basic_stat(player_ptr, i);
147 r_adj += compensate_special_race(player_ptr, i);
149 e_adj -= cp_ptr->c_adj[i];
150 e_adj -= ap_ptr->a_adj[i];
152 display_basic_stat_name(player_ptr, i, row, stat_col);
153 cnv_stat(player_ptr->stat_max[i], buf);
154 if (player_ptr->stat_max[i] == player_ptr->stat_max_max[i])
155 c_put_str(TERM_WHITE, "!", row + i + 1, _(stat_col + 6, stat_col + 4));
157 c_put_str(TERM_BLUE, buf, row + i + 1, stat_col + 13 - strlen(buf));
159 display_basic_stat_value(player_ptr, i, r_adj, e_adj, row, stat_col, buf);
164 * @brief pval付きの装備に依るステータス補正を表示する
167 * @param o_ptr 装備品への参照ポインタ
169 * @param flags 装備品に立っているフラグ
171 static void compensate_stat_by_weapon(char *c, TERM_COLOR *a, object_type *o_ptr, tr_type tr_flag, const TrFlags &flags)
175 if (o_ptr->pval > 0) {
177 if (o_ptr->pval < 10)
178 *c = '0' + o_ptr->pval;
181 if (flags.has(tr_flag)) {
185 if (o_ptr->pval < 0) {
187 if (o_ptr->pval > -10)
188 *c = '0' - o_ptr->pval;
193 * @brief 装備品を走査してpval付きのものをそれと分かるように表示する
194 * @param player_ptr プレイヤーへの参照ポインタ
195 * @param flags 装備品に立っているフラグ
199 static void display_equipments_compensation(player_type *player_ptr, int row, int *col)
201 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
203 o_ptr = &player_ptr->inventory_list[i];
204 auto flags = object_flags_known(o_ptr);
205 for (int stat = 0; stat < A_MAX; stat++) {
206 TERM_COLOR a = TERM_SLATE;
208 if (flags.has(TR_STATUS_LIST[stat])) {
209 compensate_stat_by_weapon(&c, &a, o_ptr, TR_SUST_STATUS_LIST[stat], flags);
210 } else if (flags.has(TR_SUST_STATUS_LIST[stat])) {
215 term_putch(*col, row + stat + 1, a, c);
224 * @param player_ptr プレイヤーへの参照ポインタ
227 static int compensation_stat_by_mutation(player_type *player_ptr, int stat)
229 int compensation = 0;
231 if (player_ptr->muta.has(PlayerMutationType::HYPER_STR))
233 if (player_ptr->muta.has(PlayerMutationType::PUNY))
235 if (player_ptr->tsuyoshi)
240 if (stat == A_WIS || stat == A_INT) {
241 if (player_ptr->muta.has(PlayerMutationType::HYPER_INT))
243 if (player_ptr->muta.has(PlayerMutationType::MORONIC))
249 if (player_ptr->muta.has(PlayerMutationType::IRON_SKIN))
251 if (player_ptr->muta.has(PlayerMutationType::LIMBER))
253 if (player_ptr->muta.has(PlayerMutationType::ARTHRITIS))
259 if (player_ptr->muta.has(PlayerMutationType::RESILIENT))
261 if (player_ptr->muta.has(PlayerMutationType::XTRA_FAT))
263 if (player_ptr->muta.has(PlayerMutationType::ALBINO))
265 if (player_ptr->muta.has(PlayerMutationType::FLESH_ROT))
267 if (player_ptr->tsuyoshi)
273 if (player_ptr->muta.has(PlayerMutationType::SILLY_VOI))
275 if (player_ptr->muta.has(PlayerMutationType::BLANK_FAC))
277 if (player_ptr->muta.has(PlayerMutationType::FLESH_ROT))
279 if (player_ptr->muta.has(PlayerMutationType::SCALES))
281 if (player_ptr->muta.has(PlayerMutationType::WART_SKIN))
283 if (player_ptr->muta.has(PlayerMutationType::ILL_NORM))
292 * @brief 突然変異 (と、つよしスペシャル)による能力値の補正有無で表示する記号を変える
293 * @param player_ptr プレイヤーへの参照ポインタ
298 static void change_display_by_mutation(player_type *player_ptr, int stat, char *c, TERM_COLOR *a)
300 int compensation = compensation_stat_by_mutation(player_ptr, stat);
301 if (compensation == 0)
305 if (compensation > 0) {
307 if (compensation < 10)
308 *c = '0' + compensation;
311 if (compensation < 0) {
313 if (compensation > -10)
314 *c = '0' - compensation;
319 * @brief 能力値を走査し、突然変異 (と、つよしスペシャル)で補正をかける必要があればかける
320 * @param player_ptr プレイヤーへの参照ポインタ
324 static void display_mutation_compensation(player_type *player_ptr, int row, int col)
327 player_flags(player_ptr, flags);
329 for (int stat = 0; stat < A_MAX; stat++) {
332 change_display_by_mutation(player_ptr, stat, &c, &a);
334 if (flags.has(TR_SUST_STATUS_LIST[stat])) {
339 term_putch(col, row + stat + 1, a, c);
344 * @brief プレイヤーの特性フラグ一覧表示2b /
345 * Special display, part 2b
346 * @param player_ptr プレイヤーへの参照ポインタ
349 * How to print out the modifications and sustains.
350 * Positive mods with no sustain will be light green.
351 * Positive mods with a sustain will be dark green.
352 * Sustains (with no modification) will be a dark green 's'.
353 * Negative mods (from a curse) will be red.
354 * Huge mods (>9), like from MICoMorgoth, will be a '*'
355 * No mod, no sustain, will be a slate '.'
358 void display_player_stat_info(player_type *player_ptr)
362 c_put_str(TERM_WHITE, _("能力", "Stat"), row, stat_col + 1);
363 c_put_str(TERM_BLUE, _(" 基本", " Base"), row, stat_col + 7);
364 c_put_str(TERM_L_BLUE, _(" 種 職 性 装 ", "RacClaPerMod"), row, stat_col + 13);
365 c_put_str(TERM_L_GREEN, _("合計", "Actual"), row, stat_col + 28);
366 c_put_str(TERM_YELLOW, _("現在", "Current"), row, stat_col + 35);
367 process_stats(player_ptr, row, stat_col);
369 int col = stat_col + 41;
370 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
371 c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
373 display_equipments_compensation(player_ptr, row, &col);
374 display_mutation_compensation(player_ptr, row, col);