OSDN Git Service

[Refactor] #38662 Moved util.* to util/
[hengband/hengband.git] / src / cmd / cmd-spell.c
index ac39fef..b7ebd72 100644 (file)
@@ -6,43 +6,36 @@
     2013 Deskull rearranged comment for Doxygen.
  */
 
-#include "angband.h"
-#include "core.h"
-#include "util.h"
-#include "cmd-spell.h"
-
-#include "cmd-dump.h"
-#include "selfinfo.h"
-#include "spells.h"
-#include "spells-summon.h"
-#include "realm.h"
-#include "realm-arcane.h"
-#include "realm-chaos.h"
-#include "realm-craft.h"
-#include "realm-crusade.h"
-#include "realm-daemon.h"
-#include "realm-death.h"
-#include "realm-hex.h"
-#include "realm-hissatsu.h"
-#include "realm-life.h"
-#include "realm-nature.h"
-#include "realm-song.h"
-#include "realm-sorcery.h"
-#include "realm-trump.h"
-#include "mind.h"
-#include "avatar.h"
-#include "player-damage.h"
-#include "player-status.h"
-#include "player-effects.h"
-#include "player-skill.h"
-#include "player-class.h"
-#include "player-inventory.h"
-#include "object-hook.h"
+#include "system/angband.h"
+#include "core/stuff-handler.h"
+#include "util/util.h"
+#include "main/sound-definitions-table.h"
+#include "cmd/cmd-spell.h"
+
+#include "io/write-diary.h"
+#include "cmd/cmd-dump.h"
+#include "player/selfinfo.h"
+#include "spell/technic-info-table.h"
+#include "spell/spells2.h"
+#include "spell/spells3.h"
+#include "spell/spells-summon.h"
+#include "realm/realm-hex.h"
+#include "mind/mind.h"
+#include "player/avatar.h"
+#include "player/player-damage.h"
+#include "player/player-status.h"
+#include "player/player-effects.h"
+#include "player/player-skill.h"
+#include "player/player-class.h"
+#include "inventory/player-inventory.h"
+#include "object/object-hook.h"
 #include "cmd-basic.h"
-#include "view-mainwindow.h"
-#include "floor.h"
-#include "autopick.h"
-#include "japanese.h"
+#include "view/display-main-window.h"
+#include "floor/floor.h"
+#include "autopick/autopick-reader-writer.h"
+#include "locale/japanese.h"
+#include "spell/spells-util.h"
+#include "spell/spells-execution.h"
 
  /*!
   * 魔法領域フラグ管理テーブル /
@@ -265,37 +258,6 @@ static bool spell_okay(player_type *caster_ptr, int spell, bool learned, bool st
        return (!learned);
 }
 
-
-/*!
- * @brief 魔法処理のメインルーチン
- * @param realm 魔法領域のID
- * @param spell 各領域の魔法ID
- * @param mode 求める処理
- * @return 各領域魔法に各種テキストを求めた場合は文字列参照ポインタ、そうでない場合はNULLポインタを返す。
- */
-concptr exe_spell(player_type *caster_ptr, REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode)
-{
-       switch (realm)
-       {
-       case REALM_LIFE:     return do_life_spell(caster_ptr, spell, mode);
-       case REALM_SORCERY:  return do_sorcery_spell(caster_ptr, spell, mode);
-       case REALM_NATURE:   return do_nature_spell(caster_ptr, spell, mode);
-       case REALM_CHAOS:    return do_chaos_spell(caster_ptr, spell, mode);
-       case REALM_DEATH:    return do_death_spell(caster_ptr, spell, mode);
-       case REALM_TRUMP:    return do_trump_spell(caster_ptr, spell, mode);
-       case REALM_ARCANE:   return do_arcane_spell(caster_ptr, spell, mode);
-       case REALM_CRAFT:    return do_craft_spell(caster_ptr, spell, mode);
-       case REALM_DAEMON:   return do_daemon_spell(caster_ptr, spell, mode);
-       case REALM_CRUSADE:  return do_crusade_spell(caster_ptr, spell, mode);
-       case REALM_MUSIC:    return do_music_spell(caster_ptr, spell, mode);
-       case REALM_HISSATSU: return do_hissatsu_spell(caster_ptr, spell, mode);
-       case REALM_HEX:      return do_hex_spell(caster_ptr, spell, mode);
-       }
-
-       return NULL;
-}
-
-
 /*!
  * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
  * Allow user to choose a spell/prayer from the given book.
@@ -639,6 +601,7 @@ void do_cmd_browse(player_type *caster_ptr)
        object_type *o_ptr;
 
        concptr q, s;
+       OBJECT_TYPE_VALUE tval = 0;
 
        /* Warriors are illiterate */
        if (!(caster_ptr->realm1 || caster_ptr->realm2) && (caster_ptr->pclass != CLASS_SORCERER) && (caster_ptr->pclass != CLASS_RED_MAGE))
