OSDN Git Service

[Refactor] #38824 choose_object()拡張。 / expand choose_object().
[hengband/hengband.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         screen_save();
1237
1238         Term_get_size(&wid, &hgt);
1239
1240         /* Display Item name */
1241         if (!(mode & SCROBJ_FAKE_OBJECT))
1242                 object_desc(o_name, o_ptr, 0);
1243         else
1244                 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1245
1246         prt(o_name, 0, 0);
1247
1248         /* Erase the screen */
1249         for (k = 1; k < hgt; k++) prt("", k, 13);
1250
1251         /* Label the information */
1252         if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1253         {
1254                 monster_race *r_ptr = &r_info[o_ptr->pval];
1255                 int namelen = strlen(r_name + r_ptr->name);
1256                 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1257                 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1258                 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1259         }
1260         else
1261         {
1262                 prt(_("     アイテムの能力:", "     Item Attributes:"), 1, 15);
1263         }
1264
1265         /* We will print on top of the map (column 13) */
1266         for (k = 2, j = 0; j < i; j++)
1267         {
1268                 /* Show the info */
1269                 prt(info[j], k++, 15);
1270
1271                 /* Every 20 entries (lines 2 to 21), start over */
1272                 if ((k == hgt - 2) && (j+1 < i))
1273                 {
1274                         prt(_("-- 続く --", "-- more --"), k, 15);
1275                         inkey();
1276                         for (; k > 2; k--) prt("", k, 15);
1277                 }
1278         }
1279
1280         /* Wait for it */
1281         prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 15);
1282
1283         inkey();
1284         screen_load();
1285
1286         /* Gave knowledge */
1287         return (TRUE);
1288 }
1289
1290
1291
1292 /*!
1293  * @brief オブジェクト選択時の選択アルファベットラベルを返す /
1294  * Convert an inventory index into a one character label
1295  * @param i プレイヤーの所持/装備オブジェクトID
1296  * @return 対応するアルファベット
1297  * @details Note that the label does NOT distinguish inven/equip.
1298  */
1299 char index_to_label(int i)
1300 {
1301         /* Indexes for "inven" are easy */
1302         if (i < INVEN_RARM) return (I2A(i));
1303
1304         /* Indexes for "equip" are offset */
1305         return (I2A(i - INVEN_RARM));
1306 }
1307
1308 /*!
1309  * @brief 選択アルファベットラベルからプレイヤーの所持オブジェクトIDを返す /
1310  * Convert a label into the index of an item in the "inven"
1311  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1312  * @details Note that the label does NOT distinguish inven/equip.
1313  */
1314 INVENTORY_IDX label_to_inven(int c)
1315 {
1316         INVENTORY_IDX i;
1317
1318         /* Convert */
1319         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1);
1320
1321         /* Verify the index */
1322         if ((i < 0) || (i > INVEN_PACK)) return (-1);
1323
1324         /* Empty slots can never be chosen */
1325         if (!inventory[i].k_idx) return (-1);
1326
1327         /* Return the index */
1328         return (i);
1329 }
1330
1331
1332 /*! See cmd5.c */
1333 extern bool select_ring_slot;
1334
1335
1336 /*!
1337  * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1338  * @param i プレイヤーの所持/装備オブジェクトID
1339  * @return 指輪枠ならばTRUEを返す。
1340  */
1341 static bool is_ring_slot(int i)
1342 {
1343         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1344 }
1345
1346
1347 /*!
1348  * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1349  * Convert a label into the index of a item in the "equip"
1350  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1351  */
1352 INVENTORY_IDX label_to_equip(int c)
1353 {
1354         INVENTORY_IDX i;
1355
1356         /* Convert */
1357         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1358
1359         /* Verify the index */
1360         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1361
1362         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1363
1364         /* Empty slots can never be chosen */
1365         if (!inventory[i].k_idx) return (-1);
1366
1367         /* Return the index */
1368         return (i);
1369 }
1370
1371
1372
1373 /*!
1374  * @brief オブジェクトの該当装備部位IDを返す /
1375  * Determine which equipment slot (if any) an item likes
1376  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
1377  * @return 対応する装備部位ID
1378  */
1379 s16b wield_slot(object_type *o_ptr)
1380 {
1381         /* Slot for equipment */
1382         switch (o_ptr->tval)
1383         {
1384                 case TV_DIGGING:
1385                 case TV_HAFTED:
1386                 case TV_POLEARM:
1387                 case TV_SWORD:
1388                 {
1389                         if (!inventory[INVEN_RARM].k_idx) return (INVEN_RARM);
1390                         if (inventory[INVEN_LARM].k_idx) return (INVEN_RARM);
1391                         return (INVEN_LARM);
1392                 }
1393
1394                 case TV_CAPTURE:
1395                 case TV_CARD:
1396                 case TV_SHIELD:
1397                 {
1398                         if (!inventory[INVEN_LARM].k_idx) return (INVEN_LARM);
1399                         if (inventory[INVEN_RARM].k_idx) return (INVEN_LARM);
1400                         return (INVEN_RARM);
1401                 }
1402
1403                 case TV_BOW:
1404                 {
1405                         return (INVEN_BOW);
1406                 }
1407
1408                 case TV_RING:
1409                 {
1410                         /* Use the right hand first */
1411                         if (!inventory[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
1412
1413                         /* Use the left hand for swapping (by default) */
1414                         return (INVEN_LEFT);
1415                 }
1416
1417                 case TV_AMULET:
1418                 case TV_WHISTLE:
1419                 {
1420                         return (INVEN_NECK);
1421                 }
1422
1423                 case TV_LITE:
1424                 {
1425                         return (INVEN_LITE);
1426                 }
1427
1428                 case TV_DRAG_ARMOR:
1429                 case TV_HARD_ARMOR:
1430                 case TV_SOFT_ARMOR:
1431                 {
1432                         return (INVEN_BODY);
1433                 }
1434
1435                 case TV_CLOAK:
1436                 {
1437                         return (INVEN_OUTER);
1438                 }
1439
1440                 case TV_CROWN:
1441                 case TV_HELM:
1442                 {
1443                         return (INVEN_HEAD);
1444                 }
1445
1446                 case TV_GLOVES:
1447                 {
1448                         return (INVEN_HANDS);
1449                 }
1450
1451                 case TV_BOOTS:
1452                 {
1453                         return (INVEN_FEET);
1454                 }
1455         }
1456
1457         /* No slot available */
1458         return (-1);
1459 }
1460
1461 /*!
1462  * @brief 所持/装備オブジェクトIDの部位表現を返す /
1463  * Return a string mentioning how a given item is carried
1464  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
1465  * @return 部位表現の文字列ポインタ
1466  */
1467 cptr mention_use(int i)
1468 {
1469         cptr p;
1470
1471         /* Examine the location */
1472         switch (i)
1473         {
1474 #ifdef JP
1475                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中" : ((p_ptr->ryoute && p_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手")); break;
1476 #else
1477                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
1478 #endif
1479
1480 #ifdef JP
1481                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中" : ((p_ptr->ryoute && p_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手")); break;
1482 #else
1483                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
1484 #endif
1485
1486 #ifdef JP
1487                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "運搬中" : "射撃用"; break;
1488 #else
1489                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "Just holding" : "Shooting"; break;
1490 #endif
1491
1492 #ifdef JP
1493                 case INVEN_RIGHT: p = (left_hander ? "左手指" : "右手指"); break;
1494 #else
1495                 case INVEN_RIGHT: p = (left_hander ? "On left hand" : "On right hand"); break;
1496 #endif
1497
1498 #ifdef JP
1499                 case INVEN_LEFT:  p = (left_hander ? "右手指" : "左手指"); break;
1500 #else
1501                 case INVEN_LEFT:  p = (left_hander ? "On right hand" : "On left hand"); break;
1502 #endif
1503
1504                 case INVEN_NECK:  p = _("  首", "Around neck"); break;
1505                 case INVEN_LITE:  p = _(" 光源", "Light source"); break;
1506                 case INVEN_BODY:  p = _("  体", "On body"); break;
1507                 case INVEN_OUTER: p = _("体の上", "About body"); break;
1508                 case INVEN_HEAD:  p = _("  頭", "On head"); break;
1509                 case INVEN_HANDS: p = _("  手", "On hands"); break;
1510                 case INVEN_FEET:  p = _("  足", "On feet"); break;
1511                 default:          p = _("ザック", "In pack"); break;
1512         }
1513
1514         /* Return the result */
1515         return p;
1516 }
1517
1518
1519 /*!
1520  * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
1521  * Return a string describing how a given item is being worn.
1522  * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
1523  * @return 状態表現内容の文字列ポインタ
1524  * @details
1525  * Currently, only used for items in the equipment, not inventory.
1526  */
1527 cptr describe_use(int i)
1528 {
1529         cptr p;
1530
1531         switch (i)
1532         {
1533 #ifdef JP
1534                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している")); break;
1535 #else
1536                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
1537 #endif
1538
1539 #ifdef JP
1540                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している")); break;
1541 #else
1542                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
1543 #endif
1544
1545 #ifdef JP
1546                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "持つだけで精一杯の" : "射撃用に装備している"; break;
1547 #else
1548                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "just holding" : "shooting missiles with"; break;
1549 #endif
1550
1551 #ifdef JP
1552                 case INVEN_RIGHT: p = (left_hander ? "左手の指にはめている" : "右手の指にはめている"); break;
1553 #else
1554                 case INVEN_RIGHT: p = (left_hander ? "wearing on your left hand" : "wearing on your right hand"); break;
1555 #endif
1556
1557 #ifdef JP
1558                 case INVEN_LEFT:  p = (left_hander ? "右手の指にはめている" : "左手の指にはめている"); break;
1559 #else
1560                 case INVEN_LEFT:  p = (left_hander ? "wearing on your right hand" : "wearing on your left hand"); break;
1561 #endif
1562
1563                 case INVEN_NECK:  p = _("首にかけている", "wearing around your neck"); break;
1564                 case INVEN_LITE:  p = _("光源にしている", "using to light the way"); break;
1565                 case INVEN_BODY:  p = _("体に着ている", "wearing on your body"); break;
1566                 case INVEN_OUTER: p = _("身にまとっている", "wearing on your back"); break;
1567                 case INVEN_HEAD:  p = _("頭にかぶっている", "wearing on your head"); break;
1568                 case INVEN_HANDS: p = _("手につけている", "wearing on your hands"); break;
1569                 case INVEN_FEET:  p = _("足にはいている", "wearing on your feet"); break;
1570                 default:          p = _("ザックに入っている", "carrying in your pack"); break;
1571         }
1572
1573         /* Return the result */
1574         return p;
1575 }
1576
1577
1578 /*!
1579  * @brief tval/sval指定のベースアイテムがプレイヤーの使用可能な魔法書かどうかを返す /
1580  * Hack: Check if a spellbook is one of the realms we can use. -- TY
1581  * @param book_tval ベースアイテムのtval
1582  * @param book_sval ベースアイテムのsval
1583  * @return 使用可能な魔法書ならばTRUEを返す。
1584  */
1585
1586 bool check_book_realm(const OBJECT_TYPE_VALUE book_tval, const OBJECT_SUBTYPE_VALUE book_sval)
1587 {
1588         if (book_tval < TV_LIFE_BOOK) return FALSE;
1589         if (p_ptr->pclass == CLASS_SORCERER)
1590         {
1591                 return is_magic(tval2realm(book_tval));
1592         }
1593         else if (p_ptr->pclass == CLASS_RED_MAGE)
1594         {
1595                 if (is_magic(tval2realm(book_tval)))
1596                         return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
1597         }
1598         return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
1599 }
1600
1601 /*!
1602  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1603  * Check an item against the item tester info
1604  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1605  * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1606  */
1607 bool item_tester_okay(object_type *o_ptr)
1608 {
1609         /* Hack -- allow listing empty slots */
1610         if (item_tester_full) return (TRUE);
1611
1612         /* Require an item */
1613         if (!o_ptr->k_idx) return (FALSE);
1614
1615         /* Hack -- ignore "gold" */
1616         if (o_ptr->tval == TV_GOLD)
1617         {
1618                 /* See xtra2.c */
1619                 extern bool show_gold_on_floor;
1620
1621                 if (!show_gold_on_floor) return (FALSE);
1622         }
1623
1624         /* Check the tval */
1625         if (item_tester_tval)
1626         {
1627                 /* Is it a spellbook? If so, we need a hack -- TY */
1628                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1629                         (item_tester_tval >= TV_LIFE_BOOK))
1630                         return check_book_realm(o_ptr->tval, o_ptr->sval);
1631                 else
1632                         if (item_tester_tval != o_ptr->tval) return (FALSE);
1633         }
1634
1635         /* Check the hook */
1636         if (item_tester_hook)
1637         {
1638                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1639         }
1640
1641         /* Assume okay */
1642         return (TRUE);
1643 }
1644
1645
1646 /*!
1647  * @brief 所持アイテム一覧を表示する /
1648  * Choice window "shadow" of the "show_inven()" function
1649  * @return なし
1650  */
1651 void display_inven(void)
1652 {
1653         register        int i, n, z = 0;
1654         object_type     *o_ptr;
1655         TERM_COLOR      attr = TERM_WHITE;
1656         char            tmp_val[80];
1657         char            o_name[MAX_NLEN];
1658         int             wid, hgt;
1659
1660         Term_get_size(&wid, &hgt);
1661
1662         /* Find the "final" slot */
1663         for (i = 0; i < INVEN_PACK; i++)
1664         {
1665                 o_ptr = &inventory[i];
1666
1667                 /* Skip non-objects */
1668                 if (!o_ptr->k_idx) continue;
1669
1670                 /* Track */
1671                 z = i + 1;
1672         }
1673
1674         /* Display the pack */
1675         for (i = 0; i < z; i++)
1676         {
1677                 /* Examine the item */
1678                 o_ptr = &inventory[i];
1679
1680                 /* Start with an empty "index" */
1681                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1682
1683                 /* Is this item "acceptable"? */
1684                 if (item_tester_okay(o_ptr))
1685                 {
1686                         /* Prepare an "index" */
1687                         tmp_val[0] = index_to_label(i);
1688
1689                         /* Bracket the "index" --(-- */
1690                         tmp_val[1] = ')';
1691                 }
1692
1693                 /* Display the index (or blank space) */
1694                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1695
1696                 /* Obtain an item description */
1697                 object_desc(o_name, o_ptr, 0);
1698
1699                 /* Obtain the length of the description */
1700                 n = strlen(o_name);
1701
1702                 /* Get a color */
1703                 attr = tval_to_attr[o_ptr->tval % 128];
1704
1705                 /* Grey out charging items */
1706                 if (o_ptr->timeout)
1707                 {
1708                         attr = TERM_L_DARK;
1709                 }
1710
1711                 /* Display the entry itself */
1712                 Term_putstr(3, i, n, attr, o_name);
1713
1714                 /* Erase the rest of the line */
1715                 Term_erase(3+n, i, 255);
1716
1717                 /* Display the weight if needed */
1718                 if (show_weights)
1719                 {
1720                         int wgt = o_ptr->weight * o_ptr->number;
1721 #ifdef JP
1722                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt),lbtokg2(wgt) );
1723 #else
1724                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1725 #endif
1726
1727                         prt(tmp_val, i, wid - 9);
1728                 }
1729         }
1730
1731         /* Erase the rest of the window */
1732         for (i = z; i < hgt; i++)
1733         {
1734                 /* Erase the line */
1735                 Term_erase(0, i, 255);
1736         }
1737 }
1738
1739
1740
1741 /*!
1742  * @brief 装備アイテム一覧を表示する /
1743  * Choice window "shadow" of the "show_equip()" function
1744  * @return なし
1745  */
1746 void display_equip(void)
1747 {
1748         register        int i, n;
1749         object_type     *o_ptr;
1750         TERM_COLOR      attr = TERM_WHITE;
1751         char            tmp_val[80];
1752         char            o_name[MAX_NLEN];
1753         int             wid, hgt;
1754
1755         Term_get_size(&wid, &hgt);
1756
1757         /* Display the equipment */
1758         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1759         {
1760                 /* Examine the item */
1761                 o_ptr = &inventory[i];
1762
1763                 /* Start with an empty "index" */
1764                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1765
1766                 /* Is this item "acceptable"? */
1767                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1768                 {
1769                         /* Prepare an "index" */
1770                         tmp_val[0] = index_to_label(i);
1771
1772                         /* Bracket the "index" --(-- */
1773                         tmp_val[1] = ')';
1774                 }
1775
1776                 /* Display the index (or blank space) */
1777                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1778
1779                 /* Obtain an item description */
1780                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1781                 {
1782                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1783                         attr = TERM_WHITE;
1784                 }
1785                 else
1786                 {
1787                         object_desc(o_name, o_ptr, 0);
1788                         attr = tval_to_attr[o_ptr->tval % 128];
1789                 }
1790
1791                 /* Obtain the length of the description */
1792                 n = strlen(o_name);
1793
1794                 /* Grey out charging items */
1795                 if (o_ptr->timeout)
1796                 {
1797                         attr = TERM_L_DARK;
1798                 }
1799
1800                 /* Display the entry itself */
1801                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1802
1803                 /* Erase the rest of the line */
1804                 Term_erase(3+n, i - INVEN_RARM, 255);
1805
1806                 /* Display the weight (if needed) */
1807                 if (show_weights)
1808                 {
1809                         int wgt = o_ptr->weight * o_ptr->number;
1810 #ifdef JP
1811                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1812 #else
1813                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1814 #endif
1815
1816                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1817                 }
1818
1819                 /* Display the slot description (if needed) */
1820                 if (show_labels)
1821                 {
1822                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1823                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
1824                 }
1825         }
1826
1827         /* Erase the rest of the window */
1828         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1829         {
1830                 /* Clear that line */
1831                 Term_erase(0, i, 255);
1832         }
1833 }
1834
1835
1836 /*!
1837  * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1838  * Find the "first" inventory object with the given "tag".
1839  * @param cp 対応するタグIDを与える参照ポインタ
1840  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1841  * @param mode 所持、装備の切り替え
1842  * @return タグに該当するオブジェクトがあるならTRUEを返す
1843  * @details
1844  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1845  * inscription of an object.  Alphabetical characters don't work as a\n
1846  * tag in this form.\n
1847  *\n
1848  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1849  * and "x" is the "current" command_cmd code.\n
1850  */
1851 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1852 {
1853         COMMAND_CODE i;
1854         COMMAND_CODE start, end;
1855         cptr s;
1856
1857         /* Extract index from mode */
1858         switch (mode)
1859         {
1860         case USE_EQUIP:
1861                 start = INVEN_RARM;
1862                 end = INVEN_TOTAL - 1;
1863                 break;
1864
1865         case USE_INVEN:
1866                 start = 0;
1867                 end = INVEN_PACK - 1;
1868                 break;
1869
1870         default:
1871                 return FALSE;
1872         }
1873
1874         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1875
1876         /* Check every inventory object */
1877         for (i = start; i <= end; i++)
1878         {
1879                 object_type *o_ptr = &inventory[i];
1880
1881                 /* Skip non-objects */
1882                 if (!o_ptr->k_idx) continue;
1883
1884                 /* Skip empty inscriptions */
1885                 if (!o_ptr->inscription) continue;
1886
1887                 /* Skip non-choice */
1888                 if (!item_tester_okay(o_ptr)) continue;
1889
1890                 /* Find a '@' */
1891                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1892
1893                 /* Process all tags */
1894                 while (s)
1895                 {
1896                         /* Check the special tags */
1897                         if ((s[1] == command_cmd) && (s[2] == tag))
1898                         {
1899                                 /* Save the actual inventory ID */
1900                                 *cp = i;
1901
1902                                 /* Success */
1903                                 return (TRUE);
1904                         }
1905
1906                         /* Find another '@' */
1907                         s = my_strchr(s + 1, '@');
1908                 }
1909         }
1910
1911
1912         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1913
1914         /* Don't allow {@#} with '#' being alphabet */
1915         if (tag < '0' || '9' < tag)
1916         {
1917                 /* No such tag */
1918                 return FALSE;
1919         }
1920
1921         /* Check every object */
1922         for (i = start; i <= end; i++)
1923         {
1924                 object_type *o_ptr = &inventory[i];
1925
1926                 /* Skip non-objects */
1927                 if (!o_ptr->k_idx) continue;
1928
1929                 /* Skip empty inscriptions */
1930                 if (!o_ptr->inscription) continue;
1931
1932                 /* Skip non-choice */
1933                 if (!item_tester_okay(o_ptr)) continue;
1934
1935                 /* Find a '@' */
1936                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1937
1938                 /* Process all tags */
1939                 while (s)
1940                 {
1941                         /* Check the normal tags */
1942                         if (s[1] == tag)
1943                         {
1944                                 /* Save the actual inventory ID */
1945                                 *cp = i;
1946
1947                                 /* Success */
1948                                 return (TRUE);
1949                         }
1950
1951                         /* Find another '@' */
1952                         s = my_strchr(s + 1, '@');
1953                 }
1954         }
1955
1956         /* No such tag */
1957         return (FALSE);
1958 }
1959
1960
1961 /*!
1962  * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1963  * Find the "first" inventory object with the given "tag".
1964  * @param cp 対応するタグIDを与える参照ポインタ
1965  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1966  * @param floor_list 床上アイテムの配列
1967  * @param floor_num  床上アイテムの配列ID
1968  * @return タグに該当するオブジェクトがあるならTRUEを返す
1969  * @details
1970  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1971  * inscription of an object.  Alphabetical characters don't work as a\n
1972  * tag in this form.\n
1973  *\n
1974  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1975  * and "x" is the "current" command_cmd code.\n
1976  */
1977 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1978 {
1979         COMMAND_CODE i;
1980         cptr s;
1981
1982         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1983
1984         /* Check every object in the grid */
1985         for (i = 0; i < floor_num && i < 23; i++)
1986         {
1987                 object_type *o_ptr = &o_list[floor_list[i]];
1988
1989                 /* Skip empty inscriptions */
1990                 if (!o_ptr->inscription) continue;
1991
1992                 /* Find a '@' */
1993                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1994
1995                 /* Process all tags */
1996                 while (s)
1997                 {
1998                         /* Check the special tags */
1999                         if ((s[1] == command_cmd) && (s[2] == tag))
2000                         {
2001                                 /* Save the actual floor object ID */
2002                                 *cp = i;
2003
2004                                 /* Success */
2005                                 return (TRUE);
2006                         }
2007
2008                         /* Find another '@' */
2009                         s = my_strchr(s + 1, '@');
2010                 }
2011         }
2012
2013
2014         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
2015
2016         /* Don't allow {@#} with '#' being alphabet */
2017         if (tag < '0' || '9' < tag)
2018         {
2019                 /* No such tag */
2020                 return FALSE;
2021         }
2022
2023         /* Check every object in the grid */
2024         for (i = 0; i < floor_num && i < 23; i++)
2025         {
2026                 object_type *o_ptr = &o_list[floor_list[i]];
2027
2028                 /* Skip empty inscriptions */
2029                 if (!o_ptr->inscription) continue;
2030
2031                 /* Find a '@' */
2032                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2033
2034                 /* Process all tags */
2035                 while (s)
2036                 {
2037                         /* Check the normal tags */
2038                         if (s[1] == tag)
2039                         {
2040                                 /* Save the floor object ID */
2041                                 *cp = i;
2042
2043                                 /* Success */
2044                                 return (TRUE);
2045                         }
2046
2047                         /* Find another '@' */
2048                         s = my_strchr(s + 1, '@');
2049                 }
2050         }
2051
2052         /* No such tag */
2053         return (FALSE);
2054 }
2055
2056
2057 /*!
2058  * @brief タグIDにあわせてタグアルファベットのリストを返す /
2059  * Move around label characters with correspond tags
2060  * @param label ラベルリストを取得する文字列参照ポインタ
2061  * @param mode 所持品リストか装備品リストかの切り替え
2062  * @return なし
2063  */
2064 static void prepare_label_string(char *label, BIT_FLAGS mode)
2065 {
2066         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2067         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
2068         int  i;
2069
2070         /* Prepare normal labels */
2071         strcpy(label, alphabet_chars);
2072
2073         /* Move each label */
2074         for (i = 0; i < 52; i++)
2075         {
2076                 COMMAND_CODE index;
2077                 char c = alphabet_chars[i];
2078
2079                 /* Find a tag with this label */
2080                 if (get_tag(&index, c, mode))
2081                 {
2082                         /* Delete the overwritten label */
2083                         if (label[i] == c) label[i] = ' ';
2084
2085                         /* Move the label to the place of corresponding tag */
2086                         label[index - offset] = c;
2087                 }
2088         }
2089 }
2090
2091
2092 /*!
2093  * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2094  * Move around label characters with correspond tags (floor version)
2095  * @param label ラベルリストを取得する文字列参照ポインタ
2096  * @param floor_list 床上アイテムの配列
2097  * @param floor_num  床上アイテムの配列ID
2098  * @return なし
2099  */
2100 /*
2101  */
2102 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
2103 {
2104         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2105         int  i;
2106
2107         /* Prepare normal labels */
2108         strcpy(label, alphabet_chars);
2109
2110         /* Move each label */
2111         for (i = 0; i < 52; i++)
2112         {
2113                 COMMAND_CODE index;
2114                 char c = alphabet_chars[i];
2115
2116                 /* Find a tag with this label */
2117                 if (get_tag_floor(&index, c, floor_list, floor_num))
2118                 {
2119                         /* Delete the overwritten label */
2120                         if (label[i] == c) label[i] = ' ';
2121
2122                         /* Move the label to the place of corresponding tag */
2123                         label[index] = c;
2124                 }
2125         }
2126 }
2127
2128
2129 /*!
2130  * @brief 所持アイテムの表示を行う /
2131  * Display the inventory.
2132  * @param target_item アイテムの選択処理を行うか否か。
2133  * @return 選択したアイテムのタグ
2134  * @details
2135  * Hack -- do not display "trailing" empty slots
2136  */
2137 COMMAND_CODE show_inven(int target_item)
2138 {
2139         COMMAND_CODE i;
2140         int j, k, l, z = 0;
2141         int             col, cur_col, len;
2142         object_type     *o_ptr;
2143         char            o_name[MAX_NLEN];
2144         char            tmp_val[80];
2145         COMMAND_CODE    out_index[23];
2146         TERM_COLOR      out_color[23];
2147         char            out_desc[23][MAX_NLEN];
2148         COMMAND_CODE target_item_label = 0;
2149         TERM_LEN wid, hgt;
2150         char            inven_label[52 + 1];
2151
2152         /* Starting column */
2153         col = command_gap;
2154
2155         Term_get_size(&wid, &hgt);
2156
2157         /* Default "max-length" */
2158         len = wid - col - 1;
2159
2160
2161         /* Find the "final" slot */
2162         for (i = 0; i < INVEN_PACK; i++)
2163         {
2164                 o_ptr = &inventory[i];
2165
2166                 /* Skip non-objects */
2167                 if (!o_ptr->k_idx) continue;
2168
2169                 /* Track */
2170                 z = i + 1;
2171         }
2172
2173         prepare_label_string(inven_label, USE_INVEN);
2174
2175         /* Display the inventory */
2176         for (k = 0, i = 0; i < z; i++)
2177         {
2178                 o_ptr = &inventory[i];
2179
2180                 /* Is this item acceptable? */
2181                 if (!item_tester_okay(o_ptr)) continue;
2182
2183                 object_desc(o_name, o_ptr, 0);
2184
2185                 /* Save the object index, color, and description */
2186                 out_index[k] = i;
2187                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2188
2189                 /* Grey out charging items */
2190                 if (o_ptr->timeout)
2191                 {
2192                         out_color[k] = TERM_L_DARK;
2193                 }
2194
2195                 (void)strcpy(out_desc[k], o_name);
2196
2197                 /* Find the predicted "line length" */
2198                 l = strlen(out_desc[k]) + 5;
2199
2200                 /* Be sure to account for the weight */
2201                 if (show_weights) l += 9;
2202
2203                 /* Account for icon if displayed */
2204                 if (show_item_graph)
2205                 {
2206                         l += 2;
2207                         if (use_bigtile) l++;
2208                 }
2209
2210                 /* Maintain the maximum length */
2211                 if (l > len) len = l;
2212
2213                 /* Advance to next "line" */
2214                 k++;
2215         }
2216
2217         /* Find the column to start in */
2218         col = (len > wid - 4) ? 0 : (wid - len - 1);
2219
2220         /* Output each entry */
2221         for (j = 0; j < k; j++)
2222         {
2223                 /* Get the index */
2224                 i = out_index[j];
2225
2226                 o_ptr = &inventory[i];
2227
2228                 /* Clear the line */
2229                 prt("", j + 1, col ? col - 2 : col);
2230
2231                 if (use_menu && target_item)
2232                 {
2233                         if (j == (target_item-1))
2234                         {
2235                                 strcpy(tmp_val, _("》", "> "));
2236                                 target_item_label = i;
2237                         }
2238                         else strcpy(tmp_val, "  ");
2239                 }
2240                 else if (i <= INVEN_PACK)
2241                 {
2242                         /* Prepare an index --(-- */
2243                         sprintf(tmp_val, "%c)", inven_label[i]);
2244                 }
2245                 else
2246                 {
2247                         /* Prepare an index --(-- */
2248                         sprintf(tmp_val, "%c)", index_to_label(i));
2249                 }
2250
2251                 /* Clear the line with the (possibly indented) index */
2252                 put_str(tmp_val, j + 1, col);
2253
2254                 cur_col = col + 3;
2255
2256                 /* Display graphics for object, if desired */
2257                 if (show_item_graph)
2258                 {
2259                         byte  a = object_attr(o_ptr);
2260                         char c = object_char(o_ptr);
2261                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2262                         if (use_bigtile) cur_col++;
2263
2264                         cur_col += 2;
2265                 }
2266
2267
2268                 /* Display the entry itself */
2269                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2270
2271                 /* Display the weight if needed */
2272                 if (show_weights)
2273                 {
2274                         int wgt = o_ptr->weight * o_ptr->number;
2275 #ifdef JP
2276                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2277 #else
2278                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2279 #endif
2280
2281                         prt(tmp_val, j + 1, wid - 9);
2282                 }
2283         }
2284
2285         /* Make a "shadow" below the list (only if needed) */
2286         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2287
2288         /* Save the new column */
2289         command_gap = col;
2290
2291         return target_item_label;
2292 }
2293
2294
2295 /*!
2296  * @brief 装備アイテムの表示を行う /
2297  * Display the equipment.
2298  * @param target_item アイテムの選択処理を行うか否か。
2299  * @return 選択したアイテムのタグ
2300  */
2301 COMMAND_CODE show_equip(int target_item)
2302 {
2303         COMMAND_CODE i;
2304         int j, k, l;
2305         int             col, cur_col, len;
2306         object_type     *o_ptr;
2307         char            tmp_val[80];
2308         char            o_name[MAX_NLEN];
2309         COMMAND_CODE    out_index[23];
2310         TERM_COLOR      out_color[23];
2311         char            out_desc[23][MAX_NLEN];
2312         COMMAND_CODE target_item_label = 0;
2313         TERM_LEN wid, hgt;
2314         char            equip_label[52 + 1];
2315
2316         /* Starting column */
2317         col = command_gap;
2318
2319         Term_get_size(&wid, &hgt);
2320
2321         /* Maximal length */
2322         len = wid - col - 1;
2323
2324
2325         /* Scan the equipment list */
2326         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2327         {
2328                 o_ptr = &inventory[i];
2329
2330                 /* Is this item acceptable? */
2331                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr)) &&
2332                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2333                      item_tester_no_ryoute)) continue;
2334
2335                 /* Description */
2336                 object_desc(o_name, o_ptr, 0);
2337
2338                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2339                 {
2340                         (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2341                         out_color[k] = TERM_WHITE;
2342                 }
2343                 else
2344                 {
2345                         (void)strcpy(out_desc[k], o_name);
2346                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
2347                 }
2348
2349                 out_index[k] = i;
2350                 /* Grey out charging items */
2351                 if (o_ptr->timeout)
2352                 {
2353                         out_color[k] = TERM_L_DARK;
2354                 }
2355
2356                 /* Extract the maximal length (see below) */
2357 #ifdef JP
2358                 l = strlen(out_desc[k]) + (2 + 1);
2359 #else
2360                 l = strlen(out_desc[k]) + (2 + 3);
2361 #endif
2362
2363
2364                 /* Increase length for labels (if needed) */
2365 #ifdef JP
2366                 if (show_labels) l += (7 + 2);
2367 #else
2368                 if (show_labels) l += (14 + 2);
2369 #endif
2370
2371
2372                 /* Increase length for weight (if needed) */
2373                 if (show_weights) l += 9;
2374
2375                 if (show_item_graph) l += 2;
2376
2377                 /* Maintain the max-length */
2378                 if (l > len) len = l;
2379
2380                 /* Advance the entry */
2381                 k++;
2382         }
2383
2384         /* Hack -- Find a column to start in */
2385 #ifdef JP
2386         col = (len > wid - 6) ? 0 : (wid - len - 1);
2387 #else
2388         col = (len > wid - 4) ? 0 : (wid - len - 1);
2389 #endif
2390
2391         prepare_label_string(equip_label, USE_EQUIP);
2392
2393         /* Output each entry */
2394         for (j = 0; j < k; j++)
2395         {
2396                 /* Get the index */
2397                 i = out_index[j];
2398
2399                 o_ptr = &inventory[i];
2400
2401                 /* Clear the line */
2402                 prt("", j + 1, col ? col - 2 : col);
2403
2404                 if (use_menu && target_item)
2405                 {
2406                         if (j == (target_item-1))
2407                         {
2408                                 strcpy(tmp_val, _("》", "> "));
2409                                 target_item_label = i;
2410                         }
2411                         else strcpy(tmp_val, "  ");
2412                 }
2413                 else if (i >= INVEN_RARM)
2414                 {
2415                         /* Prepare an index --(-- */
2416                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2417                 }
2418                 else /* Paranoia */
2419                 {
2420                         /* Prepare an index --(-- */
2421                         sprintf(tmp_val, "%c)", index_to_label(i));
2422                 }
2423
2424                 /* Clear the line with the (possibly indented) index */
2425                 put_str(tmp_val, j+1, col);
2426
2427                 cur_col = col + 3;
2428
2429                 /* Display graphics for object, if desired */
2430                 if (show_item_graph)
2431                 {
2432                         byte a = object_attr(o_ptr);
2433                         char c = object_char(o_ptr);
2434                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2435                         if (use_bigtile) cur_col++;
2436
2437                         cur_col += 2;
2438                 }
2439
2440                 /* Use labels */
2441                 if (show_labels)
2442                 {
2443                         /* Mention the use */
2444                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2445
2446                         put_str(tmp_val, j+1, cur_col);
2447
2448                         /* Display the entry itself */
2449                         c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2450                 }
2451
2452                 /* No labels */
2453                 else
2454                 {
2455                         /* Display the entry itself */
2456                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2457                 }
2458
2459                 /* Display the weight if needed */
2460                 if (show_weights)
2461                 {
2462                         int wgt = o_ptr->weight * o_ptr->number;
2463 #ifdef JP
2464                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2465 #else
2466                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2467 #endif
2468
2469                         prt(tmp_val, j + 1, wid - 9);
2470                 }
2471         }
2472
2473         /* Make a "shadow" below the list (only if needed) */
2474         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2475
2476         /* Save the new column */
2477         command_gap = col;
2478
2479         return target_item_label;
2480 }
2481
2482 /*!
2483  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2484  * Flip "inven" and "equip" in any sub-windows
2485  * @return なし
2486  */
2487 void toggle_inven_equip(void)
2488 {
2489         int j;
2490
2491         /* Scan windows */
2492         for (j = 0; j < 8; j++)
2493         {
2494                 /* Unused */
2495                 if (!angband_term[j]) continue;
2496
2497                 /* Flip inven to equip */
2498                 if (window_flag[j] & (PW_INVEN))
2499                 {
2500                         /* Flip flags */
2501                         window_flag[j] &= ~(PW_INVEN);
2502                         window_flag[j] |= (PW_EQUIP);
2503
2504                         p_ptr->window |= (PW_EQUIP);
2505                 }
2506
2507                 /* Flip inven to equip */
2508                 else if (window_flag[j] & (PW_EQUIP))
2509                 {
2510                         /* Flip flags */
2511                         window_flag[j] &= ~(PW_EQUIP);
2512                         window_flag[j] |= (PW_INVEN);
2513
2514                         p_ptr->window |= (PW_INVEN);
2515                 }
2516         }
2517 }
2518
2519 /*!
2520  * @brief 選択したアイテムの確認処理の補助 /
2521  * Verify the choice of an item.
2522  * @param prompt メッセージ表示の一部
2523  * @param item 選択アイテムID
2524  * @return 確認がYesならTRUEを返す。
2525  * @details The item can be negative to mean "item on floor".
2526  */
2527 static bool verify(cptr prompt, INVENTORY_IDX item)
2528 {
2529         char        o_name[MAX_NLEN];
2530         char        out_val[MAX_NLEN+20];
2531         object_type *o_ptr;
2532
2533
2534         /* Inventory */
2535         if (item >= 0)
2536         {
2537                 o_ptr = &inventory[item];
2538         }
2539
2540         /* Floor */
2541         else
2542         {
2543                 o_ptr = &o_list[0 - item];
2544         }
2545         object_desc(o_name, o_ptr, 0);
2546
2547         /* Prompt */
2548         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2549
2550         /* Query */
2551         return (get_check(out_val));
2552 }
2553
2554
2555 /*!
2556  * @brief 選択したアイテムの確認処理のメインルーチン /
2557  * @param item 選択アイテムID
2558  * @return 確認がYesならTRUEを返す。
2559  * @details The item can be negative to mean "item on floor".
2560  * Hack -- allow user to "prevent" certain choices
2561  */
2562 static bool get_item_allow(INVENTORY_IDX item)
2563 {
2564         cptr s;
2565         object_type *o_ptr;
2566         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2567
2568         /* Inventory */
2569         if (item >= 0)
2570         {
2571                 o_ptr = &inventory[item];
2572         }
2573
2574         /* Floor */
2575         else
2576         {
2577                 o_ptr = &o_list[0 - item];
2578         }
2579
2580         /* No inscription */
2581         if (!o_ptr->inscription) return (TRUE);
2582
2583         /* Find a '!' */
2584         s = my_strchr(quark_str(o_ptr->inscription), '!');
2585
2586         /* Process preventions */
2587         while (s)
2588         {
2589                 /* Check the "restriction" */
2590                 if ((s[1] == command_cmd) || (s[1] == '*'))
2591                 {
2592                         /* Verify the choice */
2593                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2594                 }
2595
2596                 /* Find another '!' */
2597                 s = my_strchr(s + 1, '!');
2598         }
2599
2600         /* Allow it */
2601         return (TRUE);
2602 }
2603
2604
2605 /*!
2606  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2607  * Auxiliary function for "get_item()" -- test an index
2608  * @param i 選択アイテムID
2609  * @return 正規のIDならばTRUEを返す。
2610  */
2611 static bool get_item_okay(OBJECT_IDX i)
2612 {
2613         /* Illegal items */
2614         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2615
2616         if (select_ring_slot) return is_ring_slot(i);
2617
2618         /* Verify the item */
2619         if (!item_tester_okay(&inventory[i])) return (FALSE);
2620
2621         /* Assume okay */
2622         return (TRUE);
2623 }
2624
2625 /*!
2626  * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2627  * Determine whether get_item() can get some item or not
2628  * @return アイテムを拾えるならばTRUEを返す。
2629  * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2630  */
2631 bool can_get_item(void)
2632 {
2633         int j;
2634         OBJECT_IDX floor_list[23];
2635         ITEM_NUMBER floor_num = 0;
2636
2637         for (j = 0; j < INVEN_TOTAL; j++)
2638                 if (item_tester_okay(&inventory[j]))
2639                         return TRUE;
2640
2641         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2642         if (floor_num)
2643                 return TRUE;
2644
2645         return FALSE;
2646 }
2647
2648 /*!
2649  * @brief オブジェクト選択の汎用関数 /
2650  * Let the user select an item, save its "index"
2651  * @param cp 選択したオブジェクトのIDを返す。
2652  * @param pmt 選択目的のメッセージ
2653  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2654  * @param mode オプションフラグ
2655  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2656  * Return TRUE only if an acceptable item was chosen by the user.\n
2657  * @details
2658  * The selected item must satisfy the "item_tester_hook()" function,\n
2659  * if that hook is set, and the "item_tester_tval", if that value is set.\n
2660  *\n
2661  * All "item_tester" restrictions are cleared before this function returns.\n
2662  *\n
2663  * The user is allowed to choose acceptable items from the equipment,\n
2664  * inventory, or floor, respectively, if the proper flag was given,\n
2665  * and there are any acceptable items in that location.\n
2666  *\n
2667  * The equipment or inventory are displayed (even if no acceptable\n
2668  * items are in that location) if the proper flag was given.\n
2669  *\n
2670  * If there are no acceptable items available anywhere, and "str" is\n
2671  * not NULL, then it will be used as the text of a warning message\n
2672  * before the function returns.\n
2673  *\n
2674  * Note that the user must press "-" to specify the item on the floor,\n
2675  * and there is no way to "examine" the item on the floor, while the\n
2676  * use of "capital" letters will "examine" an inventory/equipment item,\n
2677  * and prompt for its use.\n
2678  *\n
2679  * If a legal item is selected from the inventory, we save it in "cp"\n
2680  * directly (0 to 35), and return TRUE.\n
2681  *\n
2682  * If a legal item is selected from the floor, we save it in "cp" as\n
2683  * a negative (-1 to -511), and return TRUE.\n
2684  *\n
2685  * If no item is available, we do nothing to "cp", and we display a\n
2686  * warning message, using "str" if available, and return FALSE.\n
2687  *\n
2688  * If no item is selected, we do nothing to "cp", and return FALSE.\n
2689  *\n
2690  * Global "p_ptr->command_new" is used when viewing the inventory or equipment\n
2691  * to allow the user to enter a command while viewing those screens, and\n
2692  * also to induce "auto-enter" of stores, and other such stuff.\n
2693  *\n
2694  * Global "p_ptr->command_see" may be set before calling this function to start\n
2695  * out in "browse" mode.  It is cleared before this function returns.\n
2696  *\n
2697  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2698  * If it is TRUE then we are viewing inventory, else equipment.\n
2699  *\n
2700  * We always erase the prompt when we are done, leaving a blank line,\n
2701  * or a warning message, if appropriate, if no items are available.\n
2702  */
2703 bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
2704 {
2705         OBJECT_IDX this_o_idx, next_o_idx = 0;
2706
2707         char which = ' ';
2708
2709         int j;
2710         OBJECT_IDX k;
2711         OBJECT_IDX i1, i2;
2712         OBJECT_IDX e1, e2;
2713
2714         bool done, item;
2715
2716         bool oops = FALSE;
2717
2718         bool equip = FALSE;
2719         bool inven = FALSE;
2720         bool floor = FALSE;
2721
2722         bool allow_floor = FALSE;
2723
2724         bool toggle = FALSE;
2725
2726         char tmp_val[160];
2727         char out_val[160];
2728
2729         /* See cmd5.c */
2730         extern bool select_the_force;
2731
2732         int menu_line = (use_menu ? 1 : 0);
2733         int max_inven = 0;
2734         int max_equip = 0;
2735
2736         static char prev_tag = '\0';
2737         char cur_tag = '\0';
2738
2739         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2740
2741         /* Extract args */
2742         if (mode & USE_EQUIP) equip = TRUE;
2743         if (mode & USE_INVEN) inven = TRUE;
2744         if (mode & USE_FLOOR) floor = TRUE;
2745
2746         /* Get the item index */
2747         if (repeat_pull(cp))
2748         {
2749                 /* the_force */
2750                 if (select_the_force && (*cp == INVEN_FORCE))
2751                 {
2752                         item_tester_tval = 0;
2753                         item_tester_hook = NULL;
2754                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2755                         return (TRUE);
2756                 }
2757
2758                 /* Floor item? */
2759                 else if (floor && (*cp < 0))
2760                 {
2761                         object_type *o_ptr;
2762
2763                         /* Special index */
2764                         k = 0 - (*cp);
2765                         o_ptr = &o_list[k];
2766
2767                         /* Validate the item */
2768                         if (item_tester_okay(o_ptr))
2769                         {
2770                                 /* Forget restrictions */
2771                                 item_tester_tval = 0;
2772                                 item_tester_hook = NULL;
2773                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2774
2775                                 /* Success */
2776                                 return TRUE;
2777                         }
2778                 }
2779
2780                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2781                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2782                 {
2783                         if (prev_tag && command_cmd)
2784                         {
2785                                 /* Look up the tag and validate the item */
2786                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2787                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2788                                 else if (!get_item_okay(k)) /* Reject */;
2789                                 else
2790                                 {
2791                                         /* Accept that choice */
2792                                         (*cp) = k;
2793
2794                                         /* Forget restrictions */
2795                                         item_tester_tval = 0;
2796                                         item_tester_hook = NULL;
2797                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2798
2799                                         /* Success */
2800                                         return TRUE;
2801                                 }
2802
2803                                 prev_tag = '\0'; /* prev_tag is no longer effective */
2804                         }
2805
2806                         /* Verify the item */
2807                         else if (get_item_okay(*cp))
2808                         {
2809                                 /* Forget restrictions */
2810                                 item_tester_tval = 0;
2811                                 item_tester_hook = NULL;
2812                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2813
2814                                 /* Success */
2815                                 return TRUE;
2816                         }
2817                 }
2818         }
2819
2820         /* Paranoia */
2821         msg_print(NULL);
2822
2823         /* Not done */
2824         done = FALSE;
2825
2826         /* No item selected */
2827         item = FALSE;
2828
2829
2830         /* Full inventory */
2831         i1 = 0;
2832         i2 = INVEN_PACK - 1;
2833
2834         /* Forbid inventory */
2835         if (!inven) i2 = -1;
2836         else if (use_menu)
2837         {
2838                 for (j = 0; j < INVEN_PACK; j++)
2839                         if (item_tester_okay(&inventory[j])) max_inven++;
2840         }
2841
2842         /* Restrict inventory indexes */
2843         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2844         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2845
2846
2847         /* Full equipment */
2848         e1 = INVEN_RARM;
2849         e2 = INVEN_TOTAL - 1;
2850
2851         /* Forbid equipment */
2852         if (!equip) e2 = -1;
2853         else if (use_menu)
2854         {
2855                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2856                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
2857                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
2858         }
2859
2860         /* Restrict equipment indexes */
2861         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2862         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2863
2864         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
2865         {
2866                 if (p_ptr->migite)
2867                 {
2868                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2869                 }
2870                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2871         }
2872
2873
2874         /* Restrict floor usage */
2875         if (floor)
2876         {
2877                 /* Scan all objects in the grid */
2878                 for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2879                 {
2880                         object_type *o_ptr;
2881                         o_ptr = &o_list[this_o_idx];
2882
2883                         /* Acquire next object */
2884                         next_o_idx = o_ptr->next_o_idx;
2885
2886                         /* Accept the item on the floor if legal */
2887                         if (item_tester_okay(o_ptr) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2888                 }
2889         }
2890
2891         /* Require at least one legal choice */
2892         if (!allow_floor && (i1 > i2) && (e1 > e2))
2893         {
2894                 /* Cancel p_ptr->command_see */
2895                 command_see = FALSE;
2896
2897                 oops = TRUE;
2898
2899                 done = TRUE;
2900
2901                 if (select_the_force) {
2902                     *cp = INVEN_FORCE;
2903                     item = TRUE;
2904                 }
2905         }
2906
2907         /* Analyze choices */
2908         else
2909         {
2910                 /* Hack -- Start on equipment if requested */
2911                 if (command_see && command_wrk && equip)
2912                 {
2913                         command_wrk = TRUE;
2914                 }
2915
2916                 /* Use inventory if allowed */
2917                 else if (inven)
2918                 {
2919                         command_wrk = FALSE;
2920                 }
2921
2922                 /* Use equipment if allowed */
2923                 else if (equip)
2924                 {
2925                         command_wrk = TRUE;
2926                 }
2927
2928                 /* Use inventory for floor */
2929                 else
2930                 {
2931                         command_wrk = FALSE;
2932                 }
2933         }
2934
2935
2936         /*
2937          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2938          */
2939         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2940
2941         /* Hack -- start out in "display" mode */
2942         if (command_see)
2943         {
2944                 screen_save();
2945         }
2946
2947
2948         /* Repeat until done */
2949         while (!done)
2950         {
2951                 COMMAND_CODE get_item_label = 0;
2952
2953                 /* Show choices */
2954                 int ni = 0;
2955                 int ne = 0;
2956
2957                 /* Scan windows */
2958                 for (j = 0; j < 8; j++)
2959                 {
2960                         /* Unused */
2961                         if (!angband_term[j]) continue;
2962
2963                         /* Count windows displaying inven */
2964                         if (window_flag[j] & (PW_INVEN)) ni++;
2965
2966                         /* Count windows displaying equip */
2967                         if (window_flag[j] & (PW_EQUIP)) ne++;
2968                 }
2969
2970                 /* Toggle if needed */
2971                 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
2972                 {
2973                         /* Toggle */
2974                         toggle_inven_equip();
2975
2976                         /* Track toggles */
2977                         toggle = !toggle;
2978                 }
2979
2980                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2981                 handle_stuff();
2982
2983                 /* Inventory screen */
2984                 if (!command_wrk)
2985                 {
2986                         /* Redraw if needed */
2987                         if (command_see) get_item_label = show_inven(menu_line);
2988                 }
2989
2990                 /* Equipment screen */
2991                 else
2992                 {
2993                         /* Redraw if needed */
2994                         if (command_see) get_item_label = show_equip(menu_line);
2995                 }
2996
2997                 /* Viewing inventory */
2998                 if (!command_wrk)
2999                 {
3000                         /* Begin the prompt */
3001                         sprintf(out_val, _("持ち物:", "Inven:"));
3002
3003                         /* Some legal items */
3004                         if ((i1 <= i2) && !use_menu)
3005                         {
3006                                 /* Build the prompt */
3007                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3008                                         index_to_label(i1), index_to_label(i2));
3009
3010                                 /* Append */
3011                                 strcat(out_val, tmp_val);
3012                         }
3013
3014                         /* Indicate ability to "view" */
3015                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3016
3017                         /* Append */
3018 #ifdef JP
3019                         if (equip) strcat(out_val, format(" %s 装備品,", use_menu ? "'4'or'6'" : "'/'"));
3020 #else
3021                         if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
3022 #endif
3023                 }
3024
3025                 /* Viewing equipment */
3026                 else
3027                 {
3028                         /* Begin the prompt */
3029                         sprintf(out_val, _("装備品:", "Equip:"));
3030
3031                         /* Some legal items */
3032                         if ((e1 <= e2) && !use_menu)
3033                         {
3034                                 /* Build the prompt */
3035                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3036                                         index_to_label(e1), index_to_label(e2));
3037
3038                                 /* Append */
3039                                 strcat(out_val, tmp_val);
3040                         }
3041
3042                         /* Indicate ability to "view" */
3043                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3044
3045                         /* Append */
3046 #ifdef JP
3047                         if (inven) strcat(out_val, format(" %s 持ち物,", use_menu ? "'4'or'6'" : "'/'"));
3048 #else
3049                         if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
3050 #endif
3051                 }
3052
3053                 /* Indicate legality of the "floor" item */
3054                 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
3055                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
3056
3057                 /* Finish the prompt */
3058                 strcat(out_val, " ESC");
3059
3060                 /* Build the prompt */
3061                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
3062
3063                 /* Show the prompt */
3064                 prt(tmp_val, 0, 0);
3065
3066                 /* Get a key */
3067                 which = inkey();
3068
3069                 if (use_menu)
3070                 {
3071                 int max_line = (command_wrk ? max_equip : max_inven);
3072                 switch (which)
3073                 {
3074                         case ESCAPE:
3075                         case 'z':
3076                         case 'Z':
3077                         case '0':
3078                         {
3079                                 done = TRUE;
3080                                 break;
3081                         }
3082
3083                         case '8':
3084                         case 'k':
3085                         case 'K':
3086                         {
3087                                 menu_line += (max_line - 1);
3088                                 break;
3089                         }
3090
3091                         case '2':
3092                         case 'j':
3093                         case 'J':
3094                         {
3095                                 menu_line++;
3096                                 break;
3097                         }
3098
3099                         case '4':
3100                         case '6':
3101                         case 'h':
3102                         case 'H':
3103                         case 'l':
3104                         case 'L':
3105                         {
3106                                 /* Verify legality */
3107                                 if (!inven || !equip)
3108                                 {
3109                                         bell();
3110                                         break;
3111                                 }
3112
3113                                 /* Hack -- Fix screen */
3114                                 if (command_see)
3115                                 {
3116                                         screen_load();
3117                                         screen_save();
3118                                 }
3119
3120                                 /* Switch inven/equip */
3121                                 command_wrk = !command_wrk;
3122                                 max_line = (command_wrk ? max_equip : max_inven);
3123                                 if (menu_line > max_line) menu_line = max_line;
3124
3125                                 /* Need to redraw */
3126                                 break;
3127                         }
3128
3129                         case 'x':
3130                         case 'X':
3131                         case '\r':
3132                         case '\n':
3133                         {
3134                                 if (command_wrk == USE_FLOOR)
3135                                 {
3136                                         /* Special index */
3137                                         (*cp) = -get_item_label;
3138                                 }
3139                                 else
3140                                 {
3141                                         /* Validate the item */
3142                                         if (!get_item_okay(get_item_label))
3143                                         {
3144                                                 bell();
3145                                                 break;
3146                                         }
3147
3148                                         /* Allow player to "refuse" certain actions */
3149                                         if (!get_item_allow(get_item_label))
3150                                         {
3151                                                 done = TRUE;
3152                                                 break;
3153                                         }
3154
3155                                         /* Accept that choice */
3156                                         (*cp) = get_item_label;
3157                                 }
3158
3159                                 item = TRUE;
3160                                 done = TRUE;
3161                                 break;
3162                         }
3163                         case 'w':
3164                         {
3165                                 if (select_the_force) {
3166                                         *cp = INVEN_FORCE;
3167                                         item = TRUE;
3168                                         done = TRUE;
3169                                         break;
3170                                 }
3171                         }
3172                 }
3173                 if (menu_line > max_line) menu_line -= max_line;
3174                 }
3175                 else
3176                 {
3177                 /* Parse it */
3178                 switch (which)
3179                 {
3180                         case ESCAPE:
3181                         {
3182                                 done = TRUE;
3183                                 break;
3184                         }
3185
3186                         case '*':
3187                         case '?':
3188                         case ' ':
3189                         {
3190                                 /* Hide the list */
3191                                 if (command_see)
3192                                 {
3193                                         /* Flip flag */
3194                                         command_see = FALSE;
3195                                         screen_load();
3196                                 }
3197
3198                                 /* Show the list */
3199                                 else
3200                                 {
3201                                         screen_save();
3202
3203                                         /* Flip flag */
3204                                         command_see = TRUE;
3205                                 }
3206                                 break;
3207                         }
3208
3209                         case '/':
3210                         {
3211                                 /* Verify legality */
3212                                 if (!inven || !equip)
3213                                 {
3214                                         bell();
3215                                         break;
3216                                 }
3217
3218                                 /* Hack -- Fix screen */
3219                                 if (command_see)
3220                                 {
3221                                         screen_load();
3222                                         screen_save();
3223                                 }
3224
3225                                 /* Switch inven/equip */
3226                                 command_wrk = !command_wrk;
3227
3228                                 /* Need to redraw */
3229                                 break;
3230                         }
3231
3232                         case '-':
3233                         {
3234                                 /* Use floor item */
3235                                 if (allow_floor)
3236                                 {
3237                                         /* Scan all objects in the grid */
3238                                         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3239                                         {
3240                                                 object_type *o_ptr;
3241                                                 o_ptr = &o_list[this_o_idx];
3242
3243                                                 /* Acquire next object */
3244                                                 next_o_idx = o_ptr->next_o_idx;
3245
3246                                                 /* Validate the item */
3247                                                 if (!item_tester_okay(o_ptr)) continue;
3248
3249                                                 /* Special index */
3250                                                 k = 0 - this_o_idx;
3251
3252                                                 /* Verify the item (if required) */
3253                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3254
3255                                                 /* Allow player to "refuse" certain actions */
3256                                                 if (!get_item_allow(k)) continue;
3257
3258                                                 /* Accept that choice */
3259                                                 (*cp) = k;
3260                                                 item = TRUE;
3261                                                 done = TRUE;
3262                                                 break;
3263                                         }
3264
3265                                         /* Outer break */
3266                                         if (done) break;
3267                                 }
3268
3269                                 bell();
3270                                 break;
3271                         }
3272
3273                         case '0':
3274                         case '1': case '2': case '3':
3275                         case '4': case '5': case '6':
3276                         case '7': case '8': case '9':
3277                         {
3278                                 /* Look up the tag */
3279                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3280                                 {
3281                                         bell();
3282                                         break;
3283                                 }
3284
3285                                 /* Hack -- Validate the item */
3286                                 if ((k < INVEN_RARM) ? !inven : !equip)
3287                                 {
3288                                         bell();
3289                                         break;
3290                                 }
3291
3292                                 /* Validate the item */
3293                                 if (!get_item_okay(k))
3294                                 {
3295                                         bell();
3296                                         break;
3297                                 }
3298
3299                                 /* Allow player to "refuse" certain actions */
3300                                 if (!get_item_allow(k))
3301                                 {
3302                                         done = TRUE;
3303                                         break;
3304                                 }
3305
3306                                 /* Accept that choice */
3307                                 (*cp) = k;
3308                                 item = TRUE;
3309                                 done = TRUE;
3310                                 cur_tag = which;
3311                                 break;
3312                         }
3313
3314 #if 0
3315                         case '\n':
3316                         case '\r':
3317                         {
3318                                 /* Choose "default" inventory item */
3319                                 if (!command_wrk)
3320                                 {
3321                                         k = ((i1 == i2) ? i1 : -1);
3322                                 }
3323
3324                                 /* Choose "default" equipment item */
3325                                 else
3326                                 {
3327                                         k = ((e1 == e2) ? e1 : -1);
3328                                 }
3329
3330                                 /* Validate the item */
3331                                 if (!get_item_okay(k))
3332                                 {
3333                                         bell();
3334                                         break;
3335                                 }
3336
3337                                 /* Allow player to "refuse" certain actions */
3338                                 if (!get_item_allow(k))
3339                                 {
3340                                         done = TRUE;
3341                                         break;
3342                                 }
3343
3344                                 /* Accept that choice */
3345                                 (*cp) = k;
3346                                 item = TRUE;
3347                                 done = TRUE;
3348                                 break;
3349                         }
3350 #endif
3351
3352                         case 'w':
3353                         {
3354                                 if (select_the_force) {
3355                                         *cp = INVEN_FORCE;
3356                                         item = TRUE;
3357                                         done = TRUE;
3358                                         break;
3359                                 }
3360
3361                                 /* Fall through */
3362                         }
3363
3364                         default:
3365                         {
3366                                 int ver;
3367                                 bool not_found = FALSE;
3368
3369                                 /* Look up the alphabetical tag */
3370                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3371                                 {
3372                                         not_found = TRUE;
3373                                 }
3374
3375                                 /* Hack -- Validate the item */
3376                                 else if ((k < INVEN_RARM) ? !inven : !equip)
3377                                 {
3378                                         not_found = TRUE;
3379                                 }
3380
3381                                 /* Validate the item */
3382                                 else if (!get_item_okay(k))
3383                                 {
3384                                         not_found = TRUE;
3385                                 }
3386
3387                                 if (!not_found)
3388                                 {
3389                                         /* Accept that choice */
3390                                         (*cp) = k;
3391                                         item = TRUE;
3392                                         done = TRUE;
3393                                         cur_tag = which;
3394                                         break;
3395                                 }
3396
3397                                 /* Extract "query" setting */
3398                                 ver = isupper(which);
3399                                 which = (char)tolower(which);
3400
3401                                 /* Convert letter to inventory index */
3402                                 if (!command_wrk)
3403                                 {
3404                                         if (which == '(') k = i1;
3405                                         else if (which == ')') k = i2;
3406                                         else k = label_to_inven(which);
3407                                 }
3408
3409                                 /* Convert letter to equipment index */
3410                                 else
3411                                 {
3412                                         if (which == '(') k = e1;
3413                                         else if (which == ')') k = e2;
3414                                         else k = label_to_equip(which);
3415                                 }
3416
3417                                 /* Validate the item */
3418                                 if (!get_item_okay(k))
3419                                 {
3420                                         bell();
3421                                         break;
3422                                 }
3423
3424                                 /* Verify the item */
3425                                 if (ver && !verify(_("本当に", "Try"), k))
3426                                 {
3427                                         done = TRUE;
3428                                         break;
3429                                 }
3430
3431                                 /* Allow player to "refuse" certain actions */
3432                                 if (!get_item_allow(k))
3433                                 {
3434                                         done = TRUE;
3435                                         break;
3436                                 }
3437
3438                                 /* Accept that choice */
3439                                 (*cp) = k;
3440                                 item = TRUE;
3441                                 done = TRUE;
3442                                 break;
3443                         }
3444                 }
3445                 }
3446         }
3447
3448
3449         /* Fix the screen if necessary */
3450         if (command_see)
3451         {
3452                 screen_load();
3453
3454                 /* Hack -- Cancel "display" */
3455                 command_see = FALSE;
3456         }
3457
3458
3459         /* Forget the item_tester_tval restriction */
3460         item_tester_tval = 0;
3461
3462         item_tester_no_ryoute = FALSE;
3463
3464         /* Forget the item_tester_hook restriction */
3465         item_tester_hook = NULL;
3466
3467
3468         /* Clean up  'show choices' */
3469         /* Toggle again if needed */
3470         if (toggle) toggle_inven_equip();
3471
3472         p_ptr->window |= (PW_INVEN | PW_EQUIP);
3473         handle_stuff();
3474
3475         /* Clear the prompt line */
3476         prt("", 0, 0);
3477
3478         /* Warning if needed */
3479         if (oops && str) msg_print(str);
3480
3481         if (item)
3482         {
3483                 repeat_push(*cp);
3484                 if (command_cmd) prev_tag = cur_tag;
3485                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3486         }
3487         return (item);
3488 }
3489
3490 /*
3491  * Choose an item and get auto-picker entry from it.
3492  */
3493 object_type *choose_object(cptr q, cptr s, BIT_FLAGS option, OBJECT_IDX *idx)
3494 {
3495         OBJECT_IDX item;
3496         if (!get_item(&item, q, s, option)) return NULL;
3497         if (idx) idx = item;
3498
3499         /* Get the item (in the pack) */
3500         if (item >= 0) return &inventory[item];
3501
3502         /* Get the item (on the floor) */
3503         else return &o_list[0 - item];
3504 }
3505
3506
3507 /*!
3508  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3509  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3510  * @param y 走査するフロアのY座標
3511  * @param x 走査するフロアのX座標
3512  * @param mode オプションフラグ
3513  * @return 対象のマスに落ちているアイテム数
3514  * @details
3515  * Return a list of o_list[] indexes of items at the given cave
3516  * location. Valid flags are:
3517  *
3518  *              mode & 0x01 -- Item tester
3519  *              mode & 0x02 -- Marked items only
3520  *              mode & 0x04 -- Stop after first
3521  */
3522 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3523 {
3524         OBJECT_IDX this_o_idx, next_o_idx;
3525
3526         ITEM_NUMBER num = 0;
3527
3528         /* Sanity */
3529         if (!in_bounds(y, x)) return 0;
3530
3531         /* Scan all objects in the grid */
3532         for (this_o_idx = cave[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3533         {
3534                 object_type *o_ptr;
3535                 o_ptr = &o_list[this_o_idx];
3536
3537                 /* Acquire next object */
3538                 next_o_idx = o_ptr->next_o_idx;
3539
3540                 /* Item tester */
3541                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3542
3543                 /* Marked */
3544                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3545
3546                 /* Accept this item */
3547                 /* XXX Hack -- Enforce limit */
3548                 if (num < 23)
3549                         items[num] = this_o_idx;
3550
3551                 num++;
3552
3553                 /* Only one */
3554                 if (mode & 0x04) break;
3555         }
3556         return num;
3557 }
3558
3559
3560 /*!
3561  * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3562  * @param target_item カーソルの初期値
3563  * @param y 走査するフロアのY座標
3564  * @param x 走査するフロアのX座標
3565  * @param min_width 表示の長さ
3566  * @return 選択したアイテムの添え字
3567  * @details
3568  */
3569 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3570 {
3571         COMMAND_CODE i, m;
3572         int j, k, l;
3573         int col, len;
3574
3575         object_type *o_ptr;
3576
3577         char o_name[MAX_NLEN];
3578         char tmp_val[80];
3579
3580         COMMAND_CODE out_index[23];
3581         TERM_COLOR out_color[23];
3582         char out_desc[23][MAX_NLEN];
3583         COMMAND_CODE target_item_label = 0;
3584
3585         OBJECT_IDX floor_list[23];
3586         ITEM_NUMBER floor_num;
3587         TERM_LEN wid, hgt;
3588         char floor_label[52 + 1];
3589
3590         bool dont_need_to_show_weights = TRUE;
3591
3592         Term_get_size(&wid, &hgt);
3593
3594         /* Default length */
3595         len = MAX((*min_width), 20);
3596
3597         /* Scan for objects in the grid, using item_tester_okay() */
3598         floor_num = scan_floor(floor_list, y, x, 0x03);
3599
3600         /* Display the floor objects */
3601         for (k = 0, i = 0; i < floor_num && i < 23; i++)
3602         {
3603                 o_ptr = &o_list[floor_list[i]];
3604
3605                 object_desc(o_name, o_ptr, 0);
3606
3607                 /* Save the index */
3608                 out_index[k] = i;
3609
3610                 /* Acquire inventory color */
3611                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3612
3613                 /* Save the object description */
3614                 strcpy(out_desc[k], o_name);
3615
3616                 /* Find the predicted "line length" */
3617                 l = strlen(out_desc[k]) + 5;
3618
3619                 /* Be sure to account for the weight */
3620                 if (show_weights) l += 9;
3621
3622                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3623
3624                 /* Maintain the maximum length */
3625                 if (l > len) len = l;
3626
3627                 /* Advance to next "line" */
3628                 k++;
3629         }
3630
3631         if (show_weights && dont_need_to_show_weights) len -= 9;
3632
3633         /* Save width */
3634         *min_width = len;
3635
3636         /* Find the column to start in */
3637         col = (len > wid - 4) ? 0 : (wid - len - 1);
3638
3639         prepare_label_string_floor(floor_label, floor_list, floor_num);
3640
3641         /* Output each entry */
3642         for (j = 0; j < k; j++)
3643         {
3644                 /* Get the index */
3645                 m = floor_list[out_index[j]];
3646
3647                 o_ptr = &o_list[m];
3648
3649                 /* Clear the line */
3650                 prt("", j + 1, col ? col - 2 : col);
3651
3652                 if (use_menu && target_item)
3653                 {
3654                         if (j == (target_item-1))
3655                         {
3656                                 strcpy(tmp_val, _("》", "> "));
3657                                 target_item_label = m;
3658                         }
3659                         else strcpy(tmp_val, "   ");
3660                 }
3661                 else
3662                 {
3663                         /* Prepare an index --(-- */
3664                         sprintf(tmp_val, "%c)", floor_label[j]);
3665                 }
3666
3667                 /* Clear the line with the (possibly indented) index */
3668                 put_str(tmp_val, j + 1, col);
3669
3670                 /* Display the entry itself */
3671                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3672
3673                 /* Display the weight if needed */
3674                 if (show_weights && (o_ptr->tval != TV_GOLD))
3675                 {
3676                         int wgt = o_ptr->weight * o_ptr->number;
3677 #ifdef JP
3678                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3679 #else
3680                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3681 #endif
3682
3683                         prt(tmp_val, j + 1, wid - 9);
3684                 }
3685         }
3686
3687         /* Make a "shadow" below the list (only if needed) */
3688         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3689
3690         return target_item_label;
3691 }
3692
3693 /*!
3694  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3695  * Let the user select an item, save its "index"
3696  * @param cp 選択したオブジェクトのIDを返す。
3697  * @param pmt 選択目的のメッセージ
3698  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3699  * @param mode オプションフラグ
3700  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3701  */
3702 bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
3703 {
3704         char n1 = ' ', n2 = ' ', which = ' ';
3705
3706         int j;
3707         COMMAND_CODE i1, i2;
3708         COMMAND_CODE e1, e2;
3709         COMMAND_CODE k;
3710
3711         bool done, item;
3712
3713         bool oops = FALSE;
3714
3715         /* Extract args */
3716         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3717         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3718         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3719
3720         bool allow_equip = FALSE;
3721         bool allow_inven = FALSE;
3722         bool allow_floor = FALSE;
3723
3724         bool toggle = FALSE;
3725
3726         char tmp_val[160];
3727         char out_val[160];
3728
3729         ITEM_NUMBER floor_num;
3730         OBJECT_IDX floor_list[23];
3731         int floor_top = 0;
3732         TERM_LEN min_width = 0;
3733
3734         extern bool select_the_force;
3735
3736         int menu_line = (use_menu ? 1 : 0);
3737         int max_inven = 0;
3738         int max_equip = 0;
3739
3740         static char prev_tag = '\0';
3741         char cur_tag = '\0';
3742
3743         /* Get the item index */
3744         if (repeat_pull(cp))
3745         {
3746                 /* the_force */
3747                 if (select_the_force && (*cp == INVEN_FORCE))
3748                 {
3749                         item_tester_tval = 0;
3750                         item_tester_hook = NULL;
3751                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3752                         return (TRUE);
3753                 }
3754
3755                 /* Floor item? */
3756                 else if (floor && (*cp < 0))
3757                 {
3758                         if (prev_tag && command_cmd)
3759                         {
3760                                 /* Scan all objects in the grid */
3761                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3762
3763                                 /* Look up the tag */
3764                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3765                                 {
3766                                         /* Accept that choice */
3767                                         (*cp) = 0 - floor_list[k];
3768
3769                                         /* Forget restrictions */
3770                                         item_tester_tval = 0;
3771                                         item_tester_hook = NULL;
3772                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3773
3774                                         /* Success */
3775                                         return TRUE;
3776                                 }
3777
3778                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3779                         }
3780
3781                         /* Validate the item */
3782                         else if (item_tester_okay(&o_list[0 - (*cp)]))
3783                         {
3784                                 /* Forget restrictions */
3785                                 item_tester_tval = 0;
3786                                 item_tester_hook = NULL;
3787                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3788
3789                                 /* Success */
3790                                 return TRUE;
3791                         }
3792                 }
3793
3794                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3795                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3796                 {
3797                         if (prev_tag && command_cmd)
3798                         {
3799                                 /* Look up the tag and validate the item */
3800                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3801                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3802                                 else if (!get_item_okay(k)) /* Reject */;
3803                                 else
3804                                 {
3805                                         /* Accept that choice */
3806                                         (*cp) = k;
3807
3808                                         /* Forget restrictions */
3809                                         item_tester_tval = 0;
3810                                         item_tester_hook = NULL;
3811                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3812
3813                                         /* Success */
3814                                         return TRUE;
3815                                 }
3816
3817                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3818                         }
3819
3820                         /* Verify the item */
3821                         else if (get_item_okay(*cp))
3822                         {
3823                                 /* Forget restrictions */
3824                                 item_tester_tval = 0;
3825                                 item_tester_hook = NULL;
3826                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3827
3828                                 /* Success */
3829                                 return TRUE;
3830                         }
3831                 }
3832         }
3833
3834
3835         /* Paranoia */
3836         msg_print(NULL);
3837
3838
3839         /* Not done */
3840         done = FALSE;
3841
3842         /* No item selected */
3843         item = FALSE;
3844
3845
3846         /* Full inventory */
3847         i1 = 0;
3848         i2 = INVEN_PACK - 1;
3849
3850         /* Forbid inventory */
3851         if (!inven) i2 = -1;
3852         else if (use_menu)
3853         {
3854                 for (j = 0; j < INVEN_PACK; j++)
3855                         if (item_tester_okay(&inventory[j])) max_inven++;
3856         }
3857
3858         /* Restrict inventory indexes */
3859         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3860         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3861
3862
3863         /* Full equipment */
3864         e1 = INVEN_RARM;
3865         e2 = INVEN_TOTAL - 1;
3866
3867         /* Forbid equipment */
3868         if (!equip) e2 = -1;
3869         else if (use_menu)
3870         {
3871                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3872                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
3873                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
3874         }
3875
3876         /* Restrict equipment indexes */
3877         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3878         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3879
3880         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
3881         {
3882                 if (p_ptr->migite)
3883                 {
3884                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3885                 }
3886                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3887         }
3888
3889
3890         /* Count "okay" floor items */
3891         floor_num = 0;
3892
3893         /* Restrict floor usage */
3894         if (floor)
3895         {
3896                 /* Scan all objects in the grid */
3897                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3898         }
3899
3900         /* Accept inventory */
3901         if (i1 <= i2) allow_inven = TRUE;
3902
3903         /* Accept equipment */
3904         if (e1 <= e2) allow_equip = TRUE;
3905
3906         /* Accept floor */
3907         if (floor_num) allow_floor = TRUE;
3908
3909         /* Require at least one legal choice */
3910         if (!allow_inven && !allow_equip && !allow_floor)
3911         {
3912                 /* Cancel p_ptr->command_see */
3913                 command_see = FALSE;
3914
3915                 oops = TRUE;
3916
3917                 done = TRUE;
3918
3919                 if (select_the_force) {
3920                     *cp = INVEN_FORCE;
3921                     item = TRUE;
3922                 }
3923         }
3924
3925         /* Analyze choices */
3926         else
3927         {
3928                 /* Hack -- Start on equipment if requested */
3929                 if (command_see && (command_wrk == (USE_EQUIP))
3930                         && allow_equip)
3931                 {
3932                         command_wrk = (USE_EQUIP);
3933                 }
3934
3935                 /* Use inventory if allowed */
3936                 else if (allow_inven)
3937                 {
3938                         command_wrk = (USE_INVEN);
3939                 }
3940
3941                 /* Use equipment if allowed */
3942                 else if (allow_equip)
3943                 {
3944                         command_wrk = (USE_EQUIP);
3945                 }
3946
3947                 /* Use floor if allowed */
3948                 else if (allow_floor)
3949                 {
3950                         command_wrk = (USE_FLOOR);
3951                 }
3952         }
3953
3954         /*
3955          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3956          */
3957         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3958
3959         /* Hack -- start out in "display" mode */
3960         if (command_see)
3961         {
3962                 screen_save();
3963         }
3964
3965         /* Repeat until done */
3966         while (!done)
3967         {
3968                 COMMAND_CODE get_item_label = 0;
3969
3970                 /* Show choices */
3971                 int ni = 0;
3972                 int ne = 0;
3973
3974                 /* Scan windows */
3975                 for (j = 0; j < 8; j++)
3976                 {
3977                         /* Unused */
3978                         if (!angband_term[j]) continue;
3979
3980                         /* Count windows displaying inven */
3981                         if (window_flag[j] & (PW_INVEN)) ni++;
3982
3983                         /* Count windows displaying equip */
3984                         if (window_flag[j] & (PW_EQUIP)) ne++;
3985                 }
3986
3987                 /* Toggle if needed */
3988                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
3989                     (command_wrk == (USE_INVEN) && !ni && ne))
3990                 {
3991                         /* Toggle */
3992                         toggle_inven_equip();
3993
3994                         /* Track toggles */
3995                         toggle = !toggle;
3996                 }
3997
3998                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3999                 handle_stuff();
4000
4001                 /* Inventory screen */
4002                 if (command_wrk == (USE_INVEN))
4003                 {
4004                         /* Extract the legal requests */
4005                         n1 = I2A(i1);
4006                         n2 = I2A(i2);
4007
4008                         /* Redraw if needed */
4009                         if (command_see) get_item_label = show_inven(menu_line);
4010                 }
4011
4012                 /* Equipment screen */
4013                 else if (command_wrk == (USE_EQUIP))
4014                 {
4015                         /* Extract the legal requests */
4016                         n1 = I2A(e1 - INVEN_RARM);
4017                         n2 = I2A(e2 - INVEN_RARM);
4018
4019                         /* Redraw if needed */
4020                         if (command_see) get_item_label = show_equip(menu_line);
4021                 }
4022
4023                 /* Floor screen */
4024                 else if (command_wrk == (USE_FLOOR))
4025                 {
4026                         j = floor_top;
4027                         k = MIN(floor_top + 23, floor_num) - 1;
4028
4029                         /* Extract the legal requests */
4030                         n1 = I2A(j - floor_top);
4031                         n2 = I2A(k - floor_top);
4032
4033                         /* Redraw if needed */
4034                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
4035                 }
4036
4037                 /* Viewing inventory */
4038                 if (command_wrk == (USE_INVEN))
4039                 {
4040                         /* Begin the prompt */
4041                         sprintf(out_val, _("持ち物:", "Inven:"));
4042
4043                         if (!use_menu)
4044                         {
4045                                 /* Build the prompt */
4046                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4047                                         index_to_label(i1), index_to_label(i2));
4048
4049                                 /* Append */
4050                                 strcat(out_val, tmp_val);
4051                         }
4052
4053                         /* Indicate ability to "view" */
4054                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4055
4056                         /* Append */
4057                         if (allow_equip)
4058                         {
4059                                 if (!use_menu)
4060                                         strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
4061                                 else if (allow_floor)
4062                                         strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
4063                                 else
4064                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4065                         }
4066
4067                         /* Append */
4068                         if (allow_floor)
4069                         {
4070                                 if (!use_menu)
4071                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
4072                                 else if (allow_equip)
4073                                         strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
4074                                 else
4075                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
4076                         }
4077                 }
4078
4079                 /* Viewing equipment */
4080                 else if (command_wrk == (USE_EQUIP))
4081                 {
4082                         /* Begin the prompt */
4083                         sprintf(out_val, _("装備品:", "Equip:"));
4084
4085                         if (!use_menu)
4086                         {
4087                                 /* Build the prompt */
4088                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4089                                         index_to_label(e1), index_to_label(e2));
4090
4091                                 /* Append */
4092                                 strcat(out_val, tmp_val);
4093                         }
4094
4095                         /* Indicate ability to "view" */
4096                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4097
4098                         /* Append */
4099                         if (allow_inven)
4100                         {
4101                                 if (!use_menu)
4102                                         strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4103                                 else if (allow_floor)
4104                                         strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
4105                                 else
4106                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4107                         }
4108
4109                         /* Append */
4110                         if (allow_floor)
4111                         {
4112                                 if (!use_menu)
4113                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
4114                                 else if (allow_inven)
4115                                         strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
4116                                 else
4117                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
4118                         }
4119                 }
4120
4121                 /* Viewing floor */
4122                 else if (command_wrk == (USE_FLOOR))
4123                 {
4124                         /* Begin the prompt */
4125                         sprintf(out_val, _("床上:", "Floor:"));
4126
4127                         if (!use_menu)
4128                         {
4129                                 /* Build the prompt */
4130                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4131
4132                                 /* Append */
4133                                 strcat(out_val, tmp_val);
4134                         }
4135
4136                         /* Indicate ability to "view" */
4137                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4138
4139                         if (use_menu)
4140                         {
4141                                 if (allow_inven && allow_equip)
4142                                 {
4143                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4144                                 }
4145                                 else if (allow_inven)
4146                                 {
4147                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4148                                 }
4149                                 else if (allow_equip)
4150                                 {
4151                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4152                                 }
4153                         }
4154                         /* Append */
4155                         else if (allow_inven)
4156                         {
4157                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4158                         }
4159                         else if (allow_equip)
4160                         {
4161                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4162                         }
4163
4164                         /* Append */
4165                         if (command_see && !use_menu)
4166                         {
4167                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4168                         }
4169                 }
4170
4171                 /* Append */
4172                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4173
4174                 /* Finish the prompt */
4175                 strcat(out_val, " ESC");
4176
4177                 /* Build the prompt */
4178                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4179
4180                 /* Show the prompt */
4181                 prt(tmp_val, 0, 0);
4182
4183                 /* Get a key */
4184                 which = inkey();
4185
4186                 if (use_menu)
4187                 {
4188                 int max_line = 1;
4189                 if (command_wrk == USE_INVEN) max_line = max_inven;
4190                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4191                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4192                 switch (which)
4193                 {
4194                         case ESCAPE:
4195                         case 'z':
4196                         case 'Z':
4197                         case '0':
4198                         {
4199                                 done = TRUE;
4200                                 break;
4201                         }
4202
4203                         case '8':
4204                         case 'k':
4205                         case 'K':
4206                         {
4207                                 menu_line += (max_line - 1);
4208                                 break;
4209                         }
4210
4211                         case '2':
4212                         case 'j':
4213                         case 'J':
4214                         {
4215                                 menu_line++;
4216                                 break;
4217                         }
4218
4219                         case '4':
4220                         case 'h':
4221                         case 'H':
4222                         {
4223                                 /* Verify legality */
4224                                 if (command_wrk == (USE_INVEN))
4225                                 {
4226                                         if (allow_floor) command_wrk = USE_FLOOR;
4227                                         else if (allow_equip) command_wrk = USE_EQUIP;
4228                                         else
4229                                         {
4230                                                 bell();
4231                                                 break;
4232                                         }
4233                                 }
4234                                 else if (command_wrk == (USE_EQUIP))
4235                                 {
4236                                         if (allow_inven) command_wrk = USE_INVEN;
4237                                         else if (allow_floor) command_wrk = USE_FLOOR;
4238                                         else
4239                                         {
4240                                                 bell();
4241                                                 break;
4242                                         }
4243                                 }
4244                                 else if (command_wrk == (USE_FLOOR))
4245                                 {
4246                                         if (allow_equip) command_wrk = USE_EQUIP;
4247                                         else if (allow_inven) command_wrk = USE_INVEN;
4248                                         else
4249                                         {
4250                                                 bell();
4251                                                 break;
4252                                         }
4253                                 }
4254                                 else
4255                                 {
4256                                         bell();
4257                                         break;
4258                                 }
4259
4260                                 /* Hack -- Fix screen */
4261                                 if (command_see)
4262                                 {
4263                                         screen_load();
4264                                         screen_save();
4265                                 }
4266
4267                                 /* Switch inven/equip */
4268                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4269                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4270                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4271                                 if (menu_line > max_line) menu_line = max_line;
4272
4273                                 /* Need to redraw */
4274                                 break;
4275                         }
4276
4277                         case '6':
4278                         case 'l':
4279                         case 'L':
4280                         {
4281                                 /* Verify legality */
4282                                 if (command_wrk == (USE_INVEN))
4283                                 {
4284                                         if (allow_equip) command_wrk = USE_EQUIP;
4285                                         else if (allow_floor) command_wrk = USE_FLOOR;
4286                                         else
4287                                         {
4288                                                 bell();
4289                                                 break;
4290                                         }
4291                                 }
4292                                 else if (command_wrk == (USE_EQUIP))
4293                                 {
4294                                         if (allow_floor) command_wrk = USE_FLOOR;
4295                                         else if (allow_inven) command_wrk = USE_INVEN;
4296                                         else
4297                                         {
4298                                                 bell();
4299                                                 break;
4300                                         }
4301                                 }
4302                                 else if (command_wrk == (USE_FLOOR))
4303                                 {
4304                                         if (allow_inven) command_wrk = USE_INVEN;
4305                                         else if (allow_equip) command_wrk = USE_EQUIP;
4306                                         else
4307                                         {
4308                                                 bell();
4309                                                 break;
4310                                         }
4311                                 }
4312                                 else
4313                                 {
4314                                         bell();
4315                                         break;
4316                                 }
4317
4318                                 /* Hack -- Fix screen */
4319                                 if (command_see)
4320                                 {
4321                                         screen_load();
4322                                         screen_save();
4323                                 }
4324
4325                                 /* Switch inven/equip */
4326                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4327                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4328                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4329                                 if (menu_line > max_line) menu_line = max_line;
4330
4331                                 /* Need to redraw */
4332                                 break;
4333                         }
4334
4335                         case 'x':
4336                         case 'X':
4337                         case '\r':
4338                         case '\n':
4339                         {
4340                                 if (command_wrk == USE_FLOOR)
4341                                 {
4342                                         /* Special index */
4343                                         (*cp) = -get_item_label;
4344                                 }
4345                                 else
4346                                 {
4347                                         /* Validate the item */
4348                                         if (!get_item_okay(get_item_label))
4349                                         {
4350                                                 bell();
4351                                                 break;
4352                                         }
4353
4354                                         /* Allow player to "refuse" certain actions */
4355                                         if (!get_item_allow(get_item_label))
4356                                         {
4357                                                 done = TRUE;
4358                                                 break;
4359                                         }
4360
4361                                         /* Accept that choice */
4362                                         (*cp) = get_item_label;
4363                                 }
4364
4365                                 item = TRUE;
4366                                 done = TRUE;
4367                                 break;
4368                         }
4369                         case 'w':
4370                         {
4371                                 if (select_the_force) {
4372                                         *cp = INVEN_FORCE;
4373                                         item = TRUE;
4374                                         done = TRUE;
4375                                         break;
4376                                 }
4377                         }
4378                 }
4379                 if (menu_line > max_line) menu_line -= max_line;
4380                 }
4381                 else
4382                 {
4383                 /* Parse it */
4384                 switch (which)
4385                 {
4386                         case ESCAPE:
4387                         {
4388                                 done = TRUE;
4389                                 break;
4390                         }
4391
4392                         case '*':
4393                         case '?':
4394                         case ' ':
4395                         {
4396                                 /* Hide the list */
4397                                 if (command_see)
4398                                 {
4399                                         /* Flip flag */
4400                                         command_see = FALSE;
4401                                         screen_load();
4402                                 }
4403
4404                                 /* Show the list */
4405                                 else
4406                                 {
4407                                         screen_save();
4408
4409                                         /* Flip flag */
4410                                         command_see = TRUE;
4411                                 }
4412                                 break;
4413                         }
4414
4415                         case '\n':
4416                         case '\r':
4417                         case '+':
4418                         {
4419                                 int i;
4420                                 OBJECT_IDX o_idx;
4421                                 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
4422
4423                                 if (command_wrk != (USE_FLOOR)) break;
4424
4425                                 /* Get the object being moved. */
4426                                 o_idx = c_ptr->o_idx;
4427
4428                                 /* Only rotate a pile of two or more objects. */
4429                                 if (!(o_idx && o_list[o_idx].next_o_idx)) break;
4430
4431                                 /* Remove the first object from the list. */
4432                                 excise_object_idx(o_idx);
4433
4434                                 /* Find end of the list. */
4435                                 i = c_ptr->o_idx;
4436                                 while (o_list[i].next_o_idx)
4437                                         i = o_list[i].next_o_idx;
4438
4439                                 /* Add after the last object. */
4440                                 o_list[i].next_o_idx = o_idx;
4441
4442                                 /* Re-scan floor list */ 
4443                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4444
4445                                 /* Hack -- Fix screen */
4446                                 if (command_see)
4447                                 {
4448                                         screen_load();
4449                                         screen_save();
4450                                 }
4451
4452                                 break;
4453                         }
4454
4455                         case '/':
4456                         {
4457                                 if (command_wrk == (USE_INVEN))
4458                                 {
4459                                         if (!allow_equip)
4460                                         {
4461                                                 bell();
4462                                                 break;
4463                                         }
4464                                         command_wrk = (USE_EQUIP);
4465                                 }
4466                                 else if (command_wrk == (USE_EQUIP))
4467                                 {
4468                                         if (!allow_inven)
4469                                         {
4470                                                 bell();
4471                                                 break;
4472                                         }
4473                                         command_wrk = (USE_INVEN);
4474                                 }
4475                                 else if (command_wrk == (USE_FLOOR))
4476                                 {
4477                                         if (allow_inven)
4478                                         {
4479                                                 command_wrk = (USE_INVEN);
4480                                         }
4481                                         else if (allow_equip)
4482                                         {
4483                                                 command_wrk = (USE_EQUIP);
4484                                         }
4485                                         else
4486                                         {
4487                                                 bell();
4488                                                 break;
4489                                         }
4490                                 }
4491
4492                                 /* Hack -- Fix screen */
4493                                 if (command_see)
4494                                 {
4495                                         screen_load();
4496                                         screen_save();
4497                                 }
4498
4499                                 /* Need to redraw */
4500                                 break;
4501                         }
4502
4503                         case '-':
4504                         {
4505                                 if (!allow_floor)
4506                                 {
4507                                         bell();
4508                                         break;
4509                                 }
4510
4511                                 /*
4512                                  * If we are already examining the floor, and there
4513                                  * is only one item, we will always select it.
4514                                  * If we aren't examining the floor and there is only
4515                                  * one item, we will select it if floor_query_flag
4516                                  * is FALSE.
4517                                  */
4518                                 if (floor_num == 1)
4519                                 {
4520                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4521                                         {
4522                                                 /* Special index */
4523                                                 k = 0 - floor_list[0];
4524
4525                                                 /* Allow player to "refuse" certain actions */
4526                                                 if (!get_item_allow(k))
4527                                                 {
4528                                                         done = TRUE;
4529                                                         break;
4530                                                 }
4531
4532                                                 /* Accept that choice */
4533                                                 (*cp) = k;
4534                                                 item = TRUE;
4535                                                 done = TRUE;
4536
4537                                                 break;
4538                                         }
4539                                 }
4540
4541                                 /* Hack -- Fix screen */
4542                                 if (command_see)
4543                                 {
4544                                         screen_load();
4545                                         screen_save();
4546                                 }
4547
4548                                 command_wrk = (USE_FLOOR);
4549
4550                                 break;
4551                         }
4552
4553                         case '0':
4554                         case '1': case '2': case '3':
4555                         case '4': case '5': case '6':
4556                         case '7': case '8': case '9':
4557                         {
4558                                 if (command_wrk != USE_FLOOR)
4559                                 {
4560                                         /* Look up the tag */
4561                                         if (!get_tag(&k, which, command_wrk))
4562                                         {
4563                                                 bell();
4564                                                 break;
4565                                         }
4566
4567                                         /* Hack -- Validate the item */
4568                                         if ((k < INVEN_RARM) ? !inven : !equip)
4569                                         {
4570                                                 bell();
4571                                                 break;
4572                                         }
4573
4574                                         /* Validate the item */
4575                                         if (!get_item_okay(k))
4576                                         {
4577                                                 bell();
4578                                                 break;
4579                                         }
4580                                 }
4581                                 else
4582                                 {
4583                                         /* Look up the alphabetical tag */
4584                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4585                                         {
4586                                                 /* Special index */
4587                                                 k = 0 - floor_list[k];
4588                                         }
4589                                         else
4590                                         {
4591                                                 bell();
4592                                                 break;
4593                                         }
4594                                 }
4595
4596                                 /* Allow player to "refuse" certain actions */
4597                                 if (!get_item_allow(k))
4598                                 {
4599                                         done = TRUE;
4600                                         break;
4601                                 }
4602
4603                                 /* Accept that choice */
4604                                 (*cp) = k;
4605                                 item = TRUE;
4606                                 done = TRUE;
4607                                 cur_tag = which;
4608                                 break;
4609                         }
4610
4611 #if 0
4612                         case '\n':
4613                         case '\r':
4614                         {
4615                                 /* Choose "default" inventory item */
4616                                 if (command_wrk == (USE_INVEN))
4617                                 {
4618                                         k = ((i1 == i2) ? i1 : -1);
4619                                 }
4620
4621                                 /* Choose "default" equipment item */
4622                                 else if (command_wrk == (USE_EQUIP))
4623                                 {
4624                                         k = ((e1 == e2) ? e1 : -1);
4625                                 }
4626
4627                                 /* Choose "default" floor item */
4628                                 else if (command_wrk == (USE_FLOOR))
4629                                 {
4630                                         if (floor_num == 1)
4631                                         {
4632                                                 /* Special index */
4633                                                 k = 0 - floor_list[0];
4634
4635                                                 /* Allow player to "refuse" certain actions */
4636                                                 if (!get_item_allow(k))
4637                                                 {
4638                                                         done = TRUE;
4639                                                         break;
4640                                                 }
4641
4642                                                 /* Accept that choice */
4643                                                 (*cp) = k;
4644                                                 item = TRUE;
4645                                                 done = TRUE;
4646                                         }
4647                                         break;
4648                                 }
4649
4650                                 /* Validate the item */
4651                                 if (!get_item_okay(k))
4652                                 {
4653                                         bell();
4654                                         break;
4655                                 }
4656
4657                                 /* Allow player to "refuse" certain actions */
4658                                 if (!get_item_allow(k))
4659                                 {
4660                                         done = TRUE;
4661                                         break;
4662                                 }
4663
4664                                 /* Accept that choice */
4665                                 (*cp) = k;
4666                                 item = TRUE;
4667                                 done = TRUE;
4668                                 break;
4669                         }
4670 #endif
4671
4672                         case 'w':
4673                         {
4674                                 if (select_the_force) {
4675                                         *cp = INVEN_FORCE;
4676                                         item = TRUE;
4677                                         done = TRUE;
4678                                         break;
4679                                 }
4680
4681                                 /* Fall through */
4682                         }
4683
4684                         default:
4685                         {
4686                                 int ver;
4687
4688                                 if (command_wrk != USE_FLOOR)
4689                                 {
4690                                         bool not_found = FALSE;
4691
4692                                         /* Look up the alphabetical tag */
4693                                         if (!get_tag(&k, which, command_wrk))
4694                                         {
4695                                                 not_found = TRUE;
4696                                         }
4697
4698                                         /* Hack -- Validate the item */
4699                                         else if ((k < INVEN_RARM) ? !inven : !equip)
4700                                         {
4701                                                 not_found = TRUE;
4702                                         }
4703
4704                                         /* Validate the item */
4705                                         else if (!get_item_okay(k))
4706                                         {
4707                                                 not_found = TRUE;
4708                                         }
4709
4710                                         if (!not_found)
4711                                         {
4712                                                 /* Accept that choice */
4713                                                 (*cp) = k;
4714                                                 item = TRUE;
4715                                                 done = TRUE;
4716                                                 cur_tag = which;
4717                                                 break;
4718                                         }
4719                                 }
4720                                 else
4721                                 {
4722                                         /* Look up the alphabetical tag */
4723                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4724                                         {
4725                                                 /* Special index */
4726                                                 k = 0 - floor_list[k];
4727
4728                                                 /* Accept that choice */
4729                                                 (*cp) = k;
4730                                                 item = TRUE;
4731                                                 done = TRUE;
4732                                                 cur_tag = which;
4733                                                 break;
4734                                         }
4735                                 }
4736
4737                                 /* Extract "query" setting */
4738                                 ver = isupper(which);
4739                                 which = (char)tolower(which);
4740
4741                                 /* Convert letter to inventory index */
4742                                 if (command_wrk == (USE_INVEN))
4743                                 {
4744                                         if (which == '(') k = i1;
4745                                         else if (which == ')') k = i2;
4746                                         else k = label_to_inven(which);
4747                                 }
4748
4749                                 /* Convert letter to equipment index */
4750                                 else if (command_wrk == (USE_EQUIP))
4751                                 {
4752                                         if (which == '(') k = e1;
4753                                         else if (which == ')') k = e2;
4754                                         else k = label_to_equip(which);
4755                                 }
4756
4757                                 /* Convert letter to floor index */
4758                                 else if (command_wrk == USE_FLOOR)
4759                                 {
4760                                         if (which == '(') k = 0;
4761                                         else if (which == ')') k = floor_num - 1;
4762                                         else k = islower(which) ? A2I(which) : -1;
4763                                         if (k < 0 || k >= floor_num || k >= 23)
4764                                         {
4765                                                 bell();
4766                                                 break;
4767                                         }
4768
4769                                         /* Special index */
4770                                         k = 0 - floor_list[k];
4771                                 }
4772
4773                                 /* Validate the item */
4774                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4775                                 {
4776                                         bell();
4777                                         break;
4778                                 }
4779
4780                                 /* Verify the item */
4781                                 if (ver && !verify(_("本当に", "Try"), k))
4782                                 {
4783                                         done = TRUE;
4784                                         break;
4785                                 }
4786
4787                                 /* Allow player to "refuse" certain actions */
4788                                 if (!get_item_allow(k))
4789                                 {
4790                                         done = TRUE;
4791                                         break;
4792                                 }
4793
4794                                 /* Accept that choice */
4795                                 (*cp) = k;
4796                                 item = TRUE;
4797                                 done = TRUE;
4798                                 break;
4799                         }
4800                 }
4801                 }
4802         }
4803
4804         /* Fix the screen if necessary */
4805         if (command_see)
4806         {
4807                 screen_load();
4808
4809                 /* Hack -- Cancel "display" */
4810                 command_see = FALSE;
4811         }
4812
4813
4814         /* Forget the item_tester_tval restriction */
4815         item_tester_tval = 0;
4816
4817         /* Forget the item_tester_hook restriction */
4818         item_tester_hook = NULL;
4819
4820
4821         /* Clean up  'show choices' */
4822         /* Toggle again if needed */
4823         if (toggle) toggle_inven_equip();
4824
4825         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4826         handle_stuff();
4827
4828         /* Clear the prompt line */
4829         prt("", 0, 0);
4830
4831         /* Warning if needed */
4832         if (oops && str) msg_print(str);
4833
4834         if (item)
4835         {
4836                 repeat_push(*cp);
4837                 if (command_cmd) prev_tag = cur_tag;
4838                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4839         }
4840         return (item);
4841 }
4842
4843 /*!
4844  * @brief 床上のアイテムを拾う選択用サブルーチン 
4845  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4846  */
4847 static bool py_pickup_floor_aux(void)
4848 {
4849         OBJECT_IDX this_o_idx;
4850
4851         cptr q, s;
4852
4853         OBJECT_IDX item;
4854
4855         /* Restrict the choices */
4856         item_tester_hook = inven_carry_okay;
4857
4858         /* Get an object */
4859         q = _("どれを拾いますか?", "Get which item? ");
4860         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4861
4862         if (get_item(&item, q, s, (USE_FLOOR)))
4863         {
4864                 this_o_idx = 0 - item;
4865         }
4866         else
4867         {
4868                 return (FALSE);
4869         }
4870
4871         /* Pick up the object */
4872         py_pickup_aux(this_o_idx);
4873
4874         return (TRUE);
4875 }
4876
4877 /*!
4878  * @brief 床上のアイテムを拾うメイン処理
4879  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4880  * @return なし
4881  * @details
4882  * This is called by py_pickup() when easy_floor is TRUE.
4883  */
4884 void py_pickup_floor(bool pickup)
4885 {
4886         OBJECT_IDX this_o_idx, next_o_idx = 0;
4887
4888         char o_name[MAX_NLEN];
4889         object_type *o_ptr;
4890
4891         int floor_num = 0;
4892         OBJECT_IDX floor_o_idx = 0;
4893
4894         int can_pickup = 0;
4895
4896         /* Scan the pile of objects */
4897         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
4898         {
4899                 /* Access the object */
4900                 o_ptr = &o_list[this_o_idx];
4901
4902                 object_desc(o_name, o_ptr, 0);
4903
4904                 /* Access the next object */
4905                 next_o_idx = o_ptr->next_o_idx;
4906
4907                 /* Hack -- disturb */
4908                 disturb(FALSE, FALSE);
4909
4910                 /* Pick up gold */
4911                 if (o_ptr->tval == TV_GOLD)
4912                 {
4913 #ifdef JP
4914                         msg_format(" $%ld の価値がある%sを見つけた。",
4915                                 (long)o_ptr->pval, o_name);
4916 #else
4917                         msg_format("You have found %ld gold pieces worth of %s.",
4918                                 (long)o_ptr->pval, o_name);
4919 #endif
4920
4921                         /* Collect the gold */
4922                         p_ptr->au += o_ptr->pval;
4923
4924                         /* Redraw gold */
4925                         p_ptr->redraw |= (PR_GOLD);
4926
4927                         p_ptr->window |= (PW_PLAYER);
4928
4929                         /* Delete the gold */
4930                         delete_object_idx(this_o_idx);
4931
4932                         /* Check the next object */
4933                         continue;
4934                 }
4935                 else if (o_ptr->marked & OM_NOMSG)
4936                 {
4937                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
4938                          * ignored. Otherwise, they are included in the prompt. */
4939                         o_ptr->marked &= ~(OM_NOMSG);
4940                         continue;
4941                 }
4942
4943                 /* Count non-gold objects that can be picked up. */
4944                 if (inven_carry_okay(o_ptr))
4945                 {
4946                         can_pickup++;
4947                 }
4948
4949                 /* Count non-gold objects */
4950                 floor_num++;
4951
4952                 /* Remember this index */
4953                 floor_o_idx = this_o_idx;
4954         }
4955
4956         /* There are no non-gold objects */
4957         if (!floor_num)
4958                 return;
4959
4960         /* Mention the number of objects */
4961         if (!pickup)
4962         {
4963                 /* One object */
4964                 if (floor_num == 1)
4965                 {
4966                         /* Access the object */
4967                         o_ptr = &o_list[floor_o_idx];
4968
4969 #ifdef ALLOW_EASY_SENSE
4970
4971                         /* Option: Make object sensing easy */
4972                         if (easy_sense)
4973                         {
4974                                 /* Sense the object */
4975                                 (void) sense_object(o_ptr);
4976                         }
4977
4978 #endif /* ALLOW_EASY_SENSE */
4979
4980                         object_desc(o_name, o_ptr, 0);
4981
4982                         msg_format(_("%sがある。", "You see %s."), o_name);
4983                 }
4984
4985                 /* Multiple objects */
4986                 else
4987                 {
4988                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
4989                 }
4990
4991                 return;
4992         }
4993
4994         /* The player has no room for anything on the floor. */
4995         if (!can_pickup)
4996         {
4997                 /* One object */
4998                 if (floor_num == 1)
4999                 {
5000                         /* Access the object */
5001                         o_ptr = &o_list[floor_o_idx];
5002
5003 #ifdef ALLOW_EASY_SENSE
5004
5005                         /* Option: Make object sensing easy */
5006                         if (easy_sense)
5007                         {
5008                                 /* Sense the object */
5009                                 (void) sense_object(o_ptr);
5010                         }
5011
5012 #endif /* ALLOW_EASY_SENSE */
5013
5014                         object_desc(o_name, o_ptr, 0);
5015
5016                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
5017                 }
5018
5019                 /* Multiple objects */
5020                 else
5021                 {
5022                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
5023
5024                 }
5025
5026                 return;
5027         }
5028
5029         /* One object */
5030         if (floor_num == 1)
5031         {
5032                 /* Hack -- query every object */
5033                 if (carry_query_flag)
5034                 {
5035                         char out_val[MAX_NLEN+20];
5036
5037                         /* Access the object */
5038                         o_ptr = &o_list[floor_o_idx];
5039
5040 #ifdef ALLOW_EASY_SENSE
5041
5042                         /* Option: Make object sensing easy */
5043                         if (easy_sense)
5044                         {
5045                                 /* Sense the object */
5046                                 (void) sense_object(o_ptr);
5047                         }
5048
5049 #endif /* ALLOW_EASY_SENSE */
5050
5051                         object_desc(o_name, o_ptr, 0);
5052
5053                         /* Build a prompt */
5054                         (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
5055
5056                         /* Ask the user to confirm */
5057                         if (!get_check(out_val))
5058                         {
5059                                 return;
5060                         }
5061                 }
5062
5063                 /* Access the object */
5064                 o_ptr = &o_list[floor_o_idx];
5065
5066 #ifdef ALLOW_EASY_SENSE
5067
5068                 /* Option: Make object sensing easy */
5069                 if (easy_sense)
5070                 {
5071                         /* Sense the object */
5072                         (void) sense_object(o_ptr);
5073                 }
5074
5075 #endif /* ALLOW_EASY_SENSE */
5076
5077                 /* Pick up the object */
5078                 py_pickup_aux(floor_o_idx);
5079         }
5080
5081         /* Allow the user to choose an object */
5082         else
5083         {
5084                 while (can_pickup--)
5085                 {
5086                         if (!py_pickup_floor_aux()) break;
5087                 }
5088         }
5089 }