}
if (leave_worth) {
- if (object_value(o_ptr) > 0) {
+ if (o_ptr->object_value() > 0) {
return false;
}
}
}
}
- if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0) {
+ if (IS_FLG(FLG_WORTHLESS) && (o_ptr->object_value() > 0)) {
return false;
}
static bool check_destory_item(PlayerType *player_ptr, destroy_type *destroy_ptr)
{
- if (destroy_ptr->force || (!confirm_destroy && (object_value(destroy_ptr->o_ptr) <= 0))) {
+ if (destroy_ptr->force || (!confirm_destroy && (destroy_ptr->o_ptr->object_value() <= 0))) {
return true;
}
continue;
}
- o_value = object_value(o_ptr);
+ o_value = o_ptr->object_value();
for (j = 0; j < INVEN_PACK; j++) {
if (object_sort_comp(player_ptr, o_ptr, o_value, &player_ptr->inventory_list[j])) {
break;
i = j;
if (i < INVEN_PACK) {
- int32_t o_value = object_value(o_ptr);
+ const auto o_value = o_ptr->object_value();
for (j = 0; j < INVEN_PACK; j++) {
if (object_sort_comp(player_ptr, o_ptr, o_value, &player_ptr->inventory_list[j])) {
break;
return;
}
- auto value = object_value(o_ptr);
+ const auto value = o_ptr->object_value();
int slot;
for (slot = 0; slot < store_ptr->stock_num; slot++) {
if (object_sort_comp(player_ptr, o_ptr, value, &store_ptr->stock[slot])) {
#include "util/bit-flags-calculator.h"
/*!
- * @brief 未鑑定なベースアイテムの基本価格を返す /
- * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
- * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトの未鑑定価格
- */
-static PRICE object_value_base(const ObjectType *o_ptr)
-{
- if (o_ptr->is_aware()) {
- return k_info[o_ptr->k_idx].cost;
- }
-
- switch (o_ptr->tval) {
- case ItemKindType::FOOD:
- return 5;
- case ItemKindType::POTION:
- return 20;
- case ItemKindType::SCROLL:
- return 20;
- case ItemKindType::STAFF:
- return 70;
- case ItemKindType::WAND:
- return 50;
- case ItemKindType::ROD:
- return 90;
- case ItemKindType::RING:
- return 45;
- case ItemKindType::AMULET:
- return 45;
- case ItemKindType::FIGURINE: {
- auto figure_r_idx = i2enum<MonsterRaceId>(o_ptr->pval);
- DEPTH level = r_info[figure_r_idx].level;
- if (level < 20) {
- return level * 50L;
- } else if (level < 30) {
- return 1000 + (level - 20) * 150;
- } else if (level < 40) {
- return 2500 + (level - 30) * 350;
- } else if (level < 50) {
- return 6000 + (level - 40) * 800;
- } else {
- return 14000 + (level - 50) * 2000;
- }
- }
- case ItemKindType::CAPTURE: {
- auto capture_r_idx = i2enum<MonsterRaceId>(o_ptr->pval);
- if (!MonsterRace(capture_r_idx).is_valid()) {
- return 1000;
- } else {
- return (r_info[capture_r_idx].level) * 50 + 1000;
- }
- }
-
- default:
- break;
- }
-
- return 0;
-}
-
-/*!
- * @brief オブジェクト価格算出のメインルーチン /
- * Return the price of an item including plusses (and charges)
- * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトの判明している現価格
- * @details
- * This function returns the "value" of the given item (qty one)\n
- *\n
- * Never notice "unknown" bonuses or properties, including "curses",\n
- * since that would give the player information he did not have.\n
- *\n
- * Note that discounted items stay discounted forever, even if\n
- * the discount is "forgotten" by the player via memory loss.\n
- */
-PRICE object_value(const ObjectType *o_ptr)
-{
- PRICE value;
-
- if (o_ptr->is_known()) {
- if (o_ptr->is_broken()) {
- return 0;
- }
- if (o_ptr->is_cursed()) {
- return 0;
- }
-
- value = object_value_real(o_ptr);
- } else {
- if ((o_ptr->ident & (IDENT_SENSE)) && o_ptr->is_broken()) {
- return 0;
- }
- if ((o_ptr->ident & (IDENT_SENSE)) && o_ptr->is_cursed()) {
- return 0;
- }
-
- value = object_value_base(o_ptr);
- }
-
- if (o_ptr->discount) {
- value -= (value * o_ptr->discount / 100L);
- }
-
- return value;
-}
-
-/*!
* @brief オブジェクトの真の価格を算出する /
* Return the value of the flags the object has...
* @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
class ObjectType;
class PlayerType;
-PRICE object_value(const ObjectType *o_ptr);
PRICE object_value_real(const ObjectType *o_ptr);
o_ptr->number = old_number;
if (!force) {
- if (confirm_destroy || (object_value(o_ptr) > 0)) {
+ if (confirm_destroy || (o_ptr->object_value() > 0)) {
char out_val[MAX_NLEN + 40];
sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
if (!get_check(out_val)) {
}
}
- PRICE value = object_value(o_ptr);
+ const auto value = o_ptr->object_value();
int slot;
for (slot = 0; slot < st_ptr->stock_num; slot++) {
if (object_sort_comp(player_ptr, o_ptr, value, &st_ptr->stock[slot])) {
continue;
}
- int32_t o_value = object_value(o_ptr);
+ const auto o_value = o_ptr->object_value();
int j;
for (j = 0; j < st_ptr->stock_num; j++) {
if (object_sort_comp(player_ptr, o_ptr, o_value, &st_ptr->stock[j])) {
*/
PRICE price_item(PlayerType *player_ptr, ObjectType *o_ptr, int greed, bool flip, StoreSaleType store_num)
{
- PRICE price = object_value(o_ptr);
+ auto price = o_ptr->object_value();
if (price <= 0) {
return 0L;
}
auto res = prompt_to_sell(player_ptr, q_ptr, store_num);
placed = res.has_value();
if (placed) {
- PRICE price = res.value();
+ const auto price = res.value();
store_owner_says_comment(player_ptr, store_num);
sound(SOUND_SELL);
player_ptr->au += price;
store_prt_gold(player_ptr);
- PRICE dummy = object_value(q_ptr) * q_ptr->number;
+ const auto dummy = q_ptr->object_value() * q_ptr->number;
identify_item(player_ptr, o_ptr);
q_ptr = &forge;
q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
}
- PRICE value = object_value(q_ptr) * q_ptr->number;
+ const auto value = q_ptr->object_value() * q_ptr->number;
describe_flavor(player_ptr, o_name, q_ptr, 0);
msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, static_cast<long>(price));
return false;
}
- return object_value(o_ptr) > 0;
+ return o_ptr->object_value() > 0;
}
static int mass_lite_produce(const PRICE cost)
*/
void mass_produce(PlayerType *, ObjectType *o_ptr, StoreSaleType store_num)
{
- const PRICE cost = object_value(o_ptr);
+ const auto cost = o_ptr->object_value();
int size = switch_mass_production(o_ptr, cost, store_num);
auto discount = decide_discount_rate(cost);
if (o_ptr->art_name) {
*/
int store_carry(ObjectType *o_ptr)
{
- PRICE value = object_value(o_ptr);
+ const auto value = o_ptr->object_value();
if (value <= 0) {
return -1;
}
}
}
- PRICE j_value = object_value(j_ptr);
+ auto j_value = j_ptr->object_value();
if (value > j_value) {
break;
}
}
if (store_num == StoreSaleType::BLACK) {
- if (black_market_crap(player_ptr, q_ptr) || (object_value(q_ptr) < 10)) {
+ if (black_market_crap(player_ptr, q_ptr) || (q_ptr->object_value() < 10)) {
continue;
}
} else {
- if (object_value(q_ptr) <= 0) {
+ if (q_ptr->object_value() <= 0) {
continue;
}
}
#include "object-enchant/trc-types.h"
#include "object-enchant/trg-types.h"
#include "object/object-flags.h"
+#include "object/object-value.h"
#include "object/tval-types.h"
#include "smith/object-smith.h"
#include "sv-definition/sv-armor-types.h"
const auto flavor = base_item.flavor;
return flavor ? k_info[flavor].x_char : base_item.x_char;
}
+
+/*!
+ * @brief オブジェクト価格算出のメインルーチン
+ * @return オブジェクトの判明している現価格
+ */
+int ObjectType::object_value() const
+{
+ PRICE value;
+ if (this->is_known()) {
+ if (this->is_broken()) {
+ return 0;
+ }
+ if (this->is_cursed()) {
+ return 0;
+ }
+
+ value = object_value_real(this);
+ } else {
+ if ((this->ident & (IDENT_SENSE)) && this->is_broken()) {
+ return 0;
+ }
+ if ((this->ident & (IDENT_SENSE)) && this->is_cursed()) {
+ return 0;
+ }
+
+ value = this->object_value_base();
+ }
+
+ if (this->discount) {
+ value -= (value * this->discount / 100L);
+ }
+
+ return value;
+}
+
+/*!
+ * @brief 未鑑定なベースアイテムの基本価格を返す
+ * @return オブジェクトの未鑑定価格
+ */
+int ObjectType::object_value_base() const
+{
+ if (this->is_aware()) {
+ return k_info[this->k_idx].cost;
+ }
+
+ switch (this->tval) {
+ case ItemKindType::FOOD:
+ return 5;
+ case ItemKindType::POTION:
+ return 20;
+ case ItemKindType::SCROLL:
+ return 20;
+ case ItemKindType::STAFF:
+ return 70;
+ case ItemKindType::WAND:
+ return 50;
+ case ItemKindType::ROD:
+ return 90;
+ case ItemKindType::RING:
+ return 45;
+ case ItemKindType::AMULET:
+ return 45;
+ case ItemKindType::FIGURINE: {
+ auto figure_r_idx = i2enum<MonsterRaceId>(this->pval);
+ DEPTH level = r_info[figure_r_idx].level;
+ if (level < 20) {
+ return level * 50L;
+ } else if (level < 30) {
+ return 1000 + (level - 20) * 150;
+ } else if (level < 40) {
+ return 2500 + (level - 30) * 350;
+ } else if (level < 50) {
+ return 6000 + (level - 40) * 800;
+ } else {
+ return 14000 + (level - 50) * 2000;
+ }
+ }
+ case ItemKindType::CAPTURE: {
+ auto capture_r_idx = i2enum<MonsterRaceId>(this->pval);
+ if (!MonsterRace(capture_r_idx).is_valid()) {
+ return 1000;
+ } else {
+ return (r_info[capture_r_idx].level) * 50 + 1000;
+ }
+ }
+
+ default:
+ break;
+ }
+
+ return 0;
+}
bool can_pile(const ObjectType *j_ptr) const;
TERM_COLOR get_color() const;
char get_symbol() const;
+ int object_value() const;
+
+private:
+ int object_value_base() const;
};
break;
}
- return o_value > object_value(j_ptr);
+ return o_value > j_ptr->object_value();
}
q_ptr->to_h = 0;
q_ptr->to_d = 0;
*lev = k_info[q_ptr->k_idx].level;
- *val = object_value(q_ptr);
+ *val = q_ptr->object_value();
if (!buf || !dam || !chance || !wgt) {
return;
}