@@ -662,13 +625,15 @@ void do_cmd_browse(player_type *caster_ptr)
        }
 
        /* Restrict choices to "useful" books */
-       if (caster_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
+       if (caster_ptr->realm2 == REALM_NONE) tval = mp_ptr->spell_book;
        else item_tester_hook = item_tester_learn_spell;
 
        q = _("どの本を読みますか? ", "Browse which book? ");
        s = _("読める本がない。", "You have no books that you can read.");
 
-       o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | (caster_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)), item_tester_tval);
+       o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | (caster_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)), tval);
+
+       item_tester_hook = NULL;
        if (!o_ptr)
        {
                if (item == INVEN_FORCE) /* the_force */
@@ -770,7 +735,7 @@ static void change_realm2(player_type *caster_ptr, CHARACTER_IDX next_realm)
        caster_ptr->spell_worked2 = 0L;
        caster_ptr->spell_forgotten2 = 0L;
 
-       sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[caster_ptr->realm2], realm_names[next_realm]);
+       sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "changed magic realm from %s to %s."), realm_names[caster_ptr->realm2], realm_names[next_realm]);
        exe_write_diary(caster_ptr, DIARY_DESCRIPTION, 0, tmp);
        caster_ptr->old_realm |= 1 << (caster_ptr->realm2 - 1);
        caster_ptr->realm2 = next_realm;
@@ -802,6 +767,8 @@ void do_cmd_study(player_type *caster_ptr)
        concptr p = spell_category_name(mp_ptr->spell_book);
        object_type *o_ptr;
        concptr q, s;
+       OBJECT_TYPE_VALUE tval = 0;
+
 
        if (!caster_ptr->realm1)
        {
@@ -839,13 +806,14 @@ void do_cmd_study(player_type *caster_ptr)
 
 
        /* Restrict choices to "useful" books */
-       if (caster_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
+       if (caster_ptr->realm2 == REALM_NONE) tval = mp_ptr->spell_book;
        else item_tester_hook = item_tester_learn_spell;
 
        q = _("どの本から学びますか? ", "Study which book? ");
        s = _("読める本がない。", "You have no books that you can read.");
 
-       o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), item_tester_tval);
+       o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), tval);
+
        if (!o_ptr) return;
 
        /* Access the item's sval */
@@ -1075,7 +1043,7 @@ void do_cmd_cast(player_type *caster_ptr)
                if (hex_spell_fully(caster_ptr))
                {
                        bool flag = FALSE;
-                       msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
+                       msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not cast more spells."));
                        flush();
                        if (caster_ptr->lev >= 35) flag = stop_hex_spell(caster_ptr);
                        if (!flag) return;
@@ -1142,7 +1110,7 @@ void do_cmd_cast(player_type *caster_ptr)
        use_realm = tval2realm(o_ptr->tval);
        if (use_realm == REALM_HEX)
        {
-               if (hex_spelling(spell))
+               if (hex_spelling(caster_ptr, spell))
                {
                        msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
                        return;