1 #include "wizard/items-spoiler.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "io/files-util.h"
5 #include "object-enchant/special-object-flags.h"
6 #include "object-enchant/trg-types.h"
7 #include "object/object-generator.h"
8 #include "object/object-kind.h"
9 #include "object/object-value.h"
10 #include "system/angband-version.h"
11 #include "system/object-type-definition.h"
12 #include "util/angband-files.h"
13 #include "view/display-messages.h"
14 #include "wizard/spoiler-util.h"
17 * @brief ベースアイテムの各情報を文字列化する /
19 * @param player_ptr プレーヤーへの参照ポインタ
20 * @param buf 名称を返すバッファ参照ポインタ
21 * @param dam ダメージダイス記述を返すバッファ参照ポインタ
22 * @param wgt 重量記述を返すバッファ参照ポインタ
23 * @param lev 生成階記述を返すバッファ参照ポインタ
24 * @param chance 生成機会を返すバッファ参照ポインタ
25 * @param val 価値を返すバッファ参照ポインタ
29 static void kind_info(player_type *player_ptr, char *buf, char *dam, char *wgt, char *chance, DEPTH *lev, PRICE *val, OBJECT_IDX k)
32 object_type *q_ptr = &forge;
33 object_prep(player_ptr, q_ptr, k);
34 q_ptr->ident |= IDENT_KNOWN;
39 *lev = k_info[q_ptr->k_idx].level;
40 *val = object_value(player_ptr, q_ptr);
41 if (!buf || !dam || !chance || !wgt)
44 describe_flavor(player_ptr, buf, q_ptr, OD_NAME_ONLY | OD_STORE);
46 switch (q_ptr->tval) {
50 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
56 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
67 sprintf(dam, "%d", q_ptr->ac);
74 for (int i = 0; i < 4; i++) {
75 char chance_aux[20] = "";
76 if (k_info[q_ptr->k_idx].chance[i] > 0) {
77 sprintf(chance_aux, "%s%3dF:%+4d", (i != 0 ? "/" : ""), (int)k_info[q_ptr->k_idx].locale[i], 100 / k_info[q_ptr->k_idx].chance[i]);
78 strcat(chance, chance_aux);
82 sprintf(wgt, "%3d.%d", (int)(q_ptr->weight / 10), (int)(q_ptr->weight % 10));
86 * @brief 各ベースアイテムの情報を一行毎に記述する /
87 * @param player_ptr プレーヤーへの参照ポインタ
88 * Create a spoiler file for items
92 void spoil_obj_desc(player_type *player_ptr, concptr fname)
95 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
96 spoiler_file = angband_fopen(buf, "w");
98 msg_print("Cannot create spoiler file.");
104 fprintf(spoiler_file, "Spoiler File -- Basic Items (%s)\n\n\n", title);
105 fprintf(spoiler_file, "%-37s%8s%7s%5s %40s%9s\n", "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost");
106 fprintf(spoiler_file, "%-37s%8s%7s%5s %40s%9s\n", "-------------------------------------", "------", "---", "---", "----------------", "----");
109 for (int i = 0; TRUE; i++) {
111 if (group_item[i].name) {
113 for (int s = 0; s < n - 1; s++) {
114 for (int t = 0; t < n - 1; t++) {
124 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e1, &t1, who[i1]);
125 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e2, &t2, who[i2]);
127 if ((t1 > t2) || ((t1 == t2) && (e1 > e2))) {
135 fprintf(spoiler_file, "\n\n%s\n\n", group_item[group_start].name);
136 for (int s = 0; s < n; s++) {
142 kind_info(player_ptr, buf, dam, wgt, chance, &e, &v, who[s]);
143 fprintf(spoiler_file, " %-35s%8s%7s%5d %-40s%9ld\n", buf, dam, wgt, (int)e, chance, (long)(v));
149 if (!group_item[i].tval)
155 for (int k = 1; k < max_k_idx; k++) {
156 object_kind *k_ptr = &k_info[k];
157 if ((k_ptr->tval != group_item[i].tval) || (k_ptr->gen_flags & TRG_INSTA_ART))
164 if (ferror(spoiler_file) || angband_fclose(spoiler_file)) {
165 msg_print("Cannot close spoiler file.");
169 msg_print("Successfully created a spoiler file.");