OSDN Git Service

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