OSDN Git Service

[feature] *_info の std::vector 化
[hengbandforosx/hengbandosx.git] / src / object / item-tester-hooker.cpp
1 /*!
2  * @brief オブジェクトに関する汎用判定処理
3  * @date 2018/09/24
4  * @author deskull
5  */
6
7 #include "object/item-tester-hooker.h"
8 #include "object/object-info.h"
9 #include "target/target-describer.h"
10
11 /*
12  * Used during calls to "get_item()" and "show_inven()" and "show_equip()", and the choice window routines.
13  */
14 bool (*item_tester_hook)(player_type *, object_type *);
15
16 /*!
17  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
18  * Check an item against the item tester info
19  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
20  * @return item_tester_hookの参照先が特にないならTRUE、その他いくつかの例外に応じてTRUE/FALSEを返す。
21  */
22 bool item_tester_okay(player_type *player_ptr, object_type *o_ptr, tval_type tval)
23 {
24     if (!o_ptr->k_idx)
25         return FALSE;
26
27     if (o_ptr->tval == TV_GOLD) {
28         if (!show_gold_on_floor)
29             return FALSE;
30     }
31
32     if (tval) {
33         if ((tval <= TV_DEATH_BOOK) && (tval >= TV_LIFE_BOOK))
34             return check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval);
35         else if (tval != o_ptr->tval)
36             return FALSE;
37     }
38
39     if (item_tester_hook == NULL)
40         return TRUE;
41
42     return (*item_tester_hook)(player_ptr, o_ptr);
43 }