OSDN Git Service

[Refactor] #2353 小文字しか入力範囲のないコマンドで大文字を入力した際の確認機能、及び大文字から小文字への自動変換機能を削除した
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 6 Mar 2022 07:06:43 +0000 (16:06 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 6 Mar 2022 07:09:22 +0000 (16:09 +0900)
src/cmd-action/cmd-hissatsu.cpp
src/cmd-action/cmd-mane.cpp
src/cmd-action/cmd-pet.cpp
src/cmd-action/cmd-spell.cpp
src/cmd-item/cmd-magiceat.cpp
src/mind/mind-elementalist.cpp
src/mind/mind-power-getter.cpp
src/mind/mind-power-getter.h
src/mind/mind-sniper.cpp
src/mind/mind-weaponsmith.cpp

index dda4480..faf9e6c 100644 (file)
@@ -69,7 +69,6 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
     POSITION y = 1;
     POSITION x = 15;
     PLAYER_LEVEL plev = player_ptr->lev;
-    int ask = true;
     char choice;
     char out_val[160];
     SPELL_IDX sentaku[32];
@@ -118,6 +117,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
             break;
         }
 
+        auto should_redraw_cursor = true;
         if (use_menu && choice != ' ') {
             switch (choice) {
             case '0': {
@@ -186,13 +186,13 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
             case '\r':
             case '\n': {
                 i = menu_line - 1;
-                ask = false;
+                should_redraw_cursor = false;
                 break;
             }
             }
         }
         /* Request redraw */
-        if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) {
+        if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && should_redraw_cursor)) {
             /* Show the list */
             if (!redraw || use_menu) {
                 char psi_desc[80];
@@ -262,19 +262,8 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
 
         if (!use_menu) {
             if (isalpha(choice)) {
-                /* Note verify */
-                ask = (isupper(choice));
-
-                /* Lowercase */
-                if (ask) {
-                    choice = (char)tolower(choice);
-                }
-
-                /* Extract request */
-                i = (islower(choice) ? A2I(choice) : -1);
+                i = A2I(choice);
             } else {
-                ask = false; /* Can't uppercase digits */
-
                 i = choice - '0' + 26;
             }
         }
@@ -287,19 +276,6 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
 
         j = sentaku[i];
 
-        /* Verify it */
-        if (ask) {
-            char tmp_val[160];
-
-            /* Prompt */
-            (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(player_ptr, REALM_HISSATSU, j, SpellProcessType::NAME));
-
-            /* Belay that order */
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         /* Stop the loop */
         flag = true;
     }
index 3e8df97..c1ba7ef 100644 (file)
@@ -147,7 +147,6 @@ static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
     PERCENTAGE minfail = 0;
     PLAYER_LEVEL plev = player_ptr->lev;
     PERCENTAGE chance = 0;
-    int ask;
     char choice;
     char out_val[MAX_MONSTER_NAME];
     char comment[80];
@@ -253,16 +252,8 @@ static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
             continue;
         }
 
-        /* Note verify */
-        ask = isupper(choice);
-
-        /* Lowercase */
-        if (ask) {
-            choice = (char)tolower(choice);
-        }
-
         /* Extract request */
-        i = (islower(choice) ? A2I(choice) : -1);
+        i = A2I(choice);
 
         /* Totally Illegal */
         if ((i < 0) || (i >= num)) {
@@ -273,19 +264,6 @@ static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
         /* Save the spell index */
         spell = monster_powers.at(mane_data->mane_list[i].spell);
 
-        /* Verify it */
-        if (ask) {
-            char tmp_val[160];
-
-            /* Prompt */
-            (void)strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), spell.name);
-
-            /* Belay that order */
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         /* Stop the loop */
         flag = true;
     }
index 3da8b31..ab1d13c 100644 (file)
@@ -556,14 +556,13 @@ void do_cmd_pet(PlayerType *player_ptr)
 
         /* Get a command from the user */
         while (!flag) {
-            int ask = true;
-
             if (choice == ESCAPE) {
                 choice = ' ';
             } else if (!get_com(prompt.c_str(), &choice, true)) {
                 break;
             }
 
+            auto should_redraw_cursor = true;
             if (use_menu && (choice != ' ')) {
                 switch (choice) {
                 case '0':
@@ -599,7 +598,7 @@ void do_cmd_pet(PlayerType *player_ptr)
                 case '\r':
                 case '\n':
                     i = menu_line - 1;
-                    ask = false;
+                    should_redraw_cursor = false;
                     break;
                 }
                 if (menu_line > num) {
@@ -608,7 +607,7 @@ void do_cmd_pet(PlayerType *player_ptr)
             }
 
             /* Request redraw */
-            if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) {
+            if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && should_redraw_cursor)) {
                 /* Show the list */
                 if (!redraw || use_menu) {
                     byte y = 1, x = 0;
@@ -649,16 +648,7 @@ void do_cmd_pet(PlayerType *player_ptr)
             }
 
             if (!use_menu) {
-                /* Note verify */
-                ask = (isupper(choice));
-
-                /* Lowercase */
-                if (ask) {
-                    choice = (char)tolower(choice);
-                }
-
-                /* Extract request */
-                i = (islower(choice) ? A2I(choice) : -1);
+                i = A2I(choice);
             }
 
             /* Totally Illegal */
@@ -667,13 +657,6 @@ void do_cmd_pet(PlayerType *player_ptr)
                 continue;
             }
 
