2 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory and equipment commands
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 #include "cmd-item/cmd-item.h"
13 #include "action/action-limited.h"
14 #include "action/activation-execution.h"
15 #include "action/weapon-shield.h"
16 #include "cmd-action/cmd-open-close.h"
17 #include "cmd-action/cmd-pet.h"
18 #include "cmd-item/cmd-eat.h"
19 #include "cmd-item/cmd-quaff.h"
20 #include "cmd-item/cmd-read.h"
21 #include "cmd-item/cmd-zaprod.h"
22 #include "cmd-item/cmd-zapwand.h"
23 #include "combat/shoot.h"
24 #include "core/asking-player.h"
25 #include "core/player-redraw-types.h"
26 #include "core/player-update-types.h"
27 #include "core/window-redrawer.h"
28 #include "flavor/flavor-describer.h"
29 #include "flavor/object-flavor-types.h"
30 #include "floor/floor-object.h"
31 #include "game-option/input-options.h"
32 #include "inventory/inventory-object.h"
33 #include "inventory/inventory-slot-types.h"
34 #include "io/input-key-acceptor.h"
35 #include "io/input-key-requester.h"
36 #include "locale/japanese.h"
37 #include "mind/snipe-types.h"
38 #include "object-activation/activation-switcher.h"
39 #include "object-hook/hook-magic.h"
40 #include "object-use/quaff-execution.h"
41 #include "object-use/read-execution.h"
42 #include "object-use/use-execution.h"
43 #include "object-use/zaprod-execution.h"
44 #include "object-use/zapwand-execution.h"
45 #include "object/item-tester-hooker.h"
46 #include "object/item-use-flags.h"
47 #include "perception/identification.h"
48 #include "perception/object-perception.h"
49 #include "player-base/player-class.h"
50 #include "player-info/class-info.h"
51 #include "player-info/race-types.h"
52 #include "player-info/samurai-data-type.h"
53 #include "player-info/self-info.h"
54 #include "player-status/player-energy.h"
55 #include "player/attack-defense-types.h"
56 #include "player/player-personality-types.h"
57 #include "player/player-status.h"
58 #include "player/special-defense-types.h"
59 #include "racial/racial-android.h"
60 #include "realm/realm-hex-numbers.h"
61 #include "realm/realm-types.h"
62 #include "status/action-setter.h"
63 #include "system/object-type-definition.h"
64 #include "system/player-type-definition.h"
65 #include "term/screen-processor.h"
66 #include "util/bit-flags-calculator.h"
67 #include "util/int-char-converter.h"
68 #include "util/quarks.h"
69 #include "util/string-processor.h"
70 #include "view/display-inventory.h"
71 #include "view/display-messages.h"
74 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list
76 void do_cmd_inven(PlayerType *player_ptr)
81 command_wrk = USE_INVEN;
84 (void)show_inventory(player_ptr, 0, USE_FULL, AllMatchItemTester());
85 WEIGHT weight = calc_inventory_weight(player_ptr);
86 WEIGHT weight_lim = calc_weight_limit(player_ptr);
88 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ", lb_to_kg_integer(weight), lb_to_kg_fraction(weight),
90 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ", weight / 10, weight % 10,
92 (long int)(weight * 100) / weight_lim);
95 command_new = inkey();
97 if (command_new != ESCAPE) {
103 term_get_size(&wid, &hgt);
105 command_gap = wid - 30;
109 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
111 void do_cmd_drop(PlayerType *player_ptr)
116 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
118 concptr q = _("どのアイテムを落としますか? ", "Drop which item? ");
119 concptr s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
120 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
124 if ((item >= INVEN_MAIN_HAND) && o_ptr->is_cursed()) {
125 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
129 if (o_ptr->number > 1) {
130 amt = get_quantity(nullptr, o_ptr->number);
135 PlayerEnergy(player_ptr).set_player_turn_energy(50);
136 drop_from_inventory(player_ptr, item, amt);
137 if (item >= INVEN_MAIN_HAND) {
138 verify_equip_slot(player_ptr, item);
139 calc_android_exp(player_ptr);
142 player_ptr->redraw |= (PR_EQUIPPY);
146 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
148 void do_cmd_observe(PlayerType *player_ptr)
152 GAME_TEXT o_name[MAX_NLEN];
153 concptr q = _("どのアイテムを調べますか? ", "Examine which item? ");
154 concptr s = _("調べられるアイテムがない。", "You have nothing to examine.");
155 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
159 if (!o_ptr->is_fully_known()) {
160 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
164 describe_flavor(player_ptr, o_name, o_ptr, 0);
165 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
166 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
167 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
171 * @brief アイテムの銘を消すコマンドのメインルーチン
172 * Remove the inscription from an object XXX Mention item (when done)?
174 void do_cmd_uninscribe(PlayerType *player_ptr)
178 concptr q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
179 concptr s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
180 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
184 if (!o_ptr->inscription) {
185 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
189 msg_print(_("銘を消した。", "Inscription removed."));
190 o_ptr->inscription = 0;
191 set_bits(player_ptr->update, PU_COMBINE);
192 set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_FLOOR_ITEM_LIST);
193 set_bits(player_ptr->update, PU_BONUS);
197 * @brief アイテムの銘を刻むコマンドのメインルーチン
198 * Inscribe an object with a comment
200 void do_cmd_inscribe(PlayerType *player_ptr)
204 GAME_TEXT o_name[MAX_NLEN];
205 char out_val[MAX_INSCRIPTION + 1] = "";
206 concptr q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
207 concptr s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
208 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
212 describe_flavor(player_ptr, o_name, o_ptr, OD_OMIT_INSCRIPTION);
213 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
216 if (o_ptr->inscription)
217 angband_strcpy(out_val, quark_str(o_ptr->inscription), MAX_INSCRIPTION);
219 if (get_string(_("銘: ", "Inscription: "), out_val, MAX_INSCRIPTION)) {
220 o_ptr->inscription = quark_add(out_val);
221 set_bits(player_ptr->update, PU_COMBINE);
222 set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_FLOOR_ITEM_LIST);
223 set_bits(player_ptr->update, PU_BONUS);
228 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
231 * XXX - Add actions for other item types
233 void do_cmd_use(PlayerType *player_ptr)
237 if (player_ptr->wild_mode || cmd_limit_arena(player_ptr))
240 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU, SamuraiStanceType::KOUKIJIN });
242 concptr q = _("どれを使いますか?", "Use which item? ");
243 concptr s = _("使えるものがありません。", "You have nothing to use.");
244 o_ptr = choose_object(
245 player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT), FuncItemTester(item_tester_hook_use, player_ptr));
249 switch (o_ptr->tval) {
250 case ItemKindType::SPIKE:
251 do_cmd_spike(player_ptr);
253 case ItemKindType::FOOD:
254 exe_eat_food(player_ptr, item);
256 case ItemKindType::WAND:
257 ObjectZapWandEntity(player_ptr).execute(item);
259 case ItemKindType::STAFF:
260 ObjectUseEntity(player_ptr, item).execute();
262 case ItemKindType::ROD:
263 ObjectZapRodEntity(player_ptr).execute(item);
265 case ItemKindType::POTION:
266 ObjectQuaffEntity(player_ptr).execute(item);
268 case ItemKindType::SCROLL:
269 if (cmd_limit_blind(player_ptr) || cmd_limit_confused(player_ptr))
272 ObjectReadEntity(player_ptr, item).execute(true);
274 case ItemKindType::SHOT:
275 case ItemKindType::ARROW:
276 case ItemKindType::BOLT:
277 exe_fire(player_ptr, item, &player_ptr->inventory_list[INVEN_BOW], SP_NONE);
280 exe_activate(player_ptr, item);
286 * @brief 装備を発動するコマンドのメインルーチン /
287 * @param player_ptr プレイヤーへの参照ポインタ
289 void do_cmd_activate(PlayerType *player_ptr)
292 if (player_ptr->wild_mode || cmd_limit_arena(player_ptr))
295 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU, SamuraiStanceType::KOUKIJIN });
297 concptr q = _("どのアイテムを始動させますか? ", "Activate which item? ");
298 concptr s = _("始動できるアイテムを装備していない。", "You have nothing to activate.");
299 if (!choose_object(player_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), FuncItemTester(&object_type::is_activatable)))
302 exe_activate(player_ptr, item);