OSDN Git Service

[Refactor] #37353 盲目時のコマンド制限処理を cmd_limit_confused() に統合。 / Integrate command limitat...
[hengband/hengband.git] / src / snipe.c
index dbae464..3900818 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "angband.h"
+#include "player-status.h"
 
 #define MAX_SNIPE_POWERS 16
 
@@ -18,11 +19,11 @@ struct snipe_power
 {
        int     min_lev;
        int     mana_cost;
-       const char *name;
+       concptr name;
 };
 
 /*! スナイパー技能の解説メッセージ */
-static const char *snipe_tips[MAX_SNIPE_POWERS] =
+static concptr const snipe_tips[MAX_SNIPE_POWERS] =
 {
 #ifdef JP
        "精神を集中する。射撃の威力、精度が上がり、高度な射撃術が使用できるようになる。",
@@ -62,7 +63,7 @@ static const char *snipe_tips[MAX_SNIPE_POWERS] =
 };
 
 /*! スナイパー技能テーブル */
-snipe_power snipe_powers[MAX_SNIPE_POWERS] =
+static snipe_power const snipe_powers[MAX_SNIPE_POWERS] =
 {
        /* Level gained,  cost,  name */
 #ifdef JP
@@ -110,22 +111,11 @@ static bool snipe_concentrate(void)
 {
        if ((int)p_ptr->concent < (2 + (p_ptr->lev + 5) / 10)) p_ptr->concent++;
 
-#ifdef JP
-       msg_format("集中した。(集中度 %d)", p_ptr->concent);
-#else
-       msg_format("You concentrate deeply. (lvl %d)", p_ptr->concent);
-#endif
-
+       msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), p_ptr->concent);
        reset_concent = FALSE;
 
-       /* Recalculate bonuses */
-       p_ptr->update |= (PU_BONUS);
-
+       p_ptr->update |= (PU_BONUS | PU_MONSTERS);
        p_ptr->redraw |= (PR_STATUS);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_MONSTERS);
-
        return (TRUE);
 }
 
@@ -138,23 +128,14 @@ void reset_concentration(bool msg)
 {
        if (msg)
        {
-#ifdef JP
-               msg_print("集中力が途切れてしまった。");
-#else
-               msg_print("Stop concentrating.");
-#endif
+               msg_print(_("集中力が途切れてしまった。", "Stop concentrating."));
        }
 
        p_ptr->concent = 0;
        reset_concent = FALSE;
 
-       /* Recalculate bonuses */
-       p_ptr->update |= (PU_BONUS);
-
+       p_ptr->update |= (PU_BONUS | PU_MONSTERS);
        p_ptr->redraw |= (PR_STATUS);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_MONSTERS);
 }
 
 /*! 
@@ -179,7 +160,7 @@ void display_snipe_list(void)
        int             i;
        int             y = 1;
        int             x = 1;
-       int             plev = p_ptr->lev;
+       PLAYER_LEVEL plev = p_ptr->lev;
        snipe_power     spell;
        char            psi_desc[80];
 
@@ -229,26 +210,20 @@ void display_snipe_list(void)
  * when you run it. It's probably easy to fix but I haven't tried,\n
  * sorry.\n
  */
-static int get_snipe_power(int *sn, bool only_browse)
+static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
 {
-       int             i;
+       COMMAND_CODE i;
        int             num = 0;
        int             y = 1;
        int             x = 20;
-       int             plev = p_ptr->lev;
+       PLAYER_LEVEL plev = p_ptr->lev;
        int             ask;
        char            choice;
        char            out_val[160];
-#ifdef JP
-       cptr            p = "射撃術";
-#else
-       cptr            p = "power";
-#endif
+       concptr            p = _("射撃術", "power");
        snipe_power     spell;
        bool            flag, redraw;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        repeat_push(*sn);
 
        /* Assume cancelled */
@@ -266,8 +241,6 @@ static int get_snipe_power(int *sn, bool only_browse)
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Nothing chosen yet */
        flag = FALSE;
 
@@ -286,21 +259,15 @@ static int get_snipe_power(int *sn, bool only_browse)
        /* Build a prompt (accept all spells) */
        if (only_browse)
        {
-#ifdef JP
-               (void)strnfmt(out_val, 78, "(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?",
-#else
-               (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ",
-#endif
-                             p, I2A(0), I2A(num), p);
+               (void)strnfmt(out_val, 78, 
+                                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
+                                       p, I2A(0), I2A(num), p);
        }
        else
        {
-#ifdef JP
-               (void)strnfmt(out_val, 78, "(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?",
-#else
-               (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ",
-#endif
-                         p, I2A(0), I2A(num), p);
+               (void)strnfmt(out_val, 78, 
+                                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
+                                       p, I2A(0), I2A(num), p);
        }
 
        /* Get a spell from the user */
@@ -320,8 +287,6 @@ static int get_snipe_power(int *sn, bool only_browse)
 
                                /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!only_browse) screen_save();
 
                                /* Display a list of spells */
@@ -362,8 +327,6 @@ static int get_snipe_power(int *sn, bool only_browse)
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                if (!only_browse) screen_load();
                        }
 
@@ -375,7 +338,7 @@ static int get_snipe_power(int *sn, bool only_browse)
                ask = isupper(choice);
 
                /* Lowercase */
-               if (ask) choice = tolower(choice);
+               if (ask) choice = (char)tolower(choice);
 
                /* Extract request */
                i = (islower(choice) ? A2I(choice) : -1);
@@ -397,11 +360,7 @@ static int get_snipe_power(int *sn, bool only_browse)
                        char tmp_val[160];
 
                        /* Prompt */
-#ifdef JP
-                       (void) strnfmt(tmp_val, 78, "%sを使いますか?", snipe_powers[i].name);
-#else
-                       (void)strnfmt(tmp_val, 78, "Use %s? ", snipe_powers[i].name);
-#endif
+                       (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), snipe_powers[i].name);
 
                        /* Belay that order */
                        if (!get_check(tmp_val)) continue;
