OSDN Git Service

75b6ec9b922eb2902262fc8a04a499c1811b1711
[hengbandforosx/hengbandosx.git] / src / object1.c
1 /*!
2  * @file object1.c
3  * @brief オブジェクトの実装 / Object code, part 1
4  * @date 2014/01/10
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  *\n
8  * This software may be copied and distributed for educational, research,\n
9  * and not for profit purposes provided that this copyright and statement\n
10  * are included in all such copies.  Other copyrights may also apply.\n
11  * 2014 Deskull rearranged comment for Doxygen.\n
12  */
13
14 #include "angband.h"
15
16 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
17 #ifdef verify
18 #undef verify
19 #endif
20 #endif
21
22 /*!
23  * @brief オブジェクト、地形の表示シンボルなど初期化する / Reset the "visual" lists
24  * @return なし
25  * This involves resetting various things to their "default" state.\n
26  *\n
27  * If the "prefs" flag is TRUE, then we will also load the appropriate\n
28  * "user pref file" based on the current setting of the "use_graphics"\n
29  * flag.  This is useful for switching "graphics" on/off.\n
30  *\n
31  * The features, objects, and monsters, should all be encoded in the\n
32  * relevant "font.pref" and/or "graf.prf" files.  \n
33  *\n
34  * The "prefs" parameter is no longer meaningful.  \n
35  */
36 void reset_visuals(void)
37 {
38         int i, j;
39
40         /* Extract some info about terrain features */
41         for (i = 0; i < max_f_idx; i++)
42         {
43                 feature_type *f_ptr = &f_info[i];
44
45                 /* Assume we will use the underlying values */
46                 for (j = 0; j < F_LIT_MAX; j++)
47                 {
48                         f_ptr->x_attr[j] = f_ptr->d_attr[j];
49                         f_ptr->x_char[j] = f_ptr->d_char[j];
50                 }
51         }
52
53         /* Extract default attr/char code for objects */
54         for (i = 0; i < max_k_idx; i++)
55         {
56                 object_kind *k_ptr = &k_info[i];
57
58                 /* Default attr/char */
59                 k_ptr->x_attr = k_ptr->d_attr;
60                 k_ptr->x_char = k_ptr->d_char;
61         }
62
63         /* Extract default attr/char code for monsters */
64         for (i = 0; i < max_r_idx; i++)
65         {
66                 monster_race *r_ptr = &r_info[i];
67
68                 /* Default attr/char */
69                 r_ptr->x_attr = r_ptr->d_attr;
70                 r_ptr->x_char = r_ptr->d_char;
71         }
72
73         if (use_graphics)
74         {
75                 char buf[1024];
76
77                 /* Process "graf.prf" */
78                 process_pref_file("graf.prf");
79
80                 /* Access the "character" pref file */
81                 sprintf(buf, "graf-%s.prf", player_base);
82
83                 /* Process "graf-<playername>.prf" */
84                 process_pref_file(buf);
85         }
86
87         /* Normal symbols */
88         else
89         {
90                 char buf[1024];
91
92                 /* Process "font.prf" */
93                 process_pref_file("font.prf");
94
95                 /* Access the "character" pref file */
96                 sprintf(buf, "font-%s.prf", player_base);
97
98                 /* Process "font-<playername>.prf" */
99                 process_pref_file(buf);
100         }
101 }
102
103 /*!
104  * @brief オブジェクトのフラグ類を配列に与える
105  * Obtain the "flags" for an item
106  * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
107  * @param flgs フラグ情報を受け取る配列
108  * @return なし
109  */
110 void object_flags(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
111 {
112         object_kind *k_ptr = &k_info[o_ptr->k_idx];
113         int i;
114
115         /* Base object */
116         for (i = 0; i < TR_FLAG_SIZE; i++)
117                 flgs[i] = k_ptr->flags[i];
118
119         /* Artifact */
120         if (object_is_fixed_artifact(o_ptr))
121         {
122                 artifact_type *a_ptr = &a_info[o_ptr->name1];
123
124                 for (i = 0; i < TR_FLAG_SIZE; i++)
125                         flgs[i] = a_ptr->flags[i];
126         }
127
128         /* Ego-item */
129         if (object_is_ego(o_ptr))
130         {
131                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
132
133                 for (i = 0; i < TR_FLAG_SIZE; i++)
134                         flgs[i] |= e_ptr->flags[i];
135
136                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
137                 {
138                         remove_flag(flgs, TR_SH_FIRE);
139                 }
140                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
141                 {
142                         remove_flag(flgs, TR_INFRA);
143                 }
144                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
145                 {
146                         remove_flag(flgs, TR_RES_BLIND);
147                         remove_flag(flgs, TR_SEE_INVIS);
148                 }
149         }
150
151         /* Random artifact ! */
152         for (i = 0; i < TR_FLAG_SIZE; i++)
153                 flgs[i] |= o_ptr->art_flags[i];
154
155         if (object_is_smith(o_ptr))
156         {
157                 int add = o_ptr->xtra3 - 1;
158
159                 if (add < TR_FLAG_MAX)
160                 {
161                         add_flag(flgs, add);
162                 }
163                 else if (add == ESSENCE_TMP_RES_ACID)
164                 {
165                         add_flag(flgs, TR_RES_ACID);
166                         add_flag(flgs, TR_ACTIVATE);
167                 }
168                 else if (add == ESSENCE_TMP_RES_ELEC)
169                 {
170                         add_flag(flgs, TR_RES_ELEC);
171                         add_flag(flgs, TR_ACTIVATE);
172                 }
173                 else if (add == ESSENCE_TMP_RES_FIRE)
174                 {
175                         add_flag(flgs, TR_RES_FIRE);
176                         add_flag(flgs, TR_ACTIVATE);
177                 }
178                 else if (add == ESSENCE_TMP_RES_COLD)
179                 {
180                         add_flag(flgs, TR_RES_COLD);
181                         add_flag(flgs, TR_ACTIVATE);
182                 }
183                 else if (add == ESSENCE_SH_FIRE)
184                 {
185                         add_flag(flgs, TR_RES_FIRE);
186                         add_flag(flgs, TR_SH_FIRE);
187                 }
188                 else if (add == ESSENCE_SH_ELEC)
189                 {
190                         add_flag(flgs, TR_RES_ELEC);
191                         add_flag(flgs, TR_SH_ELEC);
192                 }
193                 else if (add == ESSENCE_SH_COLD)
194                 {
195                         add_flag(flgs, TR_RES_COLD);
196                         add_flag(flgs, TR_SH_COLD);
197                 }
198                 else if (add == ESSENCE_RESISTANCE)
199                 {
200                         add_flag(flgs, TR_RES_ACID);
201                         add_flag(flgs, TR_RES_ELEC);
202                         add_flag(flgs, TR_RES_FIRE);
203                         add_flag(flgs, TR_RES_COLD);
204                 }
205                 else if (add == TR_IMPACT)
206                 {
207                         add_flag(flgs, TR_ACTIVATE);
208                 }
209         }
210 }
211
212 /*!
213  * @brief オブジェクトの明示されているフラグ類を取得する
214  * Obtain the "flags" for an item which are known to the player
215  * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
216  * @param flgs フラグ情報を受け取る配列
217  * @return なし
218  */
219 void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
220 {
221         bool spoil = FALSE;
222         int i;
223
224         object_kind *k_ptr = &k_info[o_ptr->k_idx];
225
226         /* Clear */
227         for (i = 0; i < TR_FLAG_SIZE; i++)
228                 flgs[i] = 0;
229
230         if (!object_is_aware(o_ptr)) return;
231
232         /* Base object */
233         for (i = 0; i < TR_FLAG_SIZE; i++)
234                 flgs[i] = k_ptr->flags[i];
235
236         /* Must be identified */
237         if (!object_is_known(o_ptr)) return;
238
239         /* Ego-item (known basic flags) */
240         if (object_is_ego(o_ptr))
241         {
242                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
243
244                 for (i = 0; i < TR_FLAG_SIZE; i++)
245                         flgs[i] |= e_ptr->flags[i];
246
247                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
248                 {
249                         remove_flag(flgs, TR_SH_FIRE);
250                 }
251                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
252                 {
253                         remove_flag(flgs, TR_INFRA);
254                 }
255                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
256                 {
257                         remove_flag(flgs, TR_RES_BLIND);
258                         remove_flag(flgs, TR_SEE_INVIS);
259                 }
260         }
261
262
263 #ifdef SPOIL_ARTIFACTS
264         /* Full knowledge for some artifacts */
265         if (object_is_artifact(o_ptr)) spoil = TRUE;
266 #endif /* SPOIL_ARTIFACTS */
267
268 #ifdef SPOIL_EGO_ITEMS
269         /* Full knowledge for some ego-items */
270         if (object_is_ego(o_ptr)) spoil = TRUE;
271 #endif /* SPOIL_EGO_ITEMS */
272
273         /* Need full knowledge or spoilers */
274         if (spoil || (o_ptr->ident & IDENT_MENTAL))
275         {
276                 /* Artifact */
277                 if (object_is_fixed_artifact(o_ptr))
278                 {
279                         artifact_type *a_ptr = &a_info[o_ptr->name1];
280
281                         for (i = 0; i < TR_FLAG_SIZE; i++)
282                                 flgs[i] = a_ptr->flags[i];
283                 }
284
285                 /* Random artifact ! */
286                 for (i = 0; i < TR_FLAG_SIZE; i++)
287                         flgs[i] |= o_ptr->art_flags[i];
288         }
289
290         if (object_is_smith(o_ptr))
291         {
292                 int add = o_ptr->xtra3 - 1;
293
294                 if (add < TR_FLAG_MAX)
295                 {
296                         add_flag(flgs, add);
297                 }
298                 else if (add == ESSENCE_TMP_RES_ACID)
299                 {
300                         add_flag(flgs, TR_RES_ACID);
301                 }
302                 else if (add == ESSENCE_TMP_RES_ELEC)
303                 {
304                         add_flag(flgs, TR_RES_ELEC);
305                 }
306                 else if (add == ESSENCE_TMP_RES_FIRE)
307                 {
308                         add_flag(flgs, TR_RES_FIRE);
309                 }
310                 else if (add == ESSENCE_TMP_RES_COLD)
311                 {
312                         add_flag(flgs, TR_RES_COLD);
313                 }
314                 else if (add == ESSENCE_SH_FIRE)
315                 {
316                         add_flag(flgs, TR_RES_FIRE);
317                         add_flag(flgs, TR_SH_FIRE);
318                 }
319                 else if (add == ESSENCE_SH_ELEC)
320                 {
321                         add_flag(flgs, TR_RES_ELEC);
322                         add_flag(flgs, TR_SH_ELEC);
323                 }
324                 else if (add == ESSENCE_SH_COLD)
325                 {
326                         add_flag(flgs, TR_RES_COLD);
327                         add_flag(flgs, TR_SH_COLD);
328                 }
329                 else if (add == ESSENCE_RESISTANCE)
330                 {
331                         add_flag(flgs, TR_RES_ACID);
332                         add_flag(flgs, TR_RES_ELEC);
333                         add_flag(flgs, TR_RES_FIRE);
334                         add_flag(flgs, TR_RES_COLD);
335                 }
336         }
337 }
338
339 /*!
340  * @brief オブジェクトの発動効果名称を返す(サブルーチン/ブレス)
341  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
342  * @return cptr 発動名称を返す文字列ポインタ
343  */
344 static cptr item_activation_dragon_breath(object_type *o_ptr)
345 {
346         static char desc[256];
347         BIT_FLAGS flgs[TR_FLAG_SIZE]; /* for resistance flags */
348         int i, n = 0;
349
350         object_flags(o_ptr, flgs);
351         strcpy(desc, _("", "breath "));
352
353         for (i = 0; dragonbreath_info[i].flag != 0; i++)
354         {
355                 if (have_flag(flgs, dragonbreath_info[i].flag))
356                 {
357                         if (n > 0) strcat(desc, _("、", ", "));
358                         strcat(desc, dragonbreath_info[i].name);
359                         n++;
360                 }
361         }
362
363         strcat(desc, _("のブレス(250)", ""));
364
365         return (desc);
366 }
367
368 /*!
369  * @brief オブジェクトの発動効果名称を返す(サブルーチン/汎用)
370  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
371  * @return cptr 発動名称を返す文字列ポインタ
372  */
373 static cptr item_activation_aux(object_type *o_ptr)
374 {
375         static char activation_detail[256];
376         cptr desc;
377         char timeout[32];
378         int constant, dice;
379         const activation_type* const act_ptr = find_activation_info(o_ptr);
380
381         if (!act_ptr) return _("未定義", "something undefined");
382
383         desc = act_ptr->desc;
384
385         /* Overwrite description if it is special */
386         switch (act_ptr->index) {
387         case ACT_BR_FIRE:
388                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
389                         desc = _("火炎のブレス (200) と火への耐性", "breath of fire (200) and resist fire");
390                 break;
391         case ACT_BR_COLD:
392                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
393                         desc = _("冷気のブレス (200) と冷気への耐性", "breath of cold (200) and resist cold");
394                 break;
395         case ACT_BR_DRAGON:
396                 desc = item_activation_dragon_breath(o_ptr);
397                 break;
398         case ACT_AGGRAVATE:
399                 if (o_ptr->name1 == ART_HYOUSIGI)
400                         desc = _("拍子木を打ちならす", "beat wooden clappers");
401                 break;
402         case ACT_RESIST_ACID:
403                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ACID)) || (o_ptr->name2 == EGO_BRAND_ACID))
404                         desc = _("アシッド・ボール (100) と酸への耐性", "ball of acid (100) and resist acid");
405                 break;
406         case ACT_RESIST_FIRE:
407                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) || (o_ptr->name2 == EGO_BRAND_FIRE))
408                         desc = _("ファイア・ボール (100) と火への耐性", "ball of fire (100) and resist fire");
409                 break;
410         case ACT_RESIST_COLD:
411                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) || (o_ptr->name2 == EGO_BRAND_COLD))
412                         desc = _("アイス・ボール (100) と冷気への耐性", "ball of cold (100) and resist cold");
413                 break;
414         case ACT_RESIST_ELEC:
415                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ELEC)) || (o_ptr->name2 == EGO_BRAND_ELEC))
416                         desc = _("サンダー・ボール (100) と電撃への耐性", "ball of elec (100) and resist elec");
417                 break;
418         case ACT_RESIST_POIS:
419                 if (o_ptr->name2 == EGO_BRAND_POIS)
420                         desc = _("悪臭雲 (100) と毒への耐性", "ball of poison (100) and resist elec");
421                 break;
422         }
423
424         /* Timeout description */
425         constant = act_ptr->timeout.constant;
426         dice = act_ptr->timeout.dice;
427         if (constant == 0 && dice == 0) {
428                 /* We can activate it every turn */
429                 strcpy(timeout, _("いつでも", "every turn"));
430         } else if (constant < 0) {
431                 /* Activations that have special timeout */
432                 switch (act_ptr->index) {
433                 case ACT_BR_FIRE:
434                         sprintf(timeout, _("%d ターン毎", "every %d turns"),
435                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
436                         break;
437                 case ACT_BR_COLD:
438                         sprintf(timeout, _("%d ターン毎", "every %d turns"),
439                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250);
440                         break;
441                 case ACT_TERROR:
442                         strcpy(timeout, _("3*(レベル+10) ターン毎", "every 3 * (level+10) turns"));
443                         break;
444                 case ACT_MURAMASA:
445                         strcpy(timeout, _("確率50%で壊れる", "(destroyed 50%)"));
446                         break;
447                 default:
448                         strcpy(timeout, "undefined");
449                         break;
450                 }
451         } else {
452                 /* Normal timeout activations */
453                 char constant_str[16], dice_str[16];
454                 sprintf(constant_str, "%d", constant);
455                 sprintf(dice_str, "d%d", dice);
456                 sprintf(timeout, _("%s%s%s ターン毎", "every %s%s%s turns"),
457                         (constant > 0) ? constant_str : "",
458                         (constant > 0 && dice > 0) ? "+" : "",
459                         (dice > 0) ? dice_str : "");
460         }
461
462         /* Build detail activate description */
463         sprintf(activation_detail, _("%s : %s", "%s %s"), desc, timeout);
464
465         return activation_detail;
466 }
467
468 /*!
469  * @brief オブジェクトの発動効果名称を返す(メインルーチン) /
470  * Determine the "Activation" (if any) for an artifact Return a string, or NULL for "no activation"
471  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
472  * @return cptr 発動名称を返す文字列ポインタ
473  */
474 cptr item_activation(object_type *o_ptr)
475 {
476         BIT_FLAGS flgs[TR_FLAG_SIZE];
477
478         /* Extract the flags */
479         object_flags(o_ptr, flgs);
480
481         /* Require activation ability */
482         if (!(have_flag(flgs, TR_ACTIVATE))) return (_("なし", "nothing"));
483
484         /* Get an explain of an activation */
485         if (activation_index(o_ptr))
486         {
487                 return item_activation_aux(o_ptr);
488         }
489
490         /* Special items */
491         if (o_ptr->tval == TV_WHISTLE)
492         {
493                 return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
494         }
495
496         if (o_ptr->tval == TV_CAPTURE)
497         {
498                 return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
499         }
500
501         return _("何も起きない", "Nothing");
502 }
503
504
505 /*!
506  * @brief オブジェクトの*鑑定*内容を詳述して表示する /
507  * Describe a "fully identified" item
508  * @param o_ptr *鑑定*情報を取得する元のオブジェクト構造体参照ポインタ
509  * @param mode 表示オプション
510  * @return 特筆すべき情報が一つでもあった場合TRUE、一つもなく表示がキャンセルされた場合FALSEを返す。
511  */
512 bool screen_object(object_type *o_ptr, BIT_FLAGS mode)
513 {
514         int i = 0, j, k;
515
516         BIT_FLAGS flgs[TR_FLAG_SIZE];
517
518         char temp[70 * 20];
519         cptr            info[128];
520         char o_name[MAX_NLEN];
521         int wid, hgt;
522         POSITION rad;
523         char desc[256];
524
525         int trivial_info = 0;
526
527         /* Extract the flags */
528         object_flags(o_ptr, flgs);
529
530         /* Extract the description */
531         {
532                 roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) :
533                             (k_text + k_info[o_ptr->k_idx].text),
534                             77 - 15, temp, sizeof(temp));
535                 for (j = 0; temp[j]; j += 1 + strlen(&temp[j]))
536                 { info[i] = &temp[j]; i++;}
537         }
538
539         if (object_is_equipment(o_ptr))
540         {
541                 /* Descriptions of a basic equipment is just a flavor */
542                 trivial_info = i;
543         }
544
545         /* Mega-Hack -- describe activation */
546         if (have_flag(flgs, TR_ACTIVATE))
547         {
548                 info[i++] = _("始動したときの効果...", "It can be activated for...");
549                 info[i++] = item_activation(o_ptr);
550                 info[i++] = _("...ただし装備していなければならない。", "...if it is being worn.");
551         }
552
553         /* Figurines, a hack */
554         if (o_ptr->tval == TV_FIGURINE)
555         {
556                 info[i++] = _("それは投げた時ペットに変化する。", "It will transform into a pet when thrown.");
557         }
558
559         /* Figurines, a hack */
560         if (o_ptr->name1 == ART_STONEMASK)
561         {
562                 info[i++] = _("それを装備した者は吸血鬼になる。", "It makes you turn into a vampire permanently.");
563         }
564
565         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
566         {
567                 info[i++] = _("それは相手を一撃で倒すことがある。", "It will attempt to kill a monster instantly.");
568         }
569
570         if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
571         {
572                 info[i++] = _("それは自分自身に攻撃が返ってくることがある。", "It causes you to strike yourself sometimes.");
573                 info[i++] = _("それは無敵のバリアを切り裂く。", "It always penetrates invulnerability barriers.");
574         }
575
576         if (o_ptr->name2 == EGO_2WEAPON)
577         {
578                 info[i++] = _("それは二刀流での命中率を向上させる。", "It affects your ability to hit when you are wielding two weapons.");
579         }
580
581         if (have_flag(flgs, TR_EASY_SPELL))
582         {
583                 info[i++] = _("それは魔法の難易度を下げる。", "It affects your ability to cast spells.");
584         }
585
586         if (o_ptr->name2 == EGO_AMU_FOOL)
587         {
588                 info[i++] = _("それは魔法の難易度を上げる。", "It interferes with casting spells.");
589         }
590
591         if (o_ptr->name2 == EGO_RING_THROW)
592         {
593                 info[i++] = _("それは物を強く投げることを可能にする。", "It provides great strength when you throw an item.");
594         }
595
596         if (o_ptr->name2 == EGO_AMU_NAIVETY)
597         {
598                 info[i++] = _("それは魔法抵抗力を下げる。", "It decreases your magic resistance.");
599         }
600
601         if (o_ptr->tval == TV_STATUE)
602         {
603                 monster_race *r_ptr = &r_info[o_ptr->pval];
604
605                 if (o_ptr->pval == MON_BULLGATES)
606                         info[i++] = _("それは部屋に飾ると恥ずかしい。", "It is shameful.");
607                 else if ( r_ptr->flags2 & (RF2_ELDRITCH_HORROR))
608                         info[i++] = _("それは部屋に飾ると恐い。", "It is fearful.");
609                 else
610                         info[i++] = _("それは部屋に飾ると楽しい。", "It is cheerful.");
611         }
612         
613         /* Hack -- describe lite's */
614         
615         if (o_ptr->name2 == EGO_LITE_DARKNESS) info[i++] = _("それは全く光らない。", "It provides no light.");
616         
617         rad = 0;
618         if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
619         if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
620         if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
621         if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
622         if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
623         if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
624         
625         if(o_ptr->name2 == EGO_LITE_SHINE) rad++;
626                 
627         if (have_flag(flgs, TR_LITE_FUEL) && o_ptr->name2 != EGO_LITE_DARKNESS)
628         {
629                 if(rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);   
630         }
631         else
632         {
633                 if(rad > 0) sprintf(desc, _("それは永遠なる明かり(半径 %d)を授ける。", "It provides light (radius %d) forever."), (int)rad);
634                 if(rad < 0) sprintf(desc, _("それは明かりの半径を狭める(半径に-%d)。", "It decreases radius of light source by %d."), (int)-rad);
635         }
636         
637         if(rad != 0) info[i++] = desc;
638
639         
640         if (o_ptr->name2 == EGO_LITE_LONG)
641         {
642                 info[i++] = _("それは長いターン明かりを授ける。", "It provides light for much longer time.");
643         }
644
645         /* And then describe it fully */
646
647         if (have_flag(flgs, TR_RIDING))
648         {
649                 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
650                         info[i++] = _("それは乗馬中は非常に使いやすい。", "It is made for use while riding.");
651                 else
652                 {
653                         info[i++] = _("それは乗馬中でも使いやすい。", "It is suitable for use while riding.");
654                         /* This information is not important enough */
655                         trivial_info++;
656                 }
657         }
658         if (have_flag(flgs, TR_STR))
659         {
660                 info[i++] = _("それは腕力に影響を及ぼす。", "It affects your strength.");
661         }
662         if (have_flag(flgs, TR_INT))
663         {
664                 info[i++] = _("それは知能に影響を及ぼす。", "It affects your intelligence.");
665         }
666         if (have_flag(flgs, TR_WIS))
667         {
668                 info[i++] = _("それは賢さに影響を及ぼす。", "It affects your wisdom.");
669         }
670         if (have_flag(flgs, TR_DEX))
671         {
672                 info[i++] = _("それは器用さに影響を及ぼす。", "It affects your dexterity.");
673         }
674         if (have_flag(flgs, TR_CON))
675         {
676                 info[i++] = _("それは耐久力に影響を及ぼす。", "It affects your constitution.");
677         }
678         if (have_flag(flgs, TR_CHR))
679         {
680                 info[i++] = _("それは魅力に影響を及ぼす。", "It affects your charisma.");
681         }
682
683         if (have_flag(flgs, TR_MAGIC_MASTERY))
684         {
685                 info[i++] = _("それは魔法道具使用能力に影響を及ぼす。", "It affects your ability to use magic devices.");
686
687         }
688         if (have_flag(flgs, TR_STEALTH))
689         {
690                 info[i++] = _("それは隠密行動能力に影響を及ぼす。", "It affects your stealth.");
691         }
692         if (have_flag(flgs, TR_SEARCH))
693         {
694                 info[i++] = _("それは探索能力に影響を及ぼす。", "It affects your searching.");
695         }
696         if (have_flag(flgs, TR_INFRA))
697         {
698                 info[i++] = _("それは赤外線視力に影響を及ぼす。", "It affects your infravision.");
699         }
700         if (have_flag(flgs, TR_TUNNEL))
701         {
702                 info[i++] = _("それは採掘能力に影響を及ぼす。", "It affects your ability to tunnel.");
703         }
704         if (have_flag(flgs, TR_SPEED))
705         {
706                 info[i++] = _("それはスピードに影響を及ぼす。", "It affects your speed.");
707         }
708         if (have_flag(flgs, TR_BLOWS))
709         {
710                 info[i++] = _("それは打撃回数に影響を及ぼす。", "It affects your attack speed.");
711         }
712
713         if (have_flag(flgs, TR_BRAND_ACID))
714         {
715                 info[i++] = _("それは酸によって大きなダメージを与える。", "It does extra damage from acid.");
716         }
717         if (have_flag(flgs, TR_BRAND_ELEC))
718         {
719                 info[i++] = _("それは電撃によって大きなダメージを与える。", "It does extra damage from electricity.");
720         }
721         if (have_flag(flgs, TR_BRAND_FIRE))
722         {
723                 info[i++] = _("それは火炎によって大きなダメージを与える。", "It does extra damage from fire.");
724         }
725         if (have_flag(flgs, TR_BRAND_COLD))
726         {
727                 info[i++] = _("それは冷気によって大きなダメージを与える。", "It does extra damage from frost.");
728         }
729
730         if (have_flag(flgs, TR_BRAND_POIS))
731         {
732                 info[i++] = _("それは敵を毒する。", "It poisons your foes.");
733         }
734
735         if (have_flag(flgs, TR_CHAOTIC))
736         {
737                 info[i++] = _("それはカオス的な効果を及ぼす。", "It produces chaotic effects.");
738         }
739
740         if (have_flag(flgs, TR_VAMPIRIC))
741         {
742                 info[i++] = _("それは敵から生命力を吸収する。", "It drains life from your foes.");
743         }
744
745         if (have_flag(flgs, TR_IMPACT))
746         {
747                 info[i++] = _("それは地震を起こすことができる。", "It can cause earthquakes.");
748         }
749
750         if (have_flag(flgs, TR_VORPAL))
751         {
752                 info[i++] = _("それは非常に切れ味が鋭く敵を切断することができる。", "It is very sharp and can cut your foes.");
753         }
754
755         if (have_flag(flgs, TR_KILL_DRAGON))
756         {
757                 info[i++] = _("それはドラゴンにとっての天敵である。", "It is a great bane of dragons.");
758         }
759         else if (have_flag(flgs, TR_SLAY_DRAGON))
760         {
761                 info[i++] = _("それはドラゴンに対して特に恐るべき力を発揮する。", "It is especially deadly against dragons.");
762         }
763
764         if (have_flag(flgs, TR_KILL_ORC))
765         {
766                 info[i++] = _("それはオークにとっての天敵である。", "It is a great bane of orcs.");
767         }
768         if (have_flag(flgs, TR_SLAY_ORC))
769         {
770                 info[i++] = _("それはオークに対して特に恐るべき力を発揮する。", "It is especially deadly against orcs.");
771         }
772
773         if (have_flag(flgs, TR_KILL_TROLL))
774         {
775                 info[i++] = _("それはトロルにとっての天敵である。", "It is a great bane of trolls.");
776         }
777         if (have_flag(flgs, TR_SLAY_TROLL))
778         {
779                 info[i++] = _("それはトロルに対して特に恐るべき力を発揮する。", "It is especially deadly against trolls.");
780         }
781
782         if (have_flag(flgs, TR_KILL_GIANT))
783         {
784                 info[i++] = _("それは巨人にとっての天敵である。", "It is a great bane of giants.");
785         }
786         else if (have_flag(flgs, TR_SLAY_GIANT))
787         {
788                 info[i++] = _("それはジャイアントに対して特に恐るべき力を発揮する。", "It is especially deadly against giants.");
789         }
790
791         if (have_flag(flgs, TR_KILL_DEMON))
792         {
793                 info[i++] = _("それはデーモンにとっての天敵である。", "It is a great bane of demons.");
794         }
795         if (have_flag(flgs, TR_SLAY_DEMON))
796         {
797                 info[i++] = _("それはデーモンに対して聖なる力を発揮する。", "It strikes at demons with holy wrath.");
798         }
799
800         if (have_flag(flgs, TR_KILL_UNDEAD))
801         {
802                 info[i++] = _("それはアンデッドにとっての天敵である。", "It is a great bane of undead.");
803         }
804         if (have_flag(flgs, TR_SLAY_UNDEAD))
805         {
806                 info[i++] = _("それはアンデッドに対して聖なる力を発揮する。", "It strikes at undead with holy wrath.");
807         }
808
809         if (have_flag(flgs, TR_KILL_EVIL))
810         {
811                 info[i++] = _("それは邪悪なる存在にとっての天敵である。", "It is a great bane of evil monsters.");
812         }
813         if (have_flag(flgs, TR_SLAY_EVIL))
814         {
815                 info[i++] = _("それは邪悪なる存在に対して聖なる力で攻撃する。", "It fights against evil with holy fury.");
816         }
817
818         if (have_flag(flgs, TR_KILL_ANIMAL))
819         {
820                 info[i++] = _("それは自然界の動物にとっての天敵である。", "It is a great bane of natural creatures.");
821         }
822         if (have_flag(flgs, TR_SLAY_ANIMAL))
823         {
824                 info[i++] = _("それは自然界の動物に対して特に恐るべき力を発揮する。", "It is especially deadly against natural creatures.");
825         }
826
827         if (have_flag(flgs, TR_KILL_HUMAN))
828         {
829                 info[i++] = _("それは人間にとっての天敵である。", "It is a great bane of humans.");
830         }
831         if (have_flag(flgs, TR_SLAY_HUMAN))
832         {
833                 info[i++] = _("それは人間に対して特に恐るべき力を発揮する。", "It is especially deadly against humans.");
834         }
835
836         if (have_flag(flgs, TR_FORCE_WEAPON))
837         {
838                 info[i++] = _("それは使用者の魔力を使って攻撃する。", "It powerfully strikes at a monster using your mana.");
839         }
840         if (have_flag(flgs, TR_DEC_MANA))
841         {
842                 info[i++] = _("それは魔力の消費を押さえる。", "It decreases your mana consumption.");
843         }
844         if (have_flag(flgs, TR_SUST_STR))
845         {
846                 info[i++] = _("それはあなたの腕力を維持する。", "It sustains your strength.");
847         }
848         if (have_flag(flgs, TR_SUST_INT))
849         {
850                 info[i++] = _("それはあなたの知能を維持する。", "It sustains your intelligence.");
851         }
852         if (have_flag(flgs, TR_SUST_WIS))
853         {
854                 info[i++] = _("それはあなたの賢さを維持する。", "It sustains your wisdom.");
855         }
856         if (have_flag(flgs, TR_SUST_DEX))
857         {
858                 info[i++] = _("それはあなたの器用さを維持する。", "It sustains your dexterity.");
859         }
860         if (have_flag(flgs, TR_SUST_CON))
861         {
862                 info[i++] = _("それはあなたの耐久力を維持する。", "It sustains your constitution.");
863         }
864         if (have_flag(flgs, TR_SUST_CHR))
865         {
866                 info[i++] = _("それはあなたの魅力を維持する。", "It sustains your charisma.");
867         }
868
869         if (have_flag(flgs, TR_IM_ACID))
870         {
871                 info[i++] = _("それは酸に対する完全な免疫を授ける。", "It provides immunity to acid.");
872         }
873         if (have_flag(flgs, TR_IM_ELEC))
874         {
875                 info[i++] = _("それは電撃に対する完全な免疫を授ける。", "It provides immunity to electricity.");
876         }
877         if (have_flag(flgs, TR_IM_FIRE))
878         {
879                 info[i++] = _("それは火に対する完全な免疫を授ける。", "It provides immunity to fire.");
880         }
881         if (have_flag(flgs, TR_IM_COLD))
882         {
883                 info[i++] = _("それは寒さに対する完全な免疫を授ける。", "It provides immunity to cold.");
884         }
885
886         if (have_flag(flgs, TR_THROW))
887         {
888                 info[i++] = _("それは敵に投げて大きなダメージを与えることができる。", "It is perfectly balanced for throwing.");
889         }
890
891         if (have_flag(flgs, TR_FREE_ACT))
892         {
893                 info[i++] = _("それは麻痺に対する完全な免疫を授ける。", "It provides immunity to paralysis.");
894         }
895         if (have_flag(flgs, TR_HOLD_EXP))
896         {
897                 info[i++] = _("それは経験値吸収に対する耐性を授ける。", "It provides resistance to experience draining.");
898         }
899         if (have_flag(flgs, TR_RES_FEAR))
900         {
901                 info[i++] = _("それは恐怖への完全な耐性を授ける。", "It makes you completely fearless.");
902         }
903         if (have_flag(flgs, TR_RES_ACID))
904         {
905                 info[i++] = _("それは酸への耐性を授ける。", "It provides resistance to acid.");
906         }
907         if (have_flag(flgs, TR_RES_ELEC))
908         {
909                 info[i++] = _("それは電撃への耐性を授ける。", "It provides resistance to electricity.");
910         }
911         if (have_flag(flgs, TR_RES_FIRE))
912         {
913                 info[i++] = _("それは火への耐性を授ける。", "It provides resistance to fire.");
914         }
915         if (have_flag(flgs, TR_RES_COLD))
916         {
917                 info[i++] = _("それは寒さへの耐性を授ける。", "It provides resistance to cold.");
918         }
919         if (have_flag(flgs, TR_RES_POIS))
920         {
921                 info[i++] = _("それは毒への耐性を授ける。", "It provides resistance to poison.");
922         }
923
924         if (have_flag(flgs, TR_RES_LITE))
925         {
926                 info[i++] = _("それは閃光への耐性を授ける。", "It provides resistance to light.");
927         }
928         if (have_flag(flgs, TR_RES_DARK))
929         {
930                 info[i++] = _("それは暗黒への耐性を授ける。", "It provides resistance to dark.");
931         }
932
933         if (have_flag(flgs, TR_RES_BLIND))
934         {
935                 info[i++] = _("それは盲目への耐性を授ける。", "It provides resistance to blindness.");
936         }
937         if (have_flag(flgs, TR_RES_CONF))
938         {
939                 info[i++] = _("それは混乱への耐性を授ける。", "It provides resistance to confusion.");
940         }
941         if (have_flag(flgs, TR_RES_SOUND))
942         {
943                 info[i++] = _("それは轟音への耐性を授ける。", "It provides resistance to sound.");
944         }
945         if (have_flag(flgs, TR_RES_SHARDS))
946         {
947                 info[i++] = _("それは破片への耐性を授ける。", "It provides resistance to shards.");
948         }
949
950         if (have_flag(flgs, TR_RES_NETHER))
951         {
952                 info[i++] = _("それは地獄への耐性を授ける。", "It provides resistance to nether.");
953         }
954         if (have_flag(flgs, TR_RES_NEXUS))
955         {
956                 info[i++] = _("それは因果混乱への耐性を授ける。", "It provides resistance to nexus.");
957         }
958         if (have_flag(flgs, TR_RES_CHAOS))
959         {
960                 info[i++] = _("それはカオスへの耐性を授ける。", "It provides resistance to chaos.");
961         }
962         if (have_flag(flgs, TR_RES_DISEN))
963         {
964                 info[i++] = _("それは劣化への耐性を授ける。", "It provides resistance to disenchantment.");
965         }
966
967         if (have_flag(flgs, TR_LEVITATION))
968         {
969                 info[i++] = _("それは宙に浮くことを可能にする。", "It allows you to levitate.");
970         }
971                 
972         if (have_flag(flgs, TR_SEE_INVIS))
973         {
974                 info[i++] = _("それは透明なモンスターを見ることを可能にする。", "It allows you to see invisible monsters.");
975         }
976         if (have_flag(flgs, TR_TELEPATHY))
977         {
978                 info[i++] = _("それはテレパシー能力を授ける。", "It gives telepathic powers.");
979         }
980         if (have_flag(flgs, TR_ESP_ANIMAL))
981         {
982                 info[i++] = _("それは自然界の生物を感知する。", "It senses natural creatures.");
983         }
984         if (have_flag(flgs, TR_ESP_UNDEAD))
985         {
986                 info[i++] = _("それはアンデッドを感知する。", "It senses undead.");
987         }
988         if (have_flag(flgs, TR_ESP_DEMON))
989         {
990                 info[i++] = _("それは悪魔を感知する。", "It senses demons.");
991         }
992         if (have_flag(flgs, TR_ESP_ORC))
993         {
994                 info[i++] = _("それはオークを感知する。", "It senses orcs.");
995         }
996         if (have_flag(flgs, TR_ESP_TROLL))
997         {
998                 info[i++] = _("それはトロルを感知する。", "It senses trolls.");
999         }
1000         if (have_flag(flgs, TR_ESP_GIANT))
1001         {
1002                 info[i++] = _("それは巨人を感知する。", "It senses giants.");
1003         }
1004         if (have_flag(flgs, TR_ESP_DRAGON))
1005         {
1006                 info[i++] = _("それはドラゴンを感知する。", "It senses dragons.");
1007         }
1008         if (have_flag(flgs, TR_ESP_HUMAN))
1009         {
1010                 info[i++] = _("それは人間を感知する。", "It senses humans.");
1011         }
1012         if (have_flag(flgs, TR_ESP_EVIL))
1013         {
1014                 info[i++] = _("それは邪悪な存在を感知する。", "It senses evil creatures.");
1015         }
1016         if (have_flag(flgs, TR_ESP_GOOD))
1017         {
1018                 info[i++] = _("それは善良な存在を感知する。", "It senses good creatures.");
1019         }
1020         if (have_flag(flgs, TR_ESP_NONLIVING))
1021         {
1022                 info[i++] = _("それは活動する無生物体を感知する。", "It senses non-living creatures.");
1023         }
1024         if (have_flag(flgs, TR_ESP_UNIQUE))
1025         {
1026                 info[i++] = _("それは特別な強敵を感知する。", "It senses unique monsters.");
1027         }
1028         if (have_flag(flgs, TR_SLOW_DIGEST))
1029         {
1030                 info[i++] = _("それはあなたの新陳代謝を遅くする。", "It slows your metabolism.");
1031         }
1032         if (have_flag(flgs, TR_REGEN))
1033         {
1034                 info[i++] = _("それは体力回復力を強化する。", "It speeds your regenerative powers.");
1035         }
1036         if (have_flag(flgs, TR_WARNING))
1037         {
1038                 info[i++] = _("それは危険に対して警告を発する。", "It warns you of danger");
1039         }
1040         if (have_flag(flgs, TR_REFLECT))
1041         {
1042                 info[i++] = _("それは矢の呪文を反射する。", "It reflects bolt spells.");
1043         }
1044         if (have_flag(flgs, TR_SH_FIRE))
1045         {
1046                 info[i++] = _("それは炎のバリアを張る。", "It produces a fiery sheath.");
1047         }
1048         if (have_flag(flgs, TR_SH_ELEC))
1049         {
1050                 info[i++] = _("それは電気のバリアを張る。", "It produces an electric sheath.");
1051         }
1052         if (have_flag(flgs, TR_SH_COLD))
1053         {
1054                 info[i++] = _("それは冷気のバリアを張る。", "It produces a sheath of coldness.");
1055         }
1056         if (have_flag(flgs, TR_NO_MAGIC))
1057         {
1058                 info[i++] = _("それは反魔法バリアを張る。", "It produces an anti-magic shell.");
1059         }
1060         if (have_flag(flgs, TR_NO_TELE))
1061         {
1062                 info[i++] = _("それはテレポートを邪魔する。", "It prevents teleportation.");
1063         }
1064         if (have_flag(flgs, TR_XTRA_MIGHT))
1065         {
1066                 info[i++] = _("それは矢/ボルト/弾をより強力に発射することができる。", "It fires missiles with extra might.");
1067         }
1068         if (have_flag(flgs, TR_XTRA_SHOTS))
1069         {
1070                 info[i++] = _("それは矢/ボルト/弾を非常に早く発射することができる。", "It fires missiles excessively fast.");
1071         }
1072
1073         if (have_flag(flgs, TR_BLESSED))
1074         {
1075                 info[i++] = _("それは神に祝福されている。", "It has been blessed by the gods.");
1076         }
1077
1078         if (object_is_cursed(o_ptr))
1079         {
1080                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1081                 {
1082                         info[i++] = _("それは永遠の呪いがかけられている。", "It is permanently cursed.");
1083                 }
1084                 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1085                 {
1086                         info[i++] = _("それは強力な呪いがかけられている。", "It is heavily cursed.");
1087                 }
1088                 else
1089                 {
1090                         info[i++] = _("それは呪われている。", "It is cursed.");
1091
1092                         /*
1093                          * It's a trivial infomation since there is
1094                          * fake inscription {cursed}
1095                          */
1096                         trivial_info++;
1097                 }
1098         }
1099
1100         if ((have_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE))
1101         {
1102                 info[i++] = _("それは太古の禍々しい怨念が宿っている。", "It carries an ancient foul curse.");
1103         }
1104         if ((have_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE))
1105         {
1106                 info[i++] = _("それは付近のモンスターを怒らせる。", "It aggravates nearby creatures.");
1107         }
1108         if ((have_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP))
1109         {
1110                 info[i++] = _("それは経験値を吸い取る。", "It drains experience.");
1111         }
1112         if (o_ptr->curse_flags & TRC_SLOW_REGEN)
1113         {
1114                 info[i++] = _("それは回復力を弱める。", "It slows your regenerative powers.");
1115         }
1116         if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || have_flag(flgs, TR_ADD_L_CURSE))
1117         {
1118                 info[i++] = _("それは弱い呪いを増やす。","It adds weak curses.");
1119         }
1120         if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
1121         {
1122                 info[i++] = _("それは強力な呪いを増やす。","It adds heavy curses.");
1123         }
1124         if ((have_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL))
1125         {
1126                 info[i++] = _("それは動物を呼び寄せる。", "It attracts animals.");
1127         }
1128         if ((have_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON))
1129         {
1130                 info[i++] = _("それは悪魔を呼び寄せる。", "It attracts demons.");
1131         }
1132         if ((have_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON))
1133         {
1134                 info[i++] = _("それはドラゴンを呼び寄せる。", "It attracts dragons.");
1135         }
1136         if ((have_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD))
1137         {
1138                 info[i++] = _("それは死霊を呼び寄せる。", "It attracts undeads.");
1139         }
1140         if ((have_flag(flgs, TR_COWARDICE)) ||  (o_ptr->curse_flags & TRC_COWARDICE))
1141         {
1142                 info[i++] = _("それは恐怖感を引き起こす。", "It makes you subject to cowardice.");
1143         }
1144         if ((have_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT))
1145         {
1146                 info[i++] = _("それはランダムなテレポートを引き起こす。", "It induces random teleportation.");
1147         }
1148         if ((have_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE)
1149         {
1150                 info[i++] = _("それは攻撃を外しやすい。", "It causes you to miss blows.");
1151         }
1152         if ((have_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC))
1153         {
1154                 info[i++] = _("それは攻撃を受けやすい。", "It helps your enemies' blows.");
1155         }
1156         if ((have_flag(flgs, TR_LOW_MAGIC)) || (o_ptr->curse_flags & TRC_LOW_MAGIC))
1157         {
1158                 info[i++] = _("それは魔法を唱えにくくする。", "It encumbers you while spellcasting.");
1159         }
1160         if ((have_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST))
1161         {
1162                 info[i++] = _("それはあなたの新陳代謝を速くする。", "It speeds your metabolism.");
1163         }
1164         if ((have_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP))
1165         {
1166                 info[i++] = _("それはあなたの体力を吸い取る。", "It drains you.");
1167         }
1168         if ((have_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA))
1169         {
1170                 info[i++] = _("それはあなたの魔力を吸い取る。", "It drains your mana.");
1171         }
1172
1173         /* Describe about this kind of object instead of THIS fake object */
1174         if (mode & SCROBJ_FAKE_OBJECT)
1175         {
1176                 switch (o_ptr->tval)
1177                 {
1178                 case TV_RING:
1179                         switch (o_ptr->sval)
1180                         {
1181                         case SV_RING_LORDLY:
1182                                 info[i++] = _("それは幾つかのランダムな耐性を授ける。", "It provides some random resistances.");
1183                                 break;
1184                         case SV_RING_WARNING:
1185                                 info[i++] = _("それはひとつの低級なESPを授ける事がある。", "It may provide a low rank ESP.");
1186                                 break;
1187                         }
1188                         break;
1189
1190                 case TV_AMULET:
1191                         switch (o_ptr->sval)
1192                         {
1193                         case SV_AMULET_RESISTANCE:
1194                                 info[i++] = _("それは毒への耐性を授ける事がある。", "It may provides resistance to poison.");
1195                                 info[i++] = _("それはランダムな耐性を授ける事がある。", "It may provide a random resistances.");
1196                                 break;
1197                         case SV_AMULET_THE_MAGI:
1198                                 info[i++] = _("それは最大で3つまでの低級なESPを授ける。", "It provides up to three low rank ESPs.");
1199                                 break;
1200                         }
1201                         break;
1202                 }
1203         }
1204
1205         if (have_flag(flgs, TR_IGNORE_ACID) &&
1206             have_flag(flgs, TR_IGNORE_ELEC) &&
1207             have_flag(flgs, TR_IGNORE_FIRE) &&
1208             have_flag(flgs, TR_IGNORE_COLD))
1209         {
1210                 info[i++] = _("それは酸・電撃・火炎・冷気では傷つかない。", "It cannot be harmed by the elements.");
1211         }
1212         else
1213         {
1214                 if (have_flag(flgs, TR_IGNORE_ACID))
1215                 {
1216                         info[i++] = _("それは酸では傷つかない。", "It cannot be harmed by acid.");
1217                 }
1218                 if (have_flag(flgs, TR_IGNORE_ELEC))
1219                 {
1220                         info[i++] = _("それは電撃では傷つかない。", "It cannot be harmed by electricity.");
1221                 }
1222                 if (have_flag(flgs, TR_IGNORE_FIRE))
1223                 {
1224                         info[i++] = _("それは火炎では傷つかない。", "It cannot be harmed by fire.");
1225                 }
1226                 if (have_flag(flgs, TR_IGNORE_COLD))
1227                 {
1228                         info[i++] = _("それは冷気では傷つかない。", "It cannot be harmed by cold.");
1229                 }
1230         }
1231
1232         if (mode & SCROBJ_FORCE_DETAIL) trivial_info = 0;
1233
1234         /* No relevant informations */
1235         if (i <= trivial_info) return (FALSE);
1236
1237         /* Save the screen */
1238         screen_save();
1239
1240         /* Get size */
1241         Term_get_size(&wid, &hgt);
1242
1243         /* Display Item name */
1244         if (!(mode & SCROBJ_FAKE_OBJECT))
1245                 object_desc(o_name, o_ptr, 0);
1246         else
1247                 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1248
1249         prt(o_name, 0, 0);
1250
1251         /* Erase the screen */
1252         for (k = 1; k < hgt; k++) prt("", k, 13);
1253
1254         /* Label the information */
1255         if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1256         {
1257                 monster_race *r_ptr = &r_info[o_ptr->pval];
1258                 int namelen = strlen(r_name + r_ptr->name);
1259                 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1260                 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1261                 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1262         }
1263         else
1264         {
1265                 prt(_("     アイテムの能力:", "     Item Attributes:"), 1, 15);
1266         }
1267
1268         /* We will print on top of the map (column 13) */
1269         for (k = 2, j = 0; j < i; j++)
1270         {
1271                 /* Show the info */
1272                 prt(info[j], k++, 15);
1273
1274                 /* Every 20 entries (lines 2 to 21), start over */
1275                 if ((k == hgt - 2) && (j+1 < i))
1276                 {
1277                         prt(_("-- 続く --", "-- more --"), k, 15);
1278                         inkey();
1279                         for (; k > 2; k--) prt("", k, 15);
1280                 }
1281         }
1282
1283         /* Wait for it */
1284         prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 15);
1285
1286         inkey();
1287
1288         /* Restore the screen */
1289         screen_load();
1290
1291         /* Gave knowledge */
1292         return (TRUE);
1293 }
1294
1295
1296
1297 /*!
1298  * @brief オブジェクト選択時の選択アルファベットラベルを返す /
1299  * Convert an inventory index into a one character label
1300  * @param i プレイヤーの所持/装備オブジェクトID
1301  * @return 対応するアルファベット
1302  * @details Note that the label does NOT distinguish inven/equip.
1303  */
1304 char index_to_label(int i)
1305 {
1306         /* Indexes for "inven" are easy */
1307         if (i < INVEN_RARM) return (I2A(i));
1308
1309         /* Indexes for "equip" are offset */
1310         return (I2A(i - INVEN_RARM));
1311 }
1312
1313 /*!
1314  * @brief 選択アルファベットラベルからプレイヤーの所持オブジェクトIDを返す /
1315  * Convert a label into the index of an item in the "inven"
1316  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1317  * @details Note that the label does NOT distinguish inven/equip.
1318  */
1319 INVENTORY_IDX label_to_inven(int c)
1320 {
1321         INVENTORY_IDX i;
1322
1323         /* Convert */
1324         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1);
1325
1326         /* Verify the index */
1327         if ((i < 0) || (i > INVEN_PACK)) return (-1);
1328
1329         /* Empty slots can never be chosen */
1330         if (!inventory[i].k_idx) return (-1);
1331
1332         /* Return the index */
1333         return (i);
1334 }
1335
1336
1337 /*! See cmd5.c */
1338 extern bool select_ring_slot;
1339
1340
1341 /*!
1342  * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1343  * @param i プレイヤーの所持/装備オブジェクトID
1344  * @return 指輪枠ならばTRUEを返す。
1345  */
1346 static bool is_ring_slot(int i)
1347 {
1348         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1349 }
1350
1351
1352 /*!
1353  * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1354  * Convert a label into the index of a item in the "equip"
1355  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1356  */
1357 INVENTORY_IDX label_to_equip(int c)
1358 {
1359         INVENTORY_IDX i;
1360
1361         /* Convert */
1362         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1363
1364         /* Verify the index */
1365         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1366
1367         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1368
1369         /* Empty slots can never be chosen */
1370         if (!inventory[i].k_idx) return (-1);
1371
1372         /* Return the index */
1373         return (i);
1374 }
1375
1376
1377
1378 /*!
1379  * @brief オブジェクトの該当装備部位IDを返す /
1380  * Determine which equipment slot (if any) an item likes
1381  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
1382  * @return 対応する装備部位ID
1383  */
1384 s16b wield_slot(object_type *o_ptr)
1385 {
1386         /* Slot for equipment */
1387         switch (o_ptr->tval)
1388         {
1389                 case TV_DIGGING:
1390                 case TV_HAFTED:
1391                 case TV_POLEARM:
1392                 case TV_SWORD:
1393                 {
1394                         if (!inventory[INVEN_RARM].k_idx) return (INVEN_RARM);
1395                         if (inventory[INVEN_LARM].k_idx) return (INVEN_RARM);
1396                         return (INVEN_LARM);
1397                 }
1398
1399                 case TV_CAPTURE:
1400                 case TV_CARD:
1401                 case TV_SHIELD:
1402                 {
1403                         if (!inventory[INVEN_LARM].k_idx) return (INVEN_LARM);
1404                         if (inventory[INVEN_RARM].k_idx) return (INVEN_LARM);
1405                         return (INVEN_RARM);
1406                 }
1407
1408                 case TV_BOW:
1409                 {
1410                         return (INVEN_BOW);
1411                 }
1412
1413                 case TV_RING:
1414                 {
1415                         /* Use the right hand first */
1416                         if (!inventory[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
1417
1418                         /* Use the left hand for swapping (by default) */
1419                         return (INVEN_LEFT);
1420                 }
1421
1422                 case TV_AMULET:
1423                 case TV_WHISTLE:
1424                 {
1425                         return (INVEN_NECK);
1426                 }
1427
1428                 case TV_LITE:
1429                 {
1430                         return (INVEN_LITE);
1431                 }
1432
1433                 case TV_DRAG_ARMOR:
1434                 case TV_HARD_ARMOR:
1435                 case TV_SOFT_ARMOR:
1436                 {
1437                         return (INVEN_BODY);
1438                 }
1439
1440                 case TV_CLOAK:
1441                 {
1442                         return (INVEN_OUTER);
1443                 }
1444
1445                 case TV_CROWN:
1446                 case TV_HELM:
1447                 {
1448                         return (INVEN_HEAD);
1449                 }
1450
1451                 case TV_GLOVES:
1452                 {
1453                         return (INVEN_HANDS);
1454                 }
1455
1456                 case TV_BOOTS:
1457                 {
1458                         return (INVEN_FEET);
1459                 }
1460         }
1461
1462         /* No slot available */
1463         return (-1);
1464 }
1465
1466 /*!
1467  * @brief 所持/装備オブジェクトIDの部位表現を返す /
1468  * Return a string mentioning how a given item is carried
1469  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
1470  * @return 部位表現の文字列ポインタ
1471  */
1472 cptr mention_use(int i)
1473 {
1474         cptr p;
1475
1476         /* Examine the location */
1477         switch (i)
1478         {
1479 #ifdef JP
1480                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中" : ((p_ptr->ryoute && p_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手")); break;
1481 #else
1482                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
1483 #endif
1484
1485 #ifdef JP
1486                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中" : ((p_ptr->ryoute && p_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手")); break;
1487 #else
1488                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
1489 #endif
1490
1491 #ifdef JP
1492                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "運搬中" : "射撃用"; break;
1493 #else
1494                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "Just holding" : "Shooting"; break;
1495 #endif
1496
1497 #ifdef JP
1498                 case INVEN_RIGHT: p = (left_hander ? "左手指" : "右手指"); break;
1499 #else
1500                 case INVEN_RIGHT: p = (left_hander ? "On left hand" : "On right hand"); break;
1501 #endif
1502
1503 #ifdef JP
1504                 case INVEN_LEFT:  p = (left_hander ? "右手指" : "左手指"); break;
1505 #else
1506                 case INVEN_LEFT:  p = (left_hander ? "On right hand" : "On left hand"); break;
1507 #endif
1508
1509                 case INVEN_NECK:  p = _("  首", "Around neck"); break;
1510                 case INVEN_LITE:  p = _(" 光源", "Light source"); break;
1511                 case INVEN_BODY:  p = _("  体", "On body"); break;
1512                 case INVEN_OUTER: p = _("体の上", "About body"); break;
1513                 case INVEN_HEAD:  p = _("  頭", "On head"); break;
1514                 case INVEN_HANDS: p = _("  手", "On hands"); break;
1515                 case INVEN_FEET:  p = _("  足", "On feet"); break;
1516                 default:          p = _("ザック", "In pack"); break;
1517         }
1518
1519         /* Return the result */
1520         return p;
1521 }
1522
1523
1524 /*!
1525  * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
1526  * Return a string describing how a given item is being worn.
1527  * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
1528  * @return 状態表現内容の文字列ポインタ
1529  * @details
1530  * Currently, only used for items in the equipment, not inventory.
1531  */
1532 cptr describe_use(int i)
1533 {
1534         cptr p;
1535
1536         switch (i)
1537         {
1538 #ifdef JP
1539                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している")); break;
1540 #else
1541                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
1542 #endif
1543
1544 #ifdef JP
1545                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している")); break;
1546 #else
1547                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
1548 #endif
1549
1550 #ifdef JP
1551                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "持つだけで精一杯の" : "射撃用に装備している"; break;
1552 #else
1553                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "just holding" : "shooting missiles with"; break;
1554 #endif
1555
1556 #ifdef JP
1557                 case INVEN_RIGHT: p = (left_hander ? "左手の指にはめている" : "右手の指にはめている"); break;
1558 #else
1559                 case INVEN_RIGHT: p = (left_hander ? "wearing on your left hand" : "wearing on your right hand"); break;
1560 #endif
1561
1562 #ifdef JP
1563                 case INVEN_LEFT:  p = (left_hander ? "右手の指にはめている" : "左手の指にはめている"); break;
1564 #else
1565                 case INVEN_LEFT:  p = (left_hander ? "wearing on your right hand" : "wearing on your left hand"); break;
1566 #endif
1567
1568                 case INVEN_NECK:  p = _("首にかけている", "wearing around your neck"); break;
1569                 case INVEN_LITE:  p = _("光源にしている", "using to light the way"); break;
1570                 case INVEN_BODY:  p = _("体に着ている", "wearing on your body"); break;
1571                 case INVEN_OUTER: p = _("身にまとっている", "wearing on your back"); break;
1572                 case INVEN_HEAD:  p = _("頭にかぶっている", "wearing on your head"); break;
1573                 case INVEN_HANDS: p = _("手につけている", "wearing on your hands"); break;
1574                 case INVEN_FEET:  p = _("足にはいている", "wearing on your feet"); break;
1575                 default:          p = _("ザックに入っている", "carrying in your pack"); break;
1576         }
1577
1578         /* Return the result */
1579         return p;
1580 }
1581
1582
1583 /*!
1584  * @brief tval/sval指定のベースアイテムがプレイヤーの使用可能な魔法書かどうかを返す /
1585  * Hack: Check if a spellbook is one of the realms we can use. -- TY
1586  * @param book_tval ベースアイテムのtval
1587  * @param book_sval ベースアイテムのsval
1588  * @return 使用可能な魔法書ならばTRUEを返す。
1589  */
1590
1591 bool check_book_realm(const OBJECT_TYPE_VALUE book_tval, const OBJECT_SUBTYPE_VALUE book_sval)
1592 {
1593         if (book_tval < TV_LIFE_BOOK) return FALSE;
1594         if (p_ptr->pclass == CLASS_SORCERER)
1595         {
1596                 return is_magic(tval2realm(book_tval));
1597         }
1598         else if (p_ptr->pclass == CLASS_RED_MAGE)
1599         {
1600                 if (is_magic(tval2realm(book_tval)))
1601                         return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
1602         }
1603         return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
1604 }
1605
1606 /*!
1607  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1608  * Check an item against the item tester info
1609  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1610  * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1611  */
1612 bool item_tester_okay(object_type *o_ptr)
1613 {
1614         /* Hack -- allow listing empty slots */
1615         if (item_tester_full) return (TRUE);
1616
1617         /* Require an item */
1618         if (!o_ptr->k_idx) return (FALSE);
1619
1620         /* Hack -- ignore "gold" */
1621         if (o_ptr->tval == TV_GOLD)
1622         {
1623                 /* See xtra2.c */
1624                 extern bool show_gold_on_floor;
1625
1626                 if (!show_gold_on_floor) return (FALSE);
1627         }
1628
1629         /* Check the tval */
1630         if (item_tester_tval)
1631         {
1632                 /* Is it a spellbook? If so, we need a hack -- TY */
1633                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1634                         (item_tester_tval >= TV_LIFE_BOOK))
1635                         return check_book_realm(o_ptr->tval, o_ptr->sval);
1636                 else
1637                         if (item_tester_tval != o_ptr->tval) return (FALSE);
1638         }
1639
1640         /* Check the hook */
1641         if (item_tester_hook)
1642         {
1643                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1644         }
1645
1646         /* Assume okay */
1647         return (TRUE);
1648 }
1649
1650
1651 /*!
1652  * @brief 所持アイテム一覧を表示する /
1653  * Choice window "shadow" of the "show_inven()" function
1654  * @return なし
1655  */
1656 void display_inven(void)
1657 {
1658         register        int i, n, z = 0;
1659         object_type     *o_ptr;
1660         TERM_COLOR      attr = TERM_WHITE;
1661         char            tmp_val[80];
1662         char            o_name[MAX_NLEN];
1663         int             wid, hgt;
1664
1665         /* Get size */
1666         Term_get_size(&wid, &hgt);
1667
1668         /* Find the "final" slot */
1669         for (i = 0; i < INVEN_PACK; i++)
1670         {
1671                 o_ptr = &inventory[i];
1672
1673                 /* Skip non-objects */
1674                 if (!o_ptr->k_idx) continue;
1675
1676                 /* Track */
1677                 z = i + 1;
1678         }
1679
1680         /* Display the pack */
1681         for (i = 0; i < z; i++)
1682         {
1683                 /* Examine the item */
1684                 o_ptr = &inventory[i];
1685
1686                 /* Start with an empty "index" */
1687                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1688
1689                 /* Is this item "acceptable"? */
1690                 if (item_tester_okay(o_ptr))
1691                 {
1692                         /* Prepare an "index" */
1693                         tmp_val[0] = index_to_label(i);
1694
1695                         /* Bracket the "index" --(-- */
1696                         tmp_val[1] = ')';
1697                 }
1698
1699                 /* Display the index (or blank space) */
1700                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1701
1702                 /* Obtain an item description */
1703                 object_desc(o_name, o_ptr, 0);
1704
1705                 /* Obtain the length of the description */
1706                 n = strlen(o_name);
1707
1708                 /* Get a color */
1709                 attr = tval_to_attr[o_ptr->tval % 128];
1710
1711                 /* Grey out charging items */
1712                 if (o_ptr->timeout)
1713                 {
1714                         attr = TERM_L_DARK;
1715                 }
1716
1717                 /* Display the entry itself */
1718                 Term_putstr(3, i, n, attr, o_name);
1719
1720                 /* Erase the rest of the line */
1721                 Term_erase(3+n, i, 255);
1722
1723                 /* Display the weight if needed */
1724                 if (show_weights)
1725                 {
1726                         int wgt = o_ptr->weight * o_ptr->number;
1727 #ifdef JP
1728                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt),lbtokg2(wgt) );
1729 #else
1730                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1731 #endif
1732
1733                         prt(tmp_val, i, wid - 9);
1734                 }
1735         }
1736
1737         /* Erase the rest of the window */
1738         for (i = z; i < hgt; i++)
1739         {
1740                 /* Erase the line */
1741                 Term_erase(0, i, 255);
1742         }
1743 }
1744
1745
1746
1747 /*!
1748  * @brief 装備アイテム一覧を表示する /
1749  * Choice window "shadow" of the "show_equip()" function
1750  * @return なし
1751  */
1752 void display_equip(void)
1753 {
1754         register        int i, n;
1755         object_type     *o_ptr;
1756         TERM_COLOR      attr = TERM_WHITE;
1757         char            tmp_val[80];
1758         char            o_name[MAX_NLEN];
1759         int             wid, hgt;
1760
1761         /* Get size */
1762         Term_get_size(&wid, &hgt);
1763
1764         /* Display the equipment */
1765         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1766         {
1767                 /* Examine the item */
1768                 o_ptr = &inventory[i];
1769
1770                 /* Start with an empty "index" */
1771                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1772
1773                 /* Is this item "acceptable"? */
1774                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1775                 {
1776                         /* Prepare an "index" */
1777                         tmp_val[0] = index_to_label(i);
1778
1779                         /* Bracket the "index" --(-- */
1780                         tmp_val[1] = ')';
1781                 }
1782
1783                 /* Display the index (or blank space) */
1784                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1785
1786                 /* Obtain an item description */
1787                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1788                 {
1789                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1790                         attr = TERM_WHITE;
1791                 }
1792                 else
1793                 {
1794                         object_desc(o_name, o_ptr, 0);
1795                         attr = tval_to_attr[o_ptr->tval % 128];
1796                 }
1797
1798                 /* Obtain the length of the description */
1799                 n = strlen(o_name);
1800
1801                 /* Grey out charging items */
1802                 if (o_ptr->timeout)
1803                 {
1804                         attr = TERM_L_DARK;
1805                 }
1806
1807                 /* Display the entry itself */
1808                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1809
1810                 /* Erase the rest of the line */
1811                 Term_erase(3+n, i - INVEN_RARM, 255);
1812
1813                 /* Display the weight (if needed) */
1814                 if (show_weights)
1815                 {
1816                         int wgt = o_ptr->weight * o_ptr->number;
1817 #ifdef JP
1818                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1819 #else
1820                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1821 #endif
1822
1823                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1824                 }
1825
1826                 /* Display the slot description (if needed) */
1827                 if (show_labels)
1828                 {
1829                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1830                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
1831                 }
1832         }
1833
1834         /* Erase the rest of the window */
1835         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1836         {
1837                 /* Clear that line */
1838                 Term_erase(0, i, 255);
1839         }
1840 }
1841
1842
1843 /*!
1844  * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1845  * Find the "first" inventory object with the given "tag".
1846  * @param cp 対応するタグIDを与える参照ポインタ
1847  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1848  * @param mode 所持、装備の切り替え
1849  * @return タグに該当するオブジェクトがあるならTRUEを返す
1850  * @details
1851  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1852  * inscription of an object.  Alphabetical characters don't work as a\n
1853  * tag in this form.\n
1854  *\n
1855  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1856  * and "x" is the "current" command_cmd code.\n
1857  */
1858 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1859 {
1860         COMMAND_CODE i;
1861         COMMAND_CODE start, end;
1862         cptr s;
1863
1864         /* Extract index from mode */
1865         switch (mode)
1866         {
1867         case USE_EQUIP:
1868                 start = INVEN_RARM;
1869                 end = INVEN_TOTAL - 1;
1870                 break;
1871
1872         case USE_INVEN:
1873                 start = 0;
1874                 end = INVEN_PACK - 1;
1875                 break;
1876
1877         default:
1878                 return FALSE;
1879         }
1880
1881         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1882
1883         /* Check every inventory object */
1884         for (i = start; i <= end; i++)
1885         {
1886                 object_type *o_ptr = &inventory[i];
1887
1888                 /* Skip non-objects */
1889                 if (!o_ptr->k_idx) continue;
1890
1891                 /* Skip empty inscriptions */
1892                 if (!o_ptr->inscription) continue;
1893
1894                 /* Skip non-choice */
1895                 if (!item_tester_okay(o_ptr)) continue;
1896
1897                 /* Find a '@' */
1898                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1899
1900                 /* Process all tags */
1901                 while (s)
1902                 {
1903                         /* Check the special tags */
1904                         if ((s[1] == command_cmd) && (s[2] == tag))
1905                         {
1906                                 /* Save the actual inventory ID */
1907                                 *cp = i;
1908
1909                                 /* Success */
1910                                 return (TRUE);
1911                         }
1912
1913                         /* Find another '@' */
1914                         s = my_strchr(s + 1, '@');
1915                 }
1916         }
1917
1918
1919         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1920
1921         /* Don't allow {@#} with '#' being alphabet */
1922         if (tag < '0' || '9' < tag)
1923         {
1924                 /* No such tag */
1925                 return FALSE;
1926         }
1927
1928         /* Check every object */
1929         for (i = start; i <= end; i++)
1930         {
1931                 object_type *o_ptr = &inventory[i];
1932
1933                 /* Skip non-objects */
1934                 if (!o_ptr->k_idx) continue;
1935
1936                 /* Skip empty inscriptions */
1937                 if (!o_ptr->inscription) continue;
1938
1939                 /* Skip non-choice */
1940                 if (!item_tester_okay(o_ptr)) continue;
1941
1942                 /* Find a '@' */
1943                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1944
1945                 /* Process all tags */
1946                 while (s)
1947                 {
1948                         /* Check the normal tags */
1949                         if (s[1] == tag)
1950                         {
1951                                 /* Save the actual inventory ID */
1952                                 *cp = i;
1953
1954                                 /* Success */
1955                                 return (TRUE);
1956                         }
1957
1958                         /* Find another '@' */
1959                         s = my_strchr(s + 1, '@');
1960                 }
1961         }
1962
1963         /* No such tag */
1964         return (FALSE);
1965 }
1966
1967
1968 /*!
1969  * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1970  * Find the "first" inventory object with the given "tag".
1971  * @param cp 対応するタグIDを与える参照ポインタ
1972  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1973  * @param floor_list 床上アイテムの配列
1974  * @param floor_num  床上アイテムの配列ID
1975  * @return タグに該当するオブジェクトがあるならTRUEを返す
1976  * @details
1977  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1978  * inscription of an object.  Alphabetical characters don't work as a\n
1979  * tag in this form.\n
1980  *\n
1981  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1982  * and "x" is the "current" command_cmd code.\n
1983  */
1984 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1985 {
1986         COMMAND_CODE i;
1987         cptr s;
1988
1989         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1990
1991         /* Check every object in the grid */
1992         for (i = 0; i < floor_num && i < 23; i++)
1993         {
1994                 object_type *o_ptr = &o_list[floor_list[i]];
1995
1996                 /* Skip empty inscriptions */
1997                 if (!o_ptr->inscription) continue;
1998
1999                 /* Find a '@' */
2000                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2001
2002                 /* Process all tags */
2003                 while (s)
2004                 {
2005                         /* Check the special tags */
2006                         if ((s[1] == command_cmd) && (s[2] == tag))
2007                         {
2008                                 /* Save the actual floor object ID */
2009                                 *cp = i;
2010
2011                                 /* Success */
2012                                 return (TRUE);
2013                         }
2014
2015                         /* Find another '@' */
2016                         s = my_strchr(s + 1, '@');
2017                 }
2018         }
2019
2020
2021         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
2022
2023         /* Don't allow {@#} with '#' being alphabet */
2024         if (tag < '0' || '9' < tag)
2025         {
2026                 /* No such tag */
2027                 return FALSE;
2028         }
2029
2030         /* Check every object in the grid */
2031         for (i = 0; i < floor_num && i < 23; i++)
2032         {
2033                 object_type *o_ptr = &o_list[floor_list[i]];
2034
2035                 /* Skip empty inscriptions */
2036                 if (!o_ptr->inscription) continue;
2037
2038                 /* Find a '@' */
2039                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2040
2041                 /* Process all tags */
2042                 while (s)
2043                 {
2044                         /* Check the normal tags */
2045                         if (s[1] == tag)
2046                         {
2047                                 /* Save the floor object ID */
2048                                 *cp = i;
2049
2050                                 /* Success */
2051                                 return (TRUE);
2052                         }
2053
2054                         /* Find another '@' */
2055                         s = my_strchr(s + 1, '@');
2056                 }
2057         }
2058
2059         /* No such tag */
2060         return (FALSE);
2061 }
2062
2063
2064 /*!
2065  * @brief タグIDにあわせてタグアルファベットのリストを返す /
2066  * Move around label characters with correspond tags
2067  * @param label ラベルリストを取得する文字列参照ポインタ
2068  * @param mode 所持品リストか装備品リストかの切り替え
2069  * @return なし
2070  */
2071 static void prepare_label_string(char *label, BIT_FLAGS mode)
2072 {
2073         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2074         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
2075         int  i;
2076
2077         /* Prepare normal labels */
2078         strcpy(label, alphabet_chars);
2079
2080         /* Move each label */
2081         for (i = 0; i < 52; i++)
2082         {
2083                 COMMAND_CODE index;
2084                 char c = alphabet_chars[i];
2085
2086                 /* Find a tag with this label */
2087                 if (get_tag(&index, c, mode))
2088                 {
2089                         /* Delete the overwritten label */
2090                         if (label[i] == c) label[i] = ' ';
2091
2092                         /* Move the label to the place of corresponding tag */
2093                         label[index - offset] = c;
2094                 }
2095         }
2096 }
2097
2098
2099 /*!
2100  * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2101  * Move around label characters with correspond tags (floor version)
2102  * @param label ラベルリストを取得する文字列参照ポインタ
2103  * @param floor_list 床上アイテムの配列
2104  * @param floor_num  床上アイテムの配列ID
2105  * @return なし
2106  */
2107 /*
2108  */
2109 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
2110 {
2111         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2112         int  i;
2113
2114         /* Prepare normal labels */
2115         strcpy(label, alphabet_chars);
2116
2117         /* Move each label */
2118         for (i = 0; i < 52; i++)
2119         {
2120                 COMMAND_CODE index;
2121                 char c = alphabet_chars[i];
2122
2123                 /* Find a tag with this label */
2124                 if (get_tag_floor(&index, c, floor_list, floor_num))
2125                 {
2126                         /* Delete the overwritten label */
2127                         if (label[i] == c) label[i] = ' ';
2128
2129                         /* Move the label to the place of corresponding tag */
2130                         label[index] = c;
2131                 }
2132         }
2133 }
2134
2135
2136 /*!
2137  * @brief 所持アイテムの表示を行う /
2138  * Display the inventory.
2139  * @param target_item アイテムの選択処理を行うか否か。
2140  * @return 選択したアイテムのタグ
2141  * @details
2142  * Hack -- do not display "trailing" empty slots
2143  */
2144 COMMAND_CODE show_inven(int target_item)
2145 {
2146         COMMAND_CODE i;
2147         int j, k, l, z = 0;
2148         int             col, cur_col, len;
2149         object_type     *o_ptr;
2150         char            o_name[MAX_NLEN];
2151         char            tmp_val[80];
2152         COMMAND_CODE    out_index[23];
2153         TERM_COLOR      out_color[23];
2154         char            out_desc[23][MAX_NLEN];
2155         COMMAND_CODE target_item_label = 0;
2156         TERM_LEN wid, hgt;
2157         char            inven_label[52 + 1];
2158
2159         /* Starting column */
2160         col = command_gap;
2161
2162         /* Get size */
2163         Term_get_size(&wid, &hgt);
2164
2165         /* Default "max-length" */
2166         len = wid - col - 1;
2167
2168
2169         /* Find the "final" slot */
2170         for (i = 0; i < INVEN_PACK; i++)
2171         {
2172                 o_ptr = &inventory[i];
2173
2174                 /* Skip non-objects */
2175                 if (!o_ptr->k_idx) continue;
2176
2177                 /* Track */
2178                 z = i + 1;
2179         }
2180
2181         prepare_label_string(inven_label, USE_INVEN);
2182
2183         /* Display the inventory */
2184         for (k = 0, i = 0; i < z; i++)
2185         {
2186                 o_ptr = &inventory[i];
2187
2188                 /* Is this item acceptable? */
2189                 if (!item_tester_okay(o_ptr)) continue;
2190
2191                 /* Describe the object */
2192                 object_desc(o_name, o_ptr, 0);
2193
2194                 /* Save the object index, color, and description */
2195                 out_index[k] = i;
2196                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2197
2198                 /* Grey out charging items */
2199                 if (o_ptr->timeout)
2200                 {
2201                         out_color[k] = TERM_L_DARK;
2202                 }
2203
2204                 (void)strcpy(out_desc[k], o_name);
2205
2206                 /* Find the predicted "line length" */
2207                 l = strlen(out_desc[k]) + 5;
2208
2209                 /* Be sure to account for the weight */
2210                 if (show_weights) l += 9;
2211
2212                 /* Account for icon if displayed */
2213                 if (show_item_graph)
2214                 {
2215                         l += 2;
2216                         if (use_bigtile) l++;
2217                 }
2218
2219                 /* Maintain the maximum length */
2220                 if (l > len) len = l;
2221
2222                 /* Advance to next "line" */
2223                 k++;
2224         }
2225
2226         /* Find the column to start in */
2227         col = (len > wid - 4) ? 0 : (wid - len - 1);
2228
2229         /* Output each entry */
2230         for (j = 0; j < k; j++)
2231         {
2232                 /* Get the index */
2233                 i = out_index[j];
2234
2235                 /* Get the item */
2236                 o_ptr = &inventory[i];
2237
2238                 /* Clear the line */
2239                 prt("", j + 1, col ? col - 2 : col);
2240
2241                 if (use_menu && target_item)
2242                 {
2243                         if (j == (target_item-1))
2244                         {
2245                                 strcpy(tmp_val, _("》", "> "));
2246                                 target_item_label = i;
2247                         }
2248                         else strcpy(tmp_val, "  ");
2249                 }
2250                 else if (i <= INVEN_PACK)
2251                 {
2252                         /* Prepare an index --(-- */
2253                         sprintf(tmp_val, "%c)", inven_label[i]);
2254                 }
2255                 else
2256                 {
2257                         /* Prepare an index --(-- */
2258                         sprintf(tmp_val, "%c)", index_to_label(i));
2259                 }
2260
2261                 /* Clear the line with the (possibly indented) index */
2262                 put_str(tmp_val, j + 1, col);
2263
2264                 cur_col = col + 3;
2265
2266                 /* Display graphics for object, if desired */
2267                 if (show_item_graph)
2268                 {
2269                         byte  a = object_attr(o_ptr);
2270                         char c = object_char(o_ptr);
2271                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2272                         if (use_bigtile) cur_col++;
2273
2274                         cur_col += 2;
2275                 }
2276
2277
2278                 /* Display the entry itself */
2279                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2280
2281                 /* Display the weight if needed */
2282                 if (show_weights)
2283                 {
2284                         int wgt = o_ptr->weight * o_ptr->number;
2285 #ifdef JP
2286                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2287 #else
2288                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2289 #endif
2290
2291                         prt(tmp_val, j + 1, wid - 9);
2292                 }
2293         }
2294
2295         /* Make a "shadow" below the list (only if needed) */
2296         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2297
2298         /* Save the new column */
2299         command_gap = col;
2300
2301         return target_item_label;
2302 }
2303
2304
2305 /*!
2306  * @brief 装備アイテムの表示を行う /
2307  * Display the equipment.
2308  * @param target_item アイテムの選択処理を行うか否か。
2309  * @return 選択したアイテムのタグ
2310  */
2311 COMMAND_CODE show_equip(int target_item)
2312 {
2313         COMMAND_CODE i;
2314         int j, k, l;
2315         int             col, cur_col, len;
2316         object_type     *o_ptr;
2317         char            tmp_val[80];
2318         char            o_name[MAX_NLEN];
2319         COMMAND_CODE    out_index[23];
2320         TERM_COLOR      out_color[23];
2321         char            out_desc[23][MAX_NLEN];
2322         COMMAND_CODE target_item_label = 0;
2323         TERM_LEN wid, hgt;
2324         char            equip_label[52 + 1];
2325
2326         /* Starting column */
2327         col = command_gap;
2328
2329         /* Get size */
2330         Term_get_size(&wid, &hgt);
2331
2332         /* Maximal length */
2333         len = wid - col - 1;
2334
2335
2336         /* Scan the equipment list */
2337         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2338         {
2339                 o_ptr = &inventory[i];
2340
2341                 /* Is this item acceptable? */
2342                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr)) &&
2343                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2344                      item_tester_no_ryoute)) continue;
2345
2346                 /* Description */
2347                 object_desc(o_name, o_ptr, 0);
2348
2349                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2350                 {
2351                         (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2352                         out_color[k] = TERM_WHITE;
2353                 }
2354                 else
2355                 {
2356                         (void)strcpy(out_desc[k], o_name);
2357                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
2358                 }
2359
2360                 out_index[k] = i;
2361                 /* Grey out charging items */
2362                 if (o_ptr->timeout)
2363                 {
2364                         out_color[k] = TERM_L_DARK;
2365                 }
2366
2367                 /* Extract the maximal length (see below) */
2368 #ifdef JP
2369                 l = strlen(out_desc[k]) + (2 + 1);
2370 #else
2371                 l = strlen(out_desc[k]) + (2 + 3);
2372 #endif
2373
2374
2375                 /* Increase length for labels (if needed) */
2376 #ifdef JP
2377                 if (show_labels) l += (7 + 2);
2378 #else
2379                 if (show_labels) l += (14 + 2);
2380 #endif
2381
2382
2383                 /* Increase length for weight (if needed) */
2384                 if (show_weights) l += 9;
2385
2386                 if (show_item_graph) l += 2;
2387
2388                 /* Maintain the max-length */
2389                 if (l > len) len = l;
2390
2391                 /* Advance the entry */
2392                 k++;
2393         }
2394
2395         /* Hack -- Find a column to start in */
2396 #ifdef JP
2397         col = (len > wid - 6) ? 0 : (wid - len - 1);
2398 #else
2399         col = (len > wid - 4) ? 0 : (wid - len - 1);
2400 #endif
2401
2402         prepare_label_string(equip_label, USE_EQUIP);
2403
2404         /* Output each entry */
2405         for (j = 0; j < k; j++)
2406         {
2407                 /* Get the index */
2408                 i = out_index[j];
2409
2410                 /* Get the item */
2411                 o_ptr = &inventory[i];
2412
2413                 /* Clear the line */
2414                 prt("", j + 1, col ? col - 2 : col);
2415
2416                 if (use_menu && target_item)
2417                 {
2418                         if (j == (target_item-1))
2419                         {
2420                                 strcpy(tmp_val, _("》", "> "));
2421                                 target_item_label = i;
2422                         }
2423                         else strcpy(tmp_val, "  ");
2424                 }
2425                 else if (i >= INVEN_RARM)
2426                 {
2427                         /* Prepare an index --(-- */
2428                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2429                 }
2430                 else /* Paranoia */
2431                 {
2432                         /* Prepare an index --(-- */
2433                         sprintf(tmp_val, "%c)", index_to_label(i));
2434                 }
2435
2436                 /* Clear the line with the (possibly indented) index */
2437                 put_str(tmp_val, j+1, col);
2438
2439                 cur_col = col + 3;
2440
2441                 /* Display graphics for object, if desired */
2442                 if (show_item_graph)
2443                 {
2444                         byte a = object_attr(o_ptr);
2445                         char c = object_char(o_ptr);
2446                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2447                         if (use_bigtile) cur_col++;
2448
2449                         cur_col += 2;
2450                 }
2451
2452                 /* Use labels */
2453                 if (show_labels)
2454                 {
2455                         /* Mention the use */
2456                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2457
2458                         put_str(tmp_val, j+1, cur_col);
2459
2460                         /* Display the entry itself */
2461                         c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2462                 }
2463
2464                 /* No labels */
2465                 else
2466                 {
2467                         /* Display the entry itself */
2468                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2469                 }
2470
2471                 /* Display the weight if needed */
2472                 if (show_weights)
2473                 {
2474                         int wgt = o_ptr->weight * o_ptr->number;
2475 #ifdef JP
2476                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2477 #else
2478                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2479 #endif
2480
2481                         prt(tmp_val, j + 1, wid - 9);
2482                 }
2483         }
2484
2485         /* Make a "shadow" below the list (only if needed) */
2486         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2487
2488         /* Save the new column */
2489         command_gap = col;
2490
2491         return target_item_label;
2492 }
2493
2494 /*!
2495  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2496  * Flip "inven" and "equip" in any sub-windows
2497  * @return なし
2498  */
2499 void toggle_inven_equip(void)
2500 {
2501         int j;
2502
2503         /* Scan windows */
2504         for (j = 0; j < 8; j++)
2505         {
2506                 /* Unused */
2507                 if (!angband_term[j]) continue;
2508
2509                 /* Flip inven to equip */
2510                 if (window_flag[j] & (PW_INVEN))
2511                 {
2512                         /* Flip flags */
2513                         window_flag[j] &= ~(PW_INVEN);
2514                         window_flag[j] |= (PW_EQUIP);
2515
2516                         p_ptr->window |= (PW_EQUIP);
2517                 }
2518
2519                 /* Flip inven to equip */
2520                 else if (window_flag[j] & (PW_EQUIP))
2521                 {
2522                         /* Flip flags */
2523                         window_flag[j] &= ~(PW_EQUIP);
2524                         window_flag[j] |= (PW_INVEN);
2525
2526                         p_ptr->window |= (PW_INVEN);
2527                 }
2528         }
2529 }
2530
2531 /*!
2532  * @brief 選択したアイテムの確認処理の補助 /
2533  * Verify the choice of an item.
2534  * @param prompt メッセージ表示の一部
2535  * @param item 選択アイテムID
2536  * @return 確認がYesならTRUEを返す。
2537  * @details The item can be negative to mean "item on floor".
2538  */
2539 static bool verify(cptr prompt, INVENTORY_IDX item)
2540 {
2541         char        o_name[MAX_NLEN];
2542         char        out_val[MAX_NLEN+20];
2543         object_type *o_ptr;
2544
2545
2546         /* Inventory */
2547         if (item >= 0)
2548         {
2549                 o_ptr = &inventory[item];
2550         }
2551
2552         /* Floor */
2553         else
2554         {
2555                 o_ptr = &o_list[0 - item];
2556         }
2557
2558         /* Describe */
2559         object_desc(o_name, o_ptr, 0);
2560
2561         /* Prompt */
2562         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2563
2564         /* Query */
2565         return (get_check(out_val));
2566 }
2567
2568
2569 /*!
2570  * @brief 選択したアイテムの確認処理のメインルーチン /
2571  * @param item 選択アイテムID
2572  * @return 確認がYesならTRUEを返す。
2573  * @details The item can be negative to mean "item on floor".
2574  * Hack -- allow user to "prevent" certain choices
2575  */
2576 static bool get_item_allow(INVENTORY_IDX item)
2577 {
2578         cptr s;
2579
2580         object_type *o_ptr;
2581
2582         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2583
2584         /* Inventory */
2585         if (item >= 0)
2586         {
2587                 o_ptr = &inventory[item];
2588         }
2589
2590         /* Floor */
2591         else
2592         {
2593                 o_ptr = &o_list[0 - item];
2594         }
2595
2596         /* No inscription */
2597         if (!o_ptr->inscription) return (TRUE);
2598
2599         /* Find a '!' */
2600         s = my_strchr(quark_str(o_ptr->inscription), '!');
2601
2602         /* Process preventions */
2603         while (s)
2604         {
2605                 /* Check the "restriction" */
2606                 if ((s[1] == command_cmd) || (s[1] == '*'))
2607                 {
2608                         /* Verify the choice */
2609                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2610                 }
2611
2612                 /* Find another '!' */
2613                 s = my_strchr(s + 1, '!');
2614         }
2615
2616         /* Allow it */
2617         return (TRUE);
2618 }
2619
2620
2621 /*!
2622  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2623  * Auxiliary function for "get_item()" -- test an index
2624  * @param i 選択アイテムID
2625  * @return 正規のIDならばTRUEを返す。
2626  */
2627 static bool get_item_okay(OBJECT_IDX i)
2628 {
2629         /* Illegal items */
2630         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2631
2632         if (select_ring_slot) return is_ring_slot(i);
2633
2634         /* Verify the item */
2635         if (!item_tester_okay(&inventory[i])) return (FALSE);
2636
2637         /* Assume okay */
2638         return (TRUE);
2639 }
2640
2641 /*!
2642  * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2643  * Determine whether get_item() can get some item or not
2644  * @return アイテムを拾えるならばTRUEを返す。
2645  * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2646  */
2647 bool can_get_item(void)
2648 {
2649         int j;
2650         OBJECT_IDX floor_list[23];
2651         ITEM_NUMBER floor_num = 0;
2652
2653         for (j = 0; j < INVEN_TOTAL; j++)
2654                 if (item_tester_okay(&inventory[j]))
2655                         return TRUE;
2656
2657         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2658         if (floor_num)
2659                 return TRUE;
2660
2661         return FALSE;
2662 }
2663
2664 /*!
2665  * @brief オブジェクト選択の汎用関数 /
2666  * Let the user select an item, save its "index"
2667  * @param cp 選択したオブジェクトのIDを返す。
2668  * @param pmt 選択目的のメッセージ
2669  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2670  * @param mode オプションフラグ
2671  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2672  * Return TRUE only if an acceptable item was chosen by the user.\n
2673  * @details
2674  * The selected item must satisfy the "item_tester_hook()" function,\n
2675  * if that hook is set, and the "item_tester_tval", if that value is set.\n
2676  *\n
2677  * All "item_tester" restrictions are cleared before this function returns.\n
2678  *\n
2679  * The user is allowed to choose acceptable items from the equipment,\n
2680  * inventory, or floor, respectively, if the proper flag was given,\n
2681  * and there are any acceptable items in that location.\n
2682  *\n
2683  * The equipment or inventory are displayed (even if no acceptable\n
2684  * items are in that location) if the proper flag was given.\n
2685  *\n
2686  * If there are no acceptable items available anywhere, and "str" is\n
2687  * not NULL, then it will be used as the text of a warning message\n
2688  * before the function returns.\n
2689  *\n
2690  * Note that the user must press "-" to specify the item on the floor,\n
2691  * and there is no way to "examine" the item on the floor, while the\n
2692  * use of "capital" letters will "examine" an inventory/equipment item,\n
2693  * and prompt for its use.\n
2694  *\n
2695  * If a legal item is selected from the inventory, we save it in "cp"\n
2696  * directly (0 to 35), and return TRUE.\n
2697  *\n
2698  * If a legal item is selected from the floor, we save it in "cp" as\n
2699  * a negative (-1 to -511), and return TRUE.\n
2700  *\n
2701  * If no item is available, we do nothing to "cp", and we display a\n
2702  * warning message, using "str" if available, and return FALSE.\n
2703  *\n
2704  * If no item is selected, we do nothing to "cp", and return FALSE.\n
2705  *\n
2706  * Global "p_ptr->command_new" is used when viewing the inventory or equipment\n
2707  * to allow the user to enter a command while viewing those screens, and\n
2708  * also to induce "auto-enter" of stores, and other such stuff.\n
2709  *\n
2710  * Global "p_ptr->command_see" may be set before calling this function to start\n
2711  * out in "browse" mode.  It is cleared before this function returns.\n
2712  *\n
2713  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2714  * If it is TRUE then we are viewing inventory, else equipment.\n
2715  *\n
2716  * We always erase the prompt when we are done, leaving a blank line,\n
2717  * or a warning message, if appropriate, if no items are available.\n
2718  */
2719 bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
2720 {
2721         OBJECT_IDX this_o_idx, next_o_idx = 0;
2722
2723         char which = ' ';
2724
2725         int j;
2726         OBJECT_IDX k;
2727         OBJECT_IDX i1, i2;
2728         OBJECT_IDX e1, e2;
2729
2730         bool done, item;
2731
2732         bool oops = FALSE;
2733
2734         bool equip = FALSE;
2735         bool inven = FALSE;
2736         bool floor = FALSE;
2737
2738         bool allow_floor = FALSE;
2739
2740         bool toggle = FALSE;
2741
2742         char tmp_val[160];
2743         char out_val[160];
2744
2745         /* See cmd5.c */
2746         extern bool select_the_force;
2747
2748         int menu_line = (use_menu ? 1 : 0);
2749         int max_inven = 0;
2750         int max_equip = 0;
2751
2752         static char prev_tag = '\0';
2753         char cur_tag = '\0';
2754
2755 #ifdef ALLOW_EASY_FLOOR /* TNB */
2756
2757         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2758
2759 #endif /* ALLOW_EASY_FLOOR -- TNB */
2760
2761         /* Extract args */
2762         if (mode & USE_EQUIP) equip = TRUE;
2763         if (mode & USE_INVEN) inven = TRUE;
2764         if (mode & USE_FLOOR) floor = TRUE;
2765
2766         /* Get the item index */
2767         if (repeat_pull(cp))
2768         {
2769                 /* the_force */
2770                 if (select_the_force && (*cp == INVEN_FORCE))
2771                 {
2772                         item_tester_tval = 0;
2773                         item_tester_hook = NULL;
2774                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2775                         return (TRUE);
2776                 }
2777
2778                 /* Floor item? */
2779                 else if (floor && (*cp < 0))
2780                 {
2781                         object_type *o_ptr;
2782
2783                         /* Special index */
2784                         k = 0 - (*cp);
2785
2786                         /* Acquire object */
2787                         o_ptr = &o_list[k];
2788
2789                         /* Validate the item */
2790                         if (item_tester_okay(o_ptr))
2791                         {
2792                                 /* Forget restrictions */
2793                                 item_tester_tval = 0;
2794                                 item_tester_hook = NULL;
2795                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2796
2797                                 /* Success */
2798                                 return TRUE;
2799                         }
2800                 }
2801
2802                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2803                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2804                 {
2805                         if (prev_tag && command_cmd)
2806                         {
2807                                 /* Look up the tag and validate the item */
2808                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2809                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2810                                 else if (!get_item_okay(k)) /* Reject */;
2811                                 else
2812                                 {
2813                                         /* Accept that choice */
2814                                         (*cp) = k;
2815
2816                                         /* Forget restrictions */
2817                                         item_tester_tval = 0;
2818                                         item_tester_hook = NULL;
2819                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2820
2821                                         /* Success */
2822                                         return TRUE;
2823                                 }
2824
2825                                 prev_tag = '\0'; /* prev_tag is no longer effective */
2826                         }
2827
2828                         /* Verify the item */
2829                         else if (get_item_okay(*cp))
2830                         {
2831                                 /* Forget restrictions */
2832                                 item_tester_tval = 0;
2833                                 item_tester_hook = NULL;
2834                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2835
2836                                 /* Success */
2837                                 return TRUE;
2838                         }
2839                 }
2840         }
2841
2842
2843         /* Paranoia */
2844         msg_print(NULL);
2845
2846
2847         /* Not done */
2848         done = FALSE;
2849
2850         /* No item selected */
2851         item = FALSE;
2852
2853
2854         /* Full inventory */
2855         i1 = 0;
2856         i2 = INVEN_PACK - 1;
2857
2858         /* Forbid inventory */
2859         if (!inven) i2 = -1;
2860         else if (use_menu)
2861         {
2862                 for (j = 0; j < INVEN_PACK; j++)
2863                         if (item_tester_okay(&inventory[j])) max_inven++;
2864         }
2865
2866         /* Restrict inventory indexes */
2867         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2868         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2869
2870
2871         /* Full equipment */
2872         e1 = INVEN_RARM;
2873         e2 = INVEN_TOTAL - 1;
2874
2875         /* Forbid equipment */
2876         if (!equip) e2 = -1;
2877         else if (use_menu)
2878         {
2879                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2880                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
2881                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
2882         }
2883
2884         /* Restrict equipment indexes */
2885         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2886         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2887
2888         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
2889         {
2890                 if (p_ptr->migite)
2891                 {
2892                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2893                 }
2894                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2895         }
2896
2897
2898         /* Restrict floor usage */
2899         if (floor)
2900         {
2901                 /* Scan all objects in the grid */
2902                 for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2903                 {
2904                         object_type *o_ptr;
2905
2906                         /* Acquire object */
2907                         o_ptr = &o_list[this_o_idx];
2908
2909                         /* Acquire next object */
2910                         next_o_idx = o_ptr->next_o_idx;
2911
2912                         /* Accept the item on the floor if legal */
2913                         if (item_tester_okay(o_ptr) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2914                 }
2915         }
2916
2917         /* Require at least one legal choice */
2918         if (!allow_floor && (i1 > i2) && (e1 > e2))
2919         {
2920                 /* Cancel p_ptr->command_see */
2921                 command_see = FALSE;
2922
2923                 oops = TRUE;
2924
2925                 done = TRUE;
2926
2927                 if (select_the_force) {
2928                     *cp = INVEN_FORCE;
2929                     item = TRUE;
2930                 }
2931         }
2932
2933         /* Analyze choices */
2934         else
2935         {
2936                 /* Hack -- Start on equipment if requested */
2937                 if (command_see && command_wrk && equip)
2938                 {
2939                         command_wrk = TRUE;
2940                 }
2941
2942                 /* Use inventory if allowed */
2943                 else if (inven)
2944                 {
2945                         command_wrk = FALSE;
2946                 }
2947
2948                 /* Use equipment if allowed */
2949                 else if (equip)
2950                 {
2951                         command_wrk = TRUE;
2952                 }
2953
2954                 /* Use inventory for floor */
2955                 else
2956                 {
2957                         command_wrk = FALSE;
2958                 }
2959         }
2960
2961
2962         /*
2963          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2964          */
2965         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2966
2967         /* Hack -- start out in "display" mode */
2968         if (command_see)
2969         {
2970                 /* Save screen */
2971                 screen_save();
2972         }
2973
2974
2975         /* Repeat until done */
2976         while (!done)
2977         {
2978                 COMMAND_CODE get_item_label = 0;
2979
2980                 /* Show choices */
2981                 int ni = 0;
2982                 int ne = 0;
2983
2984                 /* Scan windows */
2985                 for (j = 0; j < 8; j++)
2986                 {
2987                         /* Unused */
2988                         if (!angband_term[j]) continue;
2989
2990                         /* Count windows displaying inven */
2991                         if (window_flag[j] & (PW_INVEN)) ni++;
2992
2993                         /* Count windows displaying equip */
2994                         if (window_flag[j] & (PW_EQUIP)) ne++;
2995                 }
2996
2997                 /* Toggle if needed */
2998                 if ((command_wrk && ni && !ne) ||
2999                     (!command_wrk && !ni && ne))
3000                 {
3001                         /* Toggle */
3002                         toggle_inven_equip();
3003
3004                         /* Track toggles */
3005                         toggle = !toggle;
3006                 }
3007
3008                 /* Update */
3009                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3010
3011                 /* Redraw windows */
3012                 window_stuff();
3013
3014
3015                 /* Inventory screen */
3016                 if (!command_wrk)
3017                 {
3018                         /* Redraw if needed */
3019                         if (command_see) get_item_label = show_inven(menu_line);
3020                 }
3021
3022                 /* Equipment screen */
3023                 else
3024                 {
3025                         /* Redraw if needed */
3026                         if (command_see) get_item_label = show_equip(menu_line);
3027                 }
3028
3029                 /* Viewing inventory */
3030                 if (!command_wrk)
3031                 {
3032                         /* Begin the prompt */
3033                         sprintf(out_val, _("持ち物:", "Inven:"));
3034
3035                         /* Some legal items */
3036                         if ((i1 <= i2) && !use_menu)
3037                         {
3038                                 /* Build the prompt */
3039                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3040                                         index_to_label(i1), index_to_label(i2));
3041
3042                                 /* Append */
3043                                 strcat(out_val, tmp_val);
3044                         }
3045
3046                         /* Indicate ability to "view" */
3047                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3048
3049                         /* Append */
3050 #ifdef JP
3051                         if (equip) strcat(out_val, format(" %s 装備品,", use_menu ? "'4'or'6'" : "'/'"));
3052 #else
3053                         if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
3054 #endif
3055                 }
3056
3057                 /* Viewing equipment */
3058                 else
3059                 {
3060                         /* Begin the prompt */
3061                         sprintf(out_val, _("装備品:", "Equip:"));
3062
3063                         /* Some legal items */
3064                         if ((e1 <= e2) && !use_menu)
3065                         {
3066                                 /* Build the prompt */
3067                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3068                                         index_to_label(e1), index_to_label(e2));
3069
3070                                 /* Append */
3071                                 strcat(out_val, tmp_val);
3072                         }
3073
3074                         /* Indicate ability to "view" */
3075                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3076
3077                         /* Append */
3078 #ifdef JP
3079                         if (inven) strcat(out_val, format(" %s 持ち物,", use_menu ? "'4'or'6'" : "'/'"));
3080 #else
3081                         if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
3082 #endif
3083                 }
3084
3085                 /* Indicate legality of the "floor" item */
3086                 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
3087                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
3088
3089                 /* Finish the prompt */
3090                 strcat(out_val, " ESC");
3091
3092                 /* Build the prompt */
3093                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
3094
3095                 /* Show the prompt */
3096                 prt(tmp_val, 0, 0);
3097
3098                 /* Get a key */
3099                 which = inkey();
3100
3101                 if (use_menu)
3102                 {
3103                 int max_line = (command_wrk ? max_equip : max_inven);
3104                 switch (which)
3105                 {
3106                         case ESCAPE:
3107                         case 'z':
3108                         case 'Z':
3109                         case '0':
3110                         {
3111                                 done = TRUE;
3112                                 break;
3113                         }
3114
3115                         case '8':
3116                         case 'k':
3117                         case 'K':
3118                         {
3119                                 menu_line += (max_line - 1);
3120                                 break;
3121                         }
3122
3123                         case '2':
3124                         case 'j':
3125                         case 'J':
3126                         {
3127                                 menu_line++;
3128                                 break;
3129                         }
3130
3131                         case '4':
3132                         case '6':
3133                         case 'h':
3134                         case 'H':
3135                         case 'l':
3136                         case 'L':
3137                         {
3138                                 /* Verify legality */
3139                                 if (!inven || !equip)
3140                                 {
3141                                         bell();
3142                                         break;
3143                                 }
3144
3145                                 /* Hack -- Fix screen */
3146                                 if (command_see)
3147                                 {
3148                                         /* Load screen */
3149                                         screen_load();
3150
3151                                         /* Save screen */
3152                                         screen_save();
3153                                 }
3154
3155                                 /* Switch inven/equip */
3156                                 command_wrk = !command_wrk;
3157                                 max_line = (command_wrk ? max_equip : max_inven);
3158                                 if (menu_line > max_line) menu_line = max_line;
3159
3160                                 /* Need to redraw */
3161                                 break;
3162                         }
3163
3164                         case 'x':
3165                         case 'X':
3166                         case '\r':
3167                         case '\n':
3168                         {
3169                                 if (command_wrk == USE_FLOOR)
3170                                 {
3171                                         /* Special index */
3172                                         (*cp) = -get_item_label;
3173                                 }
3174                                 else
3175                                 {
3176                                         /* Validate the item */
3177                                         if (!get_item_okay(get_item_label))
3178                                         {
3179                                                 bell();
3180                                                 break;
3181                                         }
3182
3183                                         /* Allow player to "refuse" certain actions */
3184                                         if (!get_item_allow(get_item_label))
3185                                         {
3186                                                 done = TRUE;
3187                                                 break;
3188                                         }
3189
3190                                         /* Accept that choice */
3191                                         (*cp) = get_item_label;
3192                                 }
3193
3194                                 item = TRUE;
3195                                 done = TRUE;
3196                                 break;
3197                         }
3198                         case 'w':
3199                         {
3200                                 if (select_the_force) {
3201                                         *cp = INVEN_FORCE;
3202                                         item = TRUE;
3203                                         done = TRUE;
3204                                         break;
3205                                 }
3206                         }
3207                 }
3208                 if (menu_line > max_line) menu_line -= max_line;
3209                 }
3210                 else
3211                 {
3212                 /* Parse it */
3213                 switch (which)
3214                 {
3215                         case ESCAPE:
3216                         {
3217                                 done = TRUE;
3218                                 break;
3219                         }
3220
3221                         case '*':
3222                         case '?':
3223                         case ' ':
3224                         {
3225                                 /* Hide the list */
3226                                 if (command_see)
3227                                 {
3228                                         /* Flip flag */
3229                                         command_see = FALSE;
3230
3231                                         /* Load screen */
3232                                         screen_load();
3233                                 }
3234
3235                                 /* Show the list */
3236                                 else
3237                                 {
3238                                         /* Save screen */
3239                                         screen_save();
3240
3241                                         /* Flip flag */
3242                                         command_see = TRUE;
3243                                 }
3244                                 break;
3245                         }
3246
3247                         case '/':
3248                         {
3249                                 /* Verify legality */
3250                                 if (!inven || !equip)
3251                                 {
3252                                         bell();
3253                                         break;
3254                                 }
3255
3256                                 /* Hack -- Fix screen */
3257                                 if (command_see)
3258                                 {
3259                                         /* Load screen */
3260                                         screen_load();
3261
3262                                         /* Save screen */
3263                                         screen_save();
3264                                 }
3265
3266                                 /* Switch inven/equip */
3267                                 command_wrk = !command_wrk;
3268
3269                                 /* Need to redraw */
3270                                 break;
3271                         }
3272
3273                         case '-':
3274                         {
3275                                 /* Use floor item */
3276                                 if (allow_floor)
3277                                 {
3278                                         /* Scan all objects in the grid */
3279                                         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3280                                         {
3281                                                 object_type *o_ptr;
3282
3283                                                 /* Acquire object */
3284                                                 o_ptr = &o_list[this_o_idx];
3285
3286                                                 /* Acquire next object */
3287                                                 next_o_idx = o_ptr->next_o_idx;
3288
3289                                                 /* Validate the item */
3290                                                 if (!item_tester_okay(o_ptr)) continue;
3291
3292                                                 /* Special index */
3293                                                 k = 0 - this_o_idx;
3294
3295                                                 /* Verify the item (if required) */
3296                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3297
3298                                                 /* Allow player to "refuse" certain actions */
3299                                                 if (!get_item_allow(k)) continue;
3300
3301                                                 /* Accept that choice */
3302                                                 (*cp) = k;
3303                                                 item = TRUE;
3304                                                 done = TRUE;
3305                                                 break;
3306                                         }
3307
3308                                         /* Outer break */
3309                                         if (done) break;
3310                                 }
3311
3312                                 bell();
3313                                 break;
3314                         }
3315
3316                         case '0':
3317                         case '1': case '2': case '3':
3318                         case '4': case '5': case '6':
3319                         case '7': case '8': case '9':
3320                         {
3321                                 /* Look up the tag */
3322                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3323                                 {
3324                                         bell();
3325                                         break;
3326                                 }
3327
3328                                 /* Hack -- Validate the item */
3329                                 if ((k < INVEN_RARM) ? !inven : !equip)
3330                                 {
3331                                         bell();
3332                                         break;
3333                                 }
3334
3335                                 /* Validate the item */
3336                                 if (!get_item_okay(k))
3337                                 {
3338                                         bell();
3339                                         break;
3340                                 }
3341
3342                                 /* Allow player to "refuse" certain actions */
3343                                 if (!get_item_allow(k))
3344                                 {
3345                                         done = TRUE;
3346                                         break;
3347                                 }
3348
3349                                 /* Accept that choice */
3350                                 (*cp) = k;
3351                                 item = TRUE;
3352                                 done = TRUE;
3353                                 cur_tag = which;
3354                                 break;
3355                         }
3356
3357 #if 0
3358                         case '\n':
3359                         case '\r':
3360                         {
3361                                 /* Choose "default" inventory item */
3362                                 if (!command_wrk)
3363                                 {
3364                                         k = ((i1 == i2) ? i1 : -1);
3365                                 }
3366
3367                                 /* Choose "default" equipment item */
3368                                 else
3369                                 {
3370                                         k = ((e1 == e2) ? e1 : -1);
3371                                 }
3372
3373                                 /* Validate the item */
3374                                 if (!get_item_okay(k))
3375                                 {
3376                                         bell();
3377                                         break;
3378                                 }
3379
3380                                 /* Allow player to "refuse" certain actions */
3381                                 if (!get_item_allow(k))
3382                                 {
3383                                         done = TRUE;
3384                                         break;
3385                                 }
3386
3387                                 /* Accept that choice */
3388                                 (*cp) = k;
3389                                 item = TRUE;
3390                                 done = TRUE;
3391                                 break;
3392                         }
3393 #endif
3394
3395                         case 'w':
3396                         {
3397                                 if (select_the_force) {
3398                                         *cp = INVEN_FORCE;
3399                                         item = TRUE;
3400                                         done = TRUE;
3401                                         break;
3402                                 }
3403
3404                                 /* Fall through */
3405                         }
3406
3407                         default:
3408                         {
3409                                 int ver;
3410                                 bool not_found = FALSE;
3411
3412                                 /* Look up the alphabetical tag */
3413                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3414                                 {
3415                                         not_found = TRUE;
3416                                 }
3417
3418                                 /* Hack -- Validate the item */
3419                                 else if ((k < INVEN_RARM) ? !inven : !equip)
3420                                 {
3421                                         not_found = TRUE;
3422                                 }
3423
3424                                 /* Validate the item */
3425                                 else if (!get_item_okay(k))
3426                                 {
3427                                         not_found = TRUE;
3428                                 }
3429
3430                                 if (!not_found)
3431                                 {
3432                                         /* Accept that choice */
3433                                         (*cp) = k;
3434                                         item = TRUE;
3435                                         done = TRUE;
3436                                         cur_tag = which;
3437                                         break;
3438                                 }
3439
3440                                 /* Extract "query" setting */
3441                                 ver = isupper(which);
3442                                 which = (char)tolower(which);
3443
3444                                 /* Convert letter to inventory index */
3445                                 if (!command_wrk)
3446                                 {
3447                                         if (which == '(') k = i1;
3448                                         else if (which == ')') k = i2;
3449                                         else k = label_to_inven(which);
3450                                 }
3451
3452                                 /* Convert letter to equipment index */
3453                                 else
3454                                 {
3455                                         if (which == '(') k = e1;
3456                                         else if (which == ')') k = e2;
3457                                         else k = label_to_equip(which);
3458                                 }
3459
3460                                 /* Validate the item */
3461                                 if (!get_item_okay(k))
3462                                 {
3463                                         bell();
3464                                         break;
3465                                 }
3466
3467                                 /* Verify the item */
3468                                 if (ver && !verify(_("本当に", "Try"), k))
3469                                 {
3470                                         done = TRUE;
3471                                         break;
3472                                 }
3473
3474                                 /* Allow player to "refuse" certain actions */
3475                                 if (!get_item_allow(k))
3476                                 {
3477                                         done = TRUE;
3478                                         break;
3479                                 }
3480
3481                                 /* Accept that choice */
3482                                 (*cp) = k;
3483                                 item = TRUE;
3484                                 done = TRUE;
3485                                 break;
3486                         }
3487                 }
3488                 }
3489         }
3490
3491
3492         /* Fix the screen if necessary */
3493         if (command_see)
3494         {
3495                 /* Load screen */
3496                 screen_load();
3497
3498                 /* Hack -- Cancel "display" */
3499                 command_see = FALSE;
3500         }
3501
3502
3503         /* Forget the item_tester_tval restriction */
3504         item_tester_tval = 0;
3505
3506         item_tester_no_ryoute = FALSE;
3507
3508         /* Forget the item_tester_hook restriction */
3509         item_tester_hook = NULL;
3510
3511
3512         /* Clean up  'show choices' */
3513         /* Toggle again if needed */
3514         if (toggle) toggle_inven_equip();
3515
3516         /* Update */
3517         p_ptr->window |= (PW_INVEN | PW_EQUIP);
3518
3519         window_stuff();
3520
3521
3522         /* Clear the prompt line */
3523         prt("", 0, 0);
3524
3525         /* Warning if needed */
3526         if (oops && str) msg_print(str);
3527
3528         if (item)
3529         {
3530                 repeat_push(*cp);
3531                 if (command_cmd) prev_tag = cur_tag;
3532                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3533         }
3534
3535         /* Result */
3536         return (item);
3537 }
3538
3539
3540 #ifdef ALLOW_EASY_FLOOR
3541
3542 /*!
3543  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3544  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3545  * @param y 走査するフロアのY座標
3546  * @param x 走査するフロアのX座標
3547  * @param mode オプションフラグ
3548  * @return 対象のマスに落ちているアイテム数
3549  * @details
3550  * Return a list of o_list[] indexes of items at the given cave
3551  * location. Valid flags are:
3552  *
3553  *              mode & 0x01 -- Item tester
3554  *              mode & 0x02 -- Marked items only
3555  *              mode & 0x04 -- Stop after first
3556  */
3557 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3558 {
3559         OBJECT_IDX this_o_idx, next_o_idx;
3560
3561         ITEM_NUMBER num = 0;
3562
3563         /* Sanity */
3564         if (!in_bounds(y, x)) return 0;
3565
3566         /* Scan all objects in the grid */
3567         for (this_o_idx = cave[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3568         {
3569                 object_type *o_ptr;
3570
3571                 /* Acquire object */
3572                 o_ptr = &o_list[this_o_idx];
3573
3574                 /* Acquire next object */
3575                 next_o_idx = o_ptr->next_o_idx;
3576
3577                 /* Item tester */
3578                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3579
3580                 /* Marked */
3581                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3582
3583                 /* Accept this item */
3584                 /* XXX Hack -- Enforce limit */
3585                 if (num < 23)
3586                         items[num] = this_o_idx;
3587
3588                 num++;
3589
3590                 /* Only one */
3591                 if (mode & 0x04) break;
3592         }
3593
3594         /* Result */
3595         return num;
3596 }
3597
3598
3599 /*!
3600  * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3601  * @param target_item カーソルの初期値
3602  * @param y 走査するフロアのY座標
3603  * @param x 走査するフロアのX座標
3604  * @param min_width 表示の長さ
3605  * @return 選択したアイテムの添え字
3606  * @details
3607  */
3608 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3609 {
3610         COMMAND_CODE i, m;
3611         int j, k, l;
3612         int col, len;
3613
3614         object_type *o_ptr;
3615
3616         char o_name[MAX_NLEN];
3617         char tmp_val[80];
3618
3619         COMMAND_CODE out_index[23];
3620         TERM_COLOR out_color[23];
3621         char out_desc[23][MAX_NLEN];
3622         COMMAND_CODE target_item_label = 0;
3623
3624         OBJECT_IDX floor_list[23];
3625         ITEM_NUMBER floor_num;
3626         TERM_LEN wid, hgt;
3627         char floor_label[52 + 1];
3628
3629         bool dont_need_to_show_weights = TRUE;
3630
3631         /* Get size */
3632         Term_get_size(&wid, &hgt);
3633
3634         /* Default length */
3635         len = MAX((*min_width), 20);
3636
3637
3638         /* Scan for objects in the grid, using item_tester_okay() */
3639         floor_num = scan_floor(floor_list, y, x, 0x03);
3640
3641         /* Display the floor objects */
3642         for (k = 0, i = 0; i < floor_num && i < 23; i++)
3643         {
3644                 o_ptr = &o_list[floor_list[i]];
3645
3646                 /* Describe the object */
3647                 object_desc(o_name, o_ptr, 0);
3648
3649                 /* Save the index */
3650                 out_index[k] = i;
3651
3652                 /* Acquire inventory color */
3653                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3654
3655                 /* Save the object description */
3656                 strcpy(out_desc[k], o_name);
3657
3658                 /* Find the predicted "line length" */
3659                 l = strlen(out_desc[k]) + 5;
3660
3661                 /* Be sure to account for the weight */
3662                 if (show_weights) l += 9;
3663
3664                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3665
3666                 /* Maintain the maximum length */
3667                 if (l > len) len = l;
3668
3669                 /* Advance to next "line" */
3670                 k++;
3671         }
3672
3673         if (show_weights && dont_need_to_show_weights) len -= 9;
3674
3675         /* Save width */
3676         *min_width = len;
3677
3678         /* Find the column to start in */
3679         col = (len > wid - 4) ? 0 : (wid - len - 1);
3680
3681         prepare_label_string_floor(floor_label, floor_list, floor_num);
3682
3683         /* Output each entry */
3684         for (j = 0; j < k; j++)
3685         {
3686                 /* Get the index */
3687                 m = floor_list[out_index[j]];
3688
3689                 /* Get the item */
3690                 o_ptr = &o_list[m];
3691
3692                 /* Clear the line */
3693                 prt("", j + 1, col ? col - 2 : col);
3694
3695                 if (use_menu && target_item)
3696                 {
3697                         if (j == (target_item-1))
3698                         {
3699                                 strcpy(tmp_val, _("》", "> "));
3700                                 target_item_label = m;
3701                         }
3702                         else strcpy(tmp_val, "   ");
3703                 }
3704                 else
3705                 {
3706                         /* Prepare an index --(-- */
3707                         sprintf(tmp_val, "%c)", floor_label[j]);
3708                 }
3709
3710                 /* Clear the line with the (possibly indented) index */
3711                 put_str(tmp_val, j + 1, col);
3712
3713                 /* Display the entry itself */
3714                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3715
3716                 /* Display the weight if needed */
3717                 if (show_weights && (o_ptr->tval != TV_GOLD))
3718                 {
3719                         int wgt = o_ptr->weight * o_ptr->number;
3720 #ifdef JP
3721                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3722 #else
3723                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3724 #endif
3725
3726                         prt(tmp_val, j + 1, wid - 9);
3727                 }
3728         }
3729
3730         /* Make a "shadow" below the list (only if needed) */
3731         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3732
3733         return target_item_label;
3734 }
3735
3736 /*!
3737  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3738  * Let the user select an item, save its "index"
3739  * @param cp 選択したオブジェクトのIDを返す。
3740  * @param pmt 選択目的のメッセージ
3741  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3742  * @param mode オプションフラグ
3743  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3744  */
3745 bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
3746 {
3747         char n1 = ' ', n2 = ' ', which = ' ';
3748
3749         int j;
3750         COMMAND_CODE i1, i2;
3751         COMMAND_CODE e1, e2;
3752         COMMAND_CODE k;
3753
3754         bool done, item;
3755
3756         bool oops = FALSE;
3757
3758         /* Extract args */
3759         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3760         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3761         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3762
3763         bool allow_equip = FALSE;
3764         bool allow_inven = FALSE;
3765         bool allow_floor = FALSE;
3766
3767         bool toggle = FALSE;
3768
3769         char tmp_val[160];
3770         char out_val[160];
3771
3772         ITEM_NUMBER floor_num;
3773         OBJECT_IDX floor_list[23];
3774         int floor_top = 0;
3775         TERM_LEN min_width = 0;
3776
3777         extern bool select_the_force;
3778
3779         int menu_line = (use_menu ? 1 : 0);
3780         int max_inven = 0;
3781         int max_equip = 0;
3782
3783         static char prev_tag = '\0';
3784         char cur_tag = '\0';
3785
3786         /* Get the item index */
3787         if (repeat_pull(cp))
3788         {
3789                 /* the_force */
3790                 if (select_the_force && (*cp == INVEN_FORCE))
3791                 {
3792                         item_tester_tval = 0;
3793                         item_tester_hook = NULL;
3794                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3795                         return (TRUE);
3796                 }
3797
3798                 /* Floor item? */
3799                 else if (floor && (*cp < 0))
3800                 {
3801                         if (prev_tag && command_cmd)
3802                         {
3803                                 /* Scan all objects in the grid */
3804                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3805
3806                                 /* Look up the tag */
3807                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3808                                 {
3809                                         /* Accept that choice */
3810                                         (*cp) = 0 - floor_list[k];
3811
3812                                         /* Forget restrictions */
3813                                         item_tester_tval = 0;
3814                                         item_tester_hook = NULL;
3815                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3816
3817                                         /* Success */
3818                                         return TRUE;
3819                                 }
3820
3821                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3822                         }
3823
3824                         /* Validate the item */
3825                         else if (item_tester_okay(&o_list[0 - (*cp)]))
3826                         {
3827                                 /* Forget restrictions */
3828                                 item_tester_tval = 0;
3829                                 item_tester_hook = NULL;
3830                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3831
3832                                 /* Success */
3833                                 return TRUE;
3834                         }
3835                 }
3836
3837                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3838                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3839                 {
3840                         if (prev_tag && command_cmd)
3841                         {
3842                                 /* Look up the tag and validate the item */
3843                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3844                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3845                                 else if (!get_item_okay(k)) /* Reject */;
3846                                 else
3847                                 {
3848                                         /* Accept that choice */
3849                                         (*cp) = k;
3850
3851                                         /* Forget restrictions */
3852                                         item_tester_tval = 0;
3853                                         item_tester_hook = NULL;
3854                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3855
3856                                         /* Success */
3857                                         return TRUE;
3858                                 }
3859
3860                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3861                         }
3862
3863                         /* Verify the item */
3864                         else if (get_item_okay(*cp))
3865                         {
3866                                 /* Forget restrictions */
3867                                 item_tester_tval = 0;
3868                                 item_tester_hook = NULL;
3869                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3870
3871                                 /* Success */
3872                                 return TRUE;
3873                         }
3874                 }
3875         }
3876
3877
3878         /* Paranoia */
3879         msg_print(NULL);
3880
3881
3882         /* Not done */
3883         done = FALSE;
3884
3885         /* No item selected */
3886         item = FALSE;
3887
3888
3889         /* Full inventory */
3890         i1 = 0;
3891         i2 = INVEN_PACK - 1;
3892
3893         /* Forbid inventory */
3894         if (!inven) i2 = -1;
3895         else if (use_menu)
3896         {
3897                 for (j = 0; j < INVEN_PACK; j++)
3898                         if (item_tester_okay(&inventory[j])) max_inven++;
3899         }
3900
3901         /* Restrict inventory indexes */
3902         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3903         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3904
3905
3906         /* Full equipment */
3907         e1 = INVEN_RARM;
3908         e2 = INVEN_TOTAL - 1;
3909
3910         /* Forbid equipment */
3911         if (!equip) e2 = -1;
3912         else if (use_menu)
3913         {
3914                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3915                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
3916                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
3917         }
3918
3919         /* Restrict equipment indexes */
3920         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3921         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3922
3923         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
3924         {
3925                 if (p_ptr->migite)
3926                 {
3927                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3928                 }
3929                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3930         }
3931
3932
3933         /* Count "okay" floor items */
3934         floor_num = 0;
3935
3936         /* Restrict floor usage */
3937         if (floor)
3938         {
3939                 /* Scan all objects in the grid */
3940                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3941         }
3942
3943         /* Accept inventory */
3944         if (i1 <= i2) allow_inven = TRUE;
3945
3946         /* Accept equipment */
3947         if (e1 <= e2) allow_equip = TRUE;
3948
3949         /* Accept floor */
3950         if (floor_num) allow_floor = TRUE;
3951
3952         /* Require at least one legal choice */
3953         if (!allow_inven && !allow_equip && !allow_floor)
3954         {
3955                 /* Cancel p_ptr->command_see */
3956                 command_see = FALSE;
3957
3958                 oops = TRUE;
3959
3960                 done = TRUE;
3961
3962                 if (select_the_force) {
3963                     *cp = INVEN_FORCE;
3964                     item = TRUE;
3965                 }
3966         }
3967
3968         /* Analyze choices */
3969         else
3970         {
3971                 /* Hack -- Start on equipment if requested */
3972                 if (command_see && (command_wrk == (USE_EQUIP))
3973                         && allow_equip)
3974                 {
3975                         command_wrk = (USE_EQUIP);
3976                 }
3977
3978                 /* Use inventory if allowed */
3979                 else if (allow_inven)
3980                 {
3981                         command_wrk = (USE_INVEN);
3982                 }
3983
3984                 /* Use equipment if allowed */
3985                 else if (allow_equip)
3986                 {
3987                         command_wrk = (USE_EQUIP);
3988                 }
3989
3990                 /* Use floor if allowed */
3991                 else if (allow_floor)
3992                 {
3993                         command_wrk = (USE_FLOOR);
3994                 }
3995         }
3996
3997         /*
3998          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3999          */
4000         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
4001
4002         /* Hack -- start out in "display" mode */
4003         if (command_see)
4004         {
4005                 /* Save screen */
4006                 screen_save();
4007         }
4008
4009         /* Repeat until done */
4010         while (!done)
4011         {
4012                 COMMAND_CODE get_item_label = 0;
4013
4014                 /* Show choices */
4015                 int ni = 0;
4016                 int ne = 0;
4017
4018                 /* Scan windows */
4019                 for (j = 0; j < 8; j++)
4020                 {
4021                         /* Unused */
4022                         if (!angband_term[j]) continue;
4023
4024                         /* Count windows displaying inven */
4025                         if (window_flag[j] & (PW_INVEN)) ni++;
4026
4027                         /* Count windows displaying equip */
4028                         if (window_flag[j] & (PW_EQUIP)) ne++;
4029                 }
4030
4031                 /* Toggle if needed */
4032                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
4033                     (command_wrk == (USE_INVEN) && !ni && ne))
4034                 {
4035                         /* Toggle */
4036                         toggle_inven_equip();
4037
4038                         /* Track toggles */
4039                         toggle = !toggle;
4040                 }
4041
4042                 /* Update */
4043                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4044
4045                 /* Redraw windows */
4046                 window_stuff();
4047
4048                 /* Inventory screen */
4049                 if (command_wrk == (USE_INVEN))
4050                 {
4051                         /* Extract the legal requests */
4052                         n1 = I2A(i1);
4053                         n2 = I2A(i2);
4054
4055                         /* Redraw if needed */
4056                         if (command_see) get_item_label = show_inven(menu_line);
4057                 }
4058
4059                 /* Equipment screen */
4060                 else if (command_wrk == (USE_EQUIP))
4061                 {
4062                         /* Extract the legal requests */
4063                         n1 = I2A(e1 - INVEN_RARM);
4064                         n2 = I2A(e2 - INVEN_RARM);
4065
4066                         /* Redraw if needed */
4067                         if (command_see) get_item_label = show_equip(menu_line);
4068                 }
4069
4070                 /* Floor screen */
4071                 else if (command_wrk == (USE_FLOOR))
4072                 {
4073                         j = floor_top;
4074                         k = MIN(floor_top + 23, floor_num) - 1;
4075
4076                         /* Extract the legal requests */
4077                         n1 = I2A(j - floor_top);
4078                         n2 = I2A(k - floor_top);
4079
4080                         /* Redraw if needed */
4081                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
4082                 }
4083
4084                 /* Viewing inventory */
4085                 if (command_wrk == (USE_INVEN))
4086                 {
4087                         /* Begin the prompt */
4088                         sprintf(out_val, _("持ち物:", "Inven:"));
4089
4090                         if (!use_menu)
4091                         {
4092                                 /* Build the prompt */
4093                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4094                                         index_to_label(i1), index_to_label(i2));
4095
4096                                 /* Append */
4097                                 strcat(out_val, tmp_val);
4098                         }
4099
4100                         /* Indicate ability to "view" */
4101                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4102
4103                         /* Append */
4104                         if (allow_equip)
4105                         {
4106 #ifdef JP
4107                                 if (!use_menu)
4108                                         strcat(out_val, " '/' 装備品,");
4109                                 else if (allow_floor)
4110                                         strcat(out_val, " '6' 装備品,");
4111                                 else
4112                                         strcat(out_val, " '4'or'6' 装備品,");
4113 #else
4114                                 if (!use_menu)
4115                                         strcat(out_val, " / for Equip,");
4116                                 else if (allow_floor)
4117                                         strcat(out_val, " 6 for Equip,");
4118                                 else
4119                                         strcat(out_val, " 4 or 6 for Equip,");
4120 #endif
4121                         }
4122
4123                         /* Append */
4124                         if (allow_floor)
4125                         {
4126 #ifdef JP
4127                                 if (!use_menu)
4128                                         strcat(out_val, " '-'床上,");
4129                                 else if (allow_equip)
4130                                         strcat(out_val, " '4' 床上,");
4131                                 else
4132                                         strcat(out_val, " '4'or'6' 床上,");
4133 #else
4134                                 if (!use_menu)
4135                                         strcat(out_val, " - for floor,");
4136                                 else if (allow_equip)
4137                                         strcat(out_val, " 4 for floor,");
4138                                 else
4139                                         strcat(out_val, " 4 or 6 for floor,");
4140 #endif
4141                         }
4142                 }
4143
4144                 /* Viewing equipment */
4145                 else if (command_wrk == (USE_EQUIP))
4146                 {
4147                         /* Begin the prompt */
4148                         sprintf(out_val, _("装備品:", "Equip:"));
4149
4150                         if (!use_menu)
4151                         {
4152                                 /* Build the prompt */
4153                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4154                                         index_to_label(e1), index_to_label(e2));
4155
4156                                 /* Append */
4157                                 strcat(out_val, tmp_val);
4158                         }
4159
4160                         /* Indicate ability to "view" */
4161                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4162
4163                         /* Append */
4164                         if (allow_inven)
4165                         {
4166 #ifdef JP
4167                                 if (!use_menu)
4168                                         strcat(out_val, " '/' 持ち物,");
4169                                 else if (allow_floor)
4170                                         strcat(out_val, " '4' 持ち物,");
4171                                 else
4172                                         strcat(out_val, " '4'or'6' 持ち物,");
4173 #else
4174                                 if (!use_menu)
4175                                         strcat(out_val, " / for Inven,");
4176                                 else if (allow_floor)
4177                                         strcat(out_val, " 4 for Inven,");
4178                                 else
4179                                         strcat(out_val, " 4 or 6 for Inven,");
4180 #endif
4181                         }
4182
4183                         /* Append */
4184                         if (allow_floor)
4185                         {
4186 #ifdef JP
4187                                 if (!use_menu)
4188                                         strcat(out_val, " '-'床上,");
4189                                 else if (allow_inven)
4190                                         strcat(out_val, " '6' 床上,");
4191                                 else
4192                                         strcat(out_val, " '4'or'6' 床上,");
4193 #else
4194                                 if (!use_menu)
4195                                         strcat(out_val, " - for floor,");
4196                                 else if (allow_inven)
4197                                         strcat(out_val, " 6 for floor,");
4198                                 else
4199                                         strcat(out_val, " 4 or 6 for floor,");
4200 #endif
4201                         }
4202                 }
4203
4204                 /* Viewing floor */
4205                 else if (command_wrk == (USE_FLOOR))
4206                 {
4207                         /* Begin the prompt */
4208                         sprintf(out_val, _("床上:", "Floor:"));
4209
4210                         if (!use_menu)
4211                         {
4212                                 /* Build the prompt */
4213                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4214
4215                                 /* Append */
4216                                 strcat(out_val, tmp_val);
4217                         }
4218
4219                         /* Indicate ability to "view" */
4220                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4221
4222                         if (use_menu)
4223                         {
4224                                 if (allow_inven && allow_equip)
4225                                 {
4226                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4227                                 }
4228                                 else if (allow_inven)
4229                                 {
4230                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4231                                 }
4232                                 else if (allow_equip)
4233                                 {
4234                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4235                                 }
4236                         }
4237                         /* Append */
4238                         else if (allow_inven)
4239                         {
4240                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4241                         }
4242                         else if (allow_equip)
4243                         {
4244                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4245                         }
4246
4247                         /* Append */
4248                         if (command_see && !use_menu)
4249                         {
4250                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4251                         }
4252                 }
4253
4254                 /* Append */
4255                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4256
4257                 /* Finish the prompt */
4258                 strcat(out_val, " ESC");
4259
4260                 /* Build the prompt */
4261                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4262
4263                 /* Show the prompt */
4264                 prt(tmp_val, 0, 0);
4265
4266                 /* Get a key */
4267                 which = inkey();
4268
4269                 if (use_menu)
4270                 {
4271                 int max_line = 1;
4272                 if (command_wrk == USE_INVEN) max_line = max_inven;
4273                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4274                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4275                 switch (which)
4276                 {
4277                         case ESCAPE:
4278                         case 'z':
4279                         case 'Z':
4280                         case '0':
4281                         {
4282                                 done = TRUE;
4283                                 break;
4284                         }
4285
4286                         case '8':
4287                         case 'k':
4288                         case 'K':
4289                         {
4290                                 menu_line += (max_line - 1);
4291                                 break;
4292                         }
4293
4294                         case '2':
4295                         case 'j':
4296                         case 'J':
4297                         {
4298                                 menu_line++;
4299                                 break;
4300                         }
4301
4302                         case '4':
4303                         case 'h':
4304                         case 'H':
4305                         {
4306                                 /* Verify legality */
4307                                 if (command_wrk == (USE_INVEN))
4308                                 {
4309                                         if (allow_floor) command_wrk = USE_FLOOR;
4310                                         else if (allow_equip) command_wrk = USE_EQUIP;
4311                                         else
4312                                         {
4313                                                 bell();
4314                                                 break;
4315                                         }
4316                                 }
4317                                 else if (command_wrk == (USE_EQUIP))
4318                                 {
4319                                         if (allow_inven) command_wrk = USE_INVEN;
4320                                         else if (allow_floor) command_wrk = USE_FLOOR;
4321                                         else
4322                                         {
4323                                                 bell();
4324                                                 break;
4325                                         }
4326                                 }
4327                                 else if (command_wrk == (USE_FLOOR))
4328                                 {
4329                                         if (allow_equip) command_wrk = USE_EQUIP;
4330                                         else if (allow_inven) command_wrk = USE_INVEN;
4331                                         else
4332                                         {
4333                                                 bell();
4334                                                 break;
4335                                         }
4336                                 }
4337                                 else
4338                                 {
4339                                         bell();
4340                                         break;
4341                                 }
4342
4343                                 /* Hack -- Fix screen */
4344                                 if (command_see)
4345                                 {
4346                                         /* Load screen */
4347                                         screen_load();
4348
4349                                         /* Save screen */
4350                                         screen_save();
4351                                 }
4352
4353                                 /* Switch inven/equip */
4354                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4355                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4356                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4357                                 if (menu_line > max_line) menu_line = max_line;
4358
4359                                 /* Need to redraw */
4360                                 break;
4361                         }
4362
4363                         case '6':
4364                         case 'l':
4365                         case 'L':
4366                         {
4367                                 /* Verify legality */
4368                                 if (command_wrk == (USE_INVEN))
4369                                 {
4370                                         if (allow_equip) command_wrk = USE_EQUIP;
4371                                         else if (allow_floor) command_wrk = USE_FLOOR;
4372                                         else
4373                                         {
4374                                                 bell();
4375                                                 break;
4376                                         }
4377                                 }
4378                                 else if (command_wrk == (USE_EQUIP))
4379                                 {
4380                                         if (allow_floor) command_wrk = USE_FLOOR;
4381                                         else if (allow_inven) command_wrk = USE_INVEN;
4382                                         else
4383                                         {
4384                                                 bell();
4385                                                 break;
4386                                         }
4387                                 }
4388                                 else if (command_wrk == (USE_FLOOR))
4389                                 {
4390                                         if (allow_inven) command_wrk = USE_INVEN;
4391                                         else if (allow_equip) command_wrk = USE_EQUIP;
4392                                         else
4393                                         {
4394                                                 bell();
4395                                                 break;
4396                                         }
4397                                 }
4398                                 else
4399                                 {
4400                                         bell();
4401                                         break;
4402                                 }
4403
4404                                 /* Hack -- Fix screen */
4405                                 if (command_see)
4406                                 {
4407                                         /* Load screen */
4408                                         screen_load();
4409
4410                                         /* Save screen */
4411                                         screen_save();
4412                                 }
4413
4414                                 /* Switch inven/equip */
4415                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4416                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4417                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4418                                 if (menu_line > max_line) menu_line = max_line;
4419
4420                                 /* Need to redraw */
4421                                 break;
4422                         }
4423
4424                         case 'x':
4425                         case 'X':
4426                         case '\r':
4427                         case '\n':
4428                         {
4429                                 if (command_wrk == USE_FLOOR)
4430                                 {
4431                                         /* Special index */
4432                                         (*cp) = -get_item_label;
4433                                 }
4434                                 else
4435                                 {
4436                                         /* Validate the item */
4437                                         if (!get_item_okay(get_item_label))
4438                                         {
4439                                                 bell();
4440                                                 break;
4441                                         }
4442
4443                                         /* Allow player to "refuse" certain actions */
4444                                         if (!get_item_allow(get_item_label))
4445                                         {
4446                                                 done = TRUE;
4447                                                 break;
4448                                         }
4449
4450                                         /* Accept that choice */
4451                                         (*cp) = get_item_label;
4452                                 }
4453
4454                                 item = TRUE;
4455                                 done = TRUE;
4456                                 break;
4457                         }
4458                         case 'w':
4459                         {
4460                                 if (select_the_force) {
4461                                         *cp = INVEN_FORCE;
4462                                         item = TRUE;
4463                                         done = TRUE;
4464                                         break;
4465                                 }
4466                         }
4467                 }
4468                 if (menu_line > max_line) menu_line -= max_line;
4469                 }
4470                 else
4471                 {
4472                 /* Parse it */
4473                 switch (which)
4474                 {
4475                         case ESCAPE:
4476                         {
4477                                 done = TRUE;
4478                                 break;
4479                         }
4480
4481                         case '*':
4482                         case '?':
4483                         case ' ':
4484                         {
4485                                 /* Hide the list */
4486                                 if (command_see)
4487                                 {
4488                                         /* Flip flag */
4489                                         command_see = FALSE;
4490
4491                                         /* Load screen */
4492                                         screen_load();
4493                                 }
4494
4495                                 /* Show the list */
4496                                 else
4497                                 {
4498                                         /* Save screen */
4499                                         screen_save();
4500
4501                                         /* Flip flag */
4502                                         command_see = TRUE;
4503                                 }
4504                                 break;
4505                         }
4506
4507                         case '\n':
4508                         case '\r':
4509                         case '+':
4510                         {
4511                                 int i;
4512                                 OBJECT_IDX o_idx;
4513                                 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
4514
4515                                 if (command_wrk != (USE_FLOOR)) break;
4516
4517                                 /* Get the object being moved. */
4518                                 o_idx = c_ptr->o_idx;
4519
4520                                 /* Only rotate a pile of two or more objects. */
4521                                 if (!(o_idx && o_list[o_idx].next_o_idx)) break;
4522
4523                                 /* Remove the first object from the list. */
4524                                 excise_object_idx(o_idx);
4525
4526                                 /* Find end of the list. */
4527                                 i = c_ptr->o_idx;
4528                                 while (o_list[i].next_o_idx)
4529                                         i = o_list[i].next_o_idx;
4530
4531                                 /* Add after the last object. */
4532                                 o_list[i].next_o_idx = o_idx;
4533
4534                                 /* Re-scan floor list */ 
4535                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4536
4537                                 /* Hack -- Fix screen */
4538                                 if (command_see)
4539                                 {
4540                                         /* Load screen */
4541                                         screen_load();
4542
4543                                         /* Save screen */
4544                                         screen_save();
4545                                 }
4546
4547                                 break;
4548                         }
4549
4550                         case '/':
4551                         {
4552                                 if (command_wrk == (USE_INVEN))
4553                                 {
4554                                         if (!allow_equip)
4555                                         {
4556                                                 bell();
4557                                                 break;
4558                                         }
4559                                         command_wrk = (USE_EQUIP);
4560                                 }
4561                                 else if (command_wrk == (USE_EQUIP))
4562                                 {
4563                                         if (!allow_inven)
4564                                         {
4565                                                 bell();
4566                                                 break;
4567                                         }
4568                                         command_wrk = (USE_INVEN);
4569                                 }
4570                                 else if (command_wrk == (USE_FLOOR))
4571                                 {
4572                                         if (allow_inven)
4573                                         {
4574                                                 command_wrk = (USE_INVEN);
4575                                         }
4576                                         else if (allow_equip)
4577                                         {
4578                                                 command_wrk = (USE_EQUIP);
4579                                         }
4580                                         else
4581                                         {
4582                                                 bell();
4583                                                 break;
4584                                         }
4585                                 }
4586
4587                                 /* Hack -- Fix screen */
4588                                 if (command_see)
4589                                 {
4590                                         /* Load screen */
4591                                         screen_load();
4592
4593                                         /* Save screen */
4594                                         screen_save();
4595                                 }
4596
4597                                 /* Need to redraw */
4598                                 break;
4599                         }
4600
4601                         case '-':
4602                         {
4603                                 if (!allow_floor)
4604                                 {
4605                                         bell();
4606                                         break;
4607                                 }
4608
4609                                 /*
4610                                  * If we are already examining the floor, and there
4611                                  * is only one item, we will always select it.
4612                                  * If we aren't examining the floor and there is only
4613                                  * one item, we will select it if floor_query_flag
4614                                  * is FALSE.
4615                                  */
4616                                 if (floor_num == 1)
4617                                 {
4618                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4619                                         {
4620                                                 /* Special index */
4621                                                 k = 0 - floor_list[0];
4622
4623                                                 /* Allow player to "refuse" certain actions */
4624                                                 if (!get_item_allow(k))
4625                                                 {
4626                                                         done = TRUE;
4627                                                         break;
4628                                                 }
4629
4630                                                 /* Accept that choice */
4631                                                 (*cp) = k;
4632                                                 item = TRUE;
4633                                                 done = TRUE;
4634
4635                                                 break;
4636                                         }
4637                                 }
4638
4639                                 /* Hack -- Fix screen */
4640                                 if (command_see)
4641                                 {
4642                                         /* Load screen */
4643                                         screen_load();
4644
4645                                         /* Save screen */
4646                                         screen_save();
4647                                 }
4648
4649                                 command_wrk = (USE_FLOOR);
4650
4651                                 break;
4652                         }
4653
4654                         case '0':
4655                         case '1': case '2': case '3':
4656                         case '4': case '5': case '6':
4657                         case '7': case '8': case '9':
4658                         {
4659                                 if (command_wrk != USE_FLOOR)
4660                                 {
4661                                         /* Look up the tag */
4662                                         if (!get_tag(&k, which, command_wrk))
4663                                         {
4664                                                 bell();
4665                                                 break;
4666                                         }
4667
4668                                         /* Hack -- Validate the item */
4669                                         if ((k < INVEN_RARM) ? !inven : !equip)
4670                                         {
4671                                                 bell();
4672                                                 break;
4673                                         }
4674
4675                                         /* Validate the item */
4676                                         if (!get_item_okay(k))
4677                                         {
4678                                                 bell();
4679                                                 break;
4680                                         }
4681                                 }
4682                                 else
4683                                 {
4684                                         /* Look up the alphabetical tag */
4685                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4686                                         {
4687                                                 /* Special index */
4688                                                 k = 0 - floor_list[k];
4689                                         }
4690                                         else
4691                                         {
4692                                                 bell();
4693                                                 break;
4694                                         }
4695                                 }
4696
4697                                 /* Allow player to "refuse" certain actions */
4698                                 if (!get_item_allow(k))
4699                                 {
4700                                         done = TRUE;
4701                                         break;
4702                                 }
4703
4704                                 /* Accept that choice */
4705                                 (*cp) = k;
4706                                 item = TRUE;
4707                                 done = TRUE;
4708                                 cur_tag = which;
4709                                 break;
4710                         }
4711
4712 #if 0
4713                         case '\n':
4714                         case '\r':
4715                         {
4716                                 /* Choose "default" inventory item */
4717                                 if (command_wrk == (USE_INVEN))
4718                                 {
4719                                         k = ((i1 == i2) ? i1 : -1);
4720                                 }
4721
4722                                 /* Choose "default" equipment item */
4723                                 else if (command_wrk == (USE_EQUIP))
4724                                 {
4725                                         k = ((e1 == e2) ? e1 : -1);
4726                                 }
4727
4728                                 /* Choose "default" floor item */
4729                                 else if (command_wrk == (USE_FLOOR))
4730                                 {
4731                                         if (floor_num == 1)
4732                                         {
4733                                                 /* Special index */
4734                                                 k = 0 - floor_list[0];
4735
4736                                                 /* Allow player to "refuse" certain actions */
4737                                                 if (!get_item_allow(k))
4738                                                 {
4739                                                         done = TRUE;
4740                                                         break;
4741                                                 }
4742
4743                                                 /* Accept that choice */
4744                                                 (*cp) = k;
4745                                                 item = TRUE;
4746                                                 done = TRUE;
4747                                         }
4748                                         break;
4749                                 }
4750
4751                                 /* Validate the item */
4752                                 if (!get_item_okay(k))
4753                                 {
4754                                         bell();
4755                                         break;
4756                                 }
4757
4758                                 /* Allow player to "refuse" certain actions */
4759                                 if (!get_item_allow(k))
4760                                 {
4761                                         done = TRUE;
4762                                         break;
4763                                 }
4764
4765                                 /* Accept that choice */
4766                                 (*cp) = k;
4767                                 item = TRUE;
4768                                 done = TRUE;
4769                                 break;
4770                         }
4771 #endif
4772
4773                         case 'w':
4774                         {
4775                                 if (select_the_force) {
4776                                         *cp = INVEN_FORCE;
4777                                         item = TRUE;
4778                                         done = TRUE;
4779                                         break;
4780                                 }
4781
4782                                 /* Fall through */
4783                         }
4784
4785                         default:
4786                         {
4787                                 int ver;
4788
4789                                 if (command_wrk != USE_FLOOR)
4790                                 {
4791                                         bool not_found = FALSE;
4792
4793                                         /* Look up the alphabetical tag */
4794                                         if (!get_tag(&k, which, command_wrk))
4795                                         {
4796                                                 not_found = TRUE;
4797                                         }
4798
4799                                         /* Hack -- Validate the item */
4800                                         else if ((k < INVEN_RARM) ? !inven : !equip)
4801                                         {
4802                                                 not_found = TRUE;
4803                                         }
4804
4805                                         /* Validate the item */
4806                                         else if (!get_item_okay(k))
4807                                         {
4808                                                 not_found = TRUE;
4809                                         }
4810
4811                                         if (!not_found)
4812                                         {
4813                                                 /* Accept that choice */
4814                                                 (*cp) = k;
4815                                                 item = TRUE;
4816                                                 done = TRUE;
4817                                                 cur_tag = which;
4818                                                 break;
4819                                         }
4820                                 }
4821                                 else
4822                                 {
4823                                         /* Look up the alphabetical tag */
4824                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4825                                         {
4826                                                 /* Special index */
4827                                                 k = 0 - floor_list[k];
4828
4829                                                 /* Accept that choice */
4830                                                 (*cp) = k;
4831                                                 item = TRUE;
4832                                                 done = TRUE;
4833                                                 cur_tag = which;
4834                                                 break;
4835                                         }
4836                                 }
4837
4838                                 /* Extract "query" setting */
4839                                 ver = isupper(which);
4840                                 which = (char)tolower(which);
4841
4842                                 /* Convert letter to inventory index */
4843                                 if (command_wrk == (USE_INVEN))
4844                                 {
4845                                         if (which == '(') k = i1;
4846                                         else if (which == ')') k = i2;
4847                                         else k = label_to_inven(which);
4848                                 }
4849
4850                                 /* Convert letter to equipment index */
4851                                 else if (command_wrk == (USE_EQUIP))
4852                                 {
4853                                         if (which == '(') k = e1;
4854                                         else if (which == ')') k = e2;
4855                                         else k = label_to_equip(which);
4856                                 }
4857
4858                                 /* Convert letter to floor index */
4859                                 else if (command_wrk == USE_FLOOR)
4860                                 {
4861                                         if (which == '(') k = 0;
4862                                         else if (which == ')') k = floor_num - 1;
4863                                         else k = islower(which) ? A2I(which) : -1;
4864                                         if (k < 0 || k >= floor_num || k >= 23)
4865                                         {
4866                                                 bell();
4867                                                 break;
4868                                         }
4869
4870                                         /* Special index */
4871                                         k = 0 - floor_list[k];
4872                                 }
4873
4874                                 /* Validate the item */
4875                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4876                                 {
4877                                         bell();
4878                                         break;
4879                                 }
4880
4881                                 /* Verify the item */
4882                                 if (ver && !verify(_("本当に", "Try"), k))
4883                                 {
4884                                         done = TRUE;
4885                                         break;
4886                                 }
4887
4888                                 /* Allow player to "refuse" certain actions */
4889                                 if (!get_item_allow(k))
4890                                 {
4891                                         done = TRUE;
4892                                         break;
4893                                 }
4894
4895                                 /* Accept that choice */
4896                                 (*cp) = k;
4897                                 item = TRUE;
4898                                 done = TRUE;
4899                                 break;
4900                         }
4901                 }
4902                 }
4903         }
4904
4905         /* Fix the screen if necessary */
4906         if (command_see)
4907         {
4908                 /* Load screen */
4909                 screen_load();
4910
4911                 /* Hack -- Cancel "display" */
4912                 command_see = FALSE;
4913         }
4914
4915
4916         /* Forget the item_tester_tval restriction */
4917         item_tester_tval = 0;
4918
4919         /* Forget the item_tester_hook restriction */
4920         item_tester_hook = NULL;
4921
4922
4923         /* Clean up  'show choices' */
4924         /* Toggle again if needed */
4925         if (toggle) toggle_inven_equip();
4926
4927         /* Update */
4928         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4929
4930         window_stuff();
4931
4932
4933         /* Clear the prompt line */
4934         prt("", 0, 0);
4935
4936         /* Warning if needed */
4937         if (oops && str) msg_print(str);
4938
4939         if (item)
4940         {
4941                 repeat_push(*cp);
4942                 if (command_cmd) prev_tag = cur_tag;
4943                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4944         }
4945
4946         /* Result */
4947         return (item);
4948 }
4949
4950 /*!
4951  * @brief 床上のアイテムを拾う選択用サブルーチン 
4952  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4953  */
4954 static bool py_pickup_floor_aux(void)
4955 {
4956         OBJECT_IDX this_o_idx;
4957
4958         cptr q, s;
4959
4960         OBJECT_IDX item;
4961
4962         /* Restrict the choices */
4963         item_tester_hook = inven_carry_okay;
4964
4965         /* Get an object */
4966         q = _("どれを拾いますか?", "Get which item? ");
4967         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4968
4969         if (get_item(&item, q, s, (USE_FLOOR)))
4970         {
4971                 this_o_idx = 0 - item;
4972         }
4973         else
4974         {
4975                 return (FALSE);
4976         }
4977
4978         /* Pick up the object */
4979         py_pickup_aux(this_o_idx);
4980
4981         return (TRUE);
4982 }
4983
4984 /*!
4985  * @brief 床上のアイテムを拾うメイン処理
4986  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4987  * @return なし
4988  * @details
4989  * This is called by py_pickup() when easy_floor is TRUE.
4990  */
4991 void py_pickup_floor(bool pickup)
4992 {
4993         OBJECT_IDX this_o_idx, next_o_idx = 0;
4994
4995         char o_name[MAX_NLEN];
4996         object_type *o_ptr;
4997
4998         int floor_num = 0;
4999         OBJECT_IDX floor_o_idx = 0;
5000
5001         int can_pickup = 0;
5002
5003         /* Scan the pile of objects */
5004         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
5005         {
5006                 /* Access the object */
5007                 o_ptr = &o_list[this_o_idx];
5008
5009                 /* Describe the object */
5010                 object_desc(o_name, o_ptr, 0);
5011
5012                 /* Access the next object */
5013                 next_o_idx = o_ptr->next_o_idx;
5014
5015                 /* Hack -- disturb */
5016                 disturb(FALSE, FALSE);
5017
5018                 /* Pick up gold */
5019                 if (o_ptr->tval == TV_GOLD)
5020                 {
5021 #ifdef JP
5022                         msg_format(" $%ld の価値がある%sを見つけた。",
5023                                 (long)o_ptr->pval, o_name);
5024 #else
5025                         msg_format("You have found %ld gold pieces worth of %s.",
5026                                 (long)o_ptr->pval, o_name);
5027 #endif
5028
5029                         /* Collect the gold */
5030                         p_ptr->au += o_ptr->pval;
5031
5032                         /* Redraw gold */
5033                         p_ptr->redraw |= (PR_GOLD);
5034
5035                         p_ptr->window |= (PW_PLAYER);
5036
5037                         /* Delete the gold */
5038                         delete_object_idx(this_o_idx);
5039
5040                         /* Check the next object */
5041                         continue;
5042                 }
5043                 else if (o_ptr->marked & OM_NOMSG)
5044                 {
5045                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
5046                          * ignored. Otherwise, they are included in the prompt. */
5047                         o_ptr->marked &= ~(OM_NOMSG);
5048                         continue;
5049                 }
5050
5051                 /* Count non-gold objects that can be picked up. */
5052                 if (inven_carry_okay(o_ptr))
5053                 {
5054                         can_pickup++;
5055                 }
5056
5057                 /* Count non-gold objects */
5058                 floor_num++;
5059
5060                 /* Remember this index */
5061                 floor_o_idx = this_o_idx;
5062         }
5063
5064         /* There are no non-gold objects */
5065         if (!floor_num)
5066                 return;
5067
5068         /* Mention the number of objects */
5069         if (!pickup)
5070         {
5071                 /* One object */
5072                 if (floor_num == 1)
5073                 {
5074                         /* Access the object */
5075                         o_ptr = &o_list[floor_o_idx];
5076
5077 #ifdef ALLOW_EASY_SENSE
5078
5079                         /* Option: Make object sensing easy */
5080                         if (easy_sense)
5081                         {
5082                                 /* Sense the object */
5083                                 (void) sense_object(o_ptr);
5084                         }
5085
5086 #endif /* ALLOW_EASY_SENSE */
5087
5088                         /* Describe the object */
5089                         object_desc(o_name, o_ptr, 0);
5090
5091                         msg_format(_("%sがある。", "You see %s."), o_name);
5092                 }
5093
5094                 /* Multiple objects */
5095                 else
5096                 {
5097                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
5098                 }
5099
5100                 return;
5101         }
5102
5103         /* The player has no room for anything on the floor. */
5104         if (!can_pickup)
5105         {
5106                 /* One object */
5107                 if (floor_num == 1)
5108                 {
5109                         /* Access the object */
5110                         o_ptr = &o_list[floor_o_idx];
5111
5112 #ifdef ALLOW_EASY_SENSE
5113
5114                         /* Option: Make object sensing easy */
5115                         if (easy_sense)
5116                         {
5117                                 /* Sense the object */
5118                                 (void) sense_object(o_ptr);
5119                         }
5120
5121 #endif /* ALLOW_EASY_SENSE */
5122
5123                         /* Describe the object */
5124                         object_desc(o_name, o_ptr, 0);
5125
5126                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
5127                 }
5128
5129                 /* Multiple objects */
5130                 else
5131                 {
5132                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
5133
5134                 }
5135
5136                 return;
5137         }
5138
5139         /* One object */
5140         if (floor_num == 1)
5141         {
5142                 /* Hack -- query every object */
5143                 if (carry_query_flag)
5144                 {
5145                         char out_val[MAX_NLEN+20];
5146
5147                         /* Access the object */
5148                         o_ptr = &o_list[floor_o_idx];
5149
5150 #ifdef ALLOW_EASY_SENSE
5151
5152                         /* Option: Make object sensing easy */
5153                         if (easy_sense)
5154                         {
5155                                 /* Sense the object */
5156                                 (void) sense_object(o_ptr);
5157                         }
5158
5159 #endif /* ALLOW_EASY_SENSE */
5160
5161                         /* Describe the object */
5162                         object_desc(o_name, o_ptr, 0);
5163
5164                         /* Build a prompt */
5165                         (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
5166
5167                         /* Ask the user to confirm */
5168                         if (!get_check(out_val))
5169                         {
5170                                 return;
5171                         }
5172                 }
5173
5174                 /* Access the object */
5175                 o_ptr = &o_list[floor_o_idx];
5176
5177 #ifdef ALLOW_EASY_SENSE
5178
5179                 /* Option: Make object sensing easy */
5180                 if (easy_sense)
5181                 {
5182                         /* Sense the object */
5183                         (void) sense_object(o_ptr);
5184                 }
5185
5186 #endif /* ALLOW_EASY_SENSE */
5187
5188                 /* Pick up the object */
5189                 py_pickup_aux(floor_o_idx);
5190         }
5191
5192         /* Allow the user to choose an object */
5193         else
5194         {
5195                 while (can_pickup--)
5196                 {
5197                         if (!py_pickup_floor_aux()) break;
5198                 }
5199         }
5200 }
5201
5202 #endif /* ALLOW_EASY_FLOOR */