-            /* Verify it */
-            if (ask) {
-                if (!get_check(format(_("%sを使いますか? ", "Use %s? "), power_desc[i].c_str()))) {
-                    continue;
-                }
-            }
-
             /* Stop the loop */
             flag = true;
         }
index d6ceeb1..78ed1e6 100644 (file)
@@ -54,7 +54,6 @@
 #include "spell/spells-describer.h"
 #include "spell/spells-execution.h"
 #include "spell/spells-summon.h"
-#include "spell/technic-info-table.h"
 #include "status/action-setter.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
@@ -307,12 +306,9 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
     int i;
     SPELL_IDX spell = -1;
     int num = 0;
-    int ask = true;
-    MANA_POINT need_mana;
     SPELL_IDX spells[64];
     bool flag, redraw, okay;
     char choice;
-    const magic_type *s_ptr;
     char out_val[160];
     concptr p;
     COMMAND_CODE code;
@@ -398,6 +394,7 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
             break;
         }
 
+        auto should_redraw_cursor = true;
         if (use_menu && choice != ' ') {
             switch (choice) {
             case '0': {
@@ -424,7 +421,7 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
             case '\r':
             case '\n': {
                 i = menu_line - 1;
-                ask = false;
+                should_redraw_cursor = false;
                 break;
             }
             }
@@ -433,7 +430,7 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
             }
             /* Display a list of spells */
             print_spells(player_ptr, menu_line, spells, num, 1, 15, use_realm);
-            if (ask) {
+            if (should_redraw_cursor) {
                 continue;
             }
         } else {
@@ -463,16 +460,7 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
                 continue;
             }
 
-            /* Note verify */
-            ask = (isupper(choice));
-
-            /* Lowercase */
-            if (ask) {
-                choice = (char)tolower(choice);
-            }
-
-            /* Extract request */
-            i = (islower(choice) ? A2I(choice) : -1);
+            i = A2I(choice);
         }
 
         /* Totally Illegal */
@@ -496,41 +484,6 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
             continue;
         }
 
-        /* Verify it */
-        if (ask) {
-            char tmp_val[160];
-
-            /* Access the spell */
-            if (!is_magic(use_realm)) {
-                s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
-            } else {
-                s_ptr = &mp_ptr->info[use_realm - 1][spell];
-            }
-
-            /* Extract mana consumption rate */
-            if (use_realm == REALM_HISSATSU) {
-                need_mana = s_ptr->smana;
-            } else {
-                need_mana = mod_need_mana(player_ptr, s_ptr->smana, spell, use_realm);
-            }
-
-            /* Prompt */
-#ifdef JP
-            jverb(prompt, jverb_buf, JVERB_AND);
-            /* 英日切り替え機能に対応 */
-            (void)strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ", exe_spell(player_ptr, use_realm, spell, SpellProcessType::NAME), need_mana,
-                spell_chance(player_ptr, spell, use_realm), jverb_buf);
-#else
-            (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ", prompt, exe_spell(player_ptr, use_realm, spell, SpellProcessType::NAME), need_mana,
-                spell_chance(player_ptr, spell, use_realm));
-#endif
-
-            /* Belay that order */
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         /* Stop the loop */
         flag = true;
     }
index 72365b3..50a6e19 100644 (file)
@@ -142,7 +142,6 @@ static std::optional<std::tuple<ItemKindType, OBJECT_SUBTYPE_VALUE>> select_magi
     char choice;
     bool flag, request_list;
     auto tval = ItemKindType::NONE;
-    int ask = true;
     OBJECT_SUBTYPE_VALUE i = 0;
     char out_val[160];
 
@@ -361,6 +360,7 @@ static std::optional<std::tuple<ItemKindType, OBJECT_SUBTYPE_VALUE>> select_magi
             break;
         }
 
