OSDN Git Service

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