OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / cmd2.c
index b8a2597..054fb55 100644 (file)
@@ -53,10 +53,35 @@ bool confirm_leave_level(bool down_stair)
        return FALSE;
 }
 
+/*!
+ * @brief 魔法系コマンドが制限されているかを返す。
+ * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
+ */
+bool cmd_limit_cast(player_type *creature_ptr)
+{
+       if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
+       {
+               msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
+               msg_print(NULL);
+               return TRUE;
+       }
+       else if (creature_ptr->anti_magic)
+       {
+               msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
+               return TRUE;
+       }
+       else if (creature_ptr->shero)
+       {
+               msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
+               return TRUE;
+       }
+       else
+               return FALSE;
+}
 
 bool cmd_limit_confused(player_type *creature_ptr)
 {
-       if (p_ptr->confused)
+       if (creature_ptr->confused)
        {
                msg_print(_("混乱していてできない!", "You are too confused!"));
                return TRUE;
@@ -66,7 +91,7 @@ bool cmd_limit_confused(player_type *creature_ptr)
 
 bool cmd_limit_arena(player_type *creature_ptr)
 {
-       if (p_ptr->inside_arena)
+       if (creature_ptr->inside_arena)
        {
                msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
                msg_print(NULL);
@@ -77,7 +102,7 @@ bool cmd_limit_arena(player_type *creature_ptr)
 
 bool cmd_limit_time_walk(player_type *creature_ptr)
 {
-       if (world_player)
+       if (creature_ptr->timewalk)
        {
                if (flush_failure) flush();
                msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
@@ -153,8 +178,7 @@ void do_cmd_go_up(void)
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
                
-               /* Hack -- take a turn */
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
 
                /* End the command */
                return;
@@ -172,8 +196,7 @@ void do_cmd_go_up(void)
        /* Cancel the command */
        if (!go_up) return;
 
-       /* Hack -- take a turn */
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);
 
        if (autosave_l) do_cmd_save_game(TRUE);
 
@@ -303,13 +326,10 @@ void do_cmd_go_down(void)
 
                /* Leaving */
                p_ptr->leaving = TRUE;
-
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
                
-               
-        /* Hack -- take a turn */
-        p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
        }
 
        else
@@ -344,8 +364,7 @@ void do_cmd_go_down(void)
                        prepare_change_floor_mode(CFM_FIRST_FLOOR);
                }
 
-               /* Hack -- take a turn */
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
 
                if (autosave_l) do_cmd_save_game(TRUE);
 
@@ -427,7 +446,7 @@ void do_cmd_search(void)
                /* Cancel the arg */
                command_arg = 0;
        }
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Search */
        search();
@@ -485,7 +504,7 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Attempt to unlock it */
        if (o_ptr->pval > 0)
@@ -687,7 +706,7 @@ static bool do_cmd_open_aux(POSITION y, POSITION x)
        feature_type *f_ptr = &f_info[c_ptr->feat];
        bool more = FALSE;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -836,7 +855,7 @@ void do_cmd_open(void)
                /* Monster in the way */
                else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
                        py_attack(y, x, 0);
                }
@@ -879,7 +898,7 @@ static bool do_cmd_close_aux(POSITION y, POSITION x)
        FEAT_IDX old_feat = c_ptr->feat;
        bool more = FALSE;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -978,7 +997,7 @@ void do_cmd_close(void)
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1052,7 +1071,7 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
        /* Verify legality */
        if (!do_cmd_tunnel_test(y, x)) return (FALSE);
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Get grid */
        c_ptr = &cave[y][x];
@@ -1223,7 +1242,7 @@ void do_cmd_tunnel(void)
                /* A monster is in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1353,7 +1372,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Get the "disarm" factor */
        i = p_ptr->skill_dis;
@@ -1448,7 +1467,7 @@ bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
        int i = p_ptr->skill_dis;
        int j;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Penalize some conditions */
        if (p_ptr->blind || no_lite()) i = i / 10;
@@ -1631,7 +1650,7 @@ static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 
        concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
 
@@ -1754,7 +1773,7 @@ void do_cmd_bash(void)
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1829,7 +1848,7 @@ void do_cmd_alter(void)
                feat = get_feat_mimic(c_ptr);
                f_ptr = &f_info[feat];
 
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);;
 
                if (c_ptr->m_idx)
                {
@@ -1965,7 +1984,7 @@ void do_cmd_spike(void)
                /* Is a monster in the way? */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1976,7 +1995,7 @@ void do_cmd_spike(void)
                /* Go for it */
                else
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        /* Successful jamming */
                        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
@@ -2019,7 +2038,7 @@ void do_cmd_walk(bool pickup)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, FALSE))
        {
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);;
 
                if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
                {
@@ -2054,7 +2073,7 @@ void do_cmd_walk(bool pickup)
                        change_wild_mode();
 
                        /* Give first move to monsters */
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        /* HACk -- set the encouter flag for the wilderness generation */
                        generate_encounter = TRUE;
@@ -2115,7 +2134,7 @@ void do_cmd_stay(bool pickup)
                command_arg = 0;
        }
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        if (pickup) mpe_mode |= MPE_DO_PICKUP;
        (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
@@ -2182,7 +2201,7 @@ void do_cmd_rest(void)
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
 
        /* Take a turn (?) */
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* The sin of sloth */
        if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
@@ -2488,7 +2507,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                p_ptr->redraw |= (PR_EQUIPPY);
        }
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Rogue and Ninja gets bonus */
        if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))