OSDN Git Service

[Refactor] #37353 混乱時のコマンド制限処理を cmd_limit_confused() に統合。 / Integrate command limitat...
[hengband/hengband.git] / src / cmd2.c
index 6a7e2d0..b8a2597 100644 (file)
 #include "object-hook.h"
 #include "projection.h"
 #include "spells-summon.h"
+#include "spells-status.h"
 #include "monster-status.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "player-status.h"
+#include "realm-hex.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
@@ -47,6 +53,40 @@ bool confirm_leave_level(bool down_stair)
        return FALSE;
 }
 
+
+bool cmd_limit_confused(player_type *creature_ptr)
+{
+       if (p_ptr->confused)
+       {
+               msg_print(_("混乱していてできない!", "You are too confused!"));
+               return TRUE;
+       }
+       return FALSE;
+}
+
+bool cmd_limit_arena(player_type *creature_ptr)
+{
+       if (p_ptr->inside_arena)
+       {
+               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
+               msg_print(NULL);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+bool cmd_limit_time_walk(player_type *creature_ptr)
+{
+       if (world_player)
+       {
+               if (flush_failure) flush();
+               msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
+               sound(SOUND_FAIL);
+               return TRUE;
+       }
+       return FALSE;
+}
+
 /*!
  * @brief 階段を使って階層を昇る処理 / Go up one level
  * @return なし
@@ -498,18 +538,6 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 }
 
 /*!
- * @brief 地形は開くものであって、かつ開かれているかを返す /
- * Attempt to open the given chest at the given location
- * @param feat 地形ID
- * @return 開いた地形である場合TRUEを返す /  Return TRUE if the given feature is an open door
- */
-static bool is_open(IDX feat)
-{
-       return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
-}
-
-
-/*!
  * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
  * Attempt to open the given chest at the given location
  * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
@@ -2046,13 +2074,7 @@ void do_cmd_walk(bool pickup)
 void do_cmd_run(void)
 {
        DIRECTION dir;
-
-       /* Hack -- no running when confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて走れない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -2250,7 +2272,7 @@ void do_cmd_fire(void)
        }
 
        /* Fire the item */
-       do_cmd_fire_aux(item, j_ptr);
+       exe_fire(item, j_ptr);
 
        if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
 
@@ -2328,7 +2350,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        }
        else if (boomerang)
        {
-               if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
+               if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
                {
                        item_tester_hook = item_tester_hook_boomerang;
                        q = _("どの武器を投げますか? ", "Throw which item? ");
@@ -2340,7 +2362,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                return FALSE;
                        }
                }
-               else if (buki_motteruka(INVEN_LARM))
+               else if (has_melee_weapon(INVEN_LARM))
                {
                        item = INVEN_LARM;
                        o_ptr = &inventory[item];
@@ -2488,7 +2510,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
        if (shuriken) chance *= 2;
 
-       /* Save the old location */
        prev_y = y;
        prev_x = x;
 
@@ -2532,7 +2553,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        Term_xtra(TERM_XTRA_DELAY, msec);
                }
 
-               /* Save the old location */
                prev_y = y;
                prev_x = x;