OSDN Git Service

To be more idiomatic, drop "was" from English message for death of dragon centipedes.
[hengband/hengband.git] / src / knowledge / knowledge-self.c
1 /*!
2  * @brief 自己に関する情報を表示する
3  * @date 2020/04/24
4  * @author Hourier
5  */
6
7 #include "knowledge-self.h"
8 #include "birth/birth-explanations-table.h"
9 #include "core/show-file.h"
10 #include "flavor/flavor-describer.h"
11 #include "floor/floor-town.h"
12 #include "info-reader/fixed-map-parser.h"
13 #include "io-dump/dump-util.h"
14 #include "player-info/avatar.h"
15 #include "player/player-class.h"
16 #include "player/player-status-table.h"
17 #include "player/race-info-table.h"
18 #include "store/store-util.h"
19 #include "system/object-type-definition.h"
20 #include "util/angband-files.h"
21 #include "util/buffer-shaper.h"
22 #include "util/int-char-converter.h"
23 #include "world/world.h"
24
25 /*
26  * List virtues & status
27  */
28 void do_cmd_knowledge_virtues(player_type *creature_ptr)
29 {
30     FILE *fff = NULL;
31     GAME_TEXT file_name[FILE_NAME_SIZE];
32     if (!open_temporary_file(&fff, file_name))
33         return;
34
35     fprintf(fff, _("現在の属性 : %s\n\n", "Your alignment : %s\n\n"), your_alignment(creature_ptr));
36     dump_virtues(creature_ptr, fff);
37     angband_fclose(fff);
38     (void)show_file(creature_ptr, TRUE, file_name, _("八つの徳", "Virtues"), 0, 0);
39     fd_kill(file_name);
40 }
41
42 /*!
43  * @brief 自分に関する情報を画面に表示する
44  * @param creature_ptr プレーヤーへの参照ポインタ
45  * @param fff ファイルポインタ
46  * @return なし
47  */
48 static void dump_yourself(player_type *creature_ptr, FILE *fff)
49 {
50     if (!fff)
51         return;
52
53     char temp[80 * 10];
54     shape_buffer(race_explanations[creature_ptr->prace], 78, temp, sizeof(temp));
55     fprintf(fff, "\n\n");
56     fprintf(fff, _("種族: %s\n", "Race: %s\n"), race_info[creature_ptr->prace].title);
57     concptr t = temp;
58
59     for (int i = 0; i < 10; i++) {
60         if (t[0] == 0)
61             break;
62         fprintf(fff, "%s\n", t);
63         t += strlen(t) + 1;
64     }
65
66     shape_buffer(class_explanations[creature_ptr->pclass], 78, temp, sizeof(temp));
67     fprintf(fff, "\n");
68     fprintf(fff, _("職業: %s\n", "Class: %s\n"), class_info[creature_ptr->pclass].title);
69
70     t = temp;
71     for (int i = 0; i < 10; i++) {
72         if (t[0] == 0)
73             break;
74         fprintf(fff, "%s\n", t);
75         t += strlen(t) + 1;
76     }
77
78     shape_buffer(personality_explanations[creature_ptr->pseikaku], 78, temp, sizeof(temp));
79     fprintf(fff, "\n");
80     fprintf(fff, _("性格: %s\n", "Pesonality: %s\n"), personality_info[creature_ptr->pseikaku].title);
81
82     t = temp;
83     for (int i = 0; i < A_MAX; i++) {
84         if (t[0] == 0)
85             break;
86         fprintf(fff, "%s\n", t);
87         t += strlen(t) + 1;
88     }
89
90     fprintf(fff, "\n");
91     if (creature_ptr->realm1) {
92         shape_buffer(realm_explanations[technic2magic(creature_ptr->realm1) - 1], 78, temp, sizeof(temp));
93         fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), realm_names[creature_ptr->realm1]);
94
95         t = temp;
96         for (int i = 0; i < A_MAX; i++) {
97             if (t[0] == 0)
98                 break;
99
100             fprintf(fff, "%s\n", t);
101             t += strlen(t) + 1;
102         }
103     }
104
105     fprintf(fff, "\n");
106     if (creature_ptr->realm2) {
107         shape_buffer(realm_explanations[technic2magic(creature_ptr->realm2) - 1], 78, temp, sizeof(temp));
108         fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), realm_names[creature_ptr->realm2]);
109
110         t = temp;
111         for (int i = 0; i < A_MAX; i++) {
112             if (t[0] == 0)
113                 break;
114
115             fprintf(fff, "%s\n", t);
116             t += strlen(t) + 1;
117         }
118     }
119 }
120
121 /*
122  * List virtues & status
123  *
124  */
125 void do_cmd_knowledge_stat(player_type *creature_ptr)
126 {
127     FILE *fff = NULL;
128     GAME_TEXT file_name[FILE_NAME_SIZE];
129     if (!open_temporary_file(&fff, file_name))
130         return;
131
132     int percent
133         = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) / (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
134
135     if (creature_ptr->knowledge & KNOW_HPRATE)
136         fprintf(fff, _("現在の体力ランク : %d/100\n\n", "Your current Life Rating is %d/100.\n\n"), percent);
137     else
138         fprintf(fff, _("現在の体力ランク : ???\n\n", "Your current Life Rating is ???.\n\n"));
139
140     fprintf(fff, _("能力の最大値\n\n", "Limits of maximum stats\n\n"));
141     for (int v_nr = 0; v_nr < A_MAX; v_nr++) {
142         if ((creature_ptr->knowledge & KNOW_STAT) || creature_ptr->stat_max[v_nr] == creature_ptr->stat_max_max[v_nr])
143             fprintf(fff, "%s 18/%d\n", stat_names[v_nr], creature_ptr->stat_max_max[v_nr] - 18);
144         else
145             fprintf(fff, "%s ???\n", stat_names[v_nr]);
146     }
147
148     dump_yourself(creature_ptr, fff);
149     angband_fclose(fff);
150     (void)show_file(creature_ptr, TRUE, file_name, _("自分に関する情報", "HP-rate & Max stat"), 0, 0);
151     fd_kill(file_name);
152 }
153
154 /*
155  * List my home
156  * @param player_ptr プレーヤーへの参照ポインタ
157  * @return なし
158  */
159 void do_cmd_knowledge_home(player_type *player_ptr)
160 {
161     parse_fixed_map(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
162
163     FILE *fff = NULL;
164     GAME_TEXT file_name[FILE_NAME_SIZE];
165     if (!open_temporary_file(&fff, file_name))
166         return;
167
168     store_type *store_ptr;
169     store_ptr = &town_info[1].store[STORE_HOME];
170
171     if (store_ptr->stock_num) {
172 #ifdef JP
173         TERM_LEN x = 1;
174 #endif
175         fprintf(fff, _("  [ 我が家のアイテム ]\n", "  [Home Inventory]\n"));
176         concptr paren = ")";
177         GAME_TEXT o_name[MAX_NLEN];
178         for (int i = 0; i < store_ptr->stock_num; i++) {
179 #ifdef JP
180             if ((i % 12) == 0)
181                 fprintf(fff, "\n ( %d ページ )\n", x++);
182             describe_flavor(player_ptr, o_name, &store_ptr->stock[i], 0);
183             if (strlen(o_name) <= 80 - 3) {
184                 fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
185             } else {
186                 int n;
187                 char *t;
188                 for (n = 0, t = o_name; n < 80 - 3; n++, t++)
189                     if (iskanji(*t)) {
190                         t++;
191                         n++;
192                     }
193                 if (n == 81 - 3)
194                     n = 79 - 3; /* 最後が漢字半分 */
195
196                 fprintf(fff, "%c%s %.*s\n", I2A(i % 12), paren, n, o_name);
197                 fprintf(fff, "   %.77s\n", o_name + n);
198             }
199 #else
200             describe_flavor(player_ptr, o_name, &store_ptr->stock[i], 0);
201             fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
202 #endif
203         }
204
205         fprintf(fff, "\n\n");
206     }
207
208     angband_fclose(fff);
209     (void)show_file(player_ptr, TRUE, file_name, _("我が家のアイテム", "Home Inventory"), 0, 0);
210     fd_kill(file_name);
211 }