@@ -410,15 +369,10 @@ static int get_snipe_power(int *sn, bool only_browse)
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw && !only_browse) screen_load();
 
-       /* Show choices */
        p_ptr->window |= (PW_SPELL);
-
-       /* Window stuff */
-       window_stuff();
+       handle_stuff();
 
        /* Abort if needed */
        if (!flag) return (FALSE);
@@ -426,12 +380,8 @@ static int get_snipe_power(int *sn, bool only_browse)
        /* Save the choice */
        (*sn) = i;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        repeat_push(*sn);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Success */
        return (TRUE);
 }
@@ -547,11 +497,7 @@ static bool cast_sniper_spell(int spell)
 
        if (o_ptr->tval != TV_BOW)
        {
-#ifdef JP
-               msg_print("弓を装備していない!");
-#else
-               msg_print("You wield no bow!");
-#endif
+               msg_print(_("弓を装備していない!", "You wield no bow!"));
                return (FALSE);
        }
 
@@ -560,7 +506,7 @@ static bool cast_sniper_spell(int spell)
        {
        case 0: /* Concentration */
                if (!snipe_concentrate()) return (FALSE);
-               energy_use = 100;
+               take_turn(p_ptr, 100);;
                return (TRUE);
        case 1: snipe_type = SP_LITE; break;
        case 2: snipe_type = SP_AWAY; break;
@@ -578,11 +524,7 @@ static bool cast_sniper_spell(int spell)
        case 14: snipe_type = SP_NEEDLE; break;
        case 15: snipe_type = SP_FINAL; break;
        default:
-#ifdef JP
-               msg_print("なに?");
-#else
-               msg_print("Zap?");
-#endif
+               msg_print(_("なに?", "Zap?"));
        }
 
        command_cmd = 'f';
@@ -598,40 +540,22 @@ static bool cast_sniper_spell(int spell)
  */
 void do_cmd_snipe(void)
 {
-       int             n = 0;
+       COMMAND_CODE n = 0;
        bool            cast;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-#ifdef JP
-               msg_print("混乱していて集中できない!");
-#else
-               msg_print("You are too confused!");
-#endif
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        /* not if hullucinated */
        if (p_ptr->image)
        {
-#ifdef JP
-               msg_print("幻覚が見えて集中できない!");
-#else
-               msg_print("You are too hallucinated!");
-#endif
+               msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
                return;
        }
 
        /* not if stuned */
        if (p_ptr->stun)
        {
-#ifdef JP
-               msg_print("頭が朦朧としていて集中できない!");
-#else
-               msg_print("You are too stuned!");
-#endif
+               msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
                return;
        }
 
@@ -644,14 +568,8 @@ void do_cmd_snipe(void)
        cast = cast_sniper_spell(n);
 
        if (!cast) return;
-#if 0
-       /* Take a turn */
-       energy_use = 100;
-#endif
-       /* Redraw mana */
        p_ptr->redraw |= (PR_HP | PR_MANA);
 
-       /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
 }
@@ -662,7 +580,7 @@ void do_cmd_snipe(void)
  */
 void do_cmd_snipe_browse(void)
 {
-       int n = 0;
+       COMMAND_CODE n = 0;
        int j, line;
        char temp[62 * 4];