+        auto should_redraw_cursor = true;
         if (use_menu && choice != ' ') {
             switch (choice) {
             case '0': {
@@ -428,14 +428,14 @@ static std::optional<std::tuple<ItemKindType, OBJECT_SUBTYPE_VALUE>> select_magi
             case 'X':
             case '\r': {
                 i = menu_line - 1;
-                ask = false;
+                should_redraw_cursor = false;
                 break;
             }
             }
         }
 
         /* Request redraw */
-        if (use_menu && ask) {
+        if (use_menu && should_redraw_cursor) {
             continue;
         }
 
@@ -457,19 +457,8 @@ static std::optional<std::tuple<ItemKindType, OBJECT_SUBTYPE_VALUE>> select_magi
 
         if (!use_menu) {
             if (isalpha(choice)) {
-                /* Note verify */
-                ask = (isupper(choice));
-
-                /* Lowercase */
-                if (ask) {
-                    choice = (char)tolower(choice);
-                }
-
-                /* Extract request */
-                i = (islower(choice) ? A2I(choice) : -1);
+                i = A2I(choice);
             } else {
-                ask = false; /* Can't uppercase digits */
-
                 i = choice - '0' + 26;
             }
         }
@@ -481,35 +470,17 @@ static std::optional<std::tuple<ItemKindType, OBJECT_SUBTYPE_VALUE>> select_magi
         }
 
         if (!only_browse) {
-            /* Verify it */
-            if (ask) {
-                char tmp_val[160];
-
-                /* Prompt */
-                (void)strnfmt(tmp_val, 78, _("%sを使いますか? ", "Use %s? "), k_info[lookup_kind(tval, i)].name.c_str());
-
-                /* Belay that order */
-                if (!get_check(tmp_val)) {
-                    continue;
-                }
-            }
             auto &item = item_group[i];
             if (tval == ItemKindType::ROD) {
                 if (item.charge > k_info[lookup_kind(tval, i)].pval * (item.count - 1) * EATER_ROD_CHARGE) {
                     msg_print(_("その魔法はまだ充填している最中だ。", "The magic is still charging."));
                     msg_print(nullptr);
-                    if (use_menu) {
-                        ask = true;
-                    }
                     continue;
                 }
             } else {
                 if (item.charge < EATER_CHARGE) {
                     msg_print(_("その魔法は使用回数が切れている。", "The magic has no charges left."));
                     msg_print(nullptr);
-                    if (use_menu) {
-                        ask = true;
-                    }
                     continue;
                 }
             }
index 94a079e..76e634f 100644 (file)
@@ -698,7 +698,6 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
     TERM_LEN y = 1;
     TERM_LEN x = 10;
     PLAYER_LEVEL plev = player_ptr->lev;
-    int ask = true;
     char choice;
     char out_val[160];
     char comment[80];
@@ -746,6 +745,7 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
             break;
         }
 
+        auto should_redraw_cursor = true;
         if (use_menu && choice != ' ') {
             switch (choice) {
             case '0':
@@ -768,7 +768,7 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
             case '\r':
             case '\n':
                 i = menu_line - 1;
-                ask = false;
+                should_redraw_cursor = false;
                 break;
             }
 
@@ -778,7 +778,7 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
         }
 
         int spell_max = enum2i(ElementSpells::MAX);
-        if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) {
+        if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && should_redraw_cursor)) {
             if (!redraw || use_menu) {
                 char desc[80];
                 char name[80];
@@ -828,12 +828,7 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
         }
 
         if (!use_menu) {
-            ask = isupper(choice);
-            if (ask) {
-                choice = (char)tolower(choice);
-            }
-
-            i = (islower(choice) ? A2I(choice) : -1);
+            i = A2I(choice);
         }
 
         if ((i < 0) || (i >= num)) {
@@ -841,18 +836,6 @@ bool get_element_power(PlayerType *player_ptr, SPELL_IDX *sn, bool only_browse)
             continue;
         }
 
-        if (ask) {
-            char name[80];
-            char tmp_val[160];
-            elem = get_elemental_elem(player_ptr, i);
-            spell = get_elemental_info(player_ptr, i);
-            (void)sprintf(name, spell.name, get_element_name(player_ptr->element, elem));
-            (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), name);
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         flag = true;
     }
 
index 9a3b11e..c1e15f6 100644 (file)
@@ -163,14 +163,6 @@ bool MindPowerGetter::decide_mind_choice(char *out_val, const bool only_browse)
         }
 
         this->spell = &mind_ptr->info[this->index];
-        if (this->ask) {
-            char tmp_val[160];
-            (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), this->spell->name);
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         this->flag = true;
     }
 
@@ -183,6 +175,7 @@ bool MindPowerGetter::interpret_mind_key_input(const bool only_browse)
         return true;
     }
 
