Debian Codegraph @

include/shop.h

raw symbols SCIP
1 #ifndef _SHOP_H
2 #define _SHOP_H
3
4 /**
5 * Adjust the value of the given item based on the player's skills. This
6 * function should only be used when calculating "you reckon" prices.
7 *
8 * @param obj item in question. Must not be NULL.
9 * @param who player trying to judge the value of the item. Must not be NULL.
10 * @return approximate value of obj.
11 */
12 uint64_t price_approx(const object *obj, object *who);
13
14 /**
15 * Determine the base (intrinsic) value of an item. This should not include
16 * adjustments such as bargaining, charisma, or shop specialization.
17 *
18 * @param obj item in question.
19 * @return base price.
20 */
21 uint64_t price_base(const object *obj);
22
23 /**
24 * Adjust the value of an item to be bought based on the player's bargaining skill and
25 * charisma. This should only be used if the player is in a shop.
26 *
27 * @param obj item in question. Must not be NULL.
28 * @param who player trying to judge the value of the item. Must not be NULL.
29 * @return value of obj.
30 */
31 uint64_t shop_price_buy(const object *obj, object *who);
32
33 /**
34 * Adjust the value of an item to be sold based on the player's bargaining skill and
35 * charisma. This should only be used if the player is in a shop.
36 *
37 * @param obj item in question. Must not be NULL.
38 * @param who player trying to judge the value of the item. Must not be NULL.
39 * @return value of obj.
40 */
41 uint64_t shop_price_sell(const object *obj, object *who);
42
43 /**
44 * Converts a price to number of coins.
45 *
46 * While cost is 64 bit, the number of any coin is still really
47 * limited to 32 bit (size of nrof field). If it turns out players
48 * have so much money that they have more than 2 billion platinum
49 * coins, there are certainly issues - the easiest fix at that
50 * time is to add a higher denomination (mithril piece with
51 * 10,000 silver or something)
52 *
53 * @param cost
54 * value to transform to currency.
55 * @param largest_coin
56 * maximum coin to give the price into, should be between 0 and NUM_COINS - 1.
57 * @return
58 * converted value the caller is responsible to free.
59 */
60 char* cost_string_from_value(uint64_t cost, int largest_coin);
61 char *cost_str(uint64_t cost);
62
63 /**
64 * Return a textual cost approximation in a newly-allocated string.
65 *
66 * @param obj item to query the price of, must not be NULL.
67 * @param who player asking for the price, must not be NULL.
68 * @return converted value the caller is responsible to free.
69 */
70 char *cost_approx_str(const object *obj, object *who);
71
72 /**
73 * Determine the amount of money the given object contains, including what is
74 * inside containers.
75 *
76 * @param op Player or container object
77 * @return Total amount of money inside
78 */
79 uint64_t query_money(const object *op);
80
81 int pay_for_amount(uint64_t to_pay, object *pl);
82 int can_pay(object *pl);
83
84 /**
85 * Pay for each unpaid item carried by a player, including those inside
86 * containers. It is a good idea to call can_pay() before using this function,
87 * because items are paid for here in no particular order.
88 *
89 * @param pl Player making purchase
90 * @param op Container to examine, usually the same player object
91 * @retval 0 Player still has unpaid items
92 * @retval 1 Player paid for all unpaid items
93 */
94 int shop_pay_unpaid(object *pl, object *op);
95
96 int pay_for_item(object *op, object *pl);
97 void sell_item(object *op, object *pl);
98
99 /**
100 * Return the approval ratio for a shop for a given player. This is based on
101 * both the race of the shopkeeper and the player.
102 *
103 * @param map Map with a shop
104 * @param player Player in question
105 * @return Approval ratio between 0 and 1
106 */
107 double shop_approval(const mapstruct *map, const object *player);
108
109 /**
110 * Check if an object is in a shop.
111 */
112 bool shop_contains(object *ob);
113
114 /**
115 * Give the player a description of the shop on their current map. This is
116 * used for the bargaining skill.
117 *
118 * @param op Non-null player to describe the shop to
119 * @return Zero if the object is not a player, 1 otherwise
120 */
121 int shop_describe(const object *op);
122
123 #endif