1 #include "spell-kind/spells-perception.h"
2 #include "autopick/autopick.h"
3 #include "avatar/avatar.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "flavor/flavor-describer.h"
8 #include "flavor/object-flavor-types.h"
9 #include "floor/floor-object.h"
10 #include "game-option/auto-destruction-options.h"
11 #include "game-option/play-record-options.h"
12 #include "inventory/inventory-describer.h"
13 #include "inventory/inventory-slot-types.h"
14 #include "inventory/player-inventory.h"
15 #include "io/write-diary.h"
16 #include "object-enchant/special-object-flags.h"
17 #include "object-hook/hook-perception.h"
18 #include "object-hook/hook-weapon.h"
19 #include "object/item-tester-hooker.h"
20 #include "object/item-use-flags.h"
21 #include "object/object-info.h"
22 #include "object/object-mark-types.h"
23 #include "perception/identification.h"
24 #include "perception/object-perception.h"
25 #include "system/object-type-definition.h"
26 #include "system/player-type-definition.h"
27 #include "util/bit-flags-calculator.h"
28 #include "view/display-messages.h"
29 #include "world/world.h"
34 * @brief 全所持アイテム鑑定処理 /
35 * Identify everything being carried.
36 * Done by a potion of "self knowledge".
37 * @param player_ptr プレイヤーへの参照ポインタ
39 void identify_pack(PlayerType *player_ptr)
41 for (INVENTORY_IDX i = 0; i < INVEN_TOTAL; i++) {
42 auto *o_ptr = &player_ptr->inventory_list[i];
47 identify_item(player_ptr, o_ptr);
48 autopick_alter_item(player_ptr, i, false);
55 * @param player_ptr プレイヤーへの参照ポインタ
56 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
57 * @return 実際に鑑定できたらTRUEを返す
59 bool identify_item(PlayerType *player_ptr, ObjectType *o_ptr)
61 GAME_TEXT o_name[MAX_NLEN];
62 describe_flavor(player_ptr, o_name, o_ptr, 0);
64 bool old_known = false;
65 if (any_bits(o_ptr->ident, IDENT_KNOWN)) {
69 if (!o_ptr->is_fully_known()) {
70 if (o_ptr->is_artifact() || one_in_(5)) {
71 chg_virtue(player_ptr, V_KNOWLEDGE, 1);
75 object_aware(player_ptr, o_ptr);
77 set_bits(o_ptr->marked, OM_TOUCHED);
79 set_bits(player_ptr->update, PU_BONUS | PU_COMBINE | PU_REORDER);
80 set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
82 strcpy(record_o_name, o_name);
83 record_turn = w_ptr->game_turn;
85 describe_flavor(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
87 if (record_fix_art && !old_known && o_ptr->is_fixed_artifact()) {
88 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
90 if (record_rand_art && !old_known && o_ptr->art_name) {
91 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
98 * @brief アイテム鑑定のメインルーチン処理 /
99 * Identify an object in the inventory (or on the floor)
100 * @param player_ptr プレイヤーへの参照ポインタ
101 * @param only_equip 装備品のみを対象とするならばTRUEを返す
102 * @return 実際に鑑定を行ったならばTRUEを返す
104 * This routine does *not* automatically combine objects.
105 * Returns TRUE if something was identified, else FALSE.
107 bool ident_spell(PlayerType *player_ptr, bool only_equip)
109 std::unique_ptr<ItemTester> item_tester = std::make_unique<FuncItemTester>(only_equip ? object_is_not_identified_weapon_armor : object_is_not_identified);
112 if (can_get_item(player_ptr, *item_tester)) {
113 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
116 item_tester = std::make_unique<FuncItemTester>(&ObjectType::is_weapon_armour_ammo);
118 item_tester = std::make_unique<AllMatchItemTester>();
120 q = _("すべて鑑定済みです。 ", "All items are identified. ");
123 concptr s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
126 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), *item_tester);
131 bool old_known = identify_item(player_ptr, o_ptr);
133 GAME_TEXT o_name[MAX_NLEN];
134 describe_flavor(player_ptr, o_name, o_ptr, 0);
135 if (item >= INVEN_MAIN_HAND) {
136 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(player_ptr, item), o_name, index_to_label(item));
137 } else if (item >= 0) {
138 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
140 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
143 autopick_alter_item(player_ptr, item, (bool)(destroy_identify && !old_known));
148 * @brief アイテム*鑑定*のメインルーチン処理 /
149 * Identify an object in the inventory (or on the floor)
150 * @param player_ptr プレイヤーへの参照ポインタ
151 * @param only_equip 装備品のみを対象とするならばTRUEを返す
152 * @return 実際に鑑定を行ったならばTRUEを返す
154 * Fully "identify" an object in the inventory -BEN-
155 * This routine returns TRUE if an item was identified.
157 bool identify_fully(PlayerType *player_ptr, bool only_equip)
159 std::unique_ptr<ItemTester> item_tester = std::make_unique<FuncItemTester>(only_equip ? object_is_not_fully_identified_weapon_armour : object_is_not_fully_identified);
162 if (can_get_item(player_ptr, *item_tester)) {
163 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
166 item_tester = std::make_unique<FuncItemTester>(&ObjectType::is_weapon_armour_ammo);
168 item_tester = std::make_unique<AllMatchItemTester>();
170 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
173 concptr s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
177 o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), *item_tester);
182 bool old_known = identify_item(player_ptr, o_ptr);
184 o_ptr->ident |= (IDENT_FULL_KNOWN);
186 /* Refrect item informaiton onto subwindows without updating inventory */
187 player_ptr->update &= ~(PU_COMBINE | PU_REORDER);
188 handle_stuff(player_ptr);
189 player_ptr->update |= (PU_COMBINE | PU_REORDER);
191 GAME_TEXT o_name[MAX_NLEN];
192 describe_flavor(player_ptr, o_name, o_ptr, 0);
193 if (item >= INVEN_MAIN_HAND) {
194 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(player_ptr, item), o_name, index_to_label(item));
195 } else if (item >= 0) {
196 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
198 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
201 (void)screen_object(player_ptr, o_ptr, 0L);
202 autopick_alter_item(player_ptr, item, (bool)(destroy_identify && !old_known));