OSDN Git Service

[Refactor] #968 Separated make_choice_lower() from get_mind_power()
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Mon, 17 May 2021 13:55:58 +0000 (22:55 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Wed, 19 May 2021 09:02:47 +0000 (18:02 +0900)
src/mind/mind-power-getter.cpp
src/mind/mind-power-getter.h

index c9b54c9..0b6c7bc 100644 (file)
@@ -82,10 +82,11 @@ bool MindPowerGetter::get_mind_power(SPELL_IDX *sn, bool only_browse)
 
     this->choice = (always_show_list || use_menu) ? ESCAPE : 1;
     while (!this->flag) {
-        if (this->choice == ESCAPE)
+        if (this->choice == ESCAPE) {
             this->choice = ' ';
-        else if (!get_com(out_val, &this->choice, true))
+        } else if (!get_com(out_val, &this->choice, true)) {
             break;
+        }
 
         if (!interpret_mind_key_input(only_browse)) {
             return false;
@@ -95,14 +96,7 @@ bool MindPowerGetter::get_mind_power(SPELL_IDX *sn, bool only_browse)
             continue;
         }
 
-        if (!use_menu) {
-            this->ask = (bool)isupper(this->choice);
-            if (this->ask)
-                this->choice = (char)tolower(this->choice);
-
-            this->index = (islower(this->choice) ? A2I(this->choice) : -1);
-        }
-
+        make_choice_lower();
         if ((this->index < 0) || (this->index >= this->num)) {
             bell();
             continue;
@@ -245,9 +239,9 @@ bool MindPowerGetter::display_minds_chance(const bool only_browse)
         prt("", y + this->index + 1, x);
         return true;
     }
-    
+
     if (only_browse) {
-        return true;    
+        return true;
     }
 
     this->redraw = false;
@@ -366,3 +360,17 @@ void MindPowerGetter::add_ki_chance()
         this->chance += 5;
     }
 }
+
+void MindPowerGetter::make_choice_lower()
+{
+    if (use_menu) {
+        return;
+    }
+
+    this->ask = (bool)isupper(this->choice);
+    if (this->ask) {
+        this->choice = (char)tolower(this->choice);
+    }
+
+    this->index = (islower(this->choice) ? A2I(this->choice) : -1);
+}
index 441e7bf..807a76c 100644 (file)
@@ -37,4 +37,5 @@ private:
     void calculate_mind_chance(bool *has_weapon); // 配列.
     void calculate_ki_chance(bool *has_weapon); // 配列.
     void add_ki_chance();
+    void make_choice_lower();
 };