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-stack.h"
22 #include "object/object-value.h"
23 #include "perception/object-perception.h"
24 #include "player-base/player-class.h"
25 #include "player/player-realm.h"
26 #include "system/baseitem-info-definition.h"
27 #include "system/floor-type-definition.h"
28 #include "system/monster-race-definition.h"
29 #include "system/object-type-definition.h"
30 #include "system/player-type-definition.h"
31 #include "util/string-processor.h"
34 * @brief A function for Auto-picker/destroyer Examine whether the object matches to the entry
36 bool is_autopick_match(PlayerType *player_ptr, ObjectType *o_ptr, autopick_type *entry, concptr o_name)
38 concptr ptr = entry->name.c_str();
39 if (IS_FLG(FLG_UNAWARE) && o_ptr->is_aware()) {
43 if (IS_FLG(FLG_UNIDENTIFIED) && (o_ptr->is_known() || (o_ptr->ident & IDENT_SENSE))) {
47 if (IS_FLG(FLG_IDENTIFIED) && !o_ptr->is_known()) {
51 if (IS_FLG(FLG_STAR_IDENTIFIED) && (!o_ptr->is_known() || !o_ptr->is_fully_known())) {
55 if (IS_FLG(FLG_BOOSTED)) {
56 auto *k_ptr = &k_info[o_ptr->k_idx];
57 if (!o_ptr->is_melee_weapon()) {
61 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds)) {
65 if (!o_ptr->is_known() && object_is_quest_target(player_ptr->current_floor_ptr->quest_number, o_ptr)) {
70 if (IS_FLG(FLG_MORE_DICE)) {
71 if (o_ptr->dd * o_ptr->ds < entry->dice) {
76 if (IS_FLG(FLG_MORE_BONUS)) {
77 if (!o_ptr->is_known()) {
82 if (o_ptr->pval < entry->bonus) {
86 if (o_ptr->to_h < entry->bonus && o_ptr->to_d < entry->bonus && o_ptr->to_a < entry->bonus && o_ptr->pval < entry->bonus) {
92 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0) {
96 if (IS_FLG(FLG_ARTIFACT)) {
97 if (!o_ptr->is_known() || !o_ptr->is_artifact()) {
102 if (IS_FLG(FLG_EGO)) {
103 if (!o_ptr->is_ego()) {
106 if (!o_ptr->is_known() && !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT)) {
111 if (IS_FLG(FLG_GOOD)) {
112 if (!o_ptr->is_equipment()) {
115 if (o_ptr->is_known()) {
116 if (!o_ptr->is_nameless()) {
120 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0) {
123 } else if (o_ptr->ident & IDENT_SENSE) {
124 switch (o_ptr->feeling) {
136 if (IS_FLG(FLG_NAMELESS)) {
137 if (!o_ptr->is_equipment()) {
140 if (o_ptr->is_known()) {
141 if (!o_ptr->is_nameless()) {
144 } else if (o_ptr->ident & IDENT_SENSE) {
145 switch (o_ptr->feeling) {
160 if (IS_FLG(FLG_AVERAGE)) {
161 if (!o_ptr->is_equipment()) {
164 if (o_ptr->is_known()) {
165 if (!o_ptr->is_nameless()) {
169 if (o_ptr->is_cursed() || o_ptr->is_broken()) {
173 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0) {
176 } else if (o_ptr->ident & IDENT_SENSE) {
177 switch (o_ptr->feeling) {
189 if (IS_FLG(FLG_RARE) && !o_ptr->is_rare()) {
193 if (IS_FLG(FLG_COMMON) && o_ptr->is_rare()) {
197 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr)) {
201 const auto r_idx = i2enum<MonsterRaceId>(o_ptr->pval);
202 if (IS_FLG(FLG_UNIQUE) && ((o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::STATUE) || r_info[r_idx].kind_flags.has_not(MonsterKindType::UNIQUE))) {
206 if (IS_FLG(FLG_HUMAN) && (o_ptr->tval != ItemKindType::CORPSE || !angband_strchr("pht", r_info[r_idx].d_char))) {
210 if (IS_FLG(FLG_UNREADABLE) && (o_ptr->tval < ItemKindType::LIFE_BOOK || check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval))) {
214 PlayerClass pc(player_ptr);
215 auto realm_except_class = pc.equals(PlayerClassType::SORCERER) || pc.equals(PlayerClassType::RED_MAGE);
217 if (IS_FLG(FLG_REALM1) && ((get_realm1_book(player_ptr) != o_ptr->tval) || realm_except_class)) {
221 if (IS_FLG(FLG_REALM2) && ((get_realm2_book(player_ptr) != o_ptr->tval) || realm_except_class)) {
225 if (IS_FLG(FLG_FIRST) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 0)) {
229 if (IS_FLG(FLG_SECOND) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 1)) {
233 if (IS_FLG(FLG_THIRD) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 2)) {
237 if (IS_FLG(FLG_FOURTH) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 3)) {
241 if (IS_FLG(FLG_WEAPONS)) {
242 if (!o_ptr->is_weapon()) {
245 } else if (IS_FLG(FLG_FAVORITE_WEAPONS)) {
246 if (!object_is_favorite(player_ptr, o_ptr)) {
249 } else if (IS_FLG(FLG_ARMORS)) {
250 if (!o_ptr->is_armour()) {
253 } else if (IS_FLG(FLG_MISSILES)) {
254 if (!o_ptr->is_ammo()) {
257 } else if (IS_FLG(FLG_DEVICES)) {
258 switch (o_ptr->tval) {
259 case ItemKindType::SCROLL:
260 case ItemKindType::STAFF:
261 case ItemKindType::WAND:
262 case ItemKindType::ROD:
267 } else if (IS_FLG(FLG_LIGHTS)) {
268 if (!(o_ptr->tval == ItemKindType::LITE)) {
271 } else if (IS_FLG(FLG_JUNKS)) {
272 switch (o_ptr->tval) {
273 case ItemKindType::SKELETON:
274 case ItemKindType::BOTTLE:
275 case ItemKindType::JUNK:
276 case ItemKindType::STATUE:
281 } else if (IS_FLG(FLG_CORPSES)) {
282 if (o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::SKELETON) {
285 } else if (IS_FLG(FLG_SPELLBOOKS)) {
286 if (!(o_ptr->tval >= ItemKindType::LIFE_BOOK)) {
289 } else if (IS_FLG(FLG_HAFTED)) {
290 if (!(o_ptr->tval == ItemKindType::HAFTED)) {
293 } else if (IS_FLG(FLG_SHIELDS)) {
294 if (!(o_ptr->tval == ItemKindType::SHIELD)) {
297 } else if (IS_FLG(FLG_BOWS)) {
298 if (!(o_ptr->tval == ItemKindType::BOW)) {
301 } else if (IS_FLG(FLG_RINGS)) {
302 if (!(o_ptr->tval == ItemKindType::RING)) {
305 } else if (IS_FLG(FLG_AMULETS)) {
306 if (!(o_ptr->tval == ItemKindType::AMULET)) {
309 } else if (IS_FLG(FLG_SUITS)) {
310 if (!(o_ptr->tval == ItemKindType::DRAG_ARMOR || o_ptr->tval == ItemKindType::HARD_ARMOR || o_ptr->tval == ItemKindType::SOFT_ARMOR)) {
313 } else if (IS_FLG(FLG_CLOAKS)) {
314 if (!(o_ptr->tval == ItemKindType::CLOAK)) {
317 } else if (IS_FLG(FLG_HELMS)) {
318 if (!(o_ptr->tval == ItemKindType::CROWN || o_ptr->tval == ItemKindType::HELM)) {
321 } else if (IS_FLG(FLG_GLOVES)) {
322 if (!(o_ptr->tval == ItemKindType::GLOVES)) {
325 } else if (IS_FLG(FLG_BOOTS)) {
326 if (!(o_ptr->tval == ItemKindType::BOOTS)) {
333 if (strncmp(o_name, ptr, strlen(ptr))) {
337 if (!angband_strstr(o_name, ptr)) {
342 if (!IS_FLG(FLG_COLLECTING)) {
346 for (int j = 0; j < INVEN_PACK; j++) {
348 * 'Collecting' means the item must be absorbed
349 * into an inventory slot.
350 * But an item can not be absorbed into itself!
352 if ((&player_ptr->inventory_list[j] != o_ptr) && object_similar(&player_ptr->inventory_list[j], o_ptr)) {