1 #include "store/pricing.h"
2 #include "market/gold-magnification-table.h"
3 #include "object/object-value.h"
4 #include "player/player-status-table.h"
5 #include "store/store-util.h"
6 #include "store/store.h"
9 * @brief 店舗価格を決定する. 無料にはならない /
10 * Determine the price of an item (qty one) in a store.
11 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
13 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
17 * This function takes into account the player's charisma, and the
18 * shop-keepers friendliness, and the shop-keeper's base greed, but
19 * never lets a shop-keeper lose money in a transaction.
20 * The "greed" value should exceed 100 when the player is "buying" the
21 * item, and should be less than 100 when the player is "selling" it.
22 * Hack -- the black market always charges twice as much as it should.
23 * Charisma adjustment runs from 80 to 130
24 * Racial adjustment runs from 95 to 130
25 * Since greed/charisma/racial adjustments are centered at 100, we need
26 * to adjust (by 200) to extract a usable multiplier. Note that the
27 * "greed" value is always something (?).
30 PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
32 PRICE price = object_value(player_ptr, o_ptr);
36 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
37 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
40 adjust = 100 + (300 - (greed + factor));
44 if (cur_store_num == STORE_BLACK)
47 price = (price * adjust + 50L) / 100L;
49 adjust = 100 + ((greed + factor) - 300);
53 if (cur_store_num == STORE_BLACK)
56 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
66 * @brief 店舗の割引対象外にするかどうかを判定 /
67 * Eliminate need to bargain if player has haggled well in the past
68 * @param minprice アイテムの最低販売価格
69 * @return 割引を禁止するならTRUEを返す。
71 bool noneedtobargain(PRICE minprice)
73 PRICE good = st_ptr->good_buy;
74 PRICE bad = st_ptr->bad_buy;
75 return (minprice < 10L) || (good == MAX_SHORT) || (good > ((3 * bad) + (5 + (minprice / 50))));