1 #include "object/object-value.h"
2 #include "monster-race/monster-race.h"
3 #include "object-enchant/object-curse.h"
4 #include "object-enchant/object-ego.h"
5 #include "object-enchant/special-object-flags.h"
6 #include "object-enchant/tr-types.h"
7 #include "object-hook/hook-checker.h"
8 #include "object-hook/hook-enchant.h"
9 #include "object/object-broken.h"
10 #include "object/object-flags.h"
11 #include "object/object-kind.h"
12 #include "object/object-value-calc.h"
13 #include "perception/object-perception.h"
14 #include "system/artifact-type-definition.h"
15 #include "util/bit-flags-calculator.h"
18 * @brief 未鑑定なベースアイテムの基本価格を返す /
19 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
20 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
21 * @return オブジェクトの未鑑定価格
23 static PRICE object_value_base(object_type *o_ptr)
25 if (object_is_aware(o_ptr))
26 return (k_info[o_ptr->k_idx].cost);
28 switch (o_ptr->tval) {
46 DEPTH level = r_info[o_ptr->pval].level;
50 return 1000 + (level - 20) * 150L;
52 return 2500 + (level - 30) * 350L;
54 return 6000 + (level - 40) * 800L;
56 return 14000 + (level - 50) * 2000L;
62 return ((r_info[o_ptr->pval].level) * 50L + 1000);
72 * @brief オブジェクト価格算出のメインルーチン /
73 * Return the price of an item including plusses (and charges)
74 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
75 * @return オブジェクトの判明している現価格
77 * This function returns the "value" of the given item (qty one)\n
79 * Never notice "unknown" bonuses or properties, including "curses",\n
80 * since that would give the player information he did not have.\n
82 * Note that discounted items stay discounted forever, even if\n
83 * the discount is "forgotten" by the player via memory loss.\n
85 PRICE object_value(player_type *player_ptr, object_type *o_ptr)
89 if (object_is_known(o_ptr)) {
90 if (object_is_broken(o_ptr))
92 if (object_is_cursed(o_ptr))
95 value = object_value_real(player_ptr, o_ptr);
97 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr))
99 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr))
102 value = object_value_base(o_ptr);
106 value -= (value * o_ptr->discount / 100L);
112 * @brief オブジェクトの真の価格を算出する /
113 * Return the value of the flags the object has...
114 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
117 * Return the "real" price of a "known" item, not including discounts\n
119 * Wand and staffs get cost for each charge\n
121 * Armor is worth an extra 100 gold per bonus point to armor class.\n
123 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
125 * Missiles are only worth 5 gold per bonus point, since they\n
126 * usually appear in groups of 20, and we want the player to get\n
127 * the same amount of cash for any "equivalent" item. Note that\n
128 * missiles never have any of the "pval" flags, and in fact, they\n
129 * only have a few of the available flags, primarily of the "slay"\n
130 * and "brand" and "ignore" variety.\n
132 * Armor with a negative armor bonus is worthless.\n
133 * Weapons with negative hit+damage bonuses are worthless.\n
135 * Every wearable item with a "pval" bonus is worth extra (see below).\n
137 PRICE object_value_real(player_type *player_ptr, object_type *o_ptr)
139 BIT_FLAGS flgs[TR_FLAG_SIZE];
140 object_kind *k_ptr = &k_info[o_ptr->k_idx];
142 if (!k_info[o_ptr->k_idx].cost)
145 PRICE value = k_info[o_ptr->k_idx].cost;
146 object_flags(player_ptr, o_ptr, flgs);
147 if (object_is_fixed_artifact(o_ptr)) {
148 artifact_type *a_ptr = &a_info[o_ptr->name1];
153 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
155 } else if (object_is_ego(o_ptr)) {
156 ego_item_type *e_ptr = &e_info[o_ptr->name2];
160 value += e_ptr->cost;
161 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
164 for (int i = 0; i < TR_FLAG_SIZE; i++)
165 if (o_ptr->art_flags[i])
169 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
172 /* Analyze pval bonus for normal object */
173 switch (o_ptr->tval) {
199 if (has_flag(flgs, TR_STR))
200 value += (o_ptr->pval * 200L);
201 if (has_flag(flgs, TR_INT))
202 value += (o_ptr->pval * 200L);
203 if (has_flag(flgs, TR_WIS))
204 value += (o_ptr->pval * 200L);
205 if (has_flag(flgs, TR_DEX))
206 value += (o_ptr->pval * 200L);
207 if (has_flag(flgs, TR_CON))
208 value += (o_ptr->pval * 200L);
209 if (has_flag(flgs, TR_CHR))
210 value += (o_ptr->pval * 200L);
211 if (has_flag(flgs, TR_MAGIC_MASTERY))
212 value += (o_ptr->pval * 100);
213 if (has_flag(flgs, TR_STEALTH))
214 value += (o_ptr->pval * 100L);
215 if (has_flag(flgs, TR_SEARCH))
216 value += (o_ptr->pval * 100L);
217 if (has_flag(flgs, TR_INFRA))
218 value += (o_ptr->pval * 50L);
219 if (has_flag(flgs, TR_TUNNEL))
220 value += (o_ptr->pval * 50L);
221 if (has_flag(flgs, TR_BLOWS))
222 value += (o_ptr->pval * 5000L);
223 if (has_flag(flgs, TR_SPEED))
224 value += (o_ptr->pval * 10000L);
231 switch (o_ptr->tval) {
233 /* Pay extra for charges, depending on standard number of
234 * charges. Handle new-style wands correctly. -LM-
236 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
240 /* Pay extra for charges, depending on standard number of
243 value += (value * o_ptr->pval / (k_ptr->pval * 2));
248 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0)
251 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
262 case TV_DRAG_ARMOR: {
266 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
274 if (o_ptr->to_h + o_ptr->to_d < 0)
277 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
278 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
279 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
285 if (o_ptr->to_h + o_ptr->to_d < 0)
288 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
289 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
290 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
294 DEPTH level = r_info[o_ptr->pval].level;
298 value = 1000 + (level - 20) * 150L;
300 value = 2500 + (level - 30) * 350L;
302 value = 6000 + (level - 40) * 800L;
304 value = 14000 + (level - 50) * 2000L;
311 value = ((r_info[o_ptr->pval].level) * 50L + 1000);