OSDN Git Service

[Refactor] #40482 Separated spells-sorcery.c/h from spells3.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 03:56:44 +0000 (12:56 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 03:56:44 +0000 (12:56 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-item/cmd-activate.c
src/mutation/mutation.c
src/realm/realm-sorcery.c
src/spell-realm/spells-sorcery.c [new file with mode: 0644]
src/spell-realm/spells-sorcery.h [new file with mode: 0644]
src/spell/spells3.c
src/spell/spells3.h

index 1676d04..45bf6e5 100644 (file)
     <ClCompile Include="..\..\src\spell-kind\spells-fetcher.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-craft.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-demon.c" />\r
+    <ClCompile Include="..\..\src\spell-realm\spells-sorcery.c" />\r
     <ClCompile Include="..\..\src\status\bad-status-setter.c" />\r
     <ClCompile Include="..\..\src\status\base-status.c" />\r
     <ClCompile Include="..\..\src\status\body-improvement.c" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-fetcher.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-craft.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-demon.h" />\r
+    <ClInclude Include="..\..\src\spell-realm\spells-sorcery.h" />\r
     <ClInclude Include="..\..\src\status\bad-status-setter.h" />\r
     <ClInclude Include="..\..\src\status\base-status.h" />\r
     <ClInclude Include="..\..\src\status\body-improvement.h" />\r
index 02ef1f4..89167a2 100644 (file)
     <ClCompile Include="..\..\src\spell-kind\spells-fetcher.c">
       <Filter>spell-kind</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\spell-realm\spells-sorcery.c">
+      <Filter>spell-realm</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\spell-kind\spells-fetcher.h">
       <Filter>spell-kind</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\spell-realm\spells-sorcery.h">
+      <Filter>spell-realm</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 7c8e02f..d6a7751 100644 (file)
@@ -563,6 +563,7 @@ hengband_SOURCES = \
        spell-realm/spells-demon.c spell-realm/spells-demon.h \
        spell-realm/spells-hex.c spell-realm/spells-hex.h \
        spell-realm/spells-song.c spell-realm/spells-song.h \
+       spell-realm/spells-sorcery.c spell-realm/spells-sorcery.h \
        spell-realm/spells-trump.c spell-realm/spells-trump.h \
        \
        status/action-setter.c status/action-setter.h \
index 7c120f2..e43b86b 100644 (file)
@@ -72,6 +72,7 @@
 #include "spell-kind/spells-specific-bolt.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-realm/spells-hex.h"
+#include "spell-realm/spells-sorcery.h"
 #include "spell/process-effect.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
