OSDN Git Service

Merge pull request #719 from sikabane-works/feature/add-cheat-immortal
[hengbandforosx/hengbandosx.git] / src / store / black-market.cpp
1 #include "store/black-market.h"
2 #include "floor/floor-town.h"
3 #include "object-hook/hook-enchant.h"
4 #include "store/store-owners.h"
5 #include "store/store-util.h"
6
7 /*!
8  * @brief ブラックマーケット用の無価値品の排除判定 /
9  * This function will keep 'crap' out of the black market.
10  * @param player_ptr プレーヤーへの参照ポインタ
11  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
12  * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
13  * @details
14  * <pre>
15  * Crap is defined as any item that is "available" elsewhere
16  * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
17  * </pre>
18  */
19 bool black_market_crap(player_type *player_ptr, object_type *o_ptr)
20 {
21     if (object_is_ego(o_ptr))
22         return FALSE;
23
24     if (o_ptr->to_a > 0)
25         return FALSE;
26
27     if (o_ptr->to_h > 0)
28         return FALSE;
29
30     if (o_ptr->to_d > 0)
31         return FALSE;
32
33     for (int i = 0; i < MAX_STORES; i++) {
34         if (i == STORE_HOME)
35             continue;
36         if (i == STORE_MUSEUM)
37             continue;
38
39         for (int j = 0; j < town_info[player_ptr->town_num].store[i].stock_num; j++) {
40             object_type *j_ptr = &town_info[player_ptr->town_num].store[i].stock[j];
41             if (o_ptr->k_idx == j_ptr->k_idx)
42                 return TRUE;
43         }
44     }
45
46     return FALSE;
47 }