OSDN Git Service

[Refactor] #39962 display_player_stat_info() からcompensate_stat_by_weapon() を分離 /...
[hengband/hengband.git] / src / view / display-player.c
1 /*!
2  * @brief プレーヤーのステータス表示メインルーチン群
3  * @date 2020/02/25
4  * @author Hourier
5  * @details
6  * ここにこれ以上関数を引っ越してくるのは禁止。何ならここから更に分割していく
7  */
8
9 #include "display-player.h"
10 #include "player-personality.h"
11 #include "term.h"
12 #include "status-first-page.h"
13 #include "player-sex.h"
14 #include "patron.h"
15 #include "world.h"
16 #include "quest.h"
17 #include "core.h" // 暫定。後で消す
18 #include "player/permanent-resistances.h" // 暫定。後で消す
19 #include "mutation.h"
20 #include "player-skill.h"
21 #include "player-effects.h"
22 #include "realm-song.h"
23 #include "object-hook.h"
24 #include "shoot.h"
25 #include "dungeon-file.h"
26 #include "objectkind.h"
27 #include "view/display-util.h"
28 #include "view/display-characteristic.h"
29
30 /*!
31  * @brief プレイヤーの特性フラグ一覧表示2a /
32  * @param creature_ptr プレーヤーへの参照ポインタ
33  * Special display, part 2a
34  * @return なし
35  */
36 static void display_player_misc_info(player_type *creature_ptr)
37 {
38 #ifdef JP
39         put_str("名前  :", 1, 26);
40         put_str("性別  :", 3, 1);
41         put_str("種族  :", 4, 1);
42         put_str("職業  :", 5, 1);
43 #else
44         put_str("Name  :", 1, 26);
45         put_str("Sex   :", 3, 1);
46         put_str("Race  :", 4, 1);
47         put_str("Class :", 5, 1);
48 #endif
49
50         char    buf[80];
51         char    tmp[80];
52         strcpy(tmp, ap_ptr->title);
53 #ifdef JP
54         if (ap_ptr->no == 1)
55                 strcat(tmp, "の");
56 #else
57         strcat(tmp, " ");
58 #endif
59         strcat(tmp, creature_ptr->name);
60
61         c_put_str(TERM_L_BLUE, tmp, 1, 34);
62         c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
63         c_put_str(TERM_L_BLUE, (creature_ptr->mimic_form ? mimic_info[creature_ptr->mimic_form].title : rp_ptr->title), 4, 9);
64         c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
65
66 #ifdef JP
67         put_str("レベル:", 6, 1);
68         put_str("HP  :", 7, 1);
69         put_str("MP  :", 8, 1);
70 #else
71         put_str("Level :", 6, 1);
72         put_str("Hits  :", 7, 1);
73         put_str("Mana  :", 8, 1);
74 #endif
75
76         (void)sprintf(buf, "%d", (int)creature_ptr->lev);
77         c_put_str(TERM_L_BLUE, buf, 6, 9);
78         (void)sprintf(buf, "%d/%d", (int)creature_ptr->chp, (int)creature_ptr->mhp);
79         c_put_str(TERM_L_BLUE, buf, 7, 9);
80         (void)sprintf(buf, "%d/%d", (int)creature_ptr->csp, (int)creature_ptr->msp);
81         c_put_str(TERM_L_BLUE, buf, 8, 9);
82 }
83
84
85 /*!
86  * @brief プレーヤーのパラメータ基礎値 (腕力等)を18以下になるようにして返す
87  * @param creature_ptr プレーヤーへの参照ポインタ
88  * @param stat_num 能力値番号
89  * @return 基礎値
90  * @details 最大が18になるのはD&D由来
91  */
92 static int calc_basic_stat(player_type *creature_ptr, int stat_num)
93 {
94         int e_adj = 0;
95         if ((creature_ptr->stat_max[stat_num] > 18) && (creature_ptr->stat_top[stat_num] > 18))
96                 e_adj = (creature_ptr->stat_top[stat_num] - creature_ptr->stat_max[stat_num]) / 10;
97
98         if ((creature_ptr->stat_max[stat_num] <= 18) && (creature_ptr->stat_top[stat_num] <= 18))
99                 e_adj = creature_ptr->stat_top[stat_num] - creature_ptr->stat_max[stat_num];
100
101         if ((creature_ptr->stat_max[stat_num] <= 18) && (creature_ptr->stat_top[stat_num] > 18))
102                 e_adj = (creature_ptr->stat_top[stat_num] - 18) / 10 - creature_ptr->stat_max[stat_num] + 18;
103
104         if ((creature_ptr->stat_max[stat_num] > 18) && (creature_ptr->stat_top[stat_num] <= 18))
105                 e_adj = creature_ptr->stat_top[stat_num] - (creature_ptr->stat_max[stat_num] - 19) / 10 - 19;
106
107         return e_adj;
108 }
109
110
111 /*!
112  * @brief 特殊な種族の時、腕力等の基礎パラメータを変動させる
113  * @param creature_ptr プレーヤーへの参照ポインタ
114  * @param stat_num 能力値番号
115  * @return 補正後の基礎パラメータ
116  */
117 static int compensate_special_race(player_type *creature_ptr, int stat_num)
118 {
119         if (!PRACE_IS_(creature_ptr, RACE_ENT)) return 0;
120
121         int r_adj = 0;
122         switch (stat_num)
123         {
124         case A_STR:
125         case A_CON:
126                 if (creature_ptr->lev > 25) r_adj++;
127                 if (creature_ptr->lev > 40) r_adj++;
128                 if (creature_ptr->lev > 45) r_adj++;
129                 break;
130         case A_DEX:
131                 if (creature_ptr->lev > 25) r_adj--;
132                 if (creature_ptr->lev > 40) r_adj--;
133                 if (creature_ptr->lev > 45) r_adj--;
134                 break;
135         }
136
137         return r_adj;
138 }
139
140
141 /*!
142  * @brief 能力値名を(もし一時的減少なら'x'を付けて)表示する
143  * @param creature_ptr プレーヤーへの参照ポインタ
144  * @param stat_num 能力値番号
145  * @param row 行数
146  * @param stat_col 列数
147  * @return なし
148  */
149 static void display_basic_stat_name(player_type *creature_ptr, int stat_num, int row, int stat_col)
150 {
151         if (creature_ptr->stat_cur[stat_num] < creature_ptr->stat_max[stat_num])
152                 c_put_str(TERM_WHITE, stat_names_reduced[stat_num], row + stat_num + 1, stat_col + 1);
153         else
154                 c_put_str(TERM_WHITE, stat_names[stat_num], row + stat_num + 1, stat_col + 1);
155 }
156
157
158 /*!
159  * @brief 能力値を、基本・種族補正・職業補正・性格補正・装備補正・合計・現在 (一時的減少のみ) の順で表示する
160  * @param creature_ptr プレーヤーへの参照ポインタ
161  * @param stat_num 能力値番号
162  * @param r_adj 補正後の基礎パラメータ
163  * @param e_adj 種族補正値
164  * @param row 行数
165  * @param stat_col 列数
166  * @param buf 能力値の数値
167  * @return なし
168  */
169 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)
170 {
171         (void)sprintf(buf, "%3d", r_adj);
172         c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 13);
173
174         (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[stat_num]);
175         c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 16);
176
177         (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[stat_num]);
178         c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 19);
179
180         (void)sprintf(buf, "%3d", (int)e_adj);
181         c_put_str(TERM_L_BLUE, buf, row + stat_num + 1, stat_col + 22);
182
183         cnv_stat(creature_ptr->stat_top[stat_num], buf);
184         c_put_str(TERM_L_GREEN, buf, row + stat_num + 1, stat_col + 26);
185
186         if (creature_ptr->stat_use[stat_num] < creature_ptr->stat_top[stat_num])
187         {
188                 cnv_stat(creature_ptr->stat_use[stat_num], buf);
189                 c_put_str(TERM_YELLOW, buf, row + stat_num + 1, stat_col + 33);
190         }
191 }
192
193
194 /*!
195  * @brief 能力値を補正しつつ表示する
196  * @param creature_ptr プレーヤーへの参照ポインタ
197  * @param row 行数
198  * @param stat_col 列数
199  * @return なし
200  */
201 static void process_stats(player_type *creature_ptr, int row, int stat_col)
202 {
203         char buf[80];
204         for (int i = 0; i < A_MAX; i++)
205         {
206                 int r_adj = creature_ptr->mimic_form
207                         ? mimic_info[creature_ptr->mimic_form].r_adj[i]
208                         : rp_ptr->r_adj[i];
209                 int e_adj = calc_basic_stat(creature_ptr, i);
210                 r_adj += compensate_special_race(creature_ptr, i);
211                 e_adj -= r_adj;
212                 e_adj -= cp_ptr->c_adj[i];
213                 e_adj -= ap_ptr->a_adj[i];
214
215                 display_basic_stat_name(creature_ptr, i, row, stat_col);
216                 cnv_stat(creature_ptr->stat_max[i], buf);
217                 if (creature_ptr->stat_max[i] == creature_ptr->stat_max_max[i])
218                         c_put_str(TERM_WHITE, "!", row + i + 1, _(stat_col + 6, stat_col + 4));
219
220                 c_put_str(TERM_BLUE, buf, row + i + 1, stat_col + 13 - strlen(buf));
221
222                 display_basic_stat_value(creature_ptr, i, r_adj, e_adj, row, stat_col, buf);
223         }
224 }
225
226
227 /*!
228  * @brief pval付きの装備に依るステータス補正を表示する
229  * @param c 補正後の表示記号
230  * @param a 表示色
231  * @param o_ptr 装備品への参照ポインタ
232  * @param stat 能力値番号
233  * @param flags 装備品に立っているフラグ
234  * @return なし
235  */
236 static void compensate_stat_by_weapon(char *c, TERM_COLOR *a, object_type *o_ptr, int stat, BIT_FLAGS *flags)
237 {
238         *c = '*';
239
240         if (o_ptr->pval > 0)
241         {
242                 *a = TERM_L_GREEN;
243                 if (o_ptr->pval < 10) *c = '0' + o_ptr->pval;
244         }
245
246         if (have_flag(flags, stat + TR_SUST_STR))
247         {
248                 *a = TERM_GREEN;
249         }
250
251         if (o_ptr->pval < 0)
252         {
253                 *a = TERM_RED;
254                 if (o_ptr->pval > -10) *c = '0' - o_ptr->pval;
255         }
256 }
257
258
259 /*!
260  * @brief プレイヤーの特性フラグ一覧表示2b /
261  * Special display, part 2b
262  * @param creature_ptr プレーヤーへの参照ポインタ
263  * @return なし
264  * @details
265  * <pre>
266  * How to print out the modifications and sustains.
267  * Positive mods with no sustain will be light green.
268  * Positive mods with a sustain will be dark green.
269  * Sustains (with no modification) will be a dark green 's'.
270  * Negative mods (from a curse) will be red.
271  * Huge mods (>9), like from MICoMorgoth, will be a '*'
272  * No mod, no sustain, will be a slate '.'
273  * </pre>
274  */
275 static void display_player_stat_info(player_type *creature_ptr)
276 {
277         int stat_col = 22;
278         int row = 3;
279         c_put_str(TERM_WHITE, _("能力", "Stat"), row, stat_col + 1);
280         c_put_str(TERM_BLUE, _("  基本", "  Base"), row, stat_col + 7);
281         c_put_str(TERM_L_BLUE, _(" 種 職 性 装 ", "RacClaPerMod"), row, stat_col + 13);
282         c_put_str(TERM_L_GREEN, _("合計", "Actual"), row, stat_col + 28);
283         c_put_str(TERM_YELLOW, _("現在", "Current"), row, stat_col + 35);
284         process_stats(creature_ptr, row, stat_col);
285
286         int col = stat_col + 41;
287         c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
288         c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
289
290         BIT_FLAGS flags[TR_FLAG_SIZE];
291         for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
292         {
293                 object_type *o_ptr;
294                 o_ptr = &creature_ptr->inventory_list[i];
295                 object_flags_known(o_ptr, flags);
296                 for (int stat = 0; stat < A_MAX; stat++)
297                 {
298                         TERM_COLOR a = TERM_SLATE;
299                         char c = '.';
300                         if (have_flag(flags, stat))
301                         {
302                                 compensate_stat_by_weapon(&c, &a, o_ptr, stat, flags);
303                         }
304                         else if (have_flag(flags, stat + TR_SUST_STR))
305                         {
306                                 a = TERM_GREEN;
307                                 c = 's';
308                         }
309
310                         Term_putch(col, row + stat + 1, a, c);
311                 }
312
313                 col++;
314         }
315
316         player_flags(creature_ptr, flags);
317         for (int stat = 0; stat < A_MAX; stat++)
318         {
319                 byte a = TERM_SLATE;
320                 char c = '.';
321
322                 if (creature_ptr->muta3 || creature_ptr->tsuyoshi)
323                 {
324                         int dummy = 0;
325
326                         if (stat == A_STR)
327                         {
328                                 if (creature_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
329                                 if (creature_ptr->muta3 & MUT3_PUNY) dummy -= 4;
330                                 if (creature_ptr->tsuyoshi) dummy += 4;
331                         }
332                         else if (stat == A_WIS || stat == A_INT)
333                         {
334                                 if (creature_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
335                                 if (creature_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
336                         }
337                         else if (stat == A_DEX)
338                         {
339                                 if (creature_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
340                                 if (creature_ptr->muta3 & MUT3_LIMBER) dummy += 3;
341                                 if (creature_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
342                         }
343                         else if (stat == A_CON)
344                         {
345                                 if (creature_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
346                                 if (creature_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
347                                 if (creature_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
348                                 if (creature_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
349                                 if (creature_ptr->tsuyoshi) dummy += 4;
350                         }
351                         else if (stat == A_CHR)
352                         {
353                                 if (creature_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
354                                 if (creature_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
355                                 if (creature_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
356                                 if (creature_ptr->muta3 & MUT3_SCALES) dummy -= 1;
357                                 if (creature_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
358                                 if (creature_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
359                         }
360
361                         if (dummy != 0)
362                         {
363                                 c = '*';
364                                 if (dummy > 0)
365                                 {
366                                         /* Good */
367                                         a = TERM_L_GREEN;
368
369                                         /* Label boost */
370                                         if (dummy < 10) c = '0' + dummy;
371                                 }
372
373                                 if (dummy < 0)
374                                 {
375                                         a = TERM_RED;
376                                         if (dummy > -10) c = '0' - dummy;
377                                 }
378                         }
379                 }
380
381                 if (have_flag(flags, stat + TR_SUST_STR))
382                 {
383                         a = TERM_GREEN;
384                         c = 's';
385                 }
386
387                 Term_putch(col, row + stat + 1, a, c);
388         }
389 }
390
391
392 /*!
393  * @brief プレイヤーの打撃能力修正を表示する
394  * @param creature_ptr プレーヤーへの参照ポインタ
395  * @param hand 武器の装備部位ID
396  * @param hand_entry 項目ID
397  * @return なし
398  */
399 static void display_player_melee_bonus(player_type *creature_ptr, int hand, int hand_entry)
400 {
401         HIT_PROB show_tohit = creature_ptr->dis_to_h[hand];
402         HIT_POINT show_todam = creature_ptr->dis_to_d[hand];
403         object_type *o_ptr = &creature_ptr->inventory_list[INVEN_RARM + hand];
404
405         if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
406         if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
407
408         show_tohit += creature_ptr->skill_thn / BTH_PLUS_ADJ;
409
410         char buf[160];
411         sprintf(buf, "(%+d,%+d)", (int)show_tohit, (int)show_todam);
412
413         if (!has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
414                 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
415         else if (creature_ptr->ryoute)
416                 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
417         else
418                 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
419 }
420
421
422 /*!
423  * @brief プレイヤーステータス表示の中央部分を表示するサブルーチン
424  * @param creature_ptr プレーヤーへの参照ポインタ
425  * Prints the following information on the screen.
426  * @return なし
427  */
428 static void display_player_middle(player_type *creature_ptr)
429 {
430         HIT_PROB show_tohit = creature_ptr->dis_to_h_b;
431         HIT_POINT show_todam = 0;
432         if (creature_ptr->migite)
433         {
434                 display_player_melee_bonus(creature_ptr, 0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
435         }
436
437         if (creature_ptr->hidarite)
438         {
439                 display_player_melee_bonus(creature_ptr, 1, left_hander ? ENTRY_RIGHT_HAND2 : ENTRY_LEFT_HAND2);
440         }
441         else if ((creature_ptr->pclass == CLASS_MONK) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))
442         {
443                 int i;
444                 if (creature_ptr->special_defense & KAMAE_MASK)
445                 {
446                         for (i = 0; i < MAX_KAMAE; i++)
447                         {
448                                 if ((creature_ptr->special_defense >> i) & KAMAE_GENBU) break;
449                         }
450                         if (i < MAX_KAMAE)
451                         {
452                                 display_player_one_line(ENTRY_POSTURE, format(_("%sの構え", "%s form"), kamae_shurui[i].desc), TERM_YELLOW);
453                         }
454                 }
455                 else
456                 {
457                         display_player_one_line(ENTRY_POSTURE, _("構えなし", "none"), TERM_YELLOW);
458                 }
459         }
460
461         object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
462         if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
463         if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
464
465         if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
466                 show_tohit += creature_ptr->weapon_exp[0][o_ptr->sval] / 400;
467         else
468                 show_tohit += (creature_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
469
470         show_tohit += creature_ptr->skill_thb / BTH_PLUS_ADJ;
471
472         display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
473         int tmul = 0;
474         if (creature_ptr->inventory_list[INVEN_BOW].k_idx)
475         {
476                 tmul = bow_tmul(creature_ptr->inventory_list[INVEN_BOW].sval);
477                 if (creature_ptr->xtra_might) tmul++;
478
479                 tmul = tmul * (100 + (int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
480         }
481
482         display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul / 100, tmul % 100), TERM_L_BLUE);
483         display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", creature_ptr->dis_ac, creature_ptr->dis_to_a), TERM_L_BLUE);
484
485         int i = creature_ptr->pspeed - 110;
486         if (creature_ptr->action == ACTION_SEARCH) i += 10;
487
488         TERM_COLOR attr;
489         if (i > 0)
490         {
491                 if (!creature_ptr->riding)
492                         attr = TERM_L_GREEN;
493                 else
494                         attr = TERM_GREEN;
495         }
496         else if (i == 0)
497         {
498                 if (!creature_ptr->riding)
499                         attr = TERM_L_BLUE;
500                 else
501                         attr = TERM_GREEN;
502         }
503         else
504         {
505                 if (!creature_ptr->riding)
506                         attr = TERM_L_UMBER;
507                 else
508                         attr = TERM_RED;
509         }
510
511         int tmp_speed = 0;
512         if (!creature_ptr->riding)
513         {
514                 if (IS_FAST(creature_ptr)) tmp_speed += 10;
515                 if (creature_ptr->slow) tmp_speed -= 10;
516                 if (creature_ptr->lightspeed) tmp_speed = 99;
517         }
518         else
519         {
520                 if (MON_FAST(&creature_ptr->current_floor_ptr->m_list[creature_ptr->riding])) tmp_speed += 10;
521                 if (MON_SLOW(&creature_ptr->current_floor_ptr->m_list[creature_ptr->riding])) tmp_speed -= 10;
522         }
523
524         char buf[160];
525         if (tmp_speed)
526         {
527                 if (!creature_ptr->riding)
528                         sprintf(buf, "(%+d%+d)", i - tmp_speed, tmp_speed);
529                 else
530                         sprintf(buf, _("乗馬中 (%+d%+d)", "Riding (%+d%+d)"), i - tmp_speed, tmp_speed);
531
532                 if (tmp_speed > 0)
533                         attr = TERM_YELLOW;
534                 else
535                         attr = TERM_VIOLET;
536         }
537         else
538         {
539                 if (!creature_ptr->riding)
540                         sprintf(buf, "(%+d)", i);
541                 else
542                         sprintf(buf, _("乗馬中 (%+d)", "Riding (%+d)"), i);
543         }
544
545         display_player_one_line(ENTRY_SPEED, buf, attr);
546         display_player_one_line(ENTRY_LEVEL, format("%d", creature_ptr->lev), TERM_L_GREEN);
547
548         int e = (creature_ptr->prace == RACE_ANDROID) ? ENTRY_EXP_ANDR : ENTRY_CUR_EXP;
549         if (creature_ptr->exp >= creature_ptr->max_exp)
550                 display_player_one_line(e, format("%ld", creature_ptr->exp), TERM_L_GREEN);
551         else
552                 display_player_one_line(e, format("%ld", creature_ptr->exp), TERM_YELLOW);
553
554         if (creature_ptr->prace != RACE_ANDROID)
555                 display_player_one_line(ENTRY_MAX_EXP, format("%ld", creature_ptr->max_exp), TERM_L_GREEN);
556
557         e = (creature_ptr->prace == RACE_ANDROID) ? ENTRY_EXP_TO_ADV_ANDR : ENTRY_EXP_TO_ADV;
558
559         if (creature_ptr->lev >= PY_MAX_LEVEL)
560                 display_player_one_line(e, "*****", TERM_L_GREEN);
561         else if (creature_ptr->prace == RACE_ANDROID)
562                 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)), TERM_L_GREEN);
563         else
564                 display_player_one_line(e, format("%ld", (s32b)(player_exp[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)), TERM_L_GREEN);
565
566         display_player_one_line(ENTRY_GOLD, format("%ld", creature_ptr->au), TERM_L_GREEN);
567
568         int day, hour, min;
569         extract_day_hour_min(creature_ptr, &day, &hour, &min);
570
571         if (day < MAX_DAYS)
572                 sprintf(buf, _("%d日目 %2d:%02d", "Day %d %2d:%02d"), day, hour, min);
573         else
574                 sprintf(buf, _("*****日目 %2d:%02d", "Day ***** %2d:%02d"), hour, min);
575
576         display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
577
578         if (creature_ptr->chp >= creature_ptr->mhp)
579                 display_player_one_line(ENTRY_HP, format("%4d/%4d", creature_ptr->chp, creature_ptr->mhp), TERM_L_GREEN);
580         else if (creature_ptr->chp > (creature_ptr->mhp * hitpoint_warn) / 10)
581                 display_player_one_line(ENTRY_HP, format("%4d/%4d", creature_ptr->chp, creature_ptr->mhp), TERM_YELLOW);
582         else
583                 display_player_one_line(ENTRY_HP, format("%4d/%4d", creature_ptr->chp, creature_ptr->mhp), TERM_RED);
584
585         if (creature_ptr->csp >= creature_ptr->msp)
586                 display_player_one_line(ENTRY_SP, format("%4d/%4d", creature_ptr->csp, creature_ptr->msp), TERM_L_GREEN);
587         else if (creature_ptr->csp > (creature_ptr->msp * mana_warn) / 10)
588                 display_player_one_line(ENTRY_SP, format("%4d/%4d", creature_ptr->csp, creature_ptr->msp), TERM_YELLOW);
589         else
590                 display_player_one_line(ENTRY_SP, format("%4d/%4d", creature_ptr->csp, creature_ptr->msp), TERM_RED);
591
592         u32b play_hour = current_world_ptr->play_time / (60 * 60);
593         u32b play_min = (current_world_ptr->play_time / 60) % 60;
594         u32b play_sec = current_world_ptr->play_time % 60;
595         display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", play_hour, play_min, play_sec), TERM_L_GREEN);
596 }
597
598
599 /*!
600  * @brief プレイヤーのステータス表示メイン処理
601  * Display the character on the screen (various modes)
602  * @param creature_ptr プレーヤーへの参照ポインタ
603  * @param mode 表示モードID
604  * @return なし
605  * @details
606  * <pre>
607  * The top one and bottom two lines are left blank.
608  * Mode 0 = standard display with skills
609  * Mode 1 = standard display with history
610  * Mode 2 = summary of various things
611  * Mode 3 = summary of various things (part 2)
612  * Mode 4 = mutations
613  * </pre>
614  */
615 void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
616 {
617         if ((creature_ptr->muta1 || creature_ptr->muta2 || creature_ptr->muta3) && display_mutations)
618                 mode = (mode % 5);
619         else
620                 mode = (mode % 4);
621
622         clear_from(0);
623
624         if (mode == 2)
625         {
626                 display_player_misc_info(creature_ptr);
627                 display_player_stat_info(creature_ptr);
628                 display_player_flag_info_1(creature_ptr, display_player_equippy);
629                 return;
630         }
631
632         if (mode == 3)
633         {
634                 display_player_flag_info_2(creature_ptr, display_player_equippy);
635                 return;
636         }
637
638         if (mode == 4)
639         {
640                 do_cmd_knowledge_mutations(creature_ptr);
641                 return;
642         }
643
644         char tmp[64];
645         if ((mode != 0) && (mode != 1)) return;
646
647         /* Name, Sex, Race, Class */
648 #ifdef JP
649         sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "の" : "", creature_ptr->name);
650 #else
651         sprintf(tmp, "%s %s", ap_ptr->title, creature_ptr->name);
652 #endif
653
654         display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
655         display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
656         display_player_one_line(ENTRY_RACE, (creature_ptr->mimic_form ? mimic_info[creature_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
657         display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
658
659         if (creature_ptr->realm1)
660         {
661                 if (creature_ptr->realm2)
662                         sprintf(tmp, "%s, %s", realm_names[creature_ptr->realm1], realm_names[creature_ptr->realm2]);
663                 else
664                         strcpy(tmp, realm_names[creature_ptr->realm1]);
665                 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
666         }
667
668         if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
669                 display_player_one_line(ENTRY_PATRON, chaos_patrons[creature_ptr->chaos_patron], TERM_L_BLUE);
670
671         /* Age, Height, Weight, Social */
672         /* 身長はセンチメートルに、体重はキログラムに変更してあります */
673 #ifdef JP
674         display_player_one_line(ENTRY_AGE, format("%d才", (int)creature_ptr->age), TERM_L_BLUE);
675         display_player_one_line(ENTRY_HEIGHT, format("%dcm", (int)((creature_ptr->ht * 254) / 100)), TERM_L_BLUE);
676         display_player_one_line(ENTRY_WEIGHT, format("%dkg", (int)((creature_ptr->wt * 4536) / 10000)), TERM_L_BLUE);
677         display_player_one_line(ENTRY_SOCIAL, format("%d  ", (int)creature_ptr->sc), TERM_L_BLUE);
678 #else
679         display_player_one_line(ENTRY_AGE, format("%d", (int)creature_ptr->age), TERM_L_BLUE);
680         display_player_one_line(ENTRY_HEIGHT, format("%d", (int)creature_ptr->ht), TERM_L_BLUE);
681         display_player_one_line(ENTRY_WEIGHT, format("%d", (int)creature_ptr->wt), TERM_L_BLUE);
682         display_player_one_line(ENTRY_SOCIAL, format("%d", (int)creature_ptr->sc), TERM_L_BLUE);
683 #endif
684         display_player_one_line(ENTRY_ALIGN, format("%s", your_alignment(creature_ptr)), TERM_L_BLUE);
685
686         char buf[80];
687         for (int i = 0; i < A_MAX; i++)
688         {
689                 if (creature_ptr->stat_cur[i] < creature_ptr->stat_max[i])
690                 {
691                         put_str(stat_names_reduced[i], 3 + i, 53);
692                         int value = creature_ptr->stat_use[i];
693                         cnv_stat(value, buf);
694                         c_put_str(TERM_YELLOW, buf, 3 + i, 60);
695                         value = creature_ptr->stat_top[i];
696                         cnv_stat(value, buf);
697                         c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
698                 }
699                 else
700                 {
701                         put_str(stat_names[i], 3 + i, 53);
702                         cnv_stat(creature_ptr->stat_use[i], buf);
703                         c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
704                 }
705
706                 if (creature_ptr->stat_max[i] == creature_ptr->stat_max_max[i])
707                 {
708                         c_put_str(TERM_WHITE, "!", 3 + i, _(58, 58 - 2));
709                 }
710         }
711
712         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
713         if (mode == 0)
714         {
715                 display_player_middle(creature_ptr);
716                 display_player_various(creature_ptr);
717                 return;
718         }
719
720         char statmsg[1000];
721         put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
722
723         for (int i = 0; i < 4; i++)
724         {
725                 put_str(creature_ptr->history[i], i + 12, 10);
726         }
727
728         *statmsg = '\0';
729
730         if (creature_ptr->is_dead)
731         {
732                 if (current_world_ptr->total_winner)
733                 {
734 #ifdef JP
735                         sprintf(statmsg, "…あなたは勝利の後%sした。", streq(creature_ptr->died_from, "Seppuku") ? "切腹" : "引退");
736 #else
737                         sprintf(statmsg, "...You %s after winning.", streq(creature_ptr->died_from, "Seppuku") ? "committed seppuku" : "retired from the adventure");
738 #endif
739                 }
740                 else if (!floor_ptr->dun_level)
741                 {
742 #ifdef JP
743                         sprintf(statmsg, "…あなたは%sで%sに殺された。", (*map_name)(creature_ptr), creature_ptr->died_from);
744 #else
745                         sprintf(statmsg, "...You were killed by %s in %s.", creature_ptr->died_from, map_name(creature_ptr));
746 #endif
747                 }
748                 else if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest))
749                 {
750                         /* Get the quest text */
751                         /* Bewere that INIT_ASSIGN resets the cur_num. */
752                         init_flags = INIT_NAME_ONLY;
753
754                         process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
755
756 #ifdef JP
757                         sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[floor_ptr->inside_quest].name, creature_ptr->died_from);
758 #else
759                         sprintf(statmsg, "...You were killed by %s in the quest '%s'.", creature_ptr->died_from, quest[floor_ptr->inside_quest].name);
760 #endif
761                 }
762                 else
763                 {
764 #ifdef JP
765                         sprintf(statmsg, "…あなたは、%sの%d階で%sに殺された。", (*map_name)(creature_ptr), (int)floor_ptr->dun_level, creature_ptr->died_from);
766 #else
767                         sprintf(statmsg, "...You were killed by %s on level %d of %s.", creature_ptr->died_from, floor_ptr->dun_level, map_name(creature_ptr));
768 #endif
769                 }
770         }
771         else if (current_world_ptr->character_dungeon)
772         {
773                 if (!floor_ptr->dun_level)
774                 {
775                         sprintf(statmsg, _("…あなたは現在、 %s にいる。", "...Now, you are in %s."), map_name(creature_ptr));
776                 }
777                 else if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest))
778                 {
779                         /* Clear the text */
780                         /* Must be done before doing INIT_SHOW_TEXT */
781                         for (int i = 0; i < 10; i++)
782                         {
783                                 quest_text[i][0] = '\0';
784                         }
785
786                         quest_text_line = 0;
787                         init_flags = INIT_NAME_ONLY;
788                         process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
789                         sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[floor_ptr->inside_quest].name);
790                 }
791                 else
792                 {
793 #ifdef JP
794                         sprintf(statmsg, "…あなたは現在、 %s の %d 階で探索している。", map_name(creature_ptr), (int)floor_ptr->dun_level);
795 #else
796                         sprintf(statmsg, "...Now, you are exploring level %d of %s.", floor_ptr->dun_level, map_name(creature_ptr));
797 #endif
798                 }
799         }
800
801         if (!*statmsg) return;
802
803         char temp[64 * 2];
804         roff_to_buf(statmsg, 60, temp, sizeof(temp));
805         char  *t;
806         t = temp;
807         for (int i = 0; i < 2; i++)
808         {
809                 if (t[0] == 0) return;
810
811                 put_str(t, i + 5 + 12, 10);
812                 t += strlen(t) + 1;
813         }
814 }
815
816
817 /*!
818  * todo y = 6、x = 0、mode = 0で固定。何とかする
819  * @brief プレイヤーの装備一覧をシンボルで並べる
820  * Equippy chars
821  * @param creature_ptr プレーヤーへの参照ポインタ
822  * @param y 表示するコンソールの行
823  * @param x 表示するコンソールの列
824  * @param mode オプション
825  * @return なし
826  */
827 void display_player_equippy(player_type *creature_ptr, TERM_LEN y, TERM_LEN x, BIT_FLAGS16 mode)
828 {
829         int max_i = (mode & DP_WP) ? INVEN_LARM + 1 : INVEN_TOTAL;
830         for (int i = INVEN_RARM; i < max_i; i++)
831         {
832                 object_type *o_ptr;
833                 o_ptr = &creature_ptr->inventory_list[i];
834
835                 TERM_COLOR a = object_attr(o_ptr);
836                 char c = object_char(o_ptr);
837
838                 if (!equippy_chars || !o_ptr->k_idx)
839                 {
840                         c = ' ';
841                         a = TERM_DARK;
842                 }
843
844                 Term_putch(x + i - INVEN_RARM, y, a, c);
845         }
846 }