OSDN Git Service

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