2 * todo 300行以上の凶悪関数なので後で分割しておく
3 * @brief 床のアイテムが自動拾いに一致するかどうかを調べる関数だけを格納したファイル
8 #include "autopick/autopick-matcher.h"
9 #include "autopick/autopick-flags-table.h"
10 #include "autopick/autopick-key-flag-process.h"
11 #include "inventory/inventory-slot-types.h"
12 #include "monster-race/monster-race.h"
13 #include "monster-race/race-flags1.h"
14 #include "perception/object-perception.h"
15 #include "object-enchant/item-feeling.h"
16 #include "object-hook/hook-armor.h"
17 #include "object-hook/hook-bow.h"
18 #include "object-hook/hook-checker.h"
19 #include "object-hook/hook-enchant.h"
20 #include "object-hook/hook-quest.h"
21 #include "object-hook/hook-weapon.h"
22 #include "object/object-kind.h"
23 #include "object/object-stack.h"
24 #include "object/object-value.h"
25 #include "object/object-info.h"
26 #include "object-enchant/special-object-flags.h"
27 #include "player/player-realm.h"
28 #include "util/string-processor.h"
31 * A function for Auto-picker/destroyer
32 * Examine whether the object matches to the entry
34 bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
36 concptr ptr = entry->name;
37 if (IS_FLG(FLG_UNAWARE) && object_is_aware(o_ptr))
40 if (IS_FLG(FLG_UNIDENTIFIED)
41 && (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
44 if (IS_FLG(FLG_IDENTIFIED) && !object_is_known(o_ptr))
47 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
48 (!object_is_known(o_ptr) || !object_is_fully_known(o_ptr)))
51 if (IS_FLG(FLG_BOOSTED))
53 object_kind *k_ptr = &k_info[o_ptr->k_idx];
54 if (!object_is_melee_weapon(o_ptr))
57 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
60 if (!object_is_known(o_ptr) && object_is_quest_target(player_ptr, o_ptr))
66 if (IS_FLG(FLG_MORE_DICE))
68 if (o_ptr->dd * o_ptr->ds < entry->dice)
72 if (IS_FLG(FLG_MORE_BONUS))
74 if (!object_is_known(o_ptr)) return FALSE;
78 if (o_ptr->pval < entry->bonus) return FALSE;
82 if (o_ptr->to_h < entry->bonus &&
83 o_ptr->to_d < entry->bonus &&
84 o_ptr->to_a < entry->bonus &&
85 o_ptr->pval < entry->bonus)
90 if (IS_FLG(FLG_WORTHLESS) && object_value(player_ptr, o_ptr) > 0)
93 if (IS_FLG(FLG_ARTIFACT))
95 if (!object_is_known(o_ptr) || !object_is_artifact(o_ptr))
101 if (!object_is_ego(o_ptr)) return FALSE;
102 if (!object_is_known(o_ptr) &&
103 !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
107 if (IS_FLG(FLG_GOOD))
109 if (!object_is_equipment(o_ptr)) return FALSE;
110 if (object_is_known(o_ptr))
112 if (!object_is_nameless(player_ptr, o_ptr))
115 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
118 else if (o_ptr->ident & IDENT_SENSE)
120 switch (o_ptr->feeling)
135 if (IS_FLG(FLG_NAMELESS))
137 if (!object_is_equipment(o_ptr)) return FALSE;
138 if (object_is_known(o_ptr))
140 if (!object_is_nameless(player_ptr, o_ptr))
143 else if (o_ptr->ident & IDENT_SENSE)
145 switch (o_ptr->feeling)
163 if (IS_FLG(FLG_AVERAGE))
165 if (!object_is_equipment(o_ptr)) return FALSE;
166 if (object_is_known(o_ptr))
168 if (!object_is_nameless(player_ptr, o_ptr))
171 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
174 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
177 else if (o_ptr->ident & IDENT_SENSE)
179 switch (o_ptr->feeling)
194 if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr))
197 if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr))
200 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr))
203 if (IS_FLG(FLG_UNIQUE) &&
204 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
205 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
208 if (IS_FLG(FLG_HUMAN) &&
209 (o_ptr->tval != TV_CORPSE ||
210 !angband_strchr("pht", r_info[o_ptr->pval].d_char)))
213 if (IS_FLG(FLG_UNREADABLE) &&
214 (o_ptr->tval < TV_LIFE_BOOK ||
215 check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
218 if (IS_FLG(FLG_REALM1) && (get_realm1_book(player_ptr) != o_ptr->tval ||
219 player_ptr->pclass == CLASS_SORCERER ||
220 player_ptr->pclass == CLASS_RED_MAGE))
223 if (IS_FLG(FLG_REALM2) && (get_realm2_book(player_ptr) != o_ptr->tval ||
224 player_ptr->pclass == CLASS_SORCERER ||
225 player_ptr->pclass == CLASS_RED_MAGE))
228 if (IS_FLG(FLG_FIRST) &&
229 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
232 if (IS_FLG(FLG_SECOND) &&
233 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
236 if (IS_FLG(FLG_THIRD) &&
237 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
240 if (IS_FLG(FLG_FOURTH) &&
241 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
244 if (IS_FLG(FLG_WEAPONS))
246 if (!object_is_weapon(player_ptr, o_ptr))
249 else if (IS_FLG(FLG_FAVORITE_WEAPONS))
251 if (!object_is_favorite(player_ptr, o_ptr))
254 else if (IS_FLG(FLG_ARMORS))
256 if (!object_is_armour(player_ptr, o_ptr))
259 else if (IS_FLG(FLG_MISSILES))
261 if (!object_is_ammo(o_ptr)) return FALSE;
263 else if (IS_FLG(FLG_DEVICES))
267 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
269 default: return FALSE;
272 else if (IS_FLG(FLG_LIGHTS))
274 if (!(o_ptr->tval == TV_LITE))
277 else if (IS_FLG(FLG_JUNKS))
281 case TV_SKELETON: case TV_BOTTLE:
282 case TV_JUNK: case TV_STATUE:
284 default: return FALSE;
287 else if (IS_FLG(FLG_CORPSES))
289 if (o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_SKELETON)
292 else if (IS_FLG(FLG_SPELLBOOKS))
294 if (!(o_ptr->tval >= TV_LIFE_BOOK))
297 else if (IS_FLG(FLG_HAFTED))
299 if (!(o_ptr->tval == TV_HAFTED))
302 else if (IS_FLG(FLG_SHIELDS))
304 if (!(o_ptr->tval == TV_SHIELD))
307 else if (IS_FLG(FLG_BOWS))
309 if (!(o_ptr->tval == TV_BOW))
312 else if (IS_FLG(FLG_RINGS))
314 if (!(o_ptr->tval == TV_RING))
317 else if (IS_FLG(FLG_AMULETS))
319 if (!(o_ptr->tval == TV_AMULET))
322 else if (IS_FLG(FLG_SUITS))
324 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
325 o_ptr->tval == TV_HARD_ARMOR ||
326 o_ptr->tval == TV_SOFT_ARMOR))
329 else if (IS_FLG(FLG_CLOAKS))
331 if (!(o_ptr->tval == TV_CLOAK))
334 else if (IS_FLG(FLG_HELMS))
336 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
339 else if (IS_FLG(FLG_GLOVES))
341 if (!(o_ptr->tval == TV_GLOVES))
344 else if (IS_FLG(FLG_BOOTS))
346 if (!(o_ptr->tval == TV_BOOTS))
353 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
357 if (!angband_strstr(o_name, ptr)) return FALSE;
360 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
362 for (int j = 0; j < INVEN_PACK; j++)
365 * 'Collecting' means the item must be absorbed
366 * into an inventory slot.
367 * But an item can not be absorbed into itself!
369 if ((&player_ptr->inventory_list[j] != o_ptr) &&
370 object_similar(&player_ptr->inventory_list[j], o_ptr))