OSDN Git Service

[Refactor] #1469 Separated gain_exp_skilled() from gain_exp_from_hex()
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Sun, 5 Sep 2021 15:13:47 +0000 (00:13 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Tue, 7 Sep 2021 09:08:32 +0000 (18:08 +0900)
src/spell-realm/spells-hex.cpp
src/spell-realm/spells-hex.h

index e50b560..d649b35 100644 (file)
@@ -230,18 +230,11 @@ void RealmHex::gain_exp_from_hex()
             continue;
         }
 
-        auto *floor_ptr = this->caster_ptr->current_floor_ptr;
-        if (this->caster_ptr->spell_exp[spell] < SPELL_EXP_SKILLED) {
-            auto gain_condition = one_in_(2);
-            gain_condition &= floor_ptr->dun_level > 4;
-            gain_condition &= (floor_ptr->dun_level + 10) > this->caster_ptr->lev;
-            if (gain_condition) {
-                this->caster_ptr->spell_exp[spell]++;
-            }
-
+        if (this->gain_exp_skilled(spell)) {
             continue;
         }
 
+        auto *floor_ptr = this->caster_ptr->current_floor_ptr;
         if (this->caster_ptr->spell_exp[spell] < SPELL_EXP_EXPERT) {
             auto gain_condition = one_in_(5);
             gain_condition &= (floor_ptr->dun_level + 5) > this->caster_ptr->lev;
@@ -264,6 +257,23 @@ void RealmHex::gain_exp_from_hex()
     }
 }
 
+bool RealmHex::gain_exp_skilled(const int spell)
+{
+    if (this->caster_ptr->spell_exp[spell] >= SPELL_EXP_SKILLED) {
+        return false;
+    }
+
+    auto *floor_ptr = this->caster_ptr->current_floor_ptr;
+    auto gain_condition = one_in_(2);
+    gain_condition &= floor_ptr->dun_level > 4;
+    gain_condition &= (floor_ptr->dun_level + 10) > this->caster_ptr->lev;
+    if (gain_condition) {
+        this->caster_ptr->spell_exp[spell]++;
+    }
+    
+    return true;
+}
+
 /*!
  * @brief プレイヤーの呪術詠唱枠がすでに最大かどうかを返す
  * @return すでに全枠を利用しているならTRUEを返す
index b7c4fa0..a16a06f 100644 (file)
@@ -20,6 +20,7 @@ private:
     bool check_restart();
     int calc_need_mana();
     void gain_exp_from_hex();
+    bool gain_exp_skilled(const int spell);
 };
 
 bool stop_hex_spell_all(player_type *caster_ptr);