1 #include "spell-kind/spells-perception.h"
2 #include "autopick/autopick.h"
3 #include "avatar/avatar.h"
4 #include "core/stuff-handler.h"
5 #include "core/window-redrawer.h"
6 #include "flavor/flavor-describer.h"
7 #include "flavor/object-flavor-types.h"
8 #include "floor/floor-object.h"
9 #include "game-option/auto-destruction-options.h"
10 #include "game-option/play-record-options.h"
11 #include "inventory/inventory-describer.h"
12 #include "inventory/inventory-slot-types.h"
13 #include "inventory/player-inventory.h"
14 #include "io/write-diary.h"
15 #include "object-enchant/special-object-flags.h"
16 #include "object-hook/hook-perception.h"
17 #include "object-hook/hook-weapon.h"
18 #include "object/item-tester-hooker.h"
19 #include "object/item-use-flags.h"
20 #include "object/object-info.h"
21 #include "object/object-mark-types.h"
22 #include "perception/identification.h"
23 #include "perception/object-perception.h"
24 #include "system/item-entity.h"
25 #include "system/player-type-definition.h"
26 #include "system/redrawing-flags-updater.h"
27 #include "util/bit-flags-calculator.h"
28 #include "util/string-processor.h"
29 #include "view/display-messages.h"
30 #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];
43 if (!o_ptr->is_valid()) {
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, ItemEntity *o_ptr)
61 const auto known_item_name = describe_flavor(player_ptr, o_ptr, 0);
62 const auto old_known = any_bits(o_ptr->ident, IDENT_KNOWN);
63 if (!o_ptr->is_fully_known()) {
64 if (o_ptr->is_fixed_or_random_artifact() || one_in_(5)) {
65 chg_virtue(player_ptr, Virtue::KNOWLEDGE, 1);
69 object_aware(player_ptr, o_ptr);
71 o_ptr->marked.set(OmType::TOUCHED);
73 auto &rfu = RedrawingFlagsUpdater::get_instance();
74 static constexpr auto flags_srf = {
75 StatusRecalculatingFlag::BONUS,
76 StatusRecalculatingFlag::COMBINATION,
77 StatusRecalculatingFlag::REORDER,
79 rfu.set_flags(flags_srf);
80 static constexpr auto flags_swrf = {
81 SubWindowRedrawingFlag::INVENTORY,
82 SubWindowRedrawingFlag::EQUIPMENT,
83 SubWindowRedrawingFlag::PLAYER,
84 SubWindowRedrawingFlag::FLOOR_ITEMS,
85 SubWindowRedrawingFlag::FOUND_ITEMS,
87 rfu.set_flags(flags_swrf);
88 angband_strcpy(record_o_name, known_item_name, MAX_NLEN);
89 record_turn = w_ptr->game_turn;
91 const auto item_name = describe_flavor(player_ptr, o_ptr, OD_NAME_ONLY);
92 if (record_fix_art && !old_known && o_ptr->is_fixed_artifact()) {
93 exe_write_diary(player_ptr, DiaryKind::ART, 0, item_name);
96 if (record_rand_art && !old_known && o_ptr->is_random_artifact()) {
97 exe_write_diary(player_ptr, DiaryKind::ART, 0, item_name);
104 * @brief アイテム鑑定のメインルーチン処理 /
105 * Identify an object in the inventory (or on the floor)
106 * @param player_ptr プレイヤーへの参照ポインタ
107 * @param only_equip 装備品のみを対象とするならばTRUEを返す
108 * @return 実際に鑑定を行ったならばTRUEを返す
110 * This routine does *not* automatically combine objects.
111 * Returns TRUE if something was identified, else FALSE.
113 bool ident_spell(PlayerType *player_ptr, bool only_equip)
115 std::unique_ptr<ItemTester> item_tester = std::make_unique<FuncItemTester>(only_equip ? object_is_not_identified_weapon_armor : object_is_not_identified);
118 if (can_get_item(player_ptr, *item_tester)) {
119 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
122 item_tester = std::make_unique<FuncItemTester>(&ItemEntity::is_weapon_armour_ammo);
124 item_tester = std::make_unique<AllMatchItemTester>();
126 q = _("すべて鑑定済みです。 ", "All items are identified. ");
129 constexpr auto s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
131 auto o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), *item_tester);
136 auto old_known = identify_item(player_ptr, o_ptr);
138 const auto item_name = describe_flavor(player_ptr, o_ptr, 0);
139 if (item >= INVEN_MAIN_HAND) {
140 msg_format(_("%s^: %s(%c)。", "%s^: %s (%c)."), describe_use(player_ptr, item), item_name.data(), index_to_label(item));
141 } else if (item >= 0) {
142 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), item_name.data(), index_to_label(item));
144 msg_format(_("床上: %s。", "On the ground: %s."), item_name.data());
147 autopick_alter_item(player_ptr, item, (bool)(destroy_identify && !old_known));
152 * @brief アイテム*鑑定*のメインルーチン処理 /
153 * Identify an object in the inventory (or on the floor)
154 * @param player_ptr プレイヤーへの参照ポインタ
155 * @param only_equip 装備品のみを対象とするならばTRUEを返す
156 * @return 実際に鑑定を行ったならばTRUEを返す
158 * Fully "identify" an object in the inventory -BEN-
159 * This routine returns TRUE if an item was identified.
161 bool identify_fully(PlayerType *player_ptr, bool only_equip)
163 std::unique_ptr<ItemTester> item_tester = std::make_unique<FuncItemTester>(only_equip ? object_is_not_fully_identified_weapon_armour : object_is_not_fully_identified);
166 if (can_get_item(player_ptr, *item_tester)) {
167 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
170 item_tester = std::make_unique<FuncItemTester>(&ItemEntity::is_weapon_armour_ammo);
172 item_tester = std::make_unique<AllMatchItemTester>();
174 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
177 constexpr auto s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
180 auto o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), *item_tester);
185 auto old_known = identify_item(player_ptr, o_ptr);
187 o_ptr->ident |= (IDENT_FULL_KNOWN);
189 window_stuff(player_ptr);
191 const auto item_name = describe_flavor(player_ptr, o_ptr, 0);
192 if (item >= INVEN_MAIN_HAND) {
193 msg_format(_("%s^: %s(%c)。", "%s^: %s (%c)."), describe_use(player_ptr, item), item_name.data(), index_to_label(item));
194 } else if (item >= 0) {
195 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), item_name.data(), index_to_label(item));
197 msg_format(_("床上: %s。", "On the ground: %s."), item_name.data());
200 (void)screen_object(player_ptr, o_ptr, 0L);
201 autopick_alter_item(player_ptr, item, (bool)(destroy_identify && !old_known));