index 0f9d760..c5f4426 100644 (file)
@@ -56,6 +56,7 @@
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-realm/spells-sorcery.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
index fb70003..fcfee1b 100644 (file)
@@ -16,6 +16,7 @@
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-realm/spells-sorcery.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
diff --git a/src/spell-realm/spells-sorcery.c b/src/spell-realm/spells-sorcery.c
new file mode 100644 (file)
index 0000000..7fdc741
--- /dev/null
@@ -0,0 +1,82 @@
+#include "spell-realm/spells-sorcery.h"
+#include "core/asking-player.h"
+#include "floor/floor-object.h"
+#include "game-option/input-options.h"
+#include "inventory/inventory-object.h"
+#include "io/input-key-requester.h"
+#include "object-hook/hook-expendable.h"
+#include "object/item-use-flags.h"
+#include "object/object-flavor.h"
+#include "object/object-value.h"
+#include "system/object-type-definition.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief アイテムの価値に応じた錬金術処理 /
+ * Turns an object into gold, gain some of its value in a shop
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return 処理が実際に行われたらTRUEを返す
+ */
+bool alchemy(player_type *caster_ptr)
+{
+    bool force = FALSE;
+    if (command_arg > 0)
+        force = TRUE;
+
+    concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
+    concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
+    OBJECT_IDX item;
+    object_type *o_ptr;
+    o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
+    if (!o_ptr)
+        return FALSE;
+
+    int amt = 1;
+    if (o_ptr->number > 1) {
+        amt = get_quantity(NULL, o_ptr->number);
+        if (amt <= 0)
+            return FALSE;
+    }
+
+    ITEM_NUMBER old_number = o_ptr->number;
+    o_ptr->number = amt;
+    GAME_TEXT o_name[MAX_NLEN];
+    object_desc(caster_ptr, o_name, o_ptr, 0);
+    o_ptr->number = old_number;
+
+    if (!force) {
+        if (confirm_destroy || (object_value(caster_ptr, o_ptr) > 0)) {
+            char out_val[MAX_NLEN + 40];
+            sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
+            if (!get_check(out_val))
+                return FALSE;
+        }
+    }
+
+    if (!can_player_destroy_object(caster_ptr, o_ptr)) {
+        msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
+        return FALSE;
+    }
+
+    PRICE price = object_value_real(caster_ptr, o_ptr);
+    if (price <= 0) {
+        msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
+        vary_item(caster_ptr, item, -amt);
+        return TRUE;
+    }
+
+    price /= 3;
+
+    if (amt > 1)
+        price *= amt;
+
+    if (price > 30000)
+        price = 30000;
+    msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
+
+    caster_ptr->au += price;
+    caster_ptr->redraw |= PR_GOLD;
+    caster_ptr->window |= PW_PLAYER;
+    vary_item(caster_ptr, item, -amt);
+    return TRUE;
+}
diff --git a/src/spell-realm/spells-sorcery.h b/src/spell-realm/spells-sorcery.h
new file mode 100644 (file)
index 0000000..3f9353b
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool alchemy(player_type *caster_ptr);
index 8337d9c..3ef8050 100644 (file)
@@ -243,76 +243,6 @@ void reserve_alter_reality(player_type *caster_ptr)
 }
 
 /*!
- * @brief アイテムの価値に応じた錬金術処理 /
- * Turns an object into gold, gain some of its value in a shop
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @return 処理が実際に行われたらTRUEを返す
- */
-bool alchemy(player_type *caster_ptr)
-{
-    bool force = FALSE;
-    if (command_arg > 0)
-        force = TRUE;
-
-    concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
-    concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
-    OBJECT_IDX item;
-    object_type *o_ptr;
-    o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
-    if (!o_ptr)
-        return FALSE;
-
-    int amt = 1;
-    if (o_ptr->number > 1) {
-        amt = get_quantity(NULL, o_ptr->number);
-        if (amt <= 0)
-            return FALSE;
-    }
-
-    ITEM_NUMBER old_number = o_ptr->number;
-    o_ptr->number = amt;
-    GAME_TEXT o_name[MAX_NLEN];
-    object_desc(caster_ptr, o_name, o_ptr, 0);
-    o_ptr->number = old_number;
-
-    if (!force) {
-        if (confirm_destroy || (object_value(caster_ptr, o_ptr) > 0)) {
-            char out_val[MAX_NLEN + 40];
-            sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
-            if (!get_check(out_val))
-                return FALSE;
-        }
-    }
-
-    if (!can_player_destroy_object(caster_ptr, o_ptr)) {
-        msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
-        return FALSE;
-    }
-
-    PRICE price = object_value_real(caster_ptr, o_ptr);
-    if (price <= 0) {
-        msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
-        vary_item(caster_ptr, item, -amt);
-        return TRUE;
-    }
-
-    price /= 3;
-
-    if (amt > 1)
-        price *= amt;
-
-    if (price > 30000)
-        price = 30000;
-    msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
-
-    caster_ptr->au += price;
-    caster_ptr->redraw |= PR_GOLD;
-    caster_ptr->window |= PW_PLAYER;
-    vary_item(caster_ptr, item, -amt);
-    return TRUE;
-}
-
-/*!
  * @brief アーティファクト生成の巻物処理 /
  * @param caster_ptr プレーヤーへの参照ポインタ
  * @return 生成が実際に試みられたらTRUEを返す
index 68fd9d5..cad4650 100644 (file)
@@ -4,7 +4,6 @@
 
 bool apply_disenchant(player_type* target_ptr, BIT_FLAGS mode);
 void reserve_alter_reality(player_type* caster_ptr);
-bool alchemy(player_type* caster_ptr);
 bool artifact_scroll(player_type* caster_ptr);
 bool mundane_spell(player_type* ownner_ptr, bool only_equip);
 bool recharge(player_type* caster_ptr, int power);