OSDN Git Service

Merge pull request #1192 from hengband/feature/3.0.0Alpha26
[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 "system/object-type-definition.h"
10 #include "system/player-type-definition.h"
11 #include "target/target-describer.h"
12
13 /*
14  * Used during calls to "get_item()" and "show_inven()" and "show_equip()", and the choice window routines.
15  */
16 bool (*item_tester_hook)(player_type *, object_type *);
17
18 /*!
19  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
20  * Check an item against the item tester info
21  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
22  * @return item_tester_hookの参照先が特にないならTRUE、その他いくつかの例外に応じてTRUE/FALSEを返す。
23  */
24 bool item_tester_okay(player_type *player_ptr, object_type *o_ptr, tval_type tval)
25 {
26     if (!o_ptr->k_idx)
27         return false;
28
29     if (o_ptr->tval == TV_GOLD) {
30         if (!show_gold_on_floor)
31             return false;
32     }
33
34     if (tval) {
35         if ((tval <= TV_DEATH_BOOK) && (tval >= TV_LIFE_BOOK))
36             return check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval);
37         else if (tval != o_ptr->tval)
38             return false;
39     }
40
41     if (item_tester_hook == NULL)
42         return true;
43
44     return (*item_tester_hook)(player_ptr, o_ptr);
45 }