OSDN Git Service

[Refactor] #40014 Separated display-monster-lore.c/h from monster2.c
[hengband/hengband.git] / src / wizard / wizard-spoiler.c
1 /*!
2  * @file wizard1.c
3  * @brief ウィザードモードの処理(スポイラー出力中心) / Spoiler generation -BEN-
4  * @date 2014/02/17
5  * @author
6  * Copyright (c) 1997 Ben Harrison, and others
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  * 2013 Deskull rearranged comment for Doxygen.
11  */
12
13 #include "wizard/wizard-spoiler.h"
14 #include "core/sort.h"
15 #include "floor/floor-town.h"
16 #include "io/files-util.h"
17 #include "monster-race/race-flags1.h"
18 #include "monster-race/race-flags7.h"
19 #include "object-enchant/artifact.h"
20 #include "object-enchant/object-ego.h"
21 #include "object-enchant/special-object-flags.h"
22 #include "object-enchant/tr-types.h"
23 #include "object-enchant/trc-types.h"
24 #include "object-enchant/trg-types.h"
25 #include "object/object-flags.h"
26 #include "object/object-flavor.h"
27 #include "object/object-generator.h"
28 #include "object/object-kind-hook.h"
29 #include "object/object-kind.h"
30 #include "object/object-value.h"
31 #include "object/object-info.h"
32 #include "perception/object-perception.h"
33 #include "store/store-util.h"
34 #include "store/store.h"
35 #include "system/angband-version.h"
36 #include "term/term-color-types.h"
37 #include "util/util.h"
38 #include "view/display-monster-lore.h"
39
40  /*
41   * The spoiler file being created
42   */
43 static FILE *fff = NULL;
44
45 /*!
46  * @brief シンボル職の記述名を返す /
47  * Extract a textual representation of an attribute
48  * @param r_ptr モンスター種族の構造体ポインタ
49  * @return シンボル職の記述名
50  */
51 static concptr attr_to_text(monster_race *r_ptr)
52 {
53         if (r_ptr->flags1 & RF1_ATTR_CLEAR)    return _("透明な", "Clear");
54         if (r_ptr->flags1 & RF1_ATTR_MULTI)    return _("万色の", "Multi");
55         if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return _("準ランダムな", "S.Rand");
56
57         switch (r_ptr->d_attr)
58         {
59         case TERM_DARK:    return _("黒い", "Dark");
60         case TERM_WHITE:   return _("白い", "White");
61         case TERM_SLATE:   return _("青灰色の", "Slate");
62         case TERM_ORANGE:  return _("オレンジの", "Orange");
63         case TERM_RED:     return _("赤い", "Red");
64         case TERM_GREEN:   return _("緑の", "Green");
65         case TERM_BLUE:    return _("青い", "Blue");
66         case TERM_UMBER:   return _("琥珀色の", "Umber");
67         case TERM_L_DARK:  return _("灰色の", "L.Dark");
68         case TERM_L_WHITE: return _("明るい青灰色の", "L.Slate");
69         case TERM_VIOLET:  return _("紫の", "Violet");
70         case TERM_YELLOW:  return _("黄色の", "Yellow");
71         case TERM_L_RED:   return _("明るい赤の", "L.Red");
72         case TERM_L_GREEN: return _("明るい緑の", "L.Green");
73         case TERM_L_BLUE:  return _("明るい青の", "L.Blue");
74         case TERM_L_UMBER: return _("明るい琥珀色の", "L.Umber");
75         }
76
77         return _("変な色の", "Icky");
78 }
79
80
81
82 /*
83  * A tval grouper
84  */
85 typedef struct
86 {
87         tval_type tval;
88         concptr name;
89 } grouper;
90
91
92
93 /*
94  * Item Spoilers by: benh@phial.com (Ben Harrison)
95  */
96
97
98  /*
99   * The basic items categorized by type
100   */
101 static grouper group_item[] =
102 {
103         { TV_SHOT,          _("射撃物", "Ammo") },
104         { TV_ARROW,         NULL },
105         { TV_BOLT,          NULL },
106         { TV_BOW,           _("弓", "Bows") },
107         { TV_DIGGING,       _("武器", "Weapons") },
108         { TV_POLEARM,       NULL },
109         { TV_HAFTED,        NULL },
110         { TV_SWORD,         NULL },
111         { TV_SOFT_ARMOR,    _("防具 (体)", "Armour (Body)") },
112         { TV_HARD_ARMOR,    NULL },
113         { TV_DRAG_ARMOR,    NULL },
114         { TV_BOOTS,         _("防具 (その他)", "Armour (Misc)") },
115         { TV_GLOVES,        NULL },
116         { TV_HELM,          NULL },
117         { TV_CROWN,         NULL },
118         { TV_SHIELD,        NULL },
119         { TV_CLOAK,         NULL },
120
121         { TV_LITE,          _("光源", "Light Sources") },
122         { TV_AMULET,        _("アミュレット", "Amulets")},
123         { TV_RING,          _("指輪", "Rings") },
124         { TV_STAFF,         _("杖", "Staffs") },
125         { TV_WAND,          _("魔法棒", "Wands") },
126         { TV_ROD,           _("ロッド", "Rods") },
127         { TV_SCROLL,        _("巻物", "Scrolls") },
128         { TV_POTION,        _("薬", "Potions") },
129         { TV_FOOD,          _("食料", "Food") },
130
131         { TV_LIFE_BOOK,     _("魔法書 (生命)", "Books (Life)") },
132         { TV_SORCERY_BOOK,  _("魔法書 (仙術)", "Books (Sorcery)") },
133         { TV_NATURE_BOOK,   _("魔法書 (自然)", "Books (Nature)") },
134         { TV_CHAOS_BOOK,    _("魔法書 (カオス)", "Books (Chaos)") },
135         { TV_DEATH_BOOK,    _("魔法書 (暗黒)", "Books (Death)") },
136         { TV_TRUMP_BOOK,    _("魔法書 (トランプ)", "Books (Trump)") },
137         { TV_ARCANE_BOOK,   _("魔法書 (秘術)", "Books (Arcane)") },
138         { TV_CRAFT_BOOK,    _("魔法書 (匠)", "Books (Craft)") },
139         { TV_DAEMON_BOOK,   _("魔法書 (悪魔)", "Books (Daemon)") },
140         { TV_CRUSADE_BOOK,  _("魔法書 (破邪)", "Books (Crusade)") },
141         { TV_MUSIC_BOOK,    _("歌集", "Song Books") },
142         { TV_HISSATSU_BOOK, _("武芸の書", "Books (Kendo)") },
143         { TV_HEX_BOOK,      _("魔法書 (呪術)", "Books (Hex)") },
144
145         { TV_WHISTLE,       _("笛", "Whistle") },
146         { TV_CAPTURE,       _("キャプチャー・ボール", "Capture Ball") },
147         { TV_CARD,          _("エクスプレスカード", "Express Card") },
148
149         { TV_CHEST,         _("箱", "Chests") },
150
151         { TV_FIGURINE,      _("人形", "Magical Figurines") },
152         { TV_STATUE,        _("像", "Statues") },
153         { TV_CORPSE,        _("死体", "Corpses") },
154
155         { TV_SKELETON,      _("その他", "Misc") },
156         { TV_BOTTLE,        NULL },
157         { TV_JUNK,          NULL },
158         { TV_SPIKE,         NULL },
159         { TV_FLASK,         NULL },
160         { TV_PARCHMENT,     NULL },
161
162         { 0, "" }
163 };
164
165
166 /*!
167  * @brief ベースアイテムの各情報を文字列化する /
168  * Describe the kind
169  * @param player_ptr プレーヤーへの参照ポインタ
170  * @param buf 名称を返すバッファ参照ポインタ
171  * @param dam ダメージダイス記述を返すバッファ参照ポインタ
172  * @param wgt 重量記述を返すバッファ参照ポインタ
173  * @param lev 生成階記述を返すバッファ参照ポインタ
174  * @param chance 生成機会を返すバッファ参照ポインタ
175  * @param val 価値を返すバッファ参照ポインタ
176  * @param k ベースアイテムID
177  * @return なし
178  */
179 static void kind_info(player_type *player_ptr, char *buf, char *dam, char *wgt, char *chance, DEPTH *lev, PRICE *val, OBJECT_IDX k)
180 {
181         object_type forge;
182         object_type *q_ptr;
183         int i;
184         q_ptr = &forge;
185
186         /* Prepare a fake item */
187         object_prep(q_ptr, k);
188
189         /* It is known */
190         q_ptr->ident |= (IDENT_KNOWN);
191
192         /* Cancel bonuses */
193         q_ptr->pval = 0;
194         q_ptr->to_a = 0;
195         q_ptr->to_h = 0;
196         q_ptr->to_d = 0;
197
198         (*lev) = k_info[q_ptr->k_idx].level;
199         (*val) = object_value(q_ptr);
200
201         if (!buf || !dam || !chance || !wgt) return;
202
203         /* Description (too brief) */
204         object_desc(player_ptr, buf, q_ptr, (OD_NAME_ONLY | OD_STORE));
205
206         /* Misc info */
207         strcpy(dam, "");
208
209         /* Damage */
210         switch (q_ptr->tval)
211         {
212                 /* Bows */
213         case TV_BOW:
214         {
215                 break;
216         }
217
218         /* Ammo */
219         case TV_SHOT:
220         case TV_BOLT:
221         case TV_ARROW:
222         {
223                 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
224                 break;
225         }
226
227         /* Weapons */
228         case TV_HAFTED:
229         case TV_POLEARM:
230         case TV_SWORD:
231         case TV_DIGGING:
232         {
233                 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
234                 break;
235         }
236
237         /* Armour */
238         case TV_BOOTS:
239         case TV_GLOVES:
240         case TV_CLOAK:
241         case TV_CROWN:
242         case TV_HELM:
243         case TV_SHIELD:
244         case TV_SOFT_ARMOR:
245         case TV_HARD_ARMOR:
246         case TV_DRAG_ARMOR:
247         {
248                 sprintf(dam, "%d", q_ptr->ac);
249                 break;
250         }
251         }
252
253         /* Chance */
254         strcpy(chance, "");
255         for (i = 0; i < 4; i++)
256         {
257                 char chance_aux[20] = "";
258                 if (k_info[q_ptr->k_idx].chance[i] > 0)
259                 {
260                         sprintf(chance_aux, "%s%3dF:%+4d", (i != 0 ? "/" : ""),
261                                 (int)k_info[q_ptr->k_idx].locale[i], 100 / k_info[q_ptr->k_idx].chance[i]);
262                         strcat(chance, chance_aux);
263                 }
264         }
265
266
267         /* Weight */
268         sprintf(wgt, "%3d.%d", (int)(q_ptr->weight / 10), (int)(q_ptr->weight % 10));
269 }
270
271
272 /*!
273  * @brief 各ベースアイテムの情報を一行毎に記述する /
274  * @param player_ptr プレーヤーへの参照ポインタ
275  * Create a spoiler file for items
276  * @param fname ファイル名
277  * @return なし
278  */
279 static void spoil_obj_desc(player_type *player_ptr, concptr fname)
280 {
281         int i, k, s, t, n = 0, group_start = 0;
282
283         OBJECT_IDX who[200];
284
285         char buf[1024];
286
287         char wgt[80];
288         char chance[80];
289         char dam[80];
290
291         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
292
293         fff = my_fopen(buf, "w");
294
295         if (!fff)
296         {
297                 msg_print("Cannot create spoiler file.");
298                 return;
299         }
300
301
302         /* Header */
303         fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d.%d)\n\n\n",
304                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA);
305
306         /* More Header */
307         fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
308                 "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost");
309         fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
310                 "-------------------------------------", "------", "---", "---", "----------------", "----");
311
312         /* List the groups */
313         for (i = 0; TRUE; i++)
314         {
315                 /* Write out the group title */
316                 if (group_item[i].name)
317                 {
318                         if (n)
319                         {
320                                 /* Hack -- bubble-sort by cost and then level */
321                                 for (s = 0; s < n - 1; s++)
322                                 {
323                                         for (t = 0; t < n - 1; t++)
324                                         {
325                                                 int i1 = t;
326                                                 int i2 = t + 1;
327
328                                                 DEPTH e1;
329                                                 DEPTH e2;
330
331                                                 PRICE t1;
332                                                 PRICE t2;
333
334                                                 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e1, &t1, who[i1]);
335                                                 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e2, &t2, who[i2]);
336
337                                                 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
338                                                 {
339                                                         u16b tmp = who[i1];
340                                                         who[i1] = who[i2];
341                                                         who[i2] = tmp;
342                                                 }
343                                         }
344                                 }
345
346                                 fprintf(fff, "\n\n%s\n\n", group_item[group_start].name);
347
348                                 /* Spoil each item */
349                                 for (s = 0; s < n; s++)
350                                 {
351                                         DEPTH e;
352                                         PRICE v;
353
354                                         /* Describe the kind */
355                                         kind_info(player_ptr, buf, dam, wgt, chance, &e, &v, who[s]);
356
357                                         /* Dump it */
358                                         fprintf(fff, "  %-35s%8s%7s%5d %-40s%9ld\n",
359                                                 buf, dam, wgt, (int)e, chance, (long)(v));
360                                 }
361
362                                 /* Start a new set */
363                                 n = 0;
364                         }
365
366                         /* Notice the end */
367                         if (!group_item[i].tval) break;
368
369                         /* Start a new set */
370                         group_start = i;
371                 }
372
373                 /* Acquire legal item types */
374                 for (k = 1; k < max_k_idx; k++)
375                 {
376                         object_kind *k_ptr = &k_info[k];
377
378                         /* Skip wrong tval's */
379                         if (k_ptr->tval != group_item[i].tval) continue;
380
381                         /* Hack -- Skip instant-artifacts */
382                         if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
383
384                         /* Save the index */
385                         who[n++] = (u16b)k;
386                 }
387         }
388
389
390         /* Check for errors */
391         if (ferror(fff) || my_fclose(fff))
392         {
393                 msg_print("Cannot close spoiler file.");
394                 return;
395         }
396
397         msg_print("Successfully created a spoiler file.");
398 }
399
400
401 /*
402  * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
403  */
404
405
406  /*
407   * Returns a "+" string if a number is non-negative and an empty
408   * string if negative
409   */
410 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
411
412   /*
413    * These are used to format the artifact spoiler file. INDENT1 is used
414    * to indent all but the first line of an artifact spoiler. INDENT2 is
415    * used when a line "wraps". (Bladeturner's resistances cause this.)
416    */
417 #define INDENT1 "    "
418 #define INDENT2 "      "
419
420    /*
421         * MAX_LINE_LEN specifies when a line should wrap.
422         */
423 #define MAX_LINE_LEN 75
424
425         /*
426          * Given an array, determine how many elements are in the array
427          */
428 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
429
430          /*
431           * The artifacts categorized by type
432           */
433 static grouper group_artifact[] =
434 {
435 #ifdef JP
436         { TV_SWORD,             "刀剣" },
437         { TV_POLEARM,           "槍/斧" },
438         { TV_HAFTED,            "鈍器" },
439         { TV_DIGGING,           "シャベル/つるはし" },
440         { TV_BOW,               "飛び道具" },
441         { TV_ARROW,             "矢" },
442         { TV_BOLT,              NULL },
443
444         { TV_SOFT_ARMOR,        "鎧" },
445         { TV_HARD_ARMOR,        NULL },
446         { TV_DRAG_ARMOR,        NULL },
447
448         { TV_CLOAK,             "クローク" },
449         { TV_SHIELD,            "盾" },
450         { TV_CARD,              NULL },
451         { TV_HELM,              "兜/冠" },
452         { TV_CROWN,             NULL },
453         { TV_GLOVES,            "籠手" },
454         { TV_BOOTS,             "靴" },
455
456         { TV_LITE,              "光源" },
457         { TV_AMULET,            "アミュレット" },
458         { TV_RING,              "指輪" },
459 #else
460         { TV_SWORD,             "Edged Weapons" },
461         { TV_POLEARM,           "Polearms" },
462         { TV_HAFTED,            "Hafted Weapons" },
463         { TV_DIGGING,           "Shovels/Picks" },
464         { TV_BOW,               "Bows" },
465         { TV_ARROW,             "Ammo" },
466         { TV_BOLT,              NULL },
467
468         { TV_SOFT_ARMOR,        "Body Armor" },
469         { TV_HARD_ARMOR,        NULL },
470         { TV_DRAG_ARMOR,        NULL },
471
472         { TV_CLOAK,             "Cloaks" },
473         { TV_SHIELD,            "Shields" },
474         { TV_CARD,              NULL },
475         { TV_HELM,              "Helms/Crowns" },
476         { TV_CROWN,             NULL },
477         { TV_GLOVES,            "Gloves" },
478         { TV_BOOTS,             "Boots" },
479
480         { TV_LITE,              "Light Sources" },
481         { TV_AMULET,            "Amulets" },
482         { TV_RING,              "Rings" },
483 #endif
484
485         { 0, NULL }
486 };
487
488
489
490 /*
491  * Pair together a constant flag with a textual description.
492  *
493  * Used by both "init.c" and "wiz-spo.c".
494  *
495  * Note that it sometimes more efficient to actually make an array
496  * of textual names, where entry 'N' is assumed to be paired with
497  * the flag whose value is "1L << N", but that requires hard-coding.
498  */
499 typedef struct flag_desc
500 {
501         const tr_type flag;
502         concptr const desc;
503 } flag_desc;
504
505
506
507 /*
508  * These are used for "+3 to STR, DEX", etc. These are separate from
509  * the other pval affected traits to simplify the case where an object
510  * affects all stats.  In this case, "All stats" is used instead of
511  * listing each stat individually.
512  */
513
514 static flag_desc stat_flags_desc[] =
515 {
516 #ifdef JP
517         { TR_STR,        "腕力" },
518         { TR_INT,        "知能" },
519         { TR_WIS,        "賢さ" },
520         { TR_DEX,        "器用さ" },
521         { TR_CON,        "耐久力" },
522         { TR_CHR,        "魅力" }
523 #else
524         { TR_STR,        "STR" },
525         { TR_INT,        "INT" },
526         { TR_WIS,        "WIS" },
527         { TR_DEX,        "DEX" },
528         { TR_CON,        "CON" },
529         { TR_CHR,        "CHR" }
530 #endif
531 };
532
533 /*
534  * Besides stats, these are the other player traits
535  * which may be affected by an object's pval
536  */
537
538 static flag_desc pval_flags1_desc[] =
539 {
540 #ifdef JP
541         { TR_MAGIC_MASTERY,    "魔法道具使用能力" },
542         { TR_STEALTH,    "隠密" },
543         { TR_SEARCH,     "探索" },
544         { TR_INFRA,      "赤外線視力" },
545         { TR_TUNNEL,     "採掘" },
546         { TR_BLOWS,      "攻撃回数" },
547         { TR_SPEED,      "スピード" }
548 #else
549         { TR_STEALTH,    "Stealth" },
550         { TR_SEARCH,     "Searching" },
551         { TR_INFRA,      "Infravision" },
552         { TR_TUNNEL,     "Tunneling" },
553         { TR_BLOWS,      "Attacks" },
554         { TR_SPEED,      "Speed" }
555 #endif
556 };
557
558 /*
559  * Slaying preferences for weapons
560  */
561
562 static flag_desc slay_flags_desc[] =
563 {
564 #ifdef JP
565         { TR_SLAY_ANIMAL,        "動物" },
566         { TR_KILL_ANIMAL,        "*動物*" },
567         { TR_SLAY_EVIL,          "邪悪" },
568         { TR_KILL_EVIL,          "*邪悪*" },
569         { TR_SLAY_HUMAN,         "人間" },
570         { TR_KILL_HUMAN,         "*人間*" },
571         { TR_SLAY_UNDEAD,        "アンデッド" },
572         { TR_KILL_UNDEAD,        "*アンデッド*" },
573         { TR_SLAY_DEMON,         "悪魔" },
574         { TR_KILL_DEMON,         "*悪魔*" },
575         { TR_SLAY_ORC,           "オーク" },
576         { TR_KILL_ORC,           "*オーク*" },
577         { TR_SLAY_TROLL,         "トロル" },
578         { TR_KILL_TROLL,         "*トロル*" },
579         { TR_SLAY_GIANT,         "巨人" },
580         { TR_KILL_GIANT,         "*巨人*" },
581         { TR_SLAY_DRAGON,        "ドラゴン" },
582         { TR_KILL_DRAGON,        "*ドラゴン*" },
583 #else
584         { TR_SLAY_ANIMAL,        "Animal" },
585         { TR_KILL_ANIMAL,        "XAnimal" },
586         { TR_SLAY_EVIL,          "Evil" },
587         { TR_KILL_EVIL,          "XEvil" },
588         { TR_SLAY_HUMAN,         "Human" },
589         { TR_KILL_HUMAN,         "XHuman" },
590         { TR_SLAY_UNDEAD,        "Undead" },
591         { TR_KILL_UNDEAD,        "XUndead" },
592         { TR_SLAY_DEMON,         "Demon" },
593         { TR_KILL_DEMON,         "XDemon" },
594         { TR_SLAY_ORC,           "Orc" },
595         { TR_KILL_ORC,           "XOrc" },
596         { TR_SLAY_TROLL,         "Troll" },
597         { TR_KILL_TROLL,         "XTroll" },
598         { TR_SLAY_GIANT,         "Giant" },
599         { TR_KILL_GIANT,         "Xgiant" },
600         { TR_SLAY_DRAGON,        "Dragon" },
601         { TR_KILL_DRAGON,        "Xdragon" }
602 #endif
603 };
604
605 /*
606  * Elemental brands for weapons
607  *
608  * Clearly, TR1_IMPACT is a bit out of place here. To simplify
609  * coding, it has been included here along with the elemental
610  * brands. It does seem to fit in with the brands and slaying
611  * more than the miscellaneous section.
612  */
613 static flag_desc brand_flags_desc[] =
614 {
615 #ifdef JP
616         { TR_BRAND_ACID,         "溶解" },
617         { TR_BRAND_ELEC,         "電撃" },
618         { TR_BRAND_FIRE,         "焼棄" },
619         { TR_BRAND_COLD,         "凍結" },
620         { TR_BRAND_POIS,         "毒殺" },
621
622         { TR_FORCE_WEAPON,       "理力" },
623         { TR_CHAOTIC,            "混沌" },
624         { TR_VAMPIRIC,           "吸血" },
625         { TR_IMPACT,             "地震" },
626         { TR_VORPAL,             "切れ味" },
627 #else
628         { TR_BRAND_ACID,         "Acid Brand" },
629         { TR_BRAND_ELEC,         "Lightning Brand" },
630         { TR_BRAND_FIRE,         "Flame Tongue" },
631         { TR_BRAND_COLD,         "Frost Brand" },
632         { TR_BRAND_POIS,         "Poisoned" },
633
634         { TR_FORCE_WEAPON,       "Force" },
635         { TR_CHAOTIC,            "Mark of Chaos" },
636         { TR_VAMPIRIC,           "Vampiric" },
637         { TR_IMPACT,             "Earthquake impact on hit" },
638         { TR_VORPAL,             "Very sharp" },
639 #endif
640 };
641
642
643 /*
644  * The 15 resistables
645  */
646 static const flag_desc resist_flags_desc[] =
647 {
648 #ifdef JP
649         { TR_RES_ACID,   "酸" },
650         { TR_RES_ELEC,   "電撃" },
651         { TR_RES_FIRE,   "火炎" },
652         { TR_RES_COLD,   "冷気" },
653         { TR_RES_POIS,   "毒" },
654         { TR_RES_FEAR,   "恐怖"},
655         { TR_RES_LITE,   "閃光" },
656         { TR_RES_DARK,   "暗黒" },
657         { TR_RES_BLIND,  "盲目" },
658         { TR_RES_CONF,   "混乱" },
659         { TR_RES_SOUND,  "轟音" },
660         { TR_RES_SHARDS, "破片" },
661         { TR_RES_NETHER, "地獄" },
662         { TR_RES_NEXUS,  "因果混乱" },
663         { TR_RES_CHAOS,  "カオス" },
664         { TR_RES_DISEN,  "劣化" },
665 #else
666         { TR_RES_ACID,   "Acid" },
667         { TR_RES_ELEC,   "Lightning" },
668         { TR_RES_FIRE,   "Fire" },
669         { TR_RES_COLD,   "Cold" },
670         { TR_RES_POIS,   "Poison" },
671         { TR_RES_FEAR,   "Fear"},
672         { TR_RES_LITE,   "Light" },
673         { TR_RES_DARK,   "Dark" },
674         { TR_RES_BLIND,  "Blindness" },
675         { TR_RES_CONF,   "Confusion" },
676         { TR_RES_SOUND,  "Sound" },
677         { TR_RES_SHARDS, "Shards" },
678         { TR_RES_NETHER, "Nether" },
679         { TR_RES_NEXUS,  "Nexus" },
680         { TR_RES_CHAOS,  "Chaos" },
681         { TR_RES_DISEN,  "Disenchantment" },
682 #endif
683 };
684
685 /*
686  * Elemental immunities (along with poison)
687  */
688
689 static const flag_desc immune_flags_desc[] =
690 {
691 #ifdef JP
692         { TR_IM_ACID,    "酸" },
693         { TR_IM_ELEC,    "電撃" },
694         { TR_IM_FIRE,    "火炎" },
695         { TR_IM_COLD,    "冷気" },
696 #else
697         { TR_IM_ACID,    "Acid" },
698         { TR_IM_ELEC,    "Lightning" },
699         { TR_IM_FIRE,    "Fire" },
700         { TR_IM_COLD,    "Cold" },
701 #endif
702 };
703
704 /*
705  * Sustain stats -  these are given their "own" line in the
706  * spoiler file, mainly for simplicity
707  */
708 static const flag_desc sustain_flags_desc[] =
709 {
710 #ifdef JP
711         { TR_SUST_STR,   "腕力" },
712         { TR_SUST_INT,   "知能" },
713         { TR_SUST_WIS,   "賢さ" },
714         { TR_SUST_DEX,   "器用さ" },
715         { TR_SUST_CON,   "耐久力" },
716         { TR_SUST_CHR,   "魅力" },
717 #else
718         { TR_SUST_STR,   "STR" },
719         { TR_SUST_INT,   "INT" },
720         { TR_SUST_WIS,   "WIS" },
721         { TR_SUST_DEX,   "DEX" },
722         { TR_SUST_CON,   "CON" },
723         { TR_SUST_CHR,   "CHR" },
724 #endif
725 };
726
727 /*
728  * Miscellaneous magic given by an object's "flags2" field
729  */
730
731 static const flag_desc misc_flags2_desc[] =
732 {
733 #ifdef JP
734         { TR_THROW,      "投擲" },
735         { TR_REFLECT,    "反射" },
736         { TR_FREE_ACT,   "麻痺知らず" },
737         { TR_HOLD_EXP,   "経験値維持" },
738 #else
739         { TR_THROW,      "Throwing" },
740         { TR_REFLECT,    "Reflection" },
741         { TR_FREE_ACT,   "Free Action" },
742         { TR_HOLD_EXP,   "Hold Experience" },
743 #endif
744 };
745
746 /*
747  * Miscellaneous magic given by an object's "flags3" field
748  *
749  * Note that cursed artifacts and objects with permanent light
750  * are handled "directly" -- see analyze_misc_magic()
751  */
752
753 static const flag_desc misc_flags3_desc[] =
754 {
755 #ifdef JP
756         { TR_SH_FIRE,            "火炎オーラ" },
757         { TR_SH_ELEC,            "電撃オーラ" },
758         { TR_SH_COLD,            "冷気オーラ" },
759         { TR_NO_TELE,            "反テレポート" },
760         { TR_NO_MAGIC,           "反魔法" },
761         { TR_LEVITATION,         "浮遊" },
762         { TR_SEE_INVIS,          "可視透明" },
763         { TR_TELEPATHY,          "テレパシー" },
764         { TR_ESP_ANIMAL,         "動物感知" },
765         { TR_ESP_UNDEAD,         "不死感知" },
766         { TR_ESP_DEMON,          "悪魔感知" },
767         { TR_ESP_ORC,            "オーク感知" },
768         { TR_ESP_TROLL,          "トロル感知" },
769         { TR_ESP_GIANT,          "巨人感知" },
770         { TR_ESP_DRAGON,         "ドラゴン感知" },
771         { TR_ESP_HUMAN,          "人間感知" },
772         { TR_ESP_EVIL,           "邪悪感知" },
773         { TR_ESP_GOOD,           "善良感知" },
774         { TR_ESP_NONLIVING,      "無生物感知" },
775         { TR_ESP_UNIQUE,         "ユニーク感知" },
776         { TR_SLOW_DIGEST,        "遅消化" },
777         { TR_REGEN,              "急速回復" },
778         { TR_WARNING,            "警告" },
779         /*      { TR_XTRA_MIGHT,         "強力射撃" }, */
780                 { TR_XTRA_SHOTS,         "追加射撃" },        /* always +1? */
781                 { TR_DRAIN_EXP,          "経験値吸収" },
782                 { TR_AGGRAVATE,          "反感" },
783                 { TR_BLESSED,            "祝福" },
784                 { TR_DEC_MANA,           "消費魔力減少" },
785         #else
786                 { TR_SH_FIRE,            "Fiery Aura" },
787                 { TR_SH_ELEC,            "Electric Aura" },
788                 { TR_SH_COLD,            "Coldly Aura" },
789                 { TR_NO_TELE,            "Prevent Teleportation" },
790                 { TR_NO_MAGIC,           "Anti-Magic" },
791                 { TR_LEVITATION,            "Levitation" },
792                 { TR_SEE_INVIS,          "See Invisible" },
793                 { TR_TELEPATHY,          "ESP" },
794                 { TR_ESP_ANIMAL,         "Sense Animal" },
795                 { TR_ESP_UNDEAD,         "Sense Undead" },
796                 { TR_ESP_DEMON,          "Sense Demon" },
797                 { TR_ESP_ORC,            "Sense Orc" },
798                 { TR_ESP_TROLL,          "Sense Troll" },
799                 { TR_ESP_GIANT,          "Sense Giant" },
800                 { TR_ESP_DRAGON,         "Sense Dragon" },
801                 { TR_ESP_HUMAN,          "Sense Human" },
802                 { TR_ESP_EVIL,           "Sense Evil" },
803                 { TR_ESP_GOOD,           "Sense Good" },
804                 { TR_ESP_NONLIVING,      "Sense Nonliving" },
805                 { TR_ESP_UNIQUE,         "Sense Unique" },
806                 { TR_SLOW_DIGEST,        "Slow Digestion" },
807                 { TR_REGEN,              "Regeneration" },
808                 { TR_WARNING,            "Warning" },
809                 /*      { TR_XTRA_MIGHT,         "Extra Might" }, */
810                         { TR_XTRA_SHOTS,         "+1 Extra Shot" },        /* always +1? */
811                         { TR_DRAIN_EXP,          "Drains Experience" },
812                         { TR_AGGRAVATE,          "Aggravates" },
813                         { TR_BLESSED,            "Blessed Blade" },
814                         { TR_DEC_MANA,           "Decrease Mana Consumption Rate" },
815                 #endif
816 };
817
818
819 /*
820  * A special type used just for deailing with pvals
821  */
822 typedef struct
823 {
824         /*
825          * This will contain a string such as "+2", "-10", etc.
826          */
827         char pval_desc[12];
828
829         /*
830          * A list of various player traits affected by an object's pval such
831          * as stats, speed, stealth, etc.  "Extra attacks" is NOT included in
832          * this list since it will probably be desirable to format its
833          * description differently.
834          *
835          * Note that room need only be reserved for the number of stats - 1
836          * since the description "All stats" is used if an object affects all
837          * all stats. Also, room must be reserved for a sentinel NULL pointer.
838          *
839          * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
840          *
841          * This list includes extra attacks, for simplicity.
842          */
843         concptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
844                 N_ELEMENTS(pval_flags1_desc) + 1];
845
846 } pval_info_type;
847
848
849 /*
850  * An "object analysis structure"
851  *
852  * It will be filled with descriptive strings detailing an object's
853  * various magical powers. The "ignore X" traits are not noted since
854  * all artifacts ignore "normal" destruction.
855  */
856
857 typedef struct
858 {
859         /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
860         char description[MAX_NLEN];
861
862         /* Description of what is affected by an object's pval */
863         pval_info_type pval_info;
864
865         /* A list of an object's slaying preferences */
866         concptr slays[N_ELEMENTS(slay_flags_desc) + 1];
867
868         /* A list if an object's elemental brands */
869         concptr brands[N_ELEMENTS(brand_flags_desc) + 1];
870
871         /* A list of immunities granted by an object */
872         concptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
873
874         /* A list of resistances granted by an object */
875         concptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
876
877         /* A list of stats sustained by an object */
878         concptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
879
880         /* A list of various magical qualities an object may have */
881         concptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
882                 + 1       /* Permanent Light */
883                 + 1       /* TY curse */
884                 + 1       /* type of curse */
885                 + 1];     /* sentinel NULL */
886
887 /* Additional ability or resistance */
888         char addition[80];
889
890         /* A string describing an artifact's activation */
891         concptr activation;
892
893         /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
894         char misc_desc[80];
895 } obj_desc_list;
896
897
898 /*!
899  * @brief ファイルポインタ先に同じ文字を複数出力する /
900  * Write out `n' of the character `c' to the spoiler file
901  * @param n 出力する数
902  * @param c 出力するキャラクタ
903  * @return なし
904  */
905 static void spoiler_out_n_chars(int n, char c)
906 {
907         while (--n >= 0) fputc(c, fff);
908 }
909
910
911 /*!
912  * @brief ファイルポインタ先に改行を複数出力する /
913  * Write out `n' blank lines to the spoiler file
914  * @param n 改行を出力する数
915  * @return なし
916  */
917 static void spoiler_blanklines(int n)
918 {
919         spoiler_out_n_chars(n, '\n');
920 }
921
922
923 /*!
924  * @brief ファイルポインタ先に複数のハイフンで装飾した文字列を出力する /
925  * Write a line to the spoiler file and then "underline" it with hypens
926  * @param str 出力したい文字列
927  * @return なし
928  */
929 static void spoiler_underline(concptr str)
930 {
931         fprintf(fff, "%s\n", str);
932         spoiler_out_n_chars(strlen(str), '-');
933         fprintf(fff, "\n");
934 }
935
936
937
938 /*!
939  * @brief アーティファクトの特性一覧を出力する /
940  * Write a line to the spoiler file and then "underline" it with hypens
941  * @param art_flags アーティファクトのフラグ群
942  * @param flag_ptr フラグ記述情報の参照ポインタ
943  * @param desc_ptr 記述内容を返すための文字列参照ポインタ
944  * @param n_elmnts フラグの要素数
945  * @return desc_ptrと同じアドレス
946  * @details
947  * <pre>
948  * This function does most of the actual "analysis". Given a set of bit flags
949  * (which will be from one of the flags fields from the object in question),
950  * a "flag description structure", a "description list", and the number of
951  * elements in the "flag description structure", this function sets the
952  * "description list" members to the appropriate descriptions contained in
953  * the "flag description structure".
954  * The possibly updated description pointer is returned.
955  * </pre>
956  */
957 static concptr *spoiler_flag_aux(const BIT_FLAGS art_flags[TR_FLAG_SIZE],
958         const flag_desc *flag_ptr,
959         concptr *desc_ptr, const int n_elmnts)
960 {
961         int i;
962
963         for (i = 0; i < n_elmnts; ++i)
964         {
965                 if (have_flag(art_flags, flag_ptr[i].flag))
966                 {
967                         *desc_ptr++ = flag_ptr[i].desc;
968                 }
969         }
970
971         return desc_ptr;
972 }
973
974
975 /*!
976  * @brief アイテムの特定記述内容を返す /
977  * Acquire a "basic" description "The Cloak of Death [1,+10]"
978  * @param o_ptr 記述を得たいオブジェクトの参照ポインタ
979  * @param desc_ptr 記述内容を返すための文字列参照ポインタ
980  * @return なし
981  */
982 static void analyze_general(player_type *player_ptr, object_type *o_ptr, char *desc_ptr)
983 {
984         /* Get a "useful" description of the object */
985         object_desc(player_ptr, desc_ptr, o_ptr, (OD_NAME_AND_ENCHANT | OD_STORE));
986 }
987
988
989 /*!
990  * @brief アーティファクトがプレイヤーに与えるpval修正を構造体に収める /
991  * List "player traits" altered by an artifact's pval. These include stats,
992  * speed, infravision, tunneling, stealth, searching, and extra attacks.
993  * @param o_ptr オブジェクト構造体の参照ポインタ
994  * @param pi_ptr pval修正構造体の参照ポインタ
995  * @return なし
996  */
997 static void analyze_pval(object_type *o_ptr, pval_info_type *pi_ptr)
998 {
999         BIT_FLAGS flgs[TR_FLAG_SIZE];
1000
1001         concptr *affects_list;
1002
1003         /* If pval == 0, there is nothing to do. */
1004         if (!o_ptr->pval)
1005         {
1006                 /* An "empty" pval description indicates that pval == 0 */
1007                 pi_ptr->pval_desc[0] = '\0';
1008                 return;
1009         }
1010         object_flags(o_ptr, flgs);
1011
1012         affects_list = pi_ptr->pval_affects;
1013
1014         /* Create the "+N" string */
1015         sprintf(pi_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1016
1017         /* First, check to see if the pval affects all stats */
1018         if (have_flag(flgs, TR_STR) && have_flag(flgs, TR_INT) &&
1019                 have_flag(flgs, TR_WIS) && have_flag(flgs, TR_DEX) &&
1020                 have_flag(flgs, TR_CON) && have_flag(flgs, TR_CHR))
1021         {
1022                 *affects_list++ = _("全能力", "All stats");
1023         }
1024
1025         /* Are any stats affected? */
1026         else if (have_flag(flgs, TR_STR) || have_flag(flgs, TR_INT) ||
1027                 have_flag(flgs, TR_WIS) || have_flag(flgs, TR_DEX) ||
1028                 have_flag(flgs, TR_CON) || have_flag(flgs, TR_CHR))
1029         {
1030                 affects_list = spoiler_flag_aux(flgs, stat_flags_desc,
1031                         affects_list,
1032                         N_ELEMENTS(stat_flags_desc));
1033         }
1034
1035         /* And now the "rest" */
1036         affects_list = spoiler_flag_aux(flgs, pval_flags1_desc,
1037                 affects_list,
1038                 N_ELEMENTS(pval_flags1_desc));
1039
1040         /* Terminate the description list */
1041         *affects_list = NULL;
1042 }
1043
1044 /*!
1045  * @brief アーティファクトの種族スレイ特性を構造体に収める /
1046  * Note the slaying specialties of a weapon
1047  * @param o_ptr オブジェクト構造体の参照ポインタ
1048  * @param slay_list 種族スレイ構造体の参照ポインタ
1049  * @return なし
1050  */
1051 static void analyze_slay(object_type *o_ptr, concptr *slay_list)
1052 {
1053         BIT_FLAGS flgs[TR_FLAG_SIZE];
1054
1055         object_flags(o_ptr, flgs);
1056
1057         slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list,
1058                 N_ELEMENTS(slay_flags_desc));
1059
1060         /* Terminate the description list */
1061         *slay_list = NULL;
1062 }
1063
1064
1065 /*!
1066  * @brief アーティファクトの属性ブランド特性を構造体に収める /
1067  * Note an object's elemental brands
1068  * @param o_ptr オブジェクト構造体の参照ポインタ
1069  * @param brand_list 属性ブランド構造体の参照ポインタ
1070  * @return なし
1071  */
1072 static void analyze_brand(object_type *o_ptr, concptr *brand_list)
1073 {
1074         BIT_FLAGS flgs[TR_FLAG_SIZE];
1075
1076         object_flags(o_ptr, flgs);
1077
1078         brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list,
1079                 N_ELEMENTS(brand_flags_desc));
1080
1081         /* Terminate the description list */
1082         *brand_list = NULL;
1083 }
1084
1085
1086 /*!
1087  * @brief アーティファクトの通常耐性を構造体に収める /
1088  * Note an object's elemental brands
1089  * @param o_ptr オブジェクト構造体の参照ポインタ
1090  * @param resist_list 通常耐性構造体の参照ポインタ
1091  * @return なし
1092  */
1093 static void analyze_resist(object_type *o_ptr, concptr *resist_list)
1094 {
1095         BIT_FLAGS flgs[TR_FLAG_SIZE];
1096
1097         object_flags(o_ptr, flgs);
1098
1099         resist_list = spoiler_flag_aux(flgs, resist_flags_desc,
1100                 resist_list, N_ELEMENTS(resist_flags_desc));
1101
1102         /* Terminate the description list */
1103         *resist_list = NULL;
1104 }
1105
1106
1107 /*!
1108  * @brief アーティファクトの免疫特性を構造体に収める /
1109  * Note the immunities granted by an object
1110  * @param o_ptr オブジェクト構造体の参照ポインタ
1111  * @param immune_list 免疫構造体の参照ポインタ
1112  * @return なし
1113  */
1114 static void analyze_immune(object_type *o_ptr, concptr *immune_list)
1115 {
1116         BIT_FLAGS flgs[TR_FLAG_SIZE];
1117
1118         object_flags(o_ptr, flgs);
1119
1120         immune_list = spoiler_flag_aux(flgs, immune_flags_desc,
1121                 immune_list, N_ELEMENTS(immune_flags_desc));
1122
1123         /* Terminate the description list */
1124         *immune_list = NULL;
1125 }
1126
1127
1128 /*!
1129  * @brief アーティファクトの維持特性を構造体に収める /
1130  * Note which stats an object sustains
1131  * @param o_ptr オブジェクト構造体の参照ポインタ
1132  * @param sustain_list 維持特性構造体の参照ポインタ
1133  * @return なし
1134  */
1135 static void analyze_sustains(object_type *o_ptr, concptr *sustain_list)
1136 {
1137         BIT_FLAGS flgs[TR_FLAG_SIZE];
1138
1139         object_flags(o_ptr, flgs);
1140
1141         /* Simplify things if an item sustains all stats */
1142         if (have_flag(flgs, TR_SUST_STR) && have_flag(flgs, TR_SUST_INT) &&
1143                 have_flag(flgs, TR_SUST_WIS) && have_flag(flgs, TR_SUST_DEX) &&
1144                 have_flag(flgs, TR_SUST_CON) && have_flag(flgs, TR_SUST_CHR))
1145         {
1146                 *sustain_list++ = _("全能力", "All stats");
1147         }
1148
1149         /* Should we bother? */
1150         else if (have_flag(flgs, TR_SUST_STR) || have_flag(flgs, TR_SUST_INT) ||
1151                 have_flag(flgs, TR_SUST_WIS) || have_flag(flgs, TR_SUST_DEX) ||
1152                 have_flag(flgs, TR_SUST_CON) || have_flag(flgs, TR_SUST_CHR))
1153         {
1154                 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc,
1155                         sustain_list,
1156                         N_ELEMENTS(sustain_flags_desc));
1157         }
1158
1159         /* Terminate the description list */
1160         *sustain_list = NULL;
1161 }
1162
1163
1164 /*!
1165  * @brief アーティファクトのその他の特性を構造体に収める /
1166  * Note miscellaneous powers bestowed by an artifact such as see invisible,
1167  * free action, permanent light, etc.
1168  * @param o_ptr オブジェクト構造体の参照ポインタ
1169  * @param misc_list その他の特性構造体の参照ポインタ
1170  * @return なし
1171  */
1172 static void analyze_misc_magic(object_type *o_ptr, concptr *misc_list)
1173 {
1174         BIT_FLAGS flgs[TR_FLAG_SIZE];
1175         POSITION rad;
1176         char desc[256];
1177
1178         object_flags(o_ptr, flgs);
1179
1180         misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list,
1181                 N_ELEMENTS(misc_flags2_desc));
1182
1183         misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list, N_ELEMENTS(misc_flags3_desc));
1184
1185         /*
1186          * Glowing artifacts -- small radius light.
1187         */
1188         rad = 0;
1189         if (have_flag(flgs, TR_LITE_1))  rad += 1;
1190         if (have_flag(flgs, TR_LITE_2))  rad += 2;
1191         if (have_flag(flgs, TR_LITE_3))  rad += 3;
1192         if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
1193         if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
1194         if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
1195
1196         if (o_ptr->name2 == EGO_LITE_SHINE) rad++;
1197
1198         if (have_flag(flgs, TR_LITE_FUEL))
1199         {
1200                 if (rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);
1201         }
1202         else
1203         {
1204                 if (rad > 0) sprintf(desc, _("永久光源(半径 %d)", "Permanent Light(radius %d)"), (int)rad);
1205                 if (rad < 0) sprintf(desc, _("永久光源(半径-%d)。", "Permanent Light(radius -%d)"), (int)-rad);
1206         }
1207
1208         if (rad != 0) *misc_list++ = quark_str(quark_add(desc));
1209
1210         /*
1211          * Handle cursed objects here to avoid redundancies such as noting
1212          * that a permanently cursed object is heavily cursed as well as
1213          * being "lightly cursed".
1214          */
1215
1216          /*     if (object_is_cursed(o_ptr)) */
1217         {
1218                 if (have_flag(flgs, TR_TY_CURSE))
1219                 {
1220                         *misc_list++ = _("太古の怨念", "Ancient Curse");
1221                 }
1222                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1223                 {
1224                         *misc_list++ = _("永遠の呪い", "Permanently Cursed");
1225                 }
1226                 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1227                 {
1228                         *misc_list++ = _("強力な呪い", "Heavily Cursed");
1229                 }
1230                 /*              else */
1231                 else if (o_ptr->curse_flags & TRC_CURSED)
1232                 {
1233                         *misc_list++ = _("呪い", "Cursed");
1234                 }
1235                 if (have_flag(flgs, TR_ADD_L_CURSE))
1236                 {
1237                         *misc_list++ = _("呪いを増やす", "Cursing");
1238                 }
1239                 if (have_flag(flgs, TR_ADD_H_CURSE))
1240                 {
1241                         *misc_list++ = _("強力な呪いを増やす", "Heavily Cursing");
1242                 }
1243         }
1244
1245         /* Terminate the description list */
1246         *misc_list = NULL;
1247 }
1248
1249
1250 /*!
1251  * @brief アーティファクトの追加ランダム特性を構造体に収める /
1252  * Note additional ability and/or resistance of fixed artifacts
1253  * @param o_ptr オブジェクト構造体の参照ポインタ
1254  * @param addition 追加ランダム耐性構造体の参照ポインタ
1255  * @return なし
1256  */
1257 static void analyze_addition(object_type *o_ptr, char *addition)
1258 {
1259         artifact_type *a_ptr = &a_info[o_ptr->name1];
1260
1261         /* Init */
1262         strcpy(addition, "");
1263
1264         if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, _("能力and耐性", "Ability and Resistance"));
1265         else if (a_ptr->gen_flags & TRG_XTRA_POWER)
1266         {
1267                 strcat(addition, _("能力", "Ability"));
1268                 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand耐性)", "(plus Resistance about 1/2)"));
1269         }
1270         else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
1271         {
1272                 strcat(addition, _("耐性", "Resistance"));
1273                 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand能力)", "(plus Ability about 1/2)"));
1274         }
1275         else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("能力or耐性", "Ability or Resistance"));
1276 }
1277
1278
1279 /*!
1280  * @brief アーティファクトの基本情報を文字列に収める /
1281  * Determine the minimum depth an artifact can appear, its rarity, its weight,
1282  * and its value in gold pieces
1283  * @param o_ptr オブジェクト構造体の参照ポインタ
1284  * @param misc_desc 基本情報を収める文字列参照ポインタ
1285  * @return なし
1286  */
1287 static void analyze_misc(object_type *o_ptr, char *misc_desc)
1288 {
1289         artifact_type *a_ptr = &a_info[o_ptr->name1];
1290
1291         sprintf(misc_desc, _("レベル %d, 希少度 %u, %d.%d kg, $%ld", "Level %d, Rarity %u, %d.%d lbs, %ld Gold"), (int)a_ptr->level, a_ptr->rarity,
1292 #ifdef JP
1293                 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), (long int)a_ptr->cost);
1294 #else
1295                 a_ptr->weight / 10, a_ptr->weight % 10, (long int)a_ptr->cost);
1296 #endif
1297 }
1298
1299
1300 /*!
1301  * @brief アーティファクトの情報全体を構造体に収める /
1302  * Fill in an object description structure for a given object
1303  * and its value in gold pieces
1304  * @param player_ptr プレーヤーへの参照ポインタ
1305  * @param o_ptr オブジェクト構造体の参照ポインタ
1306  * @param desc_ptr 全アーティファクト情報を収める文字列参照ポインタ
1307  * @return なし
1308  */
1309 static void object_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
1310 {
1311         analyze_general(player_ptr, o_ptr, desc_ptr->description);
1312         analyze_pval(o_ptr, &desc_ptr->pval_info);
1313         analyze_brand(o_ptr, desc_ptr->brands);
1314         analyze_slay(o_ptr, desc_ptr->slays);
1315         analyze_immune(o_ptr, desc_ptr->immunities);
1316         analyze_resist(o_ptr, desc_ptr->resistances);
1317         analyze_sustains(o_ptr, desc_ptr->sustains);
1318         analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1319         analyze_addition(o_ptr, desc_ptr->addition);
1320         analyze_misc(o_ptr, desc_ptr->misc_desc);
1321         desc_ptr->activation = activation_explanation(o_ptr);
1322 }
1323
1324
1325 /*!
1326  * @brief バッファにアーティファクト出力情報ヘッダを収める /
1327  * @return なし
1328  */
1329 static void print_header(void)
1330 {
1331         char buf[80];
1332
1333         sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1334         spoiler_underline(buf);
1335 }
1336
1337 /*
1338  * This is somewhat ugly.
1339  *
1340  * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1341  * and a separator character (',', e.g.), write the list to the spoiler file
1342  * in a "nice" format, such as:
1343  *
1344  *      Resist Fire, Cold, Acid
1345  *
1346  * That was a simple example, but when the list is long, a line wrap
1347  * should occur, and this should induce a new level of indention if
1348  * a list is being spread across lines. So for example, Bladeturner's
1349  * list of resistances should look something like this
1350  *
1351  *     Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1352  *       Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1353  *
1354  * However, the code distinguishes between a single list of many items vs.
1355  * many lists. (The separator is used to make this determination.) A single
1356  * list of many items will not cause line wrapping (since there is no
1357  * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1358  * might look like this:
1359  *
1360  *     Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1361  *     Blessed Blade
1362  *
1363  * So comparing the two, "Regeneration" has no trailing separator and
1364  * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1365  * but that's not relevant to line wrapping and indention.)
1366  */
1367
1368  /* ITEM_SEP separates items within a list */
1369 #define ITEM_SEP ','
1370
1371
1372 /* LIST_SEP separates lists */
1373 #ifdef JP
1374 #define LIST_SEP ','
1375 #else
1376 #define LIST_SEP ';'
1377 #endif
1378
1379 /*!
1380  * @brief フラグ名称を出力する汎用関数
1381  * @param header ヘッダに出力するフラグ群の名前
1382  * @param list フラグ名リスト
1383  * @param separator フラグ表示の区切り記号
1384  * @return なし
1385  */
1386 static void spoiler_outlist(concptr header, concptr *list, char separator)
1387 {
1388         int line_len, buf_len;
1389         char line[MAX_LINE_LEN + 1], buf[80];
1390
1391         /* Ignore an empty list */
1392         if (*list == NULL) return;
1393
1394         /* This function always indents */
1395         strcpy(line, INDENT1);
1396
1397         /* Create header (if one was given) */
1398         if (header && (header[0]))
1399         {
1400                 strcat(line, header);
1401                 strcat(line, " ");
1402         }
1403
1404         line_len = strlen(line);
1405
1406         /* Now begin the tedious task */
1407         while (TRUE)
1408         {
1409                 /* Copy the current item to a buffer */
1410                 strcpy(buf, *list);
1411
1412                 /* Note the buffer's length */
1413                 buf_len = strlen(buf);
1414
1415                 /*
1416                  * If there is an item following this one, pad with separator and
1417                  * a space and adjust the buffer length
1418                  */
1419
1420                 if (list[1])
1421                 {
1422                         sprintf(buf + buf_len, "%c ", separator);
1423                         buf_len += 2;
1424                 }
1425
1426                 /*
1427                  * If the buffer will fit on the current line, just append the
1428                  * buffer to the line and adjust the line length accordingly.
1429                  */
1430
1431                 if (line_len + buf_len <= MAX_LINE_LEN)
1432                 {
1433                         strcat(line, buf);
1434                         line_len += buf_len;
1435                 }
1436
1437                 /* Apply line wrapping and indention semantics described above */
1438                 else
1439                 {
1440                         /*
1441                          * Don't print a trailing list separator but do print a trailing
1442                          * item separator.
1443                          */
1444                         if (line_len > 1 && line[line_len - 1] == ' '
1445                                 && line[line_len - 2] == LIST_SEP)
1446                         {
1447                                 /* Ignore space and separator */
1448                                 line[line_len - 2] = '\0';
1449
1450                                 /* Write to spoiler file */
1451                                 fprintf(fff, "%s\n", line);
1452
1453                                 /* Begin new line at primary indention level */
1454                                 sprintf(line, "%s%s", INDENT1, buf);
1455                         }
1456
1457                         else
1458                         {
1459                                 /* Write to spoiler file */
1460                                 fprintf(fff, "%s\n", line);
1461
1462                                 /* Begin new line at secondary indention level */
1463                                 sprintf(line, "%s%s", INDENT2, buf);
1464                         }
1465
1466                         line_len = strlen(line);
1467                 }
1468
1469                 /* Advance, with break */
1470                 if (!*++list) break;
1471         }
1472
1473         /* Write what's left to the spoiler file */
1474         fprintf(fff, "%s\n", line);
1475 }
1476
1477 /*!
1478  * @brief アーティファクト一件をスポイラー出力する /
1479  * Create a spoiler file entry for an artifact
1480  * @param art_ptr アーティファクト情報をまとめた構造体の参照ポインタ
1481  * @return なし
1482  */
1483 static void spoiler_print_art(obj_desc_list *art_ptr)
1484 {
1485         pval_info_type *pval_ptr = &art_ptr->pval_info;
1486         char buf[80];
1487
1488         /* Don't indent the first line */
1489         fprintf(fff, "%s\n", art_ptr->description);
1490
1491         /* An "empty" pval description indicates that the pval affects nothing */
1492         if (pval_ptr->pval_desc[0])
1493         {
1494                 /* Mention the effects of pval */
1495                 sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
1496                 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1497         }
1498
1499         /* Now deal with the description lists */
1500         spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
1501         spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
1502         spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
1503         spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
1504         spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
1505         spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1506
1507         if (art_ptr->addition[0])
1508         {
1509                 fprintf(fff, _("%s追加: %s\n", "%sAdditional %s\n"), INDENT1, art_ptr->addition);
1510         }
1511
1512         /* Write out the possible activation at the primary indention level */
1513         if (art_ptr->activation)
1514         {
1515                 fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
1516         }
1517
1518         /* End with the miscellaneous facts */
1519         fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1520 }
1521
1522
1523 /*!
1524  * @brief アーティファクト情報を出力するためにダミー生成を行う /
1525  * Hack -- Create a "forged" artifact
1526  * @param o_ptr 一時生成先を保管するオブジェクト構造体
1527  * @param name1 生成するアーティファクトID
1528  * @return 生成が成功した場合TRUEを返す
1529  */
1530 static bool make_fake_artifact(object_type *o_ptr, IDX name1)
1531 {
1532         OBJECT_IDX i;
1533         artifact_type *a_ptr = &a_info[name1];
1534
1535         /* Ignore "empty" artifacts */
1536         if (!a_ptr->name) return FALSE;
1537
1538         /* Acquire the "kind" index */
1539         i = lookup_kind(a_ptr->tval, a_ptr->sval);
1540
1541         if (!i) return FALSE;
1542
1543         object_prep(o_ptr, i);
1544
1545         /* Save the name */
1546         o_ptr->name1 = (byte)name1;
1547
1548         /* Extract the fields */
1549         o_ptr->pval = a_ptr->pval;
1550         o_ptr->ac = a_ptr->ac;
1551         o_ptr->dd = a_ptr->dd;
1552         o_ptr->ds = a_ptr->ds;
1553         o_ptr->to_a = a_ptr->to_a;
1554         o_ptr->to_h = a_ptr->to_h;
1555         o_ptr->to_d = a_ptr->to_d;
1556         o_ptr->weight = a_ptr->weight;
1557
1558         /* Success */
1559         return TRUE;
1560 }
1561
1562
1563 /*!
1564  * @brief アーティファクト情報のスポイラー出力を行うメインルーチン /
1565  * Create a spoiler file for artifacts
1566  * @param player_ptr プレーヤーへの参照ポインタ
1567  * @param fname 生成ファイル名
1568  * @return なし
1569  */
1570 static void spoil_artifact(player_type *player_ptr, concptr fname)
1571 {
1572         int i;
1573         IDX j;
1574
1575         object_type forge;
1576         object_type *q_ptr;
1577         obj_desc_list artifact;
1578         char buf[1024];
1579         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1580
1581         fff = my_fopen(buf, "w");
1582
1583         if (!fff)
1584         {
1585                 msg_print("Cannot create spoiler file.");
1586                 return;
1587         }
1588
1589         /* Dump the header */
1590         print_header();
1591
1592         /* List the artifacts by tval */
1593         for (i = 0; group_artifact[i].tval; i++)
1594         {
1595                 /* Write out the group title */
1596                 if (group_artifact[i].name)
1597                 {
1598                         spoiler_blanklines(2);
1599                         spoiler_underline(group_artifact[i].name);
1600                         spoiler_blanklines(1);
1601                 }
1602
1603                 /* Now search through all of the artifacts */
1604                 for (j = 1; j < max_a_idx; ++j)
1605                 {
1606                         artifact_type *a_ptr = &a_info[j];
1607
1608                         /* We only want objects in the current group */
1609                         if (a_ptr->tval != group_artifact[i].tval) continue;
1610                         q_ptr = &forge;
1611                         object_wipe(q_ptr);
1612
1613                         /* Attempt to "forge" the artifact */
1614                         if (!make_fake_artifact(q_ptr, j)) continue;
1615
1616                         /* Analyze the artifact */
1617                         object_analyze(player_ptr, q_ptr, &artifact);
1618
1619                         /* Write out the artifact description to the spoiler file */
1620                         spoiler_print_art(&artifact);
1621                 }
1622         }
1623
1624         /* Check for errors */
1625         if (ferror(fff) || my_fclose(fff))
1626         {
1627                 msg_print("Cannot close spoiler file.");
1628                 return;
1629         }
1630
1631         msg_print("Successfully created a spoiler file.");
1632 }
1633
1634
1635 /*!
1636  * @brief モンスター簡易情報のスポイラー出力を行うメインルーチン /
1637  * Create a spoiler file for monsters   -BEN-
1638  * @param fname 生成ファイル名
1639  * @return なし
1640  */
1641 static void spoil_mon_desc(concptr fname)
1642 {
1643         int i, n = 0;
1644
1645         u16b why = 2;
1646         MONRACE_IDX *who;
1647
1648         char buf[1024];
1649
1650         char nam[80];
1651         char lev[80];
1652         char rar[80];
1653         char spd[80];
1654         char ac[80];
1655         char hp[80];
1656         char exp[80];
1657         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1658
1659         fff = my_fopen(buf, "w");
1660         if (!fff)
1661         {
1662                 msg_print("Cannot create spoiler file.");
1663                 return;
1664         }
1665
1666         /* Allocate the "who" array */
1667         C_MAKE(who, max_r_idx, MONRACE_IDX);
1668
1669         /* Dump the header */
1670         fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1671                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1672         fprintf(fff, "------------------------------------------\n\n");
1673
1674         /* Dump the header */
1675         fprintf(fff, "    %-38.38s%4s%4s%4s%7s%5s  %11.11s\n",
1676                 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1677         fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s  %11.11s\n",
1678                 "--------", "---", "---", "---", "--", "--", "-----------");
1679
1680
1681         /* Scan the monsters */
1682         for (i = 1; i < max_r_idx; i++)
1683         {
1684                 monster_race *r_ptr = &r_info[i];
1685
1686                 /* Use that monster */
1687                 if (r_ptr->name) who[n++] = (s16b)i;
1688         }
1689
1690         /* Sort the array by dungeon depth of monsters */
1691         ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1692
1693         /* Scan again */
1694         for (i = 0; i < n; i++)
1695         {
1696                 monster_race *r_ptr = &r_info[who[i]];
1697
1698                 concptr name = (r_name + r_ptr->name);
1699                 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1700
1701                 /* Get the "name" */
1702                 /*
1703                 else if (r_ptr->flags3 & (RF3_NO_CONF))
1704                 {
1705                         sprintf(nam, "[*] %s", name);
1706                 }
1707                 */
1708                 else if (r_ptr->flags1 & (RF1_UNIQUE))
1709                 {
1710                         sprintf(nam, "[U] %s", name);
1711                 }
1712                 else
1713                 {
1714                         sprintf(nam, _("    %s", "The %s"), name);
1715                 }
1716
1717                 /* Level */
1718                 sprintf(lev, "%d", (int)r_ptr->level);
1719
1720                 /* Rarity */
1721                 sprintf(rar, "%d", (int)r_ptr->rarity);
1722
1723                 if (r_ptr->speed >= 110)
1724                 {
1725                         sprintf(spd, "+%d", (r_ptr->speed - 110));
1726                 }
1727                 else
1728                 {
1729                         sprintf(spd, "-%d", (110 - r_ptr->speed));
1730                 }
1731
1732                 /* Armor Class */
1733                 sprintf(ac, "%d", r_ptr->ac);
1734
1735                 /* Hitpoints */
1736                 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1737                 {
1738                         sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1739                 }
1740                 else
1741                 {
1742                         sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1743                 }
1744
1745
1746                 /* Experience */
1747                 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1748
1749                 /* Hack -- use visual instead */
1750                 sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char);
1751
1752                 /* Dump the info */
1753                 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s  %11.11s\n",
1754                         nam, lev, rar, spd, hp, ac, exp);
1755         }
1756
1757         /* End it */
1758         fprintf(fff, "\n");
1759
1760
1761         /* Free the "who" array */
1762         C_KILL(who, max_r_idx, s16b);
1763
1764         /* Check for errors */
1765         if (ferror(fff) || my_fclose(fff))
1766         {
1767                 msg_print("Cannot close spoiler file.");
1768                 return;
1769         }
1770
1771         /* Worked */
1772         msg_print("Successfully created a spoiler file.");
1773 }
1774
1775
1776
1777
1778 /*
1779  * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1780  *
1781  * Primarily based on code already in mon-desc.c, mostly by -BEN-
1782  */
1783
1784
1785
1786  /*!
1787   * @brief 文字列をファイルポインタに出力する /
1788   * Buffer text to the given file. (-SHAWN-)
1789   * This is basically c_roff() from mon-desc.c with a few changes.
1790   * @param str 文字列参照ポインタ
1791   * @return なし
1792   */
1793 static void spoil_out(concptr str)
1794 {
1795         concptr r;
1796
1797         /* Line buffer */
1798         static char roff_buf[256];
1799
1800         /* Delay buffer */
1801         static char roff_waiting_buf[256];
1802
1803 #ifdef JP
1804         bool iskanji_flag = FALSE;
1805 #endif
1806         /* Current pointer into line roff_buf */
1807         static char *roff_p = roff_buf;
1808
1809         /* Last space saved into roff_buf */
1810         static char *roff_s = NULL;
1811
1812         /* Mega-Hack -- Delayed output */
1813         static bool waiting_output = FALSE;
1814
1815         /* Special handling for "new sequence" */
1816         if (!str)
1817         {
1818                 if (waiting_output)
1819                 {
1820                         fputs(roff_waiting_buf, fff);
1821                         waiting_output = FALSE;
1822                 }
1823
1824                 if (roff_p != roff_buf) roff_p--;
1825                 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1826
1827                 if (roff_p == roff_buf) fprintf(fff, "\n");
1828                 else
1829                 {
1830                         *(roff_p + 1) = '\0';
1831                         fprintf(fff, "%s\n\n", roff_buf);
1832                 }
1833
1834                 roff_p = roff_buf;
1835                 roff_s = NULL;
1836                 roff_buf[0] = '\0';
1837                 return;
1838         }
1839
1840         /* Scan the given string, character at a time */
1841         for (; *str; str++)
1842         {
1843 #ifdef JP
1844                 char cbak;
1845                 bool k_flag = iskanji((unsigned char)(*str));
1846 #endif
1847                 char ch = *str;
1848                 bool wrap = (ch == '\n');
1849
1850 #ifdef JP
1851                 if (!isprint((unsigned char)ch) && !k_flag && !iskanji_flag) ch = ' ';
1852                 iskanji_flag = k_flag && !iskanji_flag;
1853 #else
1854                 if (!isprint(ch)) ch = ' ';
1855 #endif
1856
1857                 if (waiting_output)
1858                 {
1859                         fputs(roff_waiting_buf, fff);
1860                         if (!wrap) fputc('\n', fff);
1861                         waiting_output = FALSE;
1862                 }
1863
1864                 if (!wrap)
1865                 {
1866 #ifdef JP
1867                         if (roff_p >= roff_buf + (k_flag ? 74 : 75)) wrap = TRUE;
1868                         else if ((ch == ' ') && (roff_p >= roff_buf + (k_flag ? 72 : 73))) wrap = TRUE;
1869 #else
1870                         if (roff_p >= roff_buf + 75) wrap = TRUE;
1871                         else if ((ch == ' ') && (roff_p >= roff_buf + 73)) wrap = TRUE;
1872 #endif
1873
1874                         if (wrap)
1875                         {
1876 #ifdef JP
1877                                 bool k_flag_local;
1878                                 bool iskanji_flag_local = FALSE;
1879                                 concptr tail = str + (k_flag ? 2 : 1);
1880 #else
1881                                 concptr tail = str + 1;
1882 #endif
1883
1884                                 for (; *tail; tail++)
1885                                 {
1886                                         if (*tail == ' ') continue;
1887
1888 #ifdef JP
1889                                         k_flag_local = iskanji((unsigned char)(*tail));
1890                                         if (isprint((unsigned char)*tail) || k_flag_local || iskanji_flag_local) break;
1891                                         iskanji_flag_local = k_flag_local && !iskanji_flag_local;
1892 #else
1893                                         if (isprint(*tail)) break;
1894 #endif
1895                                 }
1896
1897                                 if (!*tail) waiting_output = TRUE;
1898                         }
1899                 }
1900
1901                 /* Handle line-wrap */
1902                 if (wrap)
1903                 {
1904                         *roff_p = '\0';
1905                         r = roff_p;
1906 #ifdef JP
1907                         cbak = ' ';
1908 #endif
1909                         if (roff_s && (ch != ' '))
1910                         {
1911 #ifdef JP
1912                                 cbak = *roff_s;
1913 #endif
1914                                 *roff_s = '\0';
1915                                 r = roff_s + 1;
1916                         }
1917                         if (!waiting_output) fprintf(fff, "%s\n", roff_buf);
1918                         else strcpy(roff_waiting_buf, roff_buf);
1919                         roff_s = NULL;
1920                         roff_p = roff_buf;
1921 #ifdef JP
1922                         if (cbak != ' ') *roff_p++ = cbak;
1923 #endif
1924                         while (*r) *roff_p++ = *r++;
1925                 }
1926
1927                 /* Save the char */
1928                 if ((roff_p > roff_buf) || (ch != ' '))
1929                 {
1930 #ifdef JP
1931                         if (!k_flag)
1932                         {
1933                                 if ((ch == ' ') || (ch == '(')) roff_s = roff_p;
1934                         }
1935                         else
1936                         {
1937                                 if (iskanji_flag &&
1938                                         strncmp(str, "。", 2) != 0 &&
1939                                         strncmp(str, "、", 2) != 0 &&
1940                                         strncmp(str, "ィ", 2) != 0 &&
1941                                         strncmp(str, "ー", 2) != 0) roff_s = roff_p;
1942                         }
1943 #else
1944                         if (ch == ' ') roff_s = roff_p;
1945 #endif
1946
1947                         *roff_p++ = ch;
1948                 }
1949         }
1950 }
1951
1952
1953
1954 /*!
1955  * @brief 関数ポインタ用の出力関数 /
1956  * Hook function used in spoil_mon_info()
1957  * @param attr 未使用
1958  * @param str 文字列参照ポインタ
1959  * @return なし
1960  */
1961 static void roff_func(TERM_COLOR attr, concptr str)
1962 {
1963         /* Unused */
1964         (void)attr;
1965
1966         spoil_out(str);
1967 }
1968
1969
1970 /*!
1971  * @brief モンスター詳細情報をスポイラー出力するメインルーチン /
1972  * Create a spoiler file for monsters (-SHAWN-)
1973  * @param fname ファイル名
1974  * @return なし
1975  */
1976 static void spoil_mon_info(player_type *player_ptr, concptr fname)
1977 {
1978         char buf[1024];
1979         int i, l, n = 0;
1980         BIT_FLAGS flags1;
1981
1982         u16b why = 2;
1983         MONRACE_IDX *who;
1984         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1985
1986         fff = my_fopen(buf, "w");
1987         if (!fff)
1988         {
1989                 msg_print("Cannot create spoiler file.");
1990                 return;
1991         }
1992
1993
1994         /* Dump the header */
1995         sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1996                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1997
1998         spoil_out(buf);
1999         spoil_out("------------------------------------------\n\n");
2000
2001         /* Allocate the "who" array */
2002         C_MAKE(who, max_r_idx, MONRACE_IDX);
2003
2004         /* Scan the monsters */
2005         for (i = 1; i < max_r_idx; i++)
2006         {
2007                 monster_race *r_ptr = &r_info[i];
2008
2009                 /* Use that monster */
2010                 if (r_ptr->name) who[n++] = (s16b)i;
2011         }
2012
2013         ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
2014
2015         /*
2016          * List all monsters in order
2017          */
2018         for (l = 0; l < n; l++)
2019         {
2020                 monster_race *r_ptr = &r_info[who[l]];
2021                 flags1 = r_ptr->flags1;
2022
2023                 /* Prefix */
2024                 /*
2025                 if (flags1 & (RF1_QUESTOR))
2026                 {
2027                         spoil_out("[Q] ");
2028                 }
2029                 else
2030                 */
2031                 if (flags1 & (RF1_UNIQUE))
2032                 {
2033                         spoil_out("[U] ");
2034                 }
2035                 else
2036                 {
2037 #ifdef JP
2038 #else
2039                         spoil_out("The ");
2040 #endif
2041                 }
2042
2043                 /* Name */
2044                 sprintf(buf, _("%s/%s  (", "%s%s ("), (r_name + r_ptr->name), _(r_name + r_ptr->E_name, ""));  /* ---)--- */
2045
2046                 spoil_out(buf);
2047
2048                 /* Color */
2049                 spoil_out(attr_to_text(r_ptr));
2050
2051                 /* Symbol --(-- */
2052                 sprintf(buf, " '%c')\n", r_ptr->d_char);
2053                 spoil_out(buf);
2054
2055
2056                 /* Indent */
2057                 sprintf(buf, "=== ");
2058                 spoil_out(buf);
2059
2060                 /* Number */
2061                 sprintf(buf, "Num:%d  ", who[l]);
2062                 spoil_out(buf);
2063
2064                 /* Level */
2065                 sprintf(buf, "Lev:%d  ", (int)r_ptr->level);
2066                 spoil_out(buf);
2067
2068                 /* Rarity */
2069                 sprintf(buf, "Rar:%d  ", r_ptr->rarity);
2070                 spoil_out(buf);
2071
2072                 if (r_ptr->speed >= 110)
2073                 {
2074                         sprintf(buf, "Spd:+%d  ", (r_ptr->speed - 110));
2075                 }
2076                 else
2077                 {
2078                         sprintf(buf, "Spd:-%d  ", (110 - r_ptr->speed));
2079                 }
2080                 spoil_out(buf);
2081
2082                 /* Hitpoints */
2083                 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2084                 {
2085                         sprintf(buf, "Hp:%d  ", r_ptr->hdice * r_ptr->hside);
2086                 }
2087                 else
2088                 {
2089                         sprintf(buf, "Hp:%dd%d  ", r_ptr->hdice, r_ptr->hside);
2090                 }
2091                 spoil_out(buf);
2092
2093                 /* Armor Class */
2094                 sprintf(buf, "Ac:%d  ", r_ptr->ac);
2095                 spoil_out(buf);
2096
2097                 /* Experience */
2098                 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2099                 spoil_out(buf);
2100
2101                 /* Reuse the code of monster recall. */
2102                 output_monster_spoiler(player_ptr, who[l], roff_func);
2103
2104                 spoil_out(NULL);
2105         }
2106
2107         /* Free the "who" array */
2108         C_KILL(who, max_r_idx, s16b);
2109
2110         /* Check for errors */
2111         if (ferror(fff) || my_fclose(fff))
2112         {
2113                 msg_print("Cannot close spoiler file.");
2114                 return;
2115         }
2116
2117         msg_print("Successfully created a spoiler file.");
2118 }
2119
2120
2121
2122 #define MAX_EVOL_DEPTH 64
2123
2124
2125 /*!
2126  * @brief int配列でstrncmp()と似た比較処理を行う /
2127  * Compare two int-type array like strncmp() and return TRUE if equals
2128  * @param a 比較するint配列1
2129  * @param b 比較するint配列2
2130  * @param length
2131  * @return 両者の値が等しければTRUEを返す
2132  */
2133 static bool int_n_cmp(int *a, int *b, int length)
2134 {
2135         /* Null-string comparation is always TRUE */
2136         if (!length) return TRUE;
2137
2138         do
2139         {
2140                 if (*a != *(b++)) return FALSE;
2141                 if (!(*(a++))) break;
2142         } while (--length);
2143
2144         return TRUE;
2145 }
2146
2147
2148 /*!
2149  * @brief ある木が指定された木の部分木かどうかを返す /
2150  * Returns TRUE if an evolution tree is "partial tree"
2151  * @param tree 元となる木構造リスト
2152  * @param partial_tree 部分木かどうか判定したい木構造リスト
2153  * @return 部分木ならばTRUEを返す
2154  */
2155 static bool is_partial_tree(int *tree, int *partial_tree)
2156 {
2157         int pt_head = *(partial_tree++);
2158         int pt_len = 0;
2159
2160         while (partial_tree[pt_len]) pt_len++;
2161
2162         while (*tree)
2163         {
2164                 if (*(tree++) == pt_head)
2165                 {
2166                         if (int_n_cmp(tree, partial_tree, pt_len)) return TRUE;
2167                 }
2168         }
2169
2170         return FALSE;
2171 }
2172
2173 /*!
2174  * @brief 進化ツリーをスポイラー出力するメインルーチン /
2175  * Print monsters' evolution information to file
2176  * @param fname 出力ファイル名
2177  * @return なし
2178  */
2179 static void spoil_mon_evol(concptr fname)
2180 {
2181         char buf[1024];
2182         monster_race *r_ptr;
2183         int **evol_tree, i, j, n, r_idx;
2184         int *evol_tree_zero; /* For C_KILL() */
2185         path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
2186
2187         fff = my_fopen(buf, "w");
2188         if (!fff)
2189         {
2190                 msg_print("Cannot create spoiler file.");
2191                 return;
2192         }
2193
2194         /* Dump the header */
2195         sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2196                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2197
2198         spoil_out(buf);
2199         spoil_out("------------------------------------------\n\n");
2200
2201         /* Allocate the "evol_tree" array (2-dimension) */
2202         C_MAKE(evol_tree, max_r_idx, int *);
2203         C_MAKE(*evol_tree, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2204         for (i = 1; i < max_r_idx; i++) evol_tree[i] = *evol_tree + i * (MAX_EVOL_DEPTH + 1);
2205         evol_tree_zero = *evol_tree;
2206
2207         /* Step 1: Build the evolution tree */
2208         for (i = 1; i < max_r_idx; i++)
2209         {
2210                 r_ptr = &r_info[i];
2211
2212                 /* No evolution */
2213                 if (!r_ptr->next_exp) continue;
2214
2215                 /* Trace evolution */
2216                 n = 0;
2217                 evol_tree[i][n++] = i;
2218                 do
2219                 {
2220                         evol_tree[i][n++] = r_ptr->next_r_idx;
2221                         r_ptr = &r_info[r_ptr->next_r_idx];
2222                 } while (r_ptr->next_exp && (n < MAX_EVOL_DEPTH));
2223         }
2224
2225         /* Step 2: Scan the evolution trees and remove "partial tree" */
2226         for (i = 1; i < max_r_idx; i++)
2227         {
2228                 /* Not evolution tree */
2229                 if (!evol_tree[i][0]) continue;
2230
2231                 for (j = 1; j < max_r_idx; j++)
2232                 {
2233                         /* Same tree */
2234                         if (i == j) continue;
2235
2236                         /* Not evolution tree */
2237                         if (!evol_tree[j][0]) continue;
2238
2239                         /* Is evolution tree[i] is part of [j]? */
2240                         if (is_partial_tree(evol_tree[j], evol_tree[i]))
2241                         {
2242                                 /* Remove this evolution tree */
2243                                 evol_tree[i][0] = 0;
2244                                 break;
2245                         }
2246                 }
2247         }
2248
2249         /* Step 3: Sort the evolution trees */
2250         ang_sort(evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
2251
2252         /* Step 4: Print the evolution trees */
2253         for (i = 0; i < max_r_idx; i++)
2254         {
2255                 r_idx = evol_tree[i][0];
2256
2257                 /* No evolution or removed evolution tree */
2258                 if (!r_idx) continue;
2259
2260                 /* Trace the evolution tree */
2261                 r_ptr = &r_info[r_idx];
2262                 fprintf(fff, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"),
2263                         r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2264
2265                 for (n = 1; r_ptr->next_exp; n++)
2266                 {
2267                         fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp);
2268                         fprintf(fff, "[%d]: ", r_ptr->next_r_idx);
2269                         r_ptr = &r_info[r_ptr->next_r_idx];
2270                         fprintf(fff, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"),
2271                                 r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2272                 }
2273
2274                 /* End of evolution tree */
2275                 fputc('\n', fff);
2276         }
2277
2278         /* Free the "evol_tree" array (2-dimension) */
2279         C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2280         C_KILL(evol_tree, max_r_idx, int *);
2281
2282         /* Check for errors */
2283         if (ferror(fff) || my_fclose(fff))
2284         {
2285                 msg_print("Cannot close spoiler file.");
2286                 return;
2287         }
2288
2289         msg_print("Successfully created a spoiler file.");
2290 }
2291
2292
2293 /*!
2294  * @brief スポイラー出力を行うコマンドのメインルーチン /
2295  * Create Spoiler files -BEN-
2296  * @return なし
2297  */
2298 void do_cmd_spoilers(player_type *player_ptr)
2299 {
2300         screen_save();
2301
2302         /* Interact */
2303         while (TRUE)
2304         {
2305                 Term_clear();
2306
2307                 /* Info */
2308                 prt("Create a spoiler file.", 2, 0);
2309
2310                 /* Prompt for a file */
2311                 prt("(1) Brief Object Info (obj-desc.txt)", 5, 5);
2312                 prt("(2) Brief Artifact Info (artifact.txt)", 6, 5);
2313                 prt("(3) Brief Monster Info (mon-desc.txt)", 7, 5);
2314                 prt("(4) Full Monster Info (mon-info.txt)", 8, 5);
2315                 prt("(5) Monster Evolution Info (mon-evol.txt)", 9, 5);
2316
2317                 /* Prompt */
2318                 prt(_("コマンド:", "Command: "), _(18, 12), 0);
2319
2320                 /* Get a choice */
2321                 switch (inkey())
2322                 {
2323                         /* Escape */
2324                 case ESCAPE:
2325                         screen_load();
2326                         return;
2327
2328                         /* Option (1) */
2329                 case '1':
2330                         spoil_obj_desc(player_ptr, "obj-desc.txt");
2331                         break;
2332
2333                         /* Option (2) */
2334                 case '2':
2335                         spoil_artifact(player_ptr, "artifact.txt");
2336                         break;
2337
2338                         /* Option (3) */
2339                 case '3':
2340                         spoil_mon_desc("mon-desc.txt");
2341                         break;
2342
2343                         /* Option (4) */
2344                 case '4':
2345                         spoil_mon_info(player_ptr, "mon-info.txt");
2346                         break;
2347
2348                         /* Option (5) */
2349                 case '5':
2350                         spoil_mon_evol("mon-evol.txt");
2351                         break;
2352
2353                 default:
2354                         bell();
2355                         break;
2356                 }
2357
2358                 msg_erase();
2359         }
2360 }
2361
2362 /*!
2363  * @brief ランダムアーティファクト1件を解析する /
2364  * Fill in an object description structure for a given object
2365  * @param player_ptr プレーヤーへの参照ポインタ
2366  * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2367  * @param desc_ptr 記述内容を収める構造体参照ポインタ
2368  * @return なし
2369  */
2370 static void random_artifact_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
2371 {
2372         analyze_general(player_ptr, o_ptr, desc_ptr->description);
2373         analyze_pval(o_ptr, &desc_ptr->pval_info);
2374         analyze_brand(o_ptr, desc_ptr->brands);
2375         analyze_slay(o_ptr, desc_ptr->slays);
2376         analyze_immune(o_ptr, desc_ptr->immunities);
2377         analyze_resist(o_ptr, desc_ptr->resistances);
2378         analyze_sustains(o_ptr, desc_ptr->sustains);
2379         analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2380         desc_ptr->activation = activation_explanation(o_ptr);
2381 #ifdef JP
2382         sprintf(desc_ptr->misc_desc, "重さ %d.%d kg",
2383                 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2384 #else
2385         sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2386                 o_ptr->weight / 10, o_ptr->weight % 10);
2387 #endif
2388 }
2389
2390 /*!
2391  * @brief ランダムアーティファクト1件をスポイラー出力する /
2392  * Create a spoiler file entry for an artifact
2393  * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2394  * @param art_ptr 記述内容を収めた構造体参照ポインタ
2395  * Fill in an object description structure for a given object
2396  * @return なし
2397  */
2398 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2399 {
2400         pval_info_type *pval_ptr = &art_ptr->pval_info;
2401
2402         char buf[80];
2403
2404         /* Don't indent the first line */
2405         fprintf(fff, "%s\n", art_ptr->description);
2406
2407         /* unidentified */
2408         if (!object_is_fully_known(o_ptr))
2409         {
2410                 fprintf(fff, _("%s不明\n", "%sUnknown\n"), INDENT1);
2411         }
2412         else {
2413                 /* An "empty" pval description indicates that the pval affects nothing */
2414                 if (pval_ptr->pval_desc[0])
2415                 {
2416                         /* Mention the effects of pval */
2417                         sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
2418                         spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2419                 }
2420
2421                 /* Now deal with the description lists */
2422
2423                 spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
2424                 spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
2425                 spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
2426                 spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
2427                 spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
2428                 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2429
2430                 /* Write out the possible activation at the primary indention level */
2431                 if (art_ptr->activation)
2432                 {
2433                         fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
2434                 }
2435         }
2436         /* End with the miscellaneous facts */
2437         fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2438 }
2439
2440
2441 /*!
2442  * @brief ランダムアーティファクト内容をスポイラー出力するサブルーチン /
2443  * @param player_ptr プレーヤーへの参照ポインタ
2444  * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2445  * @param i 出力したい記録ランダムアーティファクトID
2446  * @return なし
2447  */
2448 static void spoil_random_artifact_aux(player_type *player_ptr, object_type *o_ptr, int i)
2449 {
2450         obj_desc_list artifact;
2451
2452         if (!object_is_known(o_ptr) || !o_ptr->art_name
2453                 || o_ptr->tval != group_artifact[i].tval)
2454                 return;
2455
2456         /* Analyze the artifact */
2457         random_artifact_analyze(player_ptr, o_ptr, &artifact);
2458
2459         /* Write out the artifact description to the spoiler file */
2460         spoiler_print_randart(o_ptr, &artifact);
2461 }
2462
2463 /*!
2464  * @brief ランダムアーティファクト内容をスポイラー出力するメインルーチン /
2465  * Create a list file for random artifacts
2466  * @param fname 出力ファイル名
2467  * @return なし
2468  */
2469 void spoil_random_artifact(player_type *creature_ptr, concptr fname)
2470 {
2471         int i, j;
2472
2473         store_type  *store_ptr;
2474         object_type *q_ptr;
2475
2476         char buf[1024];
2477         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2478
2479         fff = my_fopen(buf, "w");
2480         if (!fff)
2481         {
2482                 msg_print("Cannot create list file.");
2483                 return;
2484         }
2485
2486         /* Dump the header */
2487         sprintf(buf, "Random artifacts list.\r");
2488         spoiler_underline(buf);
2489
2490         /* List the artifacts by tval */
2491         for (j = 0; group_artifact[j].tval; j++)
2492         {
2493                 /* random artifacts wielding */
2494                 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2495                 {
2496                         q_ptr = &creature_ptr->inventory_list[i];
2497                         spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2498                 }
2499
2500                 for (i = 0; i < INVEN_PACK; i++)
2501                 {
2502                         q_ptr = &creature_ptr->inventory_list[i];
2503                         spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2504                 }
2505
2506                 /* random artifacts in home */
2507                 store_ptr = &town_info[1].store[STORE_HOME];
2508                 for (i = 0; i < store_ptr->stock_num; i++)
2509                 {
2510                         q_ptr = &store_ptr->stock[i];
2511                         spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2512                 }
2513
2514                 /* random artifacts in museum */
2515                 store_ptr = &town_info[1].store[STORE_MUSEUM];
2516                 for (i = 0; i < store_ptr->stock_num; i++)
2517                 {
2518                         q_ptr = &store_ptr->stock[i];
2519                         spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2520                 }
2521         }
2522
2523         /* Check for errors */
2524         if (ferror(fff) || my_fclose(fff))
2525         {
2526                 msg_print("Cannot close list file.");
2527                 return;
2528         }
2529
2530         msg_print("Successfully created a list file.");
2531 }