OSDN Git Service

[Refactor] #40275 Separated building-enchanter.c/h from building.c
authorHourier <hourier@users.sourceforge.jp>
Wed, 20 May 2020 12:48:06 +0000 (21:48 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 20 May 2020 12:48:06 +0000 (21:48 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/market/building-enchanter.c [new file with mode: 0644]
src/market/building-enchanter.h [new file with mode: 0644]
src/market/building.c

index 311c6c2..6b1d51c 100644 (file)
     <ClCompile Include="..\..\src\market\building-craft-armor.c" />\r
     <ClCompile Include="..\..\src\market\building-craft-fix.c" />\r
     <ClCompile Include="..\..\src\market\building-craft-weapon.c" />\r
+    <ClCompile Include="..\..\src\market\building-enchanter.c" />\r
     <ClCompile Include="..\..\src\market\building-monster.c" />\r
     <ClCompile Include="..\..\src\market\building-quest.c" />\r
     <ClCompile Include="..\..\src\market\building-recharger.c" />\r
     <ClInclude Include="..\..\src\market\building-craft-armor.h" />\r
     <ClInclude Include="..\..\src\market\building-craft-fix.h" />\r
     <ClInclude Include="..\..\src\market\building-craft-weapon.h" />\r
+    <ClInclude Include="..\..\src\market\building-enchanter.h" />\r
     <ClInclude Include="..\..\src\market\building-monster.h" />\r
     <ClInclude Include="..\..\src\market\building-quest.h" />\r
     <ClInclude Include="..\..\src\market\building-recharger.h" />\r
index 8676b91..07b671a 100644 (file)
     <ClCompile Include="..\..\src\market\building-monster.c">
       <Filter>market</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\market\building-enchanter.c">
+      <Filter>market</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-activate.h">
     <ClInclude Include="..\..\src\market\building-monster.h">
       <Filter>market</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\market\building-enchanter.h">
+      <Filter>market</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 8ab1ece..f6cc283 100644 (file)
@@ -79,6 +79,7 @@ hengband_SOURCES = \
        market/building-craft-armor.c market/building-craft-armor.h \
        market/building-craft-fix.c market/building-craft-fix.h \
        market/building-monster.c market/building-monster.h \
+       market/building-enchanter.c market/building-enchanter.h \
        \
        view/display-characteristic.c view/display-characteristic.h \
        view/display-fruit.c view/display-fruit.h \
diff --git a/src/market/building-enchanter.c b/src/market/building-enchanter.c
new file mode 100644 (file)
index 0000000..ddb783b
--- /dev/null
@@ -0,0 +1,81 @@
+#include "system/angband.h"
+#include "market/building-enchanter.h"
+#include "object/object-flavor.h"
+#include "spell/spells-object.h"
+#include "market/building-util.h"
+#include "inventory/player-inventory.h"
+#include "player/player-effects.h"
+
+/*!
+ * @brief アイテムの強化を行う。 / Enchant item
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param cost 1回毎の費用
+ * @param to_hit 命中をアップさせる量
+ * @param to_dam ダメージをアップさせる量
+ * @param to_ac ACをアップさせる量
+ * @return 実際に行ったらTRUE
+ */
+bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac, OBJECT_TYPE_VALUE item_tester_tval)
+{
+    clear_bldg(4, 18);
+    int maxenchant = (player_ptr->lev / 5);
+    prt(format(_("現在のあなたの技量だと、+%d まで改良できます。", "  Based on your skill, we can improve up to +%d."), maxenchant), 5, 0);
+    prt(format(_(" 改良の料金は一個につき$%d です。", "  The price for the service is %d gold per item."), cost), 7, 0);
+
+    concptr q = _("どのアイテムを改良しますか?", "Improve which item? ");
+    concptr s = _("改良できるものがありません。", "You have nothing to improve.");
+
+    OBJECT_IDX item;
+    object_type *o_ptr;
+    o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | IGNORE_BOTHHAND_SLOT), item_tester_tval);
+    if (!o_ptr)
+        return FALSE;
+
+    char tmp_str[MAX_NLEN];
+    if (player_ptr->au < (cost * o_ptr->number)) {
+        object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
+        msg_format(_("%sを改良するだけのゴールドがありません!", "You do not have the gold to improve %s!"), tmp_str);
+        return FALSE;
+    }
+
+    bool okay = FALSE;
+    for (int i = 0; i < to_hit; i++) {
+        if ((o_ptr->to_h < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOHIT | ENCH_FORCE))) {
+            okay = TRUE;
+            break;
+        }
+    }
+
+    for (int i = 0; i < to_dam; i++) {
+        if ((o_ptr->to_d < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TODAM | ENCH_FORCE))) {
+            okay = TRUE;
+            break;
+        }
+    }
+
+    for (int i = 0; i < to_ac; i++) {
+        if ((o_ptr->to_a < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOAC | ENCH_FORCE))) {
+            okay = TRUE;
+            break;
+        }
+    }
+
+    if (!okay) {
+        if (flush_failure)
+            flush();
+        msg_print(_("改良に失敗した。", "The improvement failed."));
+        return FALSE;
+    }
+
+    object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
+#ifdef JP
+    msg_format("$%dで%sに改良しました。", cost * o_ptr->number, tmp_str);
+#else
+    msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
+#endif
+
+    player_ptr->au -= (cost * o_ptr->number);
+    if (item >= INVEN_RARM)
+        calc_android_exp(player_ptr);
+    return TRUE;
+}
diff --git a/src/market/building-enchanter.h b/src/market/building-enchanter.h
new file mode 100644 (file)
index 0000000..38c3a55
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac, OBJECT_TYPE_VALUE item_tester_tval);
index 875bccd..94962c9 100644 (file)
@@ -1,5 +1,4 @@
 /*!
- * @file building.c
  * @brief 町の施設処理 / Building commands
  * @date 2013/12/23
  * @author
 #include "mutation/mutation.h"
 #include "cmd-spell.h"
 #include "spell/spells3.h"
-#include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "io/files-util.h"
 #include "player/player-status.h"
-#include "player/player-effects.h"
 #include "player/player-personalities-table.h"
-#include "inventory/player-inventory.h"
 #include "core/scores.h"
 #include "monster/monster-race.h"
 #include "market/poker.h"
 #include "market/building-util.h"
 #include "market/play-gamble.h"
-#include "view/display-fruit.h"
 #include "market/arena.h"
 #include "market/bounty.h"
 #include "market/building-recharger.h"
@@ -55,6 +50,7 @@
 #include "market/building-craft-armor.h"
 #include "market/building-craft-fix.h"
 #include "market/building-monster.h"
+#include "market/building-enchanter.h"
 
 building_type building[MAX_BLDG];
 
@@ -79,86 +75,6 @@ static void town_history(player_type *player_ptr)
        screen_load();
 }
 
-
-/*!
- * @brief アイテムの強化を行う。 / Enchant item
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param cost 1回毎の費用
- * @param to_hit 命中をアップさせる量
- * @param to_dam ダメージをアップさせる量
- * @param to_ac ACをアップさせる量
- * @return 実際に行ったらTRUE
- */
-static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac, OBJECT_TYPE_VALUE item_tester_tval)
-{
-       clear_bldg(4, 18);
-       int maxenchant = (player_ptr->lev / 5);
-       prt(format(_("現在のあなたの技量だと、+%d まで改良できます。", "  Based on your skill, we can improve up to +%d."), maxenchant), 5, 0);
-       prt(format(_(" 改良の料金は一個につき$%d です。", "  The price for the service is %d gold per item."), cost), 7, 0);
-
-       concptr q = _("どのアイテムを改良しますか?", "Improve which item? ");
-       concptr s = _("改良できるものがありません。", "You have nothing to improve.");
-
-       OBJECT_IDX item;
-       object_type *o_ptr;
-       o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | IGNORE_BOTHHAND_SLOT), item_tester_tval);
-       if (!o_ptr) return FALSE;
-
-       char tmp_str[MAX_NLEN];
-       if (player_ptr->au < (cost * o_ptr->number))
-       {
-               object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
-               msg_format(_("%sを改良するだけのゴールドがありません!", "You do not have the gold to improve %s!"), tmp_str);
-               return FALSE;
-       }
-
-       bool okay = FALSE;
-       for (int i = 0; i < to_hit; i++)
-       {
-               if ((o_ptr->to_h < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOHIT | ENCH_FORCE)))
-               {
-                       okay = TRUE;
-                       break;
-               }
-       }
-
-       for (int i = 0; i < to_dam; i++)
-       {
-               if ((o_ptr->to_d < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TODAM | ENCH_FORCE)))
-               {
-                       okay = TRUE;
-                       break;
-               }
-       }
-
-       for (int i = 0; i < to_ac; i++)
-       {
-               if ((o_ptr->to_a < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOAC | ENCH_FORCE)))
-               {
-                       okay = TRUE;
-                       break;
-               }
-       }
-
-       if (!okay)
-       {
-               if (flush_failure) flush();
-               msg_print(_("改良に失敗した。", "The improvement failed."));
-               return FALSE;
-       }
-
-       object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
-#ifdef JP
-       msg_format("$%dで%sに改良しました。", cost * o_ptr->number, tmp_str);
-#else
-       msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
-#endif
-
-       player_ptr->au -= (cost * o_ptr->number);
-       if (item >= INVEN_RARM) calc_android_exp(player_ptr);
-       return TRUE;
-}
-
 /*!
  * @brief 施設の処理実行メインルーチン / Execute a building command
  * @param player_ptr プレーヤーへの参照ポインタ