OSDN Git Service

[Refactor] #40575 Separated mind-monk.c/h from racial-switcher.c
authorHourier <hourier@users.sourceforge.jp>
Thu, 6 Aug 2020 09:51:38 +0000 (18:51 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 6 Aug 2020 09:51:43 +0000 (18:51 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/floor/cave-generator.c
src/mind/mind-monk.c [new file with mode: 0644]
src/mind/mind-monk.h [new file with mode: 0644]
src/racial/racial-switcher.c

index 700de08..53a4254 100644 (file)
     <ClCompile Include="..\..\src\mind\mind-info.c" />\r
     <ClCompile Include="..\..\src\mind\mind-mage.c" />\r
     <ClCompile Include="..\..\src\mind\mind-magic-resistance.c" />\r
+    <ClCompile Include="..\..\src\mind\mind-monk.c" />\r
     <ClCompile Include="..\..\src\mind\mind-power-getter.c" />\r
     <ClCompile Include="..\..\src\mind\mind-weaponsmith.c" />\r
     <ClCompile Include="..\..\src\mspell\element-resistance-checker.c" />\r
     <ClInclude Include="..\..\src\mind\mind-info.h" />\r
     <ClInclude Include="..\..\src\mind\mind-mage.h" />\r
     <ClInclude Include="..\..\src\mind\mind-magic-resistance.h" />\r
+    <ClInclude Include="..\..\src\mind\mind-monk.h" />\r
     <ClInclude Include="..\..\src\mind\mind-numbers.h" />\r
     <ClInclude Include="..\..\src\mind\mind-power-getter.h" />\r
     <ClInclude Include="..\..\src\mind\mind-types.h" />\r
index 0fdb7e7..6ba09d8 100644 (file)
     <ClCompile Include="..\..\src\grid\feature-generator.c">
       <Filter>grid</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\mind\mind-monk.c">
+      <Filter>mind</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\grid\feature-generator.h">
       <Filter>grid</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\mind\mind-monk.h">
+      <Filter>mind</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index a14b405..23da8f5 100644 (file)
@@ -407,6 +407,7 @@ hengband_SOURCES = \
        mind/mind-magic-resistance.c mind/mind-magic-resistance.h \
        mind/mind-mindcrafter.c mind/mind-mindcrafter.h \
        mind/mind-mirror-master.c mind/mind-mirror-master.h \
+       mind/mind-monk.c mind/mind-monk.h \
        mind/mind-ninja.c mind/mind-ninja.h \
        mind/mind-numbers.h \
        mind/mind-power-getter.c mind/mind-power-getter.h \
index b85179f..cc4bf70 100644 (file)
@@ -293,7 +293,7 @@ static void decide_dungeon_data_allocation(player_type *player_ptr, dun_data_typ
             dd_ptr->alloc_monster_num);
 }
 
-static void allocate_dungeon_data(player_type *player_ptr, dun_data_type *dd_ptr, dungeon_type *d_ptr)
+static bool allocate_dungeon_data(player_type *player_ptr, dun_data_type *dd_ptr, dungeon_type *d_ptr)
 {
     dd_ptr->alloc_monster_num += randint1(8);
     for (dd_ptr->alloc_monster_num = dd_ptr->alloc_monster_num + dd_ptr->alloc_object_num; dd_ptr->alloc_monster_num > 0; dd_ptr->alloc_monster_num--)
@@ -311,10 +311,11 @@ static void allocate_dungeon_data(player_type *player_ptr, dun_data_type *dd_ptr
     alloc_object(player_ptr, ALLOC_SET_BOTH, ALLOC_TYP_OBJECT, randnor(DUN_AMT_ITEM, 3));
     alloc_object(player_ptr, ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3));
     floor_ptr->object_level = floor_ptr->base_level;
-    if (!alloc_guardian(player_ptr, TRUE)) {
-        *dd_ptr->why = _("ダンジョンの主配置に失敗", "Failed to place a dungeon guardian");
-        return FALSE;
-    }
+    if (alloc_guardian(player_ptr, TRUE))
+        return TRUE;
+
+    *dd_ptr->why = _("ダンジョンの主配置に失敗", "Failed to place a dungeon guardian");
+    return FALSE;
 }
 
 static void decide_grid_glowing(floor_type *floor_ptr, dun_data_type *dd_ptr, dungeon_type *d_ptr)
@@ -370,7 +371,9 @@ bool cave_gen(player_type *player_ptr, concptr *why)
         return FALSE;
 
     decide_dungeon_data_allocation(player_ptr, dd_ptr, d_ptr);
-    allocate_dungeon_data(player_ptr, dd_ptr, d_ptr);    
+    if (!allocate_dungeon_data(player_ptr, dd_ptr, d_ptr))
+        return FALSE;
+
     decide_grid_glowing(floor_ptr, dd_ptr, d_ptr);
     return TRUE;
 }
