2 * @brief 床のアイテムが自動拾いに一致するかどうかを調べる関数だけを格納したファイル
5 * @todo 300行以上の凶悪関数なので後で分割しておく
8 #include "autopick/autopick-matcher.h"
9 #include "autopick/autopick-flags-table.h"
10 #include "autopick/autopick-key-flag-process.h"
11 #include "autopick/autopick-util.h"
12 #include "inventory/inventory-slot-types.h"
13 #include "monster-race/monster-race.h"
14 #include "monster-race/race-flags1.h"
15 #include "object-enchant/item-feeling.h"
16 #include "object-enchant/special-object-flags.h"
17 #include "object-hook/hook-armor.h"
18 #include "object-hook/hook-quest.h"
19 #include "object-hook/hook-weapon.h"
20 #include "object/object-info.h"
21 #include "object/object-kind.h"
22 #include "object/object-stack.h"
23 #include "object/object-value.h"
24 #include "perception/object-perception.h"
25 #include "player/player-realm.h"
26 #include "system/floor-type-definition.h"
27 #include "system/monster-race-definition.h"
28 #include "system/object-type-definition.h"
29 #include "system/player-type-definition.h"
30 #include "util/string-processor.h"
33 * @brief A function for Auto-picker/destroyer Examine whether the object matches to the entry
35 bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
37 concptr ptr = entry->name.c_str();
38 if (IS_FLG(FLG_UNAWARE) && o_ptr->is_aware())
41 if (IS_FLG(FLG_UNIDENTIFIED) && (o_ptr->is_known() || (o_ptr->ident & IDENT_SENSE)))
44 if (IS_FLG(FLG_IDENTIFIED) && !o_ptr->is_known())
47 if (IS_FLG(FLG_STAR_IDENTIFIED) && (!o_ptr->is_known() || !o_ptr->is_fully_known()))
50 if (IS_FLG(FLG_BOOSTED)) {
51 object_kind *k_ptr = &k_info[o_ptr->k_idx];
52 if (!o_ptr->is_melee_weapon())
55 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
58 if (!o_ptr->is_known() && object_is_quest_target(player_ptr->current_floor_ptr->inside_quest, o_ptr)) {
63 if (IS_FLG(FLG_MORE_DICE)) {
64 if (o_ptr->dd * o_ptr->ds < entry->dice)
68 if (IS_FLG(FLG_MORE_BONUS)) {
69 if (!o_ptr->is_known())
73 if (o_ptr->pval < entry->bonus)
76 if (o_ptr->to_h < entry->bonus && o_ptr->to_d < entry->bonus && o_ptr->to_a < entry->bonus && o_ptr->pval < entry->bonus)
81 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
84 if (IS_FLG(FLG_ARTIFACT)) {
85 if (!o_ptr->is_known() || !o_ptr->is_artifact())
89 if (IS_FLG(FLG_EGO)) {
92 if (!o_ptr->is_known() && !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
96 if (IS_FLG(FLG_GOOD)) {
97 if (!o_ptr->is_equipment())
99 if (o_ptr->is_known()) {
100 if (!o_ptr->is_nameless())
103 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
105 } else if (o_ptr->ident & IDENT_SENSE) {
106 switch (o_ptr->feeling) {
118 if (IS_FLG(FLG_NAMELESS)) {
119 if (!o_ptr->is_equipment())
121 if (o_ptr->is_known()) {
122 if (!o_ptr->is_nameless())
124 } else if (o_ptr->ident & IDENT_SENSE) {
125 switch (o_ptr->feeling) {
140 if (IS_FLG(FLG_AVERAGE)) {
141 if (!o_ptr->is_equipment())
143 if (o_ptr->is_known()) {
144 if (!o_ptr->is_nameless())
147 if (o_ptr->is_cursed() || o_ptr->is_broken())
150 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
152 } else if (o_ptr->ident & IDENT_SENSE) {
153 switch (o_ptr->feeling) {
165 if (IS_FLG(FLG_RARE) && !o_ptr->is_rare())
168 if (IS_FLG(FLG_COMMON) && o_ptr->is_rare())
171 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr))
174 if (IS_FLG(FLG_UNIQUE) && ((o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::STATUE) || !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
177 if (IS_FLG(FLG_HUMAN) && (o_ptr->tval != ItemKindType::CORPSE || !angband_strchr("pht", r_info[o_ptr->pval].d_char)))
180 if (IS_FLG(FLG_UNREADABLE) && (o_ptr->tval < ItemKindType::LIFE_BOOK || check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
183 bool realm_except_class = player_ptr->pclass == PlayerClassType::SORCERER || player_ptr->pclass == PlayerClassType::RED_MAGE;
185 if (IS_FLG(FLG_REALM1) && ((get_realm1_book(player_ptr) != o_ptr->tval) || realm_except_class))
188 if (IS_FLG(FLG_REALM2) && ((get_realm2_book(player_ptr) != o_ptr->tval) || realm_except_class))
191 if (IS_FLG(FLG_FIRST) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 0))
194 if (IS_FLG(FLG_SECOND) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 1))
197 if (IS_FLG(FLG_THIRD) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 2))
200 if (IS_FLG(FLG_FOURTH) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 3))
203 if (IS_FLG(FLG_WEAPONS)) {
204 if (!o_ptr->is_weapon())
206 } else if (IS_FLG(FLG_FAVORITE_WEAPONS)) {
207 if (!object_is_favorite(player_ptr, o_ptr))
209 } else if (IS_FLG(FLG_ARMORS)) {
210 if (!o_ptr->is_armour())
212 } else if (IS_FLG(FLG_MISSILES)) {
213 if (!o_ptr->is_ammo())
215 } else if (IS_FLG(FLG_DEVICES)) {
216 switch (o_ptr->tval) {
217 case ItemKindType::SCROLL:
218 case ItemKindType::STAFF:
219 case ItemKindType::WAND:
220 case ItemKindType::ROD:
225 } else if (IS_FLG(FLG_LIGHTS)) {
226 if (!(o_ptr->tval == ItemKindType::LITE))
228 } else if (IS_FLG(FLG_JUNKS)) {
229 switch (o_ptr->tval) {
230 case ItemKindType::SKELETON:
231 case ItemKindType::BOTTLE:
232 case ItemKindType::JUNK:
233 case ItemKindType::STATUE:
238 } else if (IS_FLG(FLG_CORPSES)) {
239 if (o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::SKELETON)
241 } else if (IS_FLG(FLG_SPELLBOOKS)) {
242 if (!(o_ptr->tval >= ItemKindType::LIFE_BOOK))
244 } else if (IS_FLG(FLG_HAFTED)) {
245 if (!(o_ptr->tval == ItemKindType::HAFTED))
247 } else if (IS_FLG(FLG_SHIELDS)) {
248 if (!(o_ptr->tval == ItemKindType::SHIELD))
250 } else if (IS_FLG(FLG_BOWS)) {
251 if (!(o_ptr->tval == ItemKindType::BOW))
253 } else if (IS_FLG(FLG_RINGS)) {
254 if (!(o_ptr->tval == ItemKindType::RING))
256 } else if (IS_FLG(FLG_AMULETS)) {
257 if (!(o_ptr->tval == ItemKindType::AMULET))
259 } else if (IS_FLG(FLG_SUITS)) {
260 if (!(o_ptr->tval == ItemKindType::DRAG_ARMOR || o_ptr->tval == ItemKindType::HARD_ARMOR || o_ptr->tval == ItemKindType::SOFT_ARMOR))
262 } else if (IS_FLG(FLG_CLOAKS)) {
263 if (!(o_ptr->tval == ItemKindType::CLOAK))
265 } else if (IS_FLG(FLG_HELMS)) {
266 if (!(o_ptr->tval == ItemKindType::CROWN || o_ptr->tval == ItemKindType::HELM))
268 } else if (IS_FLG(FLG_GLOVES)) {
269 if (!(o_ptr->tval == ItemKindType::GLOVES))
271 } else if (IS_FLG(FLG_BOOTS)) {
272 if (!(o_ptr->tval == ItemKindType::BOOTS))
278 if (strncmp(o_name, ptr, strlen(ptr)))
281 if (!angband_strstr(o_name, ptr))
285 if (!IS_FLG(FLG_COLLECTING))
288 for (int j = 0; j < INVEN_PACK; j++) {
290 * 'Collecting' means the item must be absorbed
291 * into an inventory slot.
292 * But an item can not be absorbed into itself!
294 if ((&player_ptr->inventory_list[j] != o_ptr) && object_similar(&player_ptr->inventory_list[j], o_ptr))