OSDN Git Service

[Chore] UTF-8エンコーディングのファイルからBOMを削除
[hengbandforosx/hengbandosx.git] / src / object / object-value.cpp
index 9289636..e187d25 100644 (file)
@@ -1,11 +1,12 @@
-#include "object/object-value.h"
+#include "object/object-value.h"
 #include "monster-race/monster-race.h"
 #include "object/object-flags.h"
 #include "object/object-value-calc.h"
 #include "object/tval-types.h"
 #include "system/artifact-type-definition.h"
-#include "system/baseitem-info-definition.h"
-#include "system/monster-race-definition.h"
+#include "system/baseitem-info.h"
+#include "system/item-entity.h"
+#include "system/monster-race-info.h"
 #include "system/player-type-definition.h"
 
 /*!
  *\n
  * Every wearable item with a "pval" bonus is worth extra (see below).\n
  */
-PRICE object_value_real(const ObjectType *o_ptr)
+PRICE object_value_real(const ItemEntity *o_ptr)
 {
-    auto *k_ptr = &baseitems_info[o_ptr->k_idx];
+    const auto &baseitem = o_ptr->get_baseitem();
 
-    if (!baseitems_info[o_ptr->k_idx].cost) {
+    if (!baseitem.cost) {
         return 0;
     }
 
-    PRICE value = baseitems_info[o_ptr->k_idx].cost;
-    auto flgs = object_flags(o_ptr);
+    PRICE value = baseitem.cost;
+    auto flags = object_flags(o_ptr);
     if (o_ptr->is_fixed_artifact()) {
-        const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-        if (!a_ref.cost) {
+        const auto &artifact = o_ptr->get_fixed_artifact();
+        if (!artifact.cost) {
             return 0;
         }
 
-        value = a_ref.cost;
+        value = artifact.cost;
         value += flag_cost(o_ptr, o_ptr->pval);
         return value;
     } else if (o_ptr->is_ego()) {
-        const auto &e_ref = egos_info[o_ptr->ego_idx];
-        if (!e_ref.cost) {
+        const auto &ego = o_ptr->get_ego();
+        if (!ego.cost) {
             return 0;
         }
 
-        value += e_ref.cost;
+        value += ego.cost;
         value += flag_cost(o_ptr, o_ptr->pval);
     } else {
         if (o_ptr->art_flags.any()) {
@@ -68,7 +69,7 @@ PRICE object_value_real(const ObjectType *o_ptr)
     }
 
     /* Analyze pval bonus for normal object */
-    switch (o_ptr->tval) {
+    switch (o_ptr->bi_key.tval()) {
     case ItemKindType::SHOT:
     case ItemKindType::ARROW:
     case ItemKindType::BOLT:
@@ -96,43 +97,43 @@ PRICE object_value_real(const ObjectType *o_ptr)
             return 0;
         }
 
-        if (flgs.has(TR_STR)) {
+        if (flags.has(TR_STR)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_INT)) {
+        if (flags.has(TR_INT)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_WIS)) {
+        if (flags.has(TR_WIS)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_DEX)) {
+        if (flags.has(TR_DEX)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_CON)) {
+        if (flags.has(TR_CON)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_CHR)) {
+        if (flags.has(TR_CHR)) {
             value += (o_ptr->pval * 200L);
         }
-        if (flgs.has(TR_MAGIC_MASTERY)) {
+        if (flags.has(TR_MAGIC_MASTERY)) {
             value += (o_ptr->pval * 100);
         }
-        if (flgs.has(TR_STEALTH)) {
+        if (flags.has(TR_STEALTH)) {
             value += (o_ptr->pval * 100L);
         }
-        if (flgs.has(TR_SEARCH)) {
+        if (flags.has(TR_SEARCH)) {
             value += (o_ptr->pval * 100L);
         }
-        if (flgs.has(TR_INFRA)) {
+        if (flags.has(TR_INFRA)) {
             value += (o_ptr->pval * 50L);
         }
-        if (flgs.has(TR_TUNNEL)) {
+        if (flags.has(TR_TUNNEL)) {
             value += (o_ptr->pval * 50L);
         }
-        if (flgs.has(TR_BLOWS)) {
+        if (flags.has(TR_BLOWS)) {
             value += (o_ptr->pval * 5000L);
         }
-        if (flgs.has(TR_SPEED)) {
+        if (flags.has(TR_SPEED)) {
             value += (o_ptr->pval * 10000L);
         }
         break;
@@ -141,19 +142,19 @@ PRICE object_value_real(const ObjectType *o_ptr)
         break;
     }
 
-    switch (o_ptr->tval) {
+    switch (o_ptr->bi_key.tval()) {
     case ItemKindType::WAND: {
         /* Pay extra for charges, depending on standard number of
          * charges.  Handle new-style wands correctly. -LM-
          */
-        value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
+        value += (value * o_ptr->pval / o_ptr->number / (baseitem.pval * 2));
         break;
     }
     case ItemKindType::STAFF: {
         /* Pay extra for charges, depending on standard number of
          * charges.  -LM-
          */
-        value += (value * o_ptr->pval / (k_ptr->pval * 2));
+        value += (value * o_ptr->pval / (baseitem.pval * 2));
         break;
     }
     case ItemKindType::RING:
@@ -178,7 +179,7 @@ PRICE object_value_real(const ObjectType *o_ptr)
             return 0;
         }
 
-        value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
+        value += (((o_ptr->to_h - baseitem.to_h) + (o_ptr->to_d - baseitem.to_d)) * 200L + (o_ptr->to_a) * 100L);
         break;
     }
     case ItemKindType::BOW:
@@ -191,8 +192,8 @@ PRICE object_value_real(const ObjectType *o_ptr)
         }
 
         value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
-        value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
-        value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
+        value += (o_ptr->dd - baseitem.dd) * o_ptr->ds * 250L;
+        value += (o_ptr->ds - baseitem.ds) * o_ptr->dd * 250L;
         break;
     }
     case ItemKindType::SHOT:
@@ -203,8 +204,8 @@ PRICE object_value_real(const ObjectType *o_ptr)
         }
 
         value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
-        value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
-        value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
+        value += (o_ptr->dd - baseitem.dd) * o_ptr->ds * 5L;
+        value += (o_ptr->ds - baseitem.ds) * o_ptr->dd * 5L;
         break;
     }
     case ItemKindType::FIGURINE: {