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-base/player-class.h"
26 #include "player/player-realm.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, object_type *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())
42 if (IS_FLG(FLG_UNIDENTIFIED) && (o_ptr->is_known() || (o_ptr->ident & IDENT_SENSE)))
45 if (IS_FLG(FLG_IDENTIFIED) && !o_ptr->is_known())
48 if (IS_FLG(FLG_STAR_IDENTIFIED) && (!o_ptr->is_known() || !o_ptr->is_fully_known()))
51 if (IS_FLG(FLG_BOOSTED)) {
52 object_kind *k_ptr = &k_info[o_ptr->k_idx];
53 if (!o_ptr->is_melee_weapon())
56 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
59 if (!o_ptr->is_known() && object_is_quest_target(player_ptr->current_floor_ptr->inside_quest, o_ptr)) {
64 if (IS_FLG(FLG_MORE_DICE)) {
65 if (o_ptr->dd * o_ptr->ds < entry->dice)
69 if (IS_FLG(FLG_MORE_BONUS)) {
70 if (!o_ptr->is_known())
74 if (o_ptr->pval < entry->bonus)
77 if (o_ptr->to_h < entry->bonus && o_ptr->to_d < entry->bonus && o_ptr->to_a < entry->bonus && o_ptr->pval < entry->bonus)
82 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
85 if (IS_FLG(FLG_ARTIFACT)) {
86 if (!o_ptr->is_known() || !o_ptr->is_artifact())
90 if (IS_FLG(FLG_EGO)) {
93 if (!o_ptr->is_known() && !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
97 if (IS_FLG(FLG_GOOD)) {
98 if (!o_ptr->is_equipment())
100 if (o_ptr->is_known()) {
101 if (!o_ptr->is_nameless())
104 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
106 } else if (o_ptr->ident & IDENT_SENSE) {
107 switch (o_ptr->feeling) {
119 if (IS_FLG(FLG_NAMELESS)) {
120 if (!o_ptr->is_equipment())
122 if (o_ptr->is_known()) {
123 if (!o_ptr->is_nameless())
125 } else if (o_ptr->ident & IDENT_SENSE) {
126 switch (o_ptr->feeling) {
141 if (IS_FLG(FLG_AVERAGE)) {
142 if (!o_ptr->is_equipment())
144 if (o_ptr->is_known()) {
145 if (!o_ptr->is_nameless())
148 if (o_ptr->is_cursed() || o_ptr->is_broken())
151 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
153 } else if (o_ptr->ident & IDENT_SENSE) {
154 switch (o_ptr->feeling) {
166 if (IS_FLG(FLG_RARE) && !o_ptr->is_rare())
169 if (IS_FLG(FLG_COMMON) && o_ptr->is_rare())
172 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr))
175 if (IS_FLG(FLG_UNIQUE) && ((o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::STATUE) || !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
178 if (IS_FLG(FLG_HUMAN) && (o_ptr->tval != ItemKindType::CORPSE || !angband_strchr("pht", r_info[o_ptr->pval].d_char)))
181 if (IS_FLG(FLG_UNREADABLE) && (o_ptr->tval < ItemKindType::LIFE_BOOK || check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
184 PlayerClass pc(player_ptr);
185 auto realm_except_class = pc.equals(PlayerClassType::SORCERER) || pc.equals(PlayerClassType::RED_MAGE);
187 if (IS_FLG(FLG_REALM1) && ((get_realm1_book(player_ptr) != o_ptr->tval) || realm_except_class))
190 if (IS_FLG(FLG_REALM2) && ((get_realm2_book(player_ptr) != o_ptr->tval) || realm_except_class))
193 if (IS_FLG(FLG_FIRST) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 0))
196 if (IS_FLG(FLG_SECOND) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 1))
199 if (IS_FLG(FLG_THIRD) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 2))
202 if (IS_FLG(FLG_FOURTH) && ((o_ptr->tval < ItemKindType::LIFE_BOOK) || (o_ptr->sval) != 3))
205 if (IS_FLG(FLG_WEAPONS)) {
206 if (!o_ptr->is_weapon())
208 } else if (IS_FLG(FLG_FAVORITE_WEAPONS)) {
209 if (!object_is_favorite(player_ptr, o_ptr))
211 } else if (IS_FLG(FLG_ARMORS)) {
212 if (!o_ptr->is_armour())
214 } else if (IS_FLG(FLG_MISSILES)) {
215 if (!o_ptr->is_ammo())
217 } else if (IS_FLG(FLG_DEVICES)) {
218 switch (o_ptr->tval) {
219 case ItemKindType::SCROLL:
220 case ItemKindType::STAFF:
221 case ItemKindType::WAND:
222 case ItemKindType::ROD:
227 } else if (IS_FLG(FLG_LIGHTS)) {
228 if (!(o_ptr->tval == ItemKindType::LITE))
230 } else if (IS_FLG(FLG_JUNKS)) {
231 switch (o_ptr->tval) {
232 case ItemKindType::SKELETON:
233 case ItemKindType::BOTTLE:
234 case ItemKindType::JUNK:
235 case ItemKindType::STATUE:
240 } else if (IS_FLG(FLG_CORPSES)) {
241 if (o_ptr->tval != ItemKindType::CORPSE && o_ptr->tval != ItemKindType::SKELETON)
243 } else if (IS_FLG(FLG_SPELLBOOKS)) {
244 if (!(o_ptr->tval >= ItemKindType::LIFE_BOOK))
246 } else if (IS_FLG(FLG_HAFTED)) {
247 if (!(o_ptr->tval == ItemKindType::HAFTED))
249 } else if (IS_FLG(FLG_SHIELDS)) {
250 if (!(o_ptr->tval == ItemKindType::SHIELD))
252 } else if (IS_FLG(FLG_BOWS)) {
253 if (!(o_ptr->tval == ItemKindType::BOW))
255 } else if (IS_FLG(FLG_RINGS)) {
256 if (!(o_ptr->tval == ItemKindType::RING))
258 } else if (IS_FLG(FLG_AMULETS)) {
259 if (!(o_ptr->tval == ItemKindType::AMULET))
261 } else if (IS_FLG(FLG_SUITS)) {
262 if (!(o_ptr->tval == ItemKindType::DRAG_ARMOR || o_ptr->tval == ItemKindType::HARD_ARMOR || o_ptr->tval == ItemKindType::SOFT_ARMOR))
264 } else if (IS_FLG(FLG_CLOAKS)) {
265 if (!(o_ptr->tval == ItemKindType::CLOAK))
267 } else if (IS_FLG(FLG_HELMS)) {
268 if (!(o_ptr->tval == ItemKindType::CROWN || o_ptr->tval == ItemKindType::HELM))
270 } else if (IS_FLG(FLG_GLOVES)) {
271 if (!(o_ptr->tval == ItemKindType::GLOVES))
273 } else if (IS_FLG(FLG_BOOTS)) {
274 if (!(o_ptr->tval == ItemKindType::BOOTS))
280 if (strncmp(o_name, ptr, strlen(ptr)))
283 if (!angband_strstr(o_name, ptr))
287 if (!IS_FLG(FLG_COLLECTING))
290 for (int j = 0; j < INVEN_PACK; j++) {
292 * 'Collecting' means the item must be absorbed
293 * into an inventory slot.
294 * But an item can not be absorbed into itself!
296 if ((&player_ptr->inventory_list[j] != o_ptr) && object_similar(&player_ptr->inventory_list[j], o_ptr))