OSDN Git Service

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