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);
69 * @brief オブジェクト価格算出のメインルーチン /
70 * Return the price of an item including plusses (and charges)
71 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
72 * @return オブジェクトの判明している現価格
74 * This function returns the "value" of the given item (qty one)\n
76 * Never notice "unknown" bonuses or properties, including "curses",\n
77 * since that would give the player information he did not have.\n
79 * Note that discounted items stay discounted forever, even if\n
80 * the discount is "forgotten" by the player via memory loss.\n
82 PRICE object_value(player_type *player_ptr, object_type *o_ptr)
86 if (object_is_known(o_ptr)) {
87 if (object_is_broken(o_ptr))
89 if (object_is_cursed(o_ptr))
92 value = object_value_real(player_ptr, o_ptr);
94 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr))
96 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr))
99 value = object_value_base(o_ptr);
103 value -= (value * o_ptr->discount / 100L);
109 * @brief オブジェクトの真の価格を算出する /
110 * Return the value of the flags the object has...
111 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
114 * Return the "real" price of a "known" item, not including discounts\n
116 * Wand and staffs get cost for each charge\n
118 * Armor is worth an extra 100 gold per bonus point to armor class.\n
120 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
122 * Missiles are only worth 5 gold per bonus point, since they\n
123 * usually appear in groups of 20, and we want the player to get\n
124 * the same amount of cash for any "equivalent" item. Note that\n
125 * missiles never have any of the "pval" flags, and in fact, they\n
126 * only have a few of the available flags, primarily of the "slay"\n
127 * and "brand" and "ignore" variety.\n
129 * Armor with a negative armor bonus is worthless.\n
130 * Weapons with negative hit+damage bonuses are worthless.\n
132 * Every wearable item with a "pval" bonus is worth extra (see below).\n
134 PRICE object_value_real(player_type *player_ptr, object_type *o_ptr)
136 BIT_FLAGS flgs[TR_FLAG_SIZE];
137 object_kind *k_ptr = &k_info[o_ptr->k_idx];
139 if (!k_info[o_ptr->k_idx].cost)
142 PRICE value = k_info[o_ptr->k_idx].cost;
143 object_flags(player_ptr, o_ptr, flgs);
144 if (object_is_fixed_artifact(o_ptr)) {
145 artifact_type *a_ptr = &a_info[o_ptr->name1];
150 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
152 } else if (object_is_ego(o_ptr)) {
153 ego_item_type *e_ptr = &e_info[o_ptr->name2];
157 value += e_ptr->cost;
158 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
161 for (int i = 0; i < TR_FLAG_SIZE; i++)
162 if (o_ptr->art_flags[i])
166 value += flag_cost(player_ptr, o_ptr, o_ptr->pval);
169 /* Analyze pval bonus for normal object */
170 switch (o_ptr->tval) {
196 if (have_flag(flgs, TR_STR))
197 value += (o_ptr->pval * 200L);
198 if (have_flag(flgs, TR_INT))
199 value += (o_ptr->pval * 200L);
200 if (have_flag(flgs, TR_WIS))
201 value += (o_ptr->pval * 200L);
202 if (have_flag(flgs, TR_DEX))
203 value += (o_ptr->pval * 200L);
204 if (have_flag(flgs, TR_CON))
205 value += (o_ptr->pval * 200L);
206 if (have_flag(flgs, TR_CHR))
207 value += (o_ptr->pval * 200L);
208 if (have_flag(flgs, TR_MAGIC_MASTERY))
209 value += (o_ptr->pval * 100);
210 if (have_flag(flgs, TR_STEALTH))
211 value += (o_ptr->pval * 100L);
212 if (have_flag(flgs, TR_SEARCH))
213 value += (o_ptr->pval * 100L);
214 if (have_flag(flgs, TR_INFRA))
215 value += (o_ptr->pval * 50L);
216 if (have_flag(flgs, TR_TUNNEL))
217 value += (o_ptr->pval * 50L);
218 if (have_flag(flgs, TR_BLOWS))
219 value += (o_ptr->pval * 5000L);
220 if (have_flag(flgs, TR_SPEED))
221 value += (o_ptr->pval * 10000L);
225 switch (o_ptr->tval) {
227 /* Pay extra for charges, depending on standard number of
228 * charges. Handle new-style wands correctly. -LM-
230 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
234 /* Pay extra for charges, depending on standard number of
237 value += (value * o_ptr->pval / (k_ptr->pval * 2));
242 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0)
245 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
256 case TV_DRAG_ARMOR: {
260 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
268 if (o_ptr->to_h + o_ptr->to_d < 0)
271 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
272 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
273 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
279 if (o_ptr->to_h + o_ptr->to_d < 0)
282 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
283 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
284 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
288 DEPTH level = r_info[o_ptr->pval].level;
292 value = 1000 + (level - 20) * 150L;
294 value = 2500 + (level - 30) * 350L;
296 value = 6000 + (level - 40) * 800L;
298 value = 14000 + (level - 50) * 2000L;
305 value = ((r_info[o_ptr->pval].level) * 50L + 1000);