OSDN Git Service

[Refactor] #40561 Separated bias_warrior_*() from random_plus()
authorHourier <hourier@users.sourceforge.jp>
Wed, 15 Jul 2020 11:29:51 +0000 (20:29 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 15 Jul 2020 11:29:51 +0000 (20:29 +0900)
src/artifact/random-art-pval-investor.c

index 3d02ae9..1004b78 100644 (file)
 #include "system/object-type-definition.h"
 #include "util/bit-flags-calculator.h"
 
+static bool bias_warrior_strength(object_type *o_ptr)
+{
+    if ((have_flag(o_ptr->art_flags, TR_STR)))
+        return FALSE;
+
+    add_flag(o_ptr->art_flags, TR_STR);
+    return one_in_(2);
+}
+
+static bool bias_warrior_constitution(object_type *o_ptr)
+{
+    if ((have_flag(o_ptr->art_flags, TR_CON)))
+        return FALSE;
+
+    add_flag(o_ptr->art_flags, TR_CON);
+    return one_in_(2);
+}
+
+static bool bias_warrior_dexterity(object_type *o_ptr)
+{
+    if ((have_flag(o_ptr->art_flags, TR_DEX)))
+        return FALSE;
+
+    add_flag(o_ptr->art_flags, TR_DEX);
+    return one_in_(2);
+}
+
 /*!
  * @brief ランダムアーティファクト生成中、対象のオブジェクトにpval能力を付加する。/ Add one pval on generation of randam artifact.
  * @details 優先的に付加されるpvalがランダムアーティファクトバイアスに依存して存在する。
@@ -25,26 +52,10 @@ void random_plus(object_type *o_ptr)
     int this_type = object_is_weapon_ammo(o_ptr) ? 23 : 19;
     switch (o_ptr->artifact_bias) {
     case BIAS_WARRIOR:
-        if (!(have_flag(o_ptr->art_flags, TR_STR))) {
-            add_flag(o_ptr->art_flags, TR_STR);
-            if (one_in_(2))
-                return;
-        }
-
-        if (!(have_flag(o_ptr->art_flags, TR_CON))) {
-            add_flag(o_ptr->art_flags, TR_CON);
-            if (one_in_(2))
-                return;
-        }
-
-        if (!(have_flag(o_ptr->art_flags, TR_DEX))) {
-            add_flag(o_ptr->art_flags, TR_DEX);
-            if (one_in_(2))
-                return;
-        }
+        if (bias_warrior_strength(o_ptr) || bias_warrior_constitution(o_ptr) || bias_warrior_dexterity(o_ptr))
+            return;
 
         break;
-
     case BIAS_MAGE:
         if (!(have_flag(o_ptr->art_flags, TR_INT))) {
             add_flag(o_ptr->art_flags, TR_INT);