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/mimic-info-table.h"
15 #include "player/permanent-resistances.h"
16 #include "player/player-class.h"
17 #include "player/player-personality.h"
18 #include "player/player-race-types.h"
19 #include "player/player-status-table.h"
20 #include "term/screen-processor.h"
21 #include "term/term-color-types.h"
22 #include "util/bit-flags-calculator.h"
25 * @brief プレーヤーのパラメータ基礎値 (腕力等)を18以下になるようにして返す
26 * @param creature_ptr プレーヤーへの参照ポインタ
27 * @param stat_num 能力値番号
29 * @details 最大が18になるのはD&D由来
31 static int calc_basic_stat(player_type *creature_ptr, int stat_num)
34 if ((creature_ptr->stat_max[stat_num] > 18) && (creature_ptr->stat_top[stat_num] > 18))
35 e_adj = (creature_ptr->stat_top[stat_num] - creature_ptr->stat_max[stat_num]) / 10;
37 if ((creature_ptr->stat_max[stat_num] <= 18) && (creature_ptr->stat_top[stat_num] <= 18))
38 e_adj = creature_ptr->stat_top[stat_num] - creature_ptr->stat_max[stat_num];
40 if ((creature_ptr->stat_max[stat_num] <= 18) && (creature_ptr->stat_top[stat_num] > 18))
41 e_adj = (creature_ptr->stat_top[stat_num] - 18) / 10 - creature_ptr->stat_max[stat_num] + 18;
43 if ((creature_ptr->stat_max[stat_num] > 18) && (creature_ptr->stat_top[stat_num] <= 18))
44 e_adj = creature_ptr->stat_top[stat_num] - (creature_ptr->stat_max[stat_num] - 19) / 10 - 19;
50 * @brief 特殊な種族の時、腕力等の基礎パラメータを変動させる
51 * @param creature_ptr プレーヤーへの参照ポインタ
52 * @param stat_num 能力値番号
55 static int compensate_special_race(player_type *creature_ptr, int stat_num)
57 if (!is_specific_player_race(creature_ptr, RACE_ENT))
64 if (creature_ptr->lev > 25)
66 if (creature_ptr->lev > 40)
68 if (creature_ptr->lev > 45)
72 if (creature_ptr->lev > 25)
74 if (creature_ptr->lev > 40)
76 if (creature_ptr->lev > 45)
85 * @brief 能力値名を(もし一時的減少なら'x'を付けて)表示する
86 * @param creature_ptr プレーヤーへの参照ポインタ
87 * @param stat_num 能力値番号
92 static void display_basic_stat_name(player_type *creature_ptr, int stat_num, int row, int stat_col)
94 if (creature_ptr->stat_cur[stat_num] < creature_ptr->stat_max[stat_num])
95 c_put_str(TERM_WHITE, stat_names_reduced[stat_num], row + stat_num + 1, stat_col + 1);
97 c_put_str(TERM_WHITE, stat_names[stat_num], row + stat_num + 1, stat_col + 1);
101 * @brief 能力値を、基本・種族補正・職業補正・性格補正・装備補正・合計・現在 (一時的減少のみ) の順で表示する
102 * @param creature_ptr プレーヤーへの参照ポインタ
103 * @param stat_num 能力値番号
104 * @param r_adj 補正後の基礎パラメータ
111 static void display_basic_stat_value(player_type *creature_ptr, int stat_num, int r_adj, int e_adj, int row, int stat_col, char *buf)
113 (void)sprintf(buf, "%3d", r_adj);
114 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 13);
116 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[stat_num]);
117 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 16);
119 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[stat_num]);
120 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 19);
122 (void)sprintf(buf, "%3d", (int)e_adj);
123 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 22);
125 cnv_stat(creature_ptr->stat_top[stat_num], buf);
126 c_put_str(TERM_L_GREEN, buf, row + stat_num + 1, stat_col + 26);
128 if (creature_ptr->stat_use[stat_num] < creature_ptr->stat_top[stat_num]) {
129 cnv_stat(creature_ptr->stat_use[stat_num], buf);
130 c_put_str(TERM_YELLOW, buf, row + stat_num + 1, stat_col + 33);
135 * @brief 能力値を補正しつつ表示する
136 * @param creature_ptr プレーヤーへの参照ポインタ
141 static void process_stats(player_type *creature_ptr, int row, int stat_col)
144 for (int i = 0; i < A_MAX; i++) {
145 int r_adj = creature_ptr->mimic_form ? mimic_info[creature_ptr->mimic_form].r_adj[i] : rp_ptr->r_adj[i];
146 int e_adj = calc_basic_stat(creature_ptr, i);
147 r_adj += compensate_special_race(creature_ptr, i);
149 e_adj -= cp_ptr->c_adj[i];
150 e_adj -= ap_ptr->a_adj[i];
152 display_basic_stat_name(creature_ptr, i, row, stat_col);
153 cnv_stat(creature_ptr->stat_max[i], buf);
154 if (creature_ptr->stat_max[i] == creature_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(creature_ptr, i, r_adj, e_adj, row, stat_col, buf);
164 * @brief pval付きの装備に依るステータス補正を表示する
167 * @param o_ptr 装備品への参照ポインタ
169 * @param flags 装備品に立っているフラグ
172 static void compensate_stat_by_weapon(char *c, TERM_COLOR *a, object_type *o_ptr, int stat, BIT_FLAGS *flags)
176 if (o_ptr->pval > 0) {
178 if (o_ptr->pval < 10)
179 *c = '0' + o_ptr->pval;
182 if (has_flag(flags, stat + TR_SUST_STR)) {
186 if (o_ptr->pval < 0) {
188 if (o_ptr->pval > -10)
189 *c = '0' - o_ptr->pval;
194 * @brief 装備品を走査してpval付きのものをそれと分かるように表示する
195 * @param creature_ptr プレーヤーへの参照ポインタ
196 * @param flags 装備品に立っているフラグ
201 static void display_equipments_compensation(player_type *creature_ptr, BIT_FLAGS *flags, int row, int *col)
203 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
205 o_ptr = &creature_ptr->inventory_list[i];
206 object_flags_known(creature_ptr, o_ptr, flags);
207 for (int stat = 0; stat < A_MAX; stat++) {
208 TERM_COLOR a = TERM_SLATE;
210 if (has_flag(flags, stat)) {
211 compensate_stat_by_weapon(&c, &a, o_ptr, stat, flags);
212 } else if (has_flag(flags, stat + TR_SUST_STR)) {
217 term_putch(*col, row + stat + 1, a, c);
226 * @param creature_ptr プレーヤーへの参照ポインタ
230 static int compensation_stat_by_mutation(player_type *creature_ptr, int stat)
232 int compensation = 0;
234 if (any_bits(creature_ptr->muta3, MUT3_HYPER_STR))
236 if (any_bits(creature_ptr->muta3, MUT3_PUNY))
238 if (creature_ptr->tsuyoshi)
243 if (stat == A_WIS || stat == A_INT) {
244 if (any_bits(creature_ptr->muta3, MUT3_HYPER_INT))
246 if (any_bits(creature_ptr->muta3, MUT3_MORONIC))
252 if (any_bits(creature_ptr->muta3, MUT3_IRON_SKIN))
254 if (any_bits(creature_ptr->muta3, MUT3_LIMBER))
256 if (any_bits(creature_ptr->muta3, MUT3_ARTHRITIS))
262 if (any_bits(creature_ptr->muta3, MUT3_RESILIENT))
264 if (any_bits(creature_ptr->muta3, MUT3_XTRA_FAT))
266 if (any_bits(creature_ptr->muta3, MUT3_ALBINO))
268 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT))
270 if (creature_ptr->tsuyoshi)
276 if (any_bits(creature_ptr->muta3, MUT3_SILLY_VOI))
278 if (any_bits(creature_ptr->muta3, MUT3_BLANK_FAC))
280 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT))
282 if (any_bits(creature_ptr->muta3, MUT3_SCALES))
284 if (any_bits(creature_ptr->muta3, MUT3_WART_SKIN))
286 if (any_bits(creature_ptr->muta3, MUT3_ILL_NORM))
295 * @brief 突然変異 (と、つよしスペシャル)による能力値の補正有無で表示する記号を変える
296 * @param creature_ptr プレーヤーへの参照ポインタ
302 static void change_display_by_mutation(player_type *creature_ptr, int stat, char *c, TERM_COLOR *a)
304 int compensation = compensation_stat_by_mutation(creature_ptr, stat);
305 if (compensation == 0)
309 if (compensation > 0) {
311 if (compensation < 10)
312 *c = '0' + compensation;
315 if (compensation < 0) {
317 if (compensation > -10)
318 *c = '0' - compensation;
323 * @brief 能力値を走査し、突然変異 (と、つよしスペシャル)で補正をかける必要があればかける
324 * @param creature_ptr プレーヤーへの参照ポインタ
330 static void display_mutation_compensation(player_type *creature_ptr, BIT_FLAGS *flags, int row, int col)
332 for (int stat = 0; stat < A_MAX; stat++) {
335 change_display_by_mutation(creature_ptr, stat, &c, &a);
337 if (has_flag(flags, stat + TR_SUST_STR)) {
342 term_putch(col, row + stat + 1, a, c);
347 * @brief プレイヤーの特性フラグ一覧表示2b /
348 * Special display, part 2b
349 * @param creature_ptr プレーヤーへの参照ポインタ
353 * How to print out the modifications and sustains.
354 * Positive mods with no sustain will be light green.
355 * Positive mods with a sustain will be dark green.
356 * Sustains (with no modification) will be a dark green 's'.
357 * Negative mods (from a curse) will be red.
358 * Huge mods (>9), like from MICoMorgoth, will be a '*'
359 * No mod, no sustain, will be a slate '.'
362 void display_player_stat_info(player_type *creature_ptr)
366 c_put_str(TERM_WHITE, _("能力", "Stat"), row, stat_col + 1);
367 c_put_str(TERM_BLUE, _(" 基本", " Base"), row, stat_col + 7);
368 c_put_str(TERM_L_BLUE, _(" 種 職 性 装 ", "RacClaPerMod"), row, stat_col + 13);
369 c_put_str(TERM_L_GREEN, _("合計", "Actual"), row, stat_col + 28);
370 c_put_str(TERM_YELLOW, _("現在", "Current"), row, stat_col + 35);
371 process_stats(creature_ptr, row, stat_col);
373 int col = stat_col + 41;
374 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
375 c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
377 BIT_FLAGS flags[TR_FLAG_SIZE];
378 display_equipments_compensation(creature_ptr, flags, row, &col);
379 player_flags(creature_ptr, flags);
380 display_mutation_compensation(creature_ptr, flags, row, col);