2 * @brief プレイヤーの耐性と能力値を表示する
6 * ここにこれ以上関数を引っ越してくるのは禁止。何ならここから更に分割していく
9 #include "view/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(PlayerType *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;
41 if ((player_ptr->stat_max[stat_num] <= 18) && (player_ptr->stat_top[stat_num] <= 18)) {
42 e_adj = player_ptr->stat_top[stat_num] - player_ptr->stat_max[stat_num];
45 if ((player_ptr->stat_max[stat_num] <= 18) && (player_ptr->stat_top[stat_num] > 18)) {
46 e_adj = (player_ptr->stat_top[stat_num] - 18) / 10 - player_ptr->stat_max[stat_num] + 18;
49 if ((player_ptr->stat_max[stat_num] > 18) && (player_ptr->stat_top[stat_num] <= 18)) {
50 e_adj = player_ptr->stat_top[stat_num] - (player_ptr->stat_max[stat_num] - 19) / 10 - 19;
57 * @brief 特殊な種族の時、腕力等の基礎パラメータを変動させる
58 * @param player_ptr プレイヤーへの参照ポインタ
59 * @param stat_num 能力値番号
62 static int compensate_special_race(PlayerType *player_ptr, int stat_num)
64 if (!PlayerRace(player_ptr).equals(PlayerRaceType::ENT)) {
72 if (player_ptr->lev > 25) {
75 if (player_ptr->lev > 40) {
78 if (player_ptr->lev > 45) {
83 if (player_ptr->lev > 25) {
86 if (player_ptr->lev > 40) {
89 if (player_ptr->lev > 45) {
99 * @brief 能力値名を(もし一時的減少なら'x'を付けて)表示する
100 * @param player_ptr プレイヤーへの参照ポインタ
101 * @param stat_num 能力値番号
105 static void display_basic_stat_name(PlayerType *player_ptr, int stat_num, int row, int stat_col)
107 if (player_ptr->stat_cur[stat_num] < player_ptr->stat_max[stat_num]) {
108 c_put_str(TERM_WHITE, stat_names_reduced[stat_num], row + stat_num + 1, stat_col + 1);
110 c_put_str(TERM_WHITE, stat_names[stat_num], row + stat_num + 1, stat_col + 1);
115 * @brief 能力値を、基本・種族補正・職業補正・性格補正・装備補正・合計・現在 (一時的減少のみ) の順で表示する
116 * @param player_ptr プレイヤーへの参照ポインタ
117 * @param stat_num 能力値番号
118 * @param r_adj 補正後の基礎パラメータ
124 static void display_basic_stat_value(PlayerType *player_ptr, int stat_num, int r_adj, int e_adj, int row, int stat_col, char *buf)
126 (void)sprintf(buf, "%3d", r_adj);
127 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 13);
129 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[stat_num]);
130 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 16);
132 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[stat_num]);
133 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 19);
135 (void)sprintf(buf, "%3d", (int)e_adj);
136 c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 22);
138 cnv_stat(player_ptr->stat_top[stat_num], buf);
139 c_put_str(TERM_L_GREEN, buf, row + stat_num + 1, stat_col + 26);
141 if (player_ptr->stat_use[stat_num] < player_ptr->stat_top[stat_num]) {
142 cnv_stat(player_ptr->stat_use[stat_num], buf);
143 c_put_str(TERM_YELLOW, buf, row + stat_num + 1, stat_col + 33);
148 * @brief 能力値を補正しつつ表示する
149 * @param player_ptr プレイヤーへの参照ポインタ
153 static void process_stats(PlayerType *player_ptr, int row, int stat_col)
156 for (int i = 0; i < A_MAX; i++) {
157 int r_adj = player_ptr->mimic_form != MimicKindType::NONE ? mimic_info.at(player_ptr->mimic_form).r_adj[i] : rp_ptr->r_adj[i];
158 int e_adj = calc_basic_stat(player_ptr, i);
159 r_adj += compensate_special_race(player_ptr, i);
161 e_adj -= cp_ptr->c_adj[i];
162 e_adj -= ap_ptr->a_adj[i];
164 display_basic_stat_name(player_ptr, i, row, stat_col);
165 cnv_stat(player_ptr->stat_max[i], buf);
166 if (player_ptr->stat_max[i] == player_ptr->stat_max_max[i]) {
167 c_put_str(TERM_WHITE, "!", row + i + 1, _(stat_col + 6, stat_col + 4));
170 c_put_str(TERM_BLUE, buf, row + i + 1, stat_col + 13 - strlen(buf));
172 display_basic_stat_value(player_ptr, i, r_adj, e_adj, row, stat_col, buf);
177 * @brief pval付きの装備に依るステータス補正を表示する
180 * @param o_ptr 装備品への参照ポインタ
182 * @param flags 装備品に立っているフラグ
184 static void compensate_stat_by_weapon(char *c, TERM_COLOR *a, ObjectType *o_ptr, tr_type tr_flag, const TrFlags &flags)
188 if (o_ptr->pval > 0) {
190 if (o_ptr->pval < 10) {
191 *c = '0' + o_ptr->pval;
195 if (flags.has(tr_flag)) {
199 if (o_ptr->pval < 0) {
201 if (o_ptr->pval > -10) {
202 *c = '0' - o_ptr->pval;
208 * @brief 装備品を走査してpval付きのものをそれと分かるように表示する
209 * @param player_ptr プレイヤーへの参照ポインタ
210 * @param flags 装備品に立っているフラグ
214 static void display_equipments_compensation(PlayerType *player_ptr, int row, int *col)
216 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
218 o_ptr = &player_ptr->inventory_list[i];
219 auto flags = object_flags_known(o_ptr);
220 for (int stat = 0; stat < A_MAX; stat++) {
221 TERM_COLOR a = TERM_SLATE;
223 if (flags.has(TR_STATUS_LIST[stat])) {
224 compensate_stat_by_weapon(&c, &a, o_ptr, TR_SUST_STATUS_LIST[stat], flags);
225 } else if (flags.has(TR_SUST_STATUS_LIST[stat])) {
230 term_putch(*col, row + stat + 1, a, c);
239 * @param player_ptr プレイヤーへの参照ポインタ
242 static int compensation_stat_by_mutation(PlayerType *player_ptr, int stat)
244 int compensation = 0;
246 if (player_ptr->muta.has(PlayerMutationType::HYPER_STR)) {
249 if (player_ptr->muta.has(PlayerMutationType::PUNY)) {
252 if (player_ptr->tsuyoshi) {
258 if (stat == A_WIS || stat == A_INT) {
259 if (player_ptr->muta.has(PlayerMutationType::HYPER_INT)) {
262 if (player_ptr->muta.has(PlayerMutationType::MORONIC)) {
269 if (player_ptr->muta.has(PlayerMutationType::IRON_SKIN)) {
272 if (player_ptr->muta.has(PlayerMutationType::LIMBER)) {
275 if (player_ptr->muta.has(PlayerMutationType::ARTHRITIS)) {
282 if (player_ptr->muta.has(PlayerMutationType::RESILIENT)) {
285 if (player_ptr->muta.has(PlayerMutationType::XTRA_FAT)) {
288 if (player_ptr->muta.has(PlayerMutationType::ALBINO)) {
291 if (player_ptr->muta.has(PlayerMutationType::FLESH_ROT)) {
294 if (player_ptr->tsuyoshi) {
301 if (player_ptr->muta.has(PlayerMutationType::SILLY_VOI)) {
304 if (player_ptr->muta.has(PlayerMutationType::BLANK_FAC)) {
307 if (player_ptr->muta.has(PlayerMutationType::FLESH_ROT)) {
310 if (player_ptr->muta.has(PlayerMutationType::SCALES)) {
313 if (player_ptr->muta.has(PlayerMutationType::WART_SKIN)) {
316 if (player_ptr->muta.has(PlayerMutationType::ILL_NORM)) {
326 * @brief 突然変異 (と、つよしスペシャル)による能力値の補正有無で表示する記号を変える
327 * @param player_ptr プレイヤーへの参照ポインタ
332 static void change_display_by_mutation(PlayerType *player_ptr, int stat, char *c, TERM_COLOR *a)
334 int compensation = compensation_stat_by_mutation(player_ptr, stat);
335 if (compensation == 0) {
340 if (compensation > 0) {
342 if (compensation < 10) {
343 *c = '0' + compensation;
347 if (compensation < 0) {
349 if (compensation > -10) {
350 *c = '0' - compensation;
356 * @brief 能力値を走査し、突然変異 (と、つよしスペシャル)で補正をかける必要があればかける
357 * @param player_ptr プレイヤーへの参照ポインタ
361 static void display_mutation_compensation(PlayerType *player_ptr, int row, int col)
364 player_flags(player_ptr, flags);
366 for (int stat = 0; stat < A_MAX; stat++) {
369 change_display_by_mutation(player_ptr, stat, &c, &a);
371 if (flags.has(TR_SUST_STATUS_LIST[stat])) {
376 term_putch(col, row + stat + 1, a, c);
381 * @brief プレイヤーの特性フラグ一覧表示2b /
382 * Special display, part 2b
383 * @param player_ptr プレイヤーへの参照ポインタ
386 * How to print out the modifications and sustains.
387 * Positive mods with no sustain will be light green.
388 * Positive mods with a sustain will be dark green.
389 * Sustains (with no modification) will be a dark green 's'.
390 * Negative mods (from a curse) will be red.
391 * Huge mods (>9), like from MICoMorgoth, will be a '*'
392 * No mod, no sustain, will be a slate '.'
395 void display_player_stat_info(PlayerType *player_ptr)
399 c_put_str(TERM_WHITE, _("能力", "Stat"), row, stat_col + 1);
400 c_put_str(TERM_BLUE, _(" 基本", " Base"), row, stat_col + 7);
401 c_put_str(TERM_L_BLUE, _(" 種 職 性 装 ", "RacClaPerMod"), row, stat_col + 13);
402 c_put_str(TERM_L_GREEN, _("合計", "Actual"), row, stat_col + 28);
403 c_put_str(TERM_YELLOW, _("現在", "Current"), row, stat_col + 35);
404 process_stats(player_ptr, row, stat_col);
406 int col = stat_col + 41;
407 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
408 c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
410 display_equipments_compensation(player_ptr, row, &col);
411 display_mutation_compensation(player_ptr, row, col);