OSDN Git Service

[Refactor] #38862 Moved floor*.c to floor/
[hengband/hengband.git] / src / knowledge / knowledge-self.c
1 /*!
2  * @brief 自己に関する情報を表示する
3  * @date 2020/04/24
4  * @author Hourier
5  */
6
7 #include "angband.h"
8 #include "knowledge-self.h"
9 #include "cmd/dump-util.h"
10 #include "avatar.h"
11 #include "birth/birth.h"
12 #include "core/show-file.h"
13 #include "dungeon/dungeon-file.h"
14 #include "world/world.h"
15 #include "market/store-util.h"
16 #include "floor/floor-town.h"
17 #include "object-flavor.h"
18
19 /*
20  * List virtues & status
21  */
22 void do_cmd_knowledge_virtues(player_type *creature_ptr)
23 {
24         FILE *fff = NULL;
25         GAME_TEXT file_name[FILE_NAME_SIZE];
26         if (!open_temporary_file(&fff, file_name)) return;
27
28         fprintf(fff, _("現在の属性 : %s\n\n", "Your alignment : %s\n\n"), your_alignment(creature_ptr));
29         dump_virtues(creature_ptr, fff);
30         my_fclose(fff);
31         (void)show_file(creature_ptr, TRUE, file_name, _("八つの徳", "Virtues"), 0, 0);
32         fd_kill(file_name);
33 }
34
35
36 /*
37 * List virtues & status
38 *
39 */
40 void do_cmd_knowledge_stat(player_type *creature_ptr)
41 {
42         FILE *fff = NULL;
43         GAME_TEXT file_name[FILE_NAME_SIZE];
44         if (!open_temporary_file(&fff, file_name)) return;
45
46         int percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
47                 (2 * creature_ptr->hitdie +
48                 ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
49
50         if (creature_ptr->knowledge & KNOW_HPRATE)
51                 fprintf(fff, _("現在の体力ランク : %d/100\n\n", "Your current Life Rating is %d/100.\n\n"), percent);
52         else fprintf(fff, _("現在の体力ランク : ???\n\n", "Your current Life Rating is ???.\n\n"));
53
54         fprintf(fff, _("能力の最大値\n\n", "Limits of maximum stats\n\n"));
55         for (int v_nr = 0; v_nr < A_MAX; v_nr++)
56         {
57                 if ((creature_ptr->knowledge & KNOW_STAT) || creature_ptr->stat_max[v_nr] == creature_ptr->stat_max_max[v_nr])
58                         fprintf(fff, "%s 18/%d\n", stat_names[v_nr], creature_ptr->stat_max_max[v_nr] - 18);
59                 else
60                         fprintf(fff, "%s ???\n", stat_names[v_nr]);
61         }
62
63         dump_yourself(creature_ptr, fff);
64         my_fclose(fff);
65         (void)show_file(creature_ptr, TRUE, file_name, _("自分に関する情報", "HP-rate & Max stat"), 0, 0);
66         fd_kill(file_name);
67 }
68
69
70 /*
71  * List my home
72  * @param player_ptr プレーヤーへの参照ポインタ
73  * @return なし
74  */
75 void do_cmd_knowledge_home(player_type *player_ptr)
76 {
77         process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
78
79         FILE *fff = NULL;
80         GAME_TEXT file_name[FILE_NAME_SIZE];
81         if (!open_temporary_file(&fff, file_name)) return;
82
83         store_type *store_ptr;
84         store_ptr = &town_info[1].store[STORE_HOME];
85
86         if (store_ptr->stock_num)
87         {
88 #ifdef JP
89                 TERM_LEN x = 1;
90 #endif
91                 fprintf(fff, _("  [ 我が家のアイテム ]\n", "  [Home Inventory]\n"));
92                 concptr paren = ")";
93                 GAME_TEXT o_name[MAX_NLEN];
94                 for (int i = 0; i < store_ptr->stock_num; i++)
95                 {
96 #ifdef JP
97                         if ((i % 12) == 0) fprintf(fff, "\n ( %d ページ )\n", x++);
98                         object_desc(player_ptr, o_name, &store_ptr->stock[i], 0);
99                         if (strlen(o_name) <= 80 - 3)
100                         {
101                                 fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
102                         }
103                         else
104                         {
105                                 int n;
106                                 char *t;
107                                 for (n = 0, t = o_name; n < 80 - 3; n++, t++)
108                                         if (iskanji(*t)) { t++; n++; }
109                                 if (n == 81 - 3) n = 79 - 3; /* 最後が漢字半分 */
110
111                                 fprintf(fff, "%c%s %.*s\n", I2A(i % 12), paren, n, o_name);
112                                 fprintf(fff, "   %.77s\n", o_name + n);
113                         }
114 #else
115                         object_desc(player_ptr, o_name, &store_ptr->stock[i], 0);
116                         fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
117 #endif
118                 }
119
120                 fprintf(fff, "\n\n");
121         }
122
123         my_fclose(fff);
124         (void)show_file(player_ptr, TRUE, file_name, _("我が家のアイテム", "Home Inventory"), 0, 0);
125         fd_kill(file_name);
126 }