OSDN Git Service

[Refactor] #40561 Separated random_art_bias_decrease_mana() from random_plus()
authorHourier <hourier@users.sourceforge.jp>
Wed, 15 Jul 2020 12:09:08 +0000 (21:09 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 15 Jul 2020 12:09:08 +0000 (21:09 +0900)
src/artifact/random-art-pval-investor.c
src/object-enchant/tr-types.h

index 238662d..113be3d 100644 (file)
@@ -6,8 +6,8 @@
 
 #include "artifact/random-art-pval-investor.h"
 #include "artifact/random-art-bias-types.h"
-#include "object-hook/hook-weapon.h"
 #include "object-enchant/tr-types.h"
+#include "object-hook/hook-weapon.h"
 #include "sv-definition/sv-armor-types.h"
 #include "system/object-type-definition.h"
 #include "util/bit-flags-calculator.h"
@@ -122,6 +122,16 @@ static bool switch_random_art_bias(object_type *o_ptr)
     }
 }
 
+static bool random_art_bias_decrease_mana(object_type *o_ptr)
+{
+    if (((o_ptr->artifact_bias != BIAS_MAGE) && (o_ptr->artifact_bias != BIAS_PRIESTLY)) || (o_ptr->tval != TV_SOFT_ARMOR) || (o_ptr->sval != SV_ROBE)
+        || have_flag(o_ptr->art_flags, TR_DEC_MANA) || !one_in_(3))
+        return FALSE;
+
+    add_flag(o_ptr->art_flags, TR_DEC_MANA);
+    return one_in_(2);
+}
+
 /*!
  * @brief ランダムアーティファクト生成中、対象のオブジェクトにpval能力を付加する。/ Add one pval on generation of randam artifact.
  * @details 優先的に付加されるpvalがランダムアーティファクトバイアスに依存して存在する。
@@ -132,18 +142,10 @@ static bool switch_random_art_bias(object_type *o_ptr)
  */
 void random_plus(object_type *o_ptr)
 {
-    int this_type = object_is_weapon_ammo(o_ptr) ? 23 : 19;
-    if (switch_random_art_bias(o_ptr))
+    if (switch_random_art_bias(o_ptr) || random_art_bias_decrease_mana(o_ptr))
         return;
 
-    if ((o_ptr->artifact_bias == BIAS_MAGE || o_ptr->artifact_bias == BIAS_PRIESTLY) && (o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE)) {
-        if (!(have_flag(o_ptr->art_flags, TR_DEC_MANA)) && one_in_(3)) {
-            add_flag(o_ptr->art_flags, TR_DEC_MANA);
-            if (one_in_(2))
-                return;
-        }
-    }
-
+    int this_type = object_is_weapon_ammo(o_ptr) ? 23 : 19;
     switch (randint1(this_type)) {
     case 1:
     case 2:
@@ -152,6 +154,7 @@ void random_plus(object_type *o_ptr)
             o_ptr->artifact_bias = BIAS_STR;
         else if (!o_ptr->artifact_bias && one_in_(7))
             o_ptr->artifact_bias = BIAS_WARRIOR;
+
         break;
     case 3:
     case 4:
@@ -160,6 +163,7 @@ void random_plus(object_type *o_ptr)
             o_ptr->artifact_bias = BIAS_INT;
         else if (!o_ptr->artifact_bias && one_in_(7))
             o_ptr->artifact_bias = BIAS_MAGE;
+
         break;
     case 5:
     case 6:
@@ -168,6 +172,7 @@ void random_plus(object_type *o_ptr)
             o_ptr->artifact_bias = BIAS_WIS;
         else if (!o_ptr->artifact_bias && one_in_(7))
             o_ptr->artifact_bias = BIAS_PRIESTLY;
+
         break;
     case 7:
     case 8:
@@ -176,6 +181,7 @@ void random_plus(object_type *o_ptr)
             o_ptr->artifact_bias = BIAS_DEX;
         else if (!o_ptr->artifact_bias && one_in_(7))
             o_ptr->artifact_bias = BIAS_ROGUE;
+
         break;
     case 9:
     case 10:
@@ -184,24 +190,28 @@ void random_plus(object_type *o_ptr)
             o_ptr->artifact_bias = BIAS_CON;
         else if (!o_ptr->artifact_bias && one_in_(9))
             o_ptr->artifact_bias = BIAS_RANGER;
+
         break;
     case 11:
     case 12:
         add_flag(o_ptr->art_flags, TR_CHR);
         if (!o_ptr->artifact_bias && !one_in_(13))
             o_ptr->artifact_bias = BIAS_CHR;
+
         break;
     case 13:
     case 14:
         add_flag(o_ptr->art_flags, TR_STEALTH);
         if (!o_ptr->artifact_bias && one_in_(3))
             o_ptr->artifact_bias = BIAS_ROGUE;
+
         break;
     case 15:
     case 16:
         add_flag(o_ptr->art_flags, TR_SEARCH);
         if (!o_ptr->artifact_bias && one_in_(9))
             o_ptr->artifact_bias = BIAS_RANGER;
+
         break;
     case 17:
     case 18:
@@ -211,6 +221,7 @@ void random_plus(object_type *o_ptr)
         add_flag(o_ptr->art_flags, TR_SPEED);
         if (!o_ptr->artifact_bias && one_in_(11))
             o_ptr->artifact_bias = BIAS_ROGUE;
+
         break;
     case 20:
     case 21:
@@ -218,14 +229,15 @@ void random_plus(object_type *o_ptr)
         break;
     case 22:
     case 23:
-        if (o_ptr->tval == TV_BOW)
+        if (o_ptr->tval == TV_BOW) {
             random_plus(o_ptr);
-        else {
-            add_flag(o_ptr->art_flags, TR_BLOWS);
-            if (!o_ptr->artifact_bias && one_in_(11))
-                o_ptr->artifact_bias = BIAS_WARRIOR;
+            break;
         }
 
+        add_flag(o_ptr->art_flags, TR_BLOWS);
+        if (!o_ptr->artifact_bias && one_in_(11))
+            o_ptr->artifact_bias = BIAS_WARRIOR;
+
         break;
     }
 }
index 7ffbbfa..7709b32 100644 (file)
@@ -76,7 +76,7 @@ typedef enum tr_type {
     TR_SH_COLD = 67, /* cold aura */
     TR_NO_TELE = 68, /* Anti-teleportation */
     TR_NO_MAGIC = 69, /* Anti-magic */
-    TR_DEC_MANA = 70, /* ??? */
+    TR_DEC_MANA = 70, /* 消費魔力減少 */
     TR_TY_CURSE = 71, /* The Ancient Curse */
     TR_WARNING = 72, /* Warning */
     TR_HIDE_TYPE = 73, /* Hide "pval" description */