OSDN Git Service

Revert "Revert "Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband""
[hengband/hengband.git] / src / autopick / autopick-describer.c
1 /*!
2  * todo 1つ300行近い関数なので後ほど要分割
3  * @brief 自動拾いの記述
4  * @date 2020/04/25
5  * @author Hourier
6  */
7
8 #include "autopick/autopick-describer.h"
9 #include "autopick/autopick-flags-table.h"
10 #include "autopick/autopick-key-flag-process.h"
11 #include "autopick/autopick-methods-table.h"
12 #include "system/angband.h"
13 #include "util/string-processor.h"
14
15 typedef struct
16 {
17         concptr str;
18         byte act;
19         concptr insc;
20         bool top;
21         int before_n;
22         concptr body_str;
23 } autopick_describer;
24
25 #if JP
26 static void describe_autpick_jp(char *buff, autopick_type *entry, autopick_describer *describer)
27 {
28         concptr before_str[100];
29         if (IS_FLG(FLG_COLLECTING))
30                 before_str[describer->before_n++] = "収集中で既に持っているスロットにまとめられる";
31
32         if (IS_FLG(FLG_UNAWARE))
33                 before_str[describer->before_n++] = "未鑑定でその効果も判明していない";
34
35         if (IS_FLG(FLG_UNIDENTIFIED))
36                 before_str[describer->before_n++] = "未鑑定の";
37
38         if (IS_FLG(FLG_IDENTIFIED))
39                 before_str[describer->before_n++] = "鑑定済みの";
40
41         if (IS_FLG(FLG_STAR_IDENTIFIED))
42                 before_str[describer->before_n++] = "完全に鑑定済みの";
43
44         if (IS_FLG(FLG_BOOSTED))
45         {
46                 before_str[describer->before_n++] = "ダメージダイスが通常より大きい";
47                 describer->body_str = "武器";
48         }
49
50         if (IS_FLG(FLG_MORE_DICE))
51         {
52                 static char more_than_desc_str[] = "___";
53                 before_str[describer->before_n++] = "ダメージダイスの最大値が";
54                 describer->body_str = "武器";
55
56                 sprintf(more_than_desc_str, "%d", entry->dice);
57                 before_str[describer->before_n++] = more_than_desc_str;
58                 before_str[describer->before_n++] = "以上の";
59         }
60
61         if (IS_FLG(FLG_MORE_BONUS))
62         {
63                 static char more_bonus_desc_str[] = "___";
64                 before_str[describer->before_n++] = "修正値が(+";
65
66                 sprintf(more_bonus_desc_str, "%d", entry->bonus);
67                 before_str[describer->before_n++] = more_bonus_desc_str;
68                 before_str[describer->before_n++] = ")以上の";
69         }
70
71         if (IS_FLG(FLG_WORTHLESS))
72                 before_str[describer->before_n++] = "店で無価値と判定される";
73
74         if (IS_FLG(FLG_ARTIFACT))
75         {
76                 before_str[describer->before_n++] = "アーティファクトの";
77                 describer->body_str = "装備";
78         }
79
80         if (IS_FLG(FLG_EGO))
81         {
82                 before_str[describer->before_n++] = "エゴアイテムの";
83                 describer->body_str = "装備";
84         }
85
86         if (IS_FLG(FLG_GOOD))
87         {
88                 before_str[describer->before_n++] = "上質の";
89                 describer->body_str = "装備";
90         }
91
92         if (IS_FLG(FLG_NAMELESS))
93         {
94                 before_str[describer->before_n++] = "エゴでもアーティファクトでもない";
95                 describer->body_str = "装備";
96         }
97
98         if (IS_FLG(FLG_AVERAGE))
99         {
100                 before_str[describer->before_n++] = "並の";
101                 describer->body_str = "装備";
102         }
103
104         if (IS_FLG(FLG_RARE))
105         {
106                 before_str[describer->before_n++] = "ドラゴン装備やカオス・ブレード等を含む珍しい";
107                 describer->body_str = "装備";
108         }
109
110         if (IS_FLG(FLG_COMMON))
111         {
112                 before_str[describer->before_n++] = "ありふれた(ドラゴン装備やカオス・ブレード等の珍しい物ではない)";
113                 describer->body_str = "装備";
114         }
115
116         if (IS_FLG(FLG_WANTED))
117         {
118                 before_str[describer->before_n++] = "ハンター事務所で賞金首とされている";
119                 describer->body_str = "死体や骨";
120         }
121
122         if (IS_FLG(FLG_HUMAN))
123         {
124                 before_str[describer->before_n++] = "悪魔魔法で使うための人間やヒューマノイドの";
125                 describer->body_str = "死体や骨";
126         }
127
128         if (IS_FLG(FLG_UNIQUE))
129         {
130                 before_str[describer->before_n++] = "ユニークモンスターの";
131                 describer->body_str = "死体や骨";
132         }
133
134         if (IS_FLG(FLG_UNREADABLE))
135         {
136                 before_str[describer->before_n++] = "あなたが読めない領域の";
137                 describer->body_str = "魔法書";
138         }
139
140         if (IS_FLG(FLG_REALM1))
141         {
142                 before_str[describer->before_n++] = "第一領域の";
143                 describer->body_str = "魔法書";
144         }
145
146         if (IS_FLG(FLG_REALM2))
147         {
148                 before_str[describer->before_n++] = "第二領域の";
149                 describer->body_str = "魔法書";
150         }
151
152         if (IS_FLG(FLG_FIRST))
153         {
154                 before_str[describer->before_n++] = "全4冊の内の1冊目の";
155                 describer->body_str = "魔法書";
156         }
157
158         if (IS_FLG(FLG_SECOND))
159         {
160                 before_str[describer->before_n++] = "全4冊の内の2冊目の";
161                 describer->body_str = "魔法書";
162         }
163
164         if (IS_FLG(FLG_THIRD))
165         {
166                 before_str[describer->before_n++] = "全4冊の内の3冊目の";
167                 describer->body_str = "魔法書";
168         }
169
170         if (IS_FLG(FLG_FOURTH))
171         {
172                 before_str[describer->before_n++] = "全4冊の内の4冊目の";
173                 describer->body_str = "魔法書";
174         }
175
176         if (IS_FLG(FLG_ITEMS))
177                 ; /* Nothing to do */
178         else if (IS_FLG(FLG_WEAPONS))
179                 describer->body_str = "武器";
180         else if (IS_FLG(FLG_FAVORITE_WEAPONS))
181                 describer->body_str = "得意武器";
182         else if (IS_FLG(FLG_ARMORS))
183                 describer->body_str = "防具";
184         else if (IS_FLG(FLG_MISSILES))
185                 describer->body_str = "弾や矢やクロスボウの矢";
186         else if (IS_FLG(FLG_DEVICES))
187                 describer->body_str = "巻物や魔法棒や杖やロッド";
188         else if (IS_FLG(FLG_LIGHTS))
189                 describer->body_str = "光源用のアイテム";
190         else if (IS_FLG(FLG_JUNKS))
191                 describer->body_str = "折れた棒等のガラクタ";
192         else if (IS_FLG(FLG_CORPSES))
193                 describer->body_str = "死体や骨";
194         else if (IS_FLG(FLG_SPELLBOOKS))
195                 describer->body_str = "魔法書";
196         else if (IS_FLG(FLG_HAFTED))
197                 describer->body_str = "鈍器";
198         else if (IS_FLG(FLG_SHIELDS))
199                 describer->body_str = "盾";
200         else if (IS_FLG(FLG_BOWS))
201                 describer->body_str = "スリングや弓やクロスボウ";
202         else if (IS_FLG(FLG_RINGS))
203                 describer->body_str = "指輪";
204         else if (IS_FLG(FLG_AMULETS))
205                 describer->body_str = "アミュレット";
206         else if (IS_FLG(FLG_SUITS))
207                 describer->body_str = "鎧";
208         else if (IS_FLG(FLG_CLOAKS))
209                 describer->body_str = "クローク";
210         else if (IS_FLG(FLG_HELMS))
211                 describer->body_str = "ヘルメットや冠";
212         else if (IS_FLG(FLG_GLOVES))
213                 describer->body_str = "籠手";
214         else if (IS_FLG(FLG_BOOTS))
215                 describer->body_str = "ブーツ";
216
217         *buff = '\0';
218         if (!describer->before_n)
219                 strcat(buff, "全ての");
220         else for (int i = 0; i < describer->before_n && before_str[i]; i++)
221                 strcat(buff, before_str[i]);
222
223         strcat(buff, describer->body_str);
224
225         if (*describer->str)
226         {
227                 if (*describer->str == '^')
228                 {
229                         describer->str++;
230                         describer->top = TRUE;
231                 }
232
233                 strcat(buff, "で、名前が「");
234                 strncat(buff, describer->str, 80);
235                 if (describer->top)
236                         strcat(buff, "」で始まるもの");
237                 else
238                         strcat(buff, "」を含むもの");
239         }
240
241         if (describer->insc)
242         {
243                 strncat(buff, format("に「%s」", describer->insc), 80);
244
245                 if (angband_strstr(describer->insc, "%%all"))
246                         strcat(buff, "(%%allは全能力を表す英字の記号で置換)");
247                 else if (angband_strstr(describer->insc, "%all"))
248                         strcat(buff, "(%allは全能力を表す記号で置換)");
249                 else if (angband_strstr(describer->insc, "%%"))
250                         strcat(buff, "(%%は追加能力を表す英字の記号で置換)");
251                 else if (angband_strstr(describer->insc, "%"))
252                         strcat(buff, "(%は追加能力を表す記号で置換)");
253
254                 strcat(buff, "と刻んで");
255         }
256         else
257                 strcat(buff, "を");
258
259         if (describer->act & DONT_AUTOPICK)
260                 strcat(buff, "放置する。");
261         else if (describer->act & DO_AUTODESTROY)
262                 strcat(buff, "破壊する。");
263         else if (describer->act & DO_QUERY_AUTOPICK)
264                 strcat(buff, "確認の後に拾う。");
265         else
266                 strcat(buff, "拾う。");
267
268         if (describer->act & DO_DISPLAY)
269         {
270                 if (describer->act & DONT_AUTOPICK)
271                         strcat(buff, "全体マップ('M')で'N'を押したときに表示する。");
272                 else if (describer->act & DO_AUTODESTROY)
273                         strcat(buff, "全体マップ('M')で'K'を押したときに表示する。");
274                 else
275                         strcat(buff, "全体マップ('M')で'M'を押したときに表示する。");
276         }
277         else
278                 strcat(buff, "全体マップには表示しない。");
279 }
280 #else
281
282
283 void describe_autopick_en(char *buff, autopick_type *entry, autopick_describer *describer)
284 {
285         concptr before_str[20], after_str[20], which_str[20], whose_str[20];
286         int after_n = 0, which_n = 0, whose_n = 0;
287         if (IS_FLG(FLG_COLLECTING))
288                 which_str[which_n++] = "can be absorbed into an existing inventory list slot";
289
290         if (IS_FLG(FLG_UNAWARE))
291         {
292                 before_str[describer->before_n++] = "unidentified";
293                 whose_str[whose_n++] = "basic abilities are not known";
294         }
295
296         if (IS_FLG(FLG_UNIDENTIFIED))
297                 before_str[describer->before_n++] = "unidentified";
298
299         if (IS_FLG(FLG_IDENTIFIED))
300                 before_str[describer->before_n++] = "identified";
301
302         if (IS_FLG(FLG_STAR_IDENTIFIED))
303                 before_str[describer->before_n++] = "fully identified";
304
305         if (IS_FLG(FLG_RARE))
306         {
307                 before_str[describer->before_n++] = "very rare";
308                 describer->body_str = "equipments";
309                 after_str[after_n++] = "such as Dragon armor, Blades of Chaos, etc.";
310         }
311
312         if (IS_FLG(FLG_COMMON))
313         {
314                 before_str[describer->before_n++] = "relatively common";
315                 describer->body_str = "equipments";
316                 after_str[after_n++] = "compared to very rare Dragon armor, Blades of Chaos, etc.";
317         }
318
319         if (IS_FLG(FLG_WORTHLESS))
320         {
321                 before_str[describer->before_n++] = "worthless";
322                 which_str[which_n++] = "can not be sold at stores";
323         }
324
325         if (IS_FLG(FLG_ARTIFACT))
326                 before_str[describer->before_n++] = "artifact";
327
328         if (IS_FLG(FLG_EGO))
329                 before_str[describer->before_n++] = "ego";
330
331         if (IS_FLG(FLG_GOOD))
332         {
333                 describer->body_str = "equipment";
334                 which_str[which_n++] = "have good quality";
335         }
336
337         if (IS_FLG(FLG_NAMELESS))
338         {
339                 describer->body_str = "equipment";
340                 which_str[which_n++] = "is neither ego-item nor artifact";
341         }
342
343         if (IS_FLG(FLG_AVERAGE))
344         {
345                 describer->body_str = "equipment";
346                 which_str[which_n++] = "have average quality";
347         }
348
349         if (IS_FLG(FLG_BOOSTED))
350         {
351                 describer->body_str = "weapons";
352                 whose_str[whose_n++] = "damage dice is bigger than normal";
353         }
354
355         if (IS_FLG(FLG_MORE_DICE))
356         {
357                 static char more_than_desc_str[] =
358                         "maximum damage from dice is bigger than __";
359                 describer->body_str = "weapons";
360
361                 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
362                         "%d", entry->dice);
363                 whose_str[whose_n++] = more_than_desc_str;
364         }
365
366         if (IS_FLG(FLG_MORE_BONUS))
367         {
368                 static char more_bonus_desc_str[] =
369                         "magical bonus is bigger than (+__)";
370
371                 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
372                         "%d)", entry->bonus);
373                 whose_str[whose_n++] = more_bonus_desc_str;
374         }
375
376         if (IS_FLG(FLG_WANTED))
377         {
378                 describer->body_str = "corpse or skeletons";
379                 which_str[which_n++] = "is wanted at the Hunter's Office";
380         }
381
382         if (IS_FLG(FLG_HUMAN))
383         {
384                 before_str[describer->before_n++] = "humanoid";
385                 describer->body_str = "corpse or skeletons";
386                 which_str[which_n++] = "can be used for Daemon magic";
387         }
388
389         if (IS_FLG(FLG_UNIQUE))
390         {
391                 before_str[describer->before_n++] = "unique monster's";
392                 describer->body_str = "corpse or skeletons";
393         }
394
395         if (IS_FLG(FLG_UNREADABLE))
396         {
397                 describer->body_str = "spellbooks";
398                 after_str[after_n++] = "of different realms from yours";
399         }
400
401         if (IS_FLG(FLG_REALM1))
402         {
403                 describer->body_str = "spellbooks";
404                 after_str[after_n++] = "of your first realm";
405         }
406
407         if (IS_FLG(FLG_REALM2))
408         {
409                 describer->body_str = "spellbooks";
410                 after_str[after_n++] = "of your second realm";
411         }
412
413         if (IS_FLG(FLG_FIRST))
414         {
415                 before_str[describer->before_n++] = "first one of four";
416                 describer->body_str = "spellbooks";
417         }
418
419         if (IS_FLG(FLG_SECOND))
420         {
421                 before_str[describer->before_n++] = "second one of four";
422                 describer->body_str = "spellbooks";
423         }
424
425         if (IS_FLG(FLG_THIRD))
426         {
427                 before_str[describer->before_n++] = "third one of four";
428                 describer->body_str = "spellbooks";
429         }
430
431         if (IS_FLG(FLG_FOURTH))
432         {
433                 before_str[describer->before_n++] = "fourth one of four";
434                 describer->body_str = "spellbooks";
435         }
436
437         if (IS_FLG(FLG_ITEMS))
438                 ; /* Nothing to do */
439         else if (IS_FLG(FLG_WEAPONS))
440                 describer->body_str = "weapons";
441         else if (IS_FLG(FLG_FAVORITE_WEAPONS))
442                 describer->body_str = "favorite weapons";
443         else if (IS_FLG(FLG_ARMORS))
444                 describer->body_str = "armors";
445         else if (IS_FLG(FLG_MISSILES))
446                 describer->body_str = "shots, arrows or crossbow bolts";
447         else if (IS_FLG(FLG_DEVICES))
448                 describer->body_str = "scrolls, wands, staffs or rods";
449         else if (IS_FLG(FLG_LIGHTS))
450                 describer->body_str = "light sources";
451         else if (IS_FLG(FLG_JUNKS))
452                 describer->body_str = "junk such as broken sticks";
453         else if (IS_FLG(FLG_CORPSES))
454                 describer->body_str = "corpses or skeletons";
455         else if (IS_FLG(FLG_SPELLBOOKS))
456                 describer->body_str = "spellbooks";
457         else if (IS_FLG(FLG_HAFTED))
458                 describer->body_str = "hafted weapons";
459         else if (IS_FLG(FLG_SHIELDS))
460                 describer->body_str = "shields";
461         else if (IS_FLG(FLG_BOWS))
462                 describer->body_str = "slings, bows or crossbows";
463         else if (IS_FLG(FLG_RINGS))
464                 describer->body_str = "rings";
465         else if (IS_FLG(FLG_AMULETS))
466                 describer->body_str = "amulets";
467         else if (IS_FLG(FLG_SUITS))
468                 describer->body_str = "body armors";
469         else if (IS_FLG(FLG_CLOAKS))
470                 describer->body_str = "cloaks";
471         else if (IS_FLG(FLG_HELMS))
472                 describer->body_str = "helms or crowns";
473         else if (IS_FLG(FLG_GLOVES))
474                 describer->body_str = "gloves";
475         else if (IS_FLG(FLG_BOOTS))
476                 describer->body_str = "boots";
477
478         if (*describer->str)
479         {
480                 if (*describer->str == '^')
481                 {
482                         describer->str++;
483                         describer->top = TRUE;
484                         whose_str[whose_n++] = "name begins with \"";
485                 }
486                 else
487                         which_str[which_n++] = "have \"";
488         }
489
490         if (describer->act & DONT_AUTOPICK)
491                 strcpy(buff, "Leave on floor ");
492         else if (describer->act & DO_AUTODESTROY)
493                 strcpy(buff, "Destroy ");
494         else if (describer->act & DO_QUERY_AUTOPICK)
495                 strcpy(buff, "Ask to pick up ");
496         else
497                 strcpy(buff, "Pickup ");
498
499         if (describer->insc)
500         {
501                 strncat(buff, format("and inscribe \"%s\"", describer->insc), 80);
502
503                 if (angband_strstr(describer->insc, "%all"))
504                         strcat(buff, ", replacing %all with code string representing all abilities,");
505                 else if (angband_strstr(describer->insc, "%"))
506                         strcat(buff, ", replacing % with code string representing extra random abilities,");
507
508                 strcat(buff, " on ");
509         }
510
511         if (!describer->before_n)
512                 strcat(buff, "all ");
513         else
514                 for (int i = 0; i < describer->before_n && before_str[i]; i++)
515                 {
516                         strcat(buff, before_str[i]);
517                         strcat(buff, " ");
518                 }
519
520         strcat(buff, describer->body_str);
521         for (int i = 0; i < after_n && after_str[i]; i++)
522         {
523                 strcat(buff, " ");
524                 strcat(buff, after_str[i]);
525         }
526
527         for (int i = 0; i < whose_n && whose_str[i]; i++)
528         {
529                 if (i == 0)
530                         strcat(buff, " whose ");
531                 else
532                         strcat(buff, ", and ");
533
534                 strcat(buff, whose_str[i]);
535         }
536
537         if (*describer->str && describer->top)
538         {
539                 strcat(buff, describer->str);
540                 strcat(buff, "\"");
541         }
542
543         if (whose_n && which_n)
544                 strcat(buff, ", and ");
545
546         for (int i = 0; i < which_n && which_str[i]; i++)
547         {
548                 if (i == 0)
549                         strcat(buff, " which ");
550                 else
551                         strcat(buff, ", and ");
552
553                 strcat(buff, which_str[i]);
554         }
555
556         if (*describer->str && !describer->top)
557         {
558                 strncat(buff, describer->str, 80);
559                 strcat(buff, "\" as part of its name");
560         }
561
562         strcat(buff, ".");
563
564         if (describer->act & DO_DISPLAY)
565         {
566                 if (describer->act & DONT_AUTOPICK)
567                         strcat(buff, "  Display these items when you press the N key in the full 'M'ap.");
568                 else if (describer->act & DO_AUTODESTROY)
569                         strcat(buff, "  Display these items when you press the K key in the full 'M'ap.");
570                 else
571                         strcat(buff, "  Display these items when you press the M key in the full 'M'ap.");
572         }
573         else
574                 strcat(buff, " Not displayed in the full map.");
575 }
576 #endif
577
578
579 /*
580  * Describe which kind of object is Auto-picked/destroyed
581  */
582 void describe_autopick(char *buff, autopick_type *entry)
583 {
584         autopick_describer describer;
585         describer.str = entry->name;
586         describer.act = entry->action;
587         describer.insc = entry->insc;
588         describer.top = FALSE;
589         describer.before_n = 0;
590         describer.body_str = _("アイテム", "items");
591 #ifdef JP
592         describe_autpick_jp(buff, entry, &describer);
593 #else
594         describe_autopick_en(buff, entry, &describer);
595 #endif
596 }