diff --git a/src/mind/mind-monk.c b/src/mind/mind-monk.c
new file mode 100644 (file)
index 0000000..795e39f
--- /dev/null
@@ -0,0 +1,82 @@
+#include "mind/mind-monk.h"
+#include "action/action-limited.h"
+#include "core/player-redraw-types.h"
+#include "core/player-update-types.h"
+#include "io/input-key-acceptor.h"
+#include "mind/stances-table.h"
+#include "player/attack-defense-types.h"
+#include "player/special-defense-types.h"
+#include "status/action-setter.h"
+#include "term/screen-processor.h"
+#include "util/int-char-converter.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief 修行僧の構え設定処理
+ * @return 構えを変化させたらTRUE、構え不能かキャンセルしたらFALSEを返す。
+ */
+bool choose_monk_stance(player_type *creature_ptr)
+{
+    char choice;
+    int new_kamae = 0;
+    int i;
+    char buf[80];
+
+    if (cmd_limit_confused(creature_ptr))
+        return FALSE;
+    screen_save();
+    prt(_(" a) 構えをとく", " a) No form"), 2, 20);
+
+    for (i = 0; i < MAX_KAMAE; i++) {
+        if (creature_ptr->lev >= monk_stances[i].min_level) {
+            sprintf(buf, " %c) %-12s  %s", I2A(i + 1), monk_stances[i].desc, monk_stances[i].info);
+            prt(buf, 3 + i, 20);
+        }
+    }
+
+    prt("", 1, 0);
+    prt(_("        どの構えをとりますか?", "        Choose Stance: "), 1, 14);
+
+    while (TRUE) {
+        choice = inkey();
+
+        if (choice == ESCAPE) {
+            screen_load();
+            return FALSE;
+        } else if ((choice == 'a') || (choice == 'A')) {
+            if (creature_ptr->action == ACTION_KAMAE) {
+                set_action(creature_ptr, ACTION_NONE);
+            } else
+                msg_print(_("もともと構えていない。", "You are not in a special stance."));
+            screen_load();
+            return TRUE;
+        } else if ((choice == 'b') || (choice == 'B')) {
+            new_kamae = 0;
+            break;
+        } else if (((choice == 'c') || (choice == 'C')) && (creature_ptr->lev > 29)) {
+            new_kamae = 1;
+            break;
+        } else if (((choice == 'd') || (choice == 'D')) && (creature_ptr->lev > 34)) {
+            new_kamae = 2;
+            break;
+        } else if (((choice == 'e') || (choice == 'E')) && (creature_ptr->lev > 39)) {
+            new_kamae = 3;
+            break;
+        }
+    }
+
+    set_action(creature_ptr, ACTION_KAMAE);
+    if (creature_ptr->special_defense & (KAMAE_GENBU << new_kamae)) {
+        msg_print(_("構え直した。", "You reassume a stance."));
+    } else {
+        creature_ptr->special_defense &= ~(KAMAE_MASK);
+        creature_ptr->update |= PU_BONUS;
+        creature_ptr->redraw |= PR_STATE;
+        msg_format(_("%sの構えをとった。", "You assume the %s stance."), monk_stances[new_kamae].desc);
+        creature_ptr->special_defense |= (KAMAE_GENBU << new_kamae);
+    }
+
+    creature_ptr->redraw |= PR_STATE;
+    screen_load();
+    return TRUE;
+}
diff --git a/src/mind/mind-monk.h b/src/mind/mind-monk.h
new file mode 100644 (file)
index 0000000..e30d007
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool choose_monk_stance(player_type *creature_ptr);
index 0f448e3..c6e6e02 100644 (file)
@@ -34,6 +34,7 @@
 #include "mind/mind-force-trainer.h"
 #include "mind/mind-mage.h"
 #include "mind/mind-mirror-master.h"