+    this->should_redraw_cursor = true;
     switch (this->choice) {
     case '0':
         if (!only_browse) {
@@ -205,7 +198,7 @@ bool MindPowerGetter::interpret_mind_key_input(const bool only_browse)
     case '\r':
     case '\n':
         this->index = this->menu_line - 1;
-        this->ask = false;
+        this->should_redraw_cursor = false;
         break;
     default:
         break;
@@ -220,7 +213,7 @@ bool MindPowerGetter::interpret_mind_key_input(const bool only_browse)
 
 bool MindPowerGetter::display_minds_chance(const bool only_browse)
 {
-    if ((this->choice != ' ') && (this->choice != '*') && (this->choice != '?') && (!use_menu || !this->ask)) {
+    if ((this->choice != ' ') && (this->choice != '*') && (this->choice != '?') && (!use_menu || !this->should_redraw_cursor)) {
         return false;
     }
 
@@ -364,10 +357,5 @@ void MindPowerGetter::make_choice_lower()
         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);
+    this->index = A2I(this->choice);
 }
index e24b11d..1e1fafa 100644 (file)
@@ -18,7 +18,7 @@ private:
     int num = 0;
     TERM_LEN y = 1;
     TERM_LEN x = 10;
-    bool ask = true;
+    bool should_redraw_cursor = true;
     char choice = 0;
     concptr mind_description = "";
     const mind_type *spell = nullptr;
index 8838d3a..a849a94 100644 (file)
@@ -249,7 +249,6 @@ static int get_snipe_power(PlayerType *player_ptr, COMMAND_CODE *sn, bool only_b
     TERM_LEN y = 1;
     TERM_LEN x = 20;
     PLAYER_LEVEL plev = player_ptr->lev;
-    int ask;
     char choice;
     char out_val[160];
     concptr p = _("射撃術", "power");
@@ -359,16 +358,7 @@ static int get_snipe_power(PlayerType *player_ptr, COMMAND_CODE *sn, bool only_b
             continue;
         }
 
-        /* Note verify */
-        ask = isupper(choice);
-
-        /* Lowercase */
-        if (ask) {
-            choice = (char)tolower(choice);
-        }
-
-        /* Extract request */
-        i = (islower(choice) ? A2I(choice) : -1);
+        i = A2I(choice);
 
         /* Totally Illegal */
         if ((i < 0) || (i > num) || (!only_browse && (snipe_powers[i].mana_cost > sniper_data->concent))) {
@@ -379,19 +369,6 @@ static int get_snipe_power(PlayerType *player_ptr, COMMAND_CODE *sn, bool only_b
         /* Save the spell index */
         spell = snipe_powers[i];
 
-        /* Verify it */
-        if (ask) {
-            char tmp_val[160];
-
-            /* Prompt */
-            (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), snipe_powers[i].name);
-
-            /* Belay that order */
-            if (!get_check(tmp_val)) {
-                continue;
-            }
-        }
-
         /* Stop the loop */
         flag = true;
     }
index 029012c..a51fcce 100644 (file)
@@ -309,7 +309,6 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
     char choice;
     concptr q, s;
     ObjectType *o_ptr;
-    int ask = true;
     char out_val[160];
     GAME_TEXT o_name[MAX_NLEN];
     int menu_line = (use_menu ? 1 : 0);
@@ -346,6 +345,7 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
                 break;
             }
 
+            auto should_redraw_cursor = true;
             if (use_menu) {
                 switch (choice) {
                 case '0': {
@@ -388,7 +388,7 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
                 case '\r':
                 case '\n': {
                     i = menu_line - 1;
-                    ask = false;
+                    should_redraw_cursor = false;
                     break;
                 }
                 }
@@ -399,7 +399,7 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
             }
 
             /* Request redraw */
-            if ((choice == ' ') || (use_menu && ask)) {
+            if ((choice == ' ') || (use_menu && should_redraw_cursor)) {
                 if (!use_menu) {
                     page++;
                 }
@@ -412,16 +412,7 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
             }
 
             if (!use_menu) {
-                /* Note verify */
-                ask = (isupper(choice));
-
-                /* Lowercase */
-                if (ask) {
-                    choice = (char)tolower(choice);
-                }
-
-                /* Extract request */
-                i = (islower(choice) ? A2I(choice) : -1);
+                i = A2I(choice);
             }
 
             effect_idx = page * effect_num_per_page + i;
@@ -431,19 +422,6 @@ static void add_essence(PlayerType *player_ptr, SmithCategoryType mode)
                 continue;
             }
 
-            /* Verify it */
-            if (ask) {
-                char tmp_val[160];
-
-                /* Prompt */
-                (void)strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the ability of %s? "), Smith::get_effect_name(smith_effect_list[i]));
-
-                /* Belay that order */
-                if (!get_check(tmp_val)) {
-                    continue;
-                }
-            }
-
             /* Stop the loop */
             flag = true;
         }