OSDN Git Service

[Refactor] #37353 gain_magic() を import_magic_device() に改名して spells-object.c に移動...
authorDeskull <deskull@users.sourceforge.jp>
Tue, 22 Jan 2019 13:05:12 +0000 (22:05 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Tue, 22 Jan 2019 13:05:12 +0000 (22:05 +0900)
src/dungeon.c
src/externs.h
src/racial.c
src/spells-object.c
src/spells-object.h

index 389492c..8e343ea 100644 (file)
@@ -26,6 +26,7 @@
 #include "object-curse.h"
 #include "store.h"
 #include "spells-summon.h"
+#include "spells-object.h"
 #include "monsterrace-hook.h"
 #include "world.h"
 #include "mutation.h"
@@ -4163,7 +4164,7 @@ static void process_command(void)
                        else if (p_ptr->pclass == CLASS_SAMURAI)
                                do_cmd_gain_hissatsu();
                        else if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                               gain_magic();
+                               import_magic_device();
                        else
                                do_cmd_study();
                        break;
index 0404180..511b894 100644 (file)
@@ -850,7 +850,6 @@ extern void torch_lost_fuel(object_type *o_ptr);
 extern concptr essence_name[];
 
 /* racial.c */
-extern bool gain_magic(void);
 extern void do_cmd_racial_power(void);
 
 /* save.c */
index 401a3e2..728b5e2 100644 (file)
 #include "spells-object.h"
 
 /*!
- * @brief 魔道具術師の魔力取り込み処理
- * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
- */
-bool gain_magic(void)
-{
-       OBJECT_IDX item;
-       PARAMETER_VALUE pval;
-       int ext = 0;
-       concptr q, s;
-       object_type *o_ptr;
-       GAME_TEXT o_name[MAX_NLEN];
-
-       /* Only accept legal items */
-       item_tester_hook = item_tester_hook_recharge;
-
-       q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
-       s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
-
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
-       if (!o_ptr) return (FALSE);
-
-       if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
-       {
-               msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
-               return FALSE;
-       }
-
-       if (!object_is_known(o_ptr))
-       {
-               msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
-               return FALSE;
-       }
-
-       if (o_ptr->timeout)
-       {
-               msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
-               return FALSE;
-       }
-
-       pval = o_ptr->pval;
-       if (o_ptr->tval == TV_ROD)
-               ext = 72;
-       else if (o_ptr->tval == TV_WAND)
-               ext = 36;
-
-       if (o_ptr->tval == TV_ROD)
-       {
-               p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
-               if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
-       }
-       else
-       {
-               int num;
-               for (num = o_ptr->number; num; num--)
-               {
-                       int gain_num = pval;
-                       if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
-                       if (p_ptr->magic_num2[o_ptr->sval + ext])
-                       {
-                               gain_num *= 256;
-                               gain_num = (gain_num/3 + randint0(gain_num/3)) / 256;
-                               if (gain_num < 1) gain_num = 1;
-                       }
-                       p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
-                       if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
-                       p_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
-                       if (p_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
-                       if (p_ptr->magic_num1[o_ptr->sval + ext] > p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
-                       if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
-               }
-       }
-
-       object_desc(o_name, o_ptr, 0);
-       msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
-
-       /* Eliminate the item (from the pack) */
-       if (item >= 0)
-       {
-               inven_item_increase(item, -999);
-               inven_item_describe(item);
-               inven_item_optimize(item);
-       }
-
-       /* Eliminate the item (from the floor) */
-       else
-       {
-               floor_item_increase(0 - item, -999);
-               floor_item_describe(0 - item);
-               floor_item_optimize(0 - item);
-       }
-       p_ptr->energy_use = 100;
-       return TRUE;
-}
-
-/*!
  * @brief 魔法系コマンドを実行できるかの判定を返す
  * @return 魔法系コマンドを使用可能ならTRUE、不可能ならば理由をメッセージ表示してFALSEを返す。
  */
@@ -736,7 +641,7 @@ static bool cmd_racial_power_aux(s32b command)
                case CLASS_MAGIC_EATER:
                {
                        if (command == -3) {
-                               if (!gain_magic()) return FALSE;
+                               if (!import_magic_device()) return FALSE;
                        } else if (command == -4) {
                                if (!can_do_cmd_cast()) return FALSE;
                                if (!do_cmd_magic_eater(FALSE, TRUE)) return FALSE;
index 0e5475e..21ae4d5 100644 (file)
@@ -206,3 +206,98 @@ bool create_ammo(void)
        }
        return TRUE;
 }
+
+/*!
+ * @brief 魔道具術師の魔力取り込み処理
+ * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
+ */
+bool import_magic_device(void)
+{
+       OBJECT_IDX item;
+       PARAMETER_VALUE pval;
+       int ext = 0;
+       concptr q, s;
+       object_type *o_ptr;
+       GAME_TEXT o_name[MAX_NLEN];
+
+       /* Only accept legal items */
+       item_tester_hook = item_tester_hook_recharge;
+
+       q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
+       s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
+
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return (FALSE);
+
+       if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
+       {
+               msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
+               return FALSE;
+       }
+
+       if (!object_is_known(o_ptr))
+       {
+               msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
+               return FALSE;
+       }
+
+       if (o_ptr->timeout)
+       {
+               msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
+               return FALSE;
+       }
+
+       pval = o_ptr->pval;
+       if (o_ptr->tval == TV_ROD)
+               ext = 72;
+       else if (o_ptr->tval == TV_WAND)
+               ext = 36;
+
+       if (o_ptr->tval == TV_ROD)
+       {
+               p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
+               if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
+       }
+       else
+       {
+               int num;
+               for (num = o_ptr->number; num; num--)
+               {
+                       int gain_num = pval;
+                       if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
+                       if (p_ptr->magic_num2[o_ptr->sval + ext])
+                       {
+                               gain_num *= 256;
+                               gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
+                               if (gain_num < 1) gain_num = 1;
+                       }
+                       p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
+                       if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
+                       p_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
+                       if (p_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
+                       if (p_ptr->magic_num1[o_ptr->sval + ext] > p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
+                       if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
+               }
+       }
+
+       object_desc(o_name, o_ptr, 0);
+       msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
+
+       /* Eliminate the item (from the pack) */
+       if (item >= 0)
+       {
+               inven_item_increase(item, -999);
+               inven_item_describe(item);
+               inven_item_optimize(item);
+       }
+
+       /* Eliminate the item (from the floor) */
+       else
+       {
+               floor_item_increase(0 - item, -999);
+               floor_item_describe(0 - item);
+               floor_item_optimize(0 - item);
+       }
+       p_ptr->energy_use = 100;
+       return TRUE;
+}
index df01a05..7c4d271 100644 (file)
@@ -1,3 +1,4 @@
 #pragma once
 
-bool create_ammo(void);
+extern bool create_ammo(void);
+extern bool import_magic_device(void);