+#include "mind/mind-monk.h"
 #include "mind/mind-ninja.h"
 #include "mind/mind-samurai.h"
 #include "mind/mind-warrior-mage.h"
 #include "view/display-messages.h"
 
 /*!
- * @brief 修行僧の構え設定処理
- * @return 構えを変化させたらTRUE、構え不能かキャンセルしたらFALSEを返す。
- */
-static bool choose_kamae(player_type *creature_ptr)
-{
-    char choice;
-    int new_kamae = 0;
-    int i;
-    char buf[80];
-
-    if (cmd_limit_confused(creature_ptr))
-        return FALSE;
-    screen_save();
-    prt(_(" a) 構えをとく", " a) No form"), 2, 20);
-
-    for (i = 0; i < MAX_KAMAE; i++) {
-        if (creature_ptr->lev >= monk_stances[i].min_level) {
-            sprintf(buf, " %c) %-12s  %s", I2A(i + 1), monk_stances[i].desc, monk_stances[i].info);
-            prt(buf, 3 + i, 20);
-        }
-    }
-
-    prt("", 1, 0);
-    prt(_("        どの構えをとりますか?", "        Choose Stance: "), 1, 14);
-
-    while (TRUE) {
-        choice = inkey();
-
-        if (choice == ESCAPE) {
-            screen_load();
-            return FALSE;
-        } else if ((choice == 'a') || (choice == 'A')) {
-            if (creature_ptr->action == ACTION_KAMAE) {
-                set_action(creature_ptr, ACTION_NONE);
-            } else
-                msg_print(_("もともと構えていない。", "You are not in a special stance."));
-            screen_load();
-            return TRUE;
-        } else if ((choice == 'b') || (choice == 'B')) {
-            new_kamae = 0;
-            break;
-        } else if (((choice == 'c') || (choice == 'C')) && (creature_ptr->lev > 29)) {
-            new_kamae = 1;
-            break;
-        } else if (((choice == 'd') || (choice == 'D')) && (creature_ptr->lev > 34)) {
-            new_kamae = 2;
-            break;
-        } else if (((choice == 'e') || (choice == 'E')) && (creature_ptr->lev > 39)) {
-            new_kamae = 3;
-            break;
-        }
-    }
-    set_action(creature_ptr, ACTION_KAMAE);
-
-    if (creature_ptr->special_defense & (KAMAE_GENBU << new_kamae)) {
-        msg_print(_("構え直した。", "You reassume a stance."));
-    } else {
-        creature_ptr->special_defense &= ~(KAMAE_MASK);
-        creature_ptr->update |= (PU_BONUS);
-        creature_ptr->redraw |= (PR_STATE);
-        msg_format(_("%sの構えをとった。", "You assume the %s stance."), monk_stances[new_kamae].desc);
-        creature_ptr->special_defense |= (KAMAE_GENBU << new_kamae);
-    }
-    creature_ptr->redraw |= PR_STATE;
-    screen_load();
-    return TRUE;
-}
-
-/*!
  * @brief レイシャル・パワー情報の構造体定義
  */
 typedef struct power_desc_type {
@@ -367,7 +299,7 @@ static bool exe_racial_power(player_type *creature_ptr, s32b command)
             }
 
             if (command == -3) {
-                if (!choose_kamae(creature_ptr))
+                if (!choose_monk_stance(creature_ptr))
                     return FALSE;
                 creature_ptr->update |= (PU_BONUS);
             } else if (command == -4) {