OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / hissatsu.c
index 0d8b00c..641cc5c 100644 (file)
@@ -1,62 +1,64 @@
-/* File: mind.c */
-
-/* Purpose: Mindcrafter code */
-
-/*
- * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies.  Other copyrights may also apply.
+/*!
+ * @file hissatsu.c
+ * @brief 剣術の実装 / Blade arts
+ * @date 2014/01/17
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies.  Other copyrights may also apply.\n
+ * 2014 Deskull rearranged comment for Doxygen.\n
  */
 
 #include "angband.h"
+#include "monsterrace-hook.h"
+#include "player-status.h"
 
 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
 
-/*
- * Allow user to choose a mindcrafter power.
- *
- * If a valid spell is chosen, saves it in '*sn' and returns TRUE
- * If the user hits escape, returns FALSE, and set '*sn' to -1
- * If there are no legal choices, returns FALSE, and sets '*sn' to -2
- *
- * The "prompt" should be "cast", "recite", or "study"
- * The "known" should be TRUE for cast/pray, FALSE for study
- *
- * nb: This function has a (trivial) display bug which will be obvious
- * when you run it. It's probably easy to fix but I haven't tried,
- * sorry.
+
+/*!
+ * @brief 使用可能な剣術を選択する /
+ * Allow user to choose a blade arts.
+ * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
+ * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
+ * @details
+ * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
+ * If the user hits escape, returns FALSE, and set '*sn' to -1\n
+ * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
+ *\n
+ * The "prompt" should be "cast", "recite", or "study"\n
+ * The "known" should be TRUE for cast/pray, FALSE for study\n
+ *\n
+ * nb: This function has a (trivial) display bug which will be obvious\n
+ * when you run it. It's probably easy to fix but I haven't tried,\n
+ * sorry.\n
  */
-static int get_hissatsu_power(int *sn)
+static int get_hissatsu_power(SPELL_IDX *sn)
 {
-       int             i, j = 0;
-       int             num = 0;
-       int             y = 1;
-       int             x = 15;
-       int             plev = p_ptr->lev;
-       int             ask = TRUE;
-       char            choice;
-       char            out_val[160];
-       char sentaku[32];
-#ifdef JP
-cptr            p = "ɬ»¦·õ";
-#else
-       cptr            p = "special attack";
-#endif
-
+       SPELL_IDX i;
+       int j = 0;
+       int num = 0;
+       POSITION y = 1;
+       POSITION x = 15;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       int ask = TRUE;
+       char choice;
+       char out_val[160];
+       SPELL_IDX sentaku[32];
+       concptr p = _("必殺剣", "special attack");
+       COMMAND_CODE code;
        magic_type spell;
-       bool            flag, redraw;
+       bool flag, redraw;
        int menu_line = (use_menu ? 1 : 0);
 
        /* Assume cancelled */
        *sn = (-1);
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the spell, if available */
-       if (repeat_pull(sn))
+       if (repeat_pull(&code))
        {
+               *sn = (SPELL_IDX)code;
                /* Verify the spell */
                if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
                {
@@ -65,8 +67,6 @@ cptr            p = "ɬ
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Nothing chosen yet */
        flag = FALSE;
 
@@ -84,11 +84,7 @@ cptr            p = "ɬ
 
        /* Build a prompt (accept all spells) */
        (void) strnfmt(out_val, 78, 
-#ifdef JP
-                      "(%^s %c-%c, '*'¤Ç°ìÍ÷, ESC) ¤É¤Î%s¤ò»È¤¤¤Þ¤¹¤«¡©",
-#else
-                      "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ",
-#endif
+                      _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
                       p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num-1], p);
 
        if (use_menu) screen_save();
@@ -188,17 +184,12 @@ cptr            p = "ɬ
 
                                /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!use_menu) screen_save();
 
                                /* Display a list of spells */
                                prt("", y, x);
-#ifdef JP
-put_str("̾Á°              Lv  MP      Ì¾Á°              Lv  MP ", y, x + 5);
-#else
-put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
-#endif
+                               put_str(_("名前              Lv  MP      名前              Lv  MP ", 
+                                                 "name              Lv  SP      name              Lv  SP "), y, x + 5);
                                prt("", y+1, x);
                                /* Dump the spells */
                                for (i = 0, line = 0; i < 32; i++)
@@ -215,11 +206,7 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
                                        if (use_menu)
                                        {
                                                if (i == (menu_line-1))
-#ifdef JP
-                                                       strcpy(psi_desc, "  ¡Õ");
-#else
-                                                       strcpy(psi_desc, "  > ");
-#endif
+                                                       strcpy(psi_desc, _("  》", "  > "));
                                                else strcpy(psi_desc, "    ");
                                                
                                        }
@@ -247,8 +234,6 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                screen_load();
                        }
 
@@ -264,7 +249,7 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
                                ask = (isupper(choice));
 
                                /* Lowercase */
-                               if (ask) choice = tolower(choice);
+                               if (ask) choice = (char)tolower(choice);
 
                                /* Extract request */
                                i = (islower(choice) ? A2I(choice) : -1);
@@ -292,12 +277,7 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
                        char tmp_val[160];
 
                        /* Prompt */
-#ifdef JP
-                       (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡©", do_spell(REALM_HISSATSU, j, SPELL_NAME));
-#else
-                       (void)strnfmt(tmp_val, 78, "Use %s? ", do_spell(REALM_HISSATSU, j, SPELL_NAME));
-#endif
-
+                       (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
 
                        /* Belay that order */
                        if (!get_check(tmp_val)) continue;
@@ -306,16 +286,10 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw) screen_load();
 
-       /* Show choices */
        p_ptr->window |= (PW_SPELL);
-
-       /* Window stuff */
-       window_stuff();
-
+       handle_stuff();
 
        /* Abort if needed */
        if (!flag) return (FALSE);
@@ -323,57 +297,32 @@ put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
        /* Save the choice */
        (*sn) = j;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-       repeat_push(*sn);
-
-#endif /* ALLOW_REPEAT -- TNB */
+       repeat_push((COMMAND_CODE)j);
 
        /* Success */
        return (TRUE);
 }
 
 
-/*
- * do_cmd_cast calls this function if the player's class
- * is 'mindcrafter'.
+/*!
+ * @brief 剣術コマンドのメインルーチン
+ * @return なし
  */
 void do_cmd_hissatsu(void)
 {
-       int             n = 0;
+       SPELL_IDX       n = 0;
        magic_type      spell;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-#ifdef JP
-msg_print("º®Í𤷤Ƥ¤¤Æ½¸Ãæ¤Ç¤­¤Ê¤¤¡ª");
-#else
-               msg_print("You are too confused!");
-#endif
-
-               return;
-       }
-       if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
+       if (cmd_limit_confused(p_ptr)) return;
+       if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
        {
                if (flush_failure) flush();
-#ifdef JP
-msg_print("Éð´ï¤ò»ý¤¿¤Ê¤¤¤Èɬ»¦µ»¤Ï»È¤¨¤Ê¤¤¡ª");
-#else
-               msg_print("You need to wield a weapon!");
-#endif
-
+               msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
                return;
        }
        if (!p_ptr->spell_learned1)
        {
-#ifdef JP
-msg_print("²¿¤âµ»¤òÃΤé¤Ê¤¤¡£");
-#else
-               msg_print("You don't know any special attacks.");
-#endif
-
+               msg_print(_("何も技を知らない。", "You don't know any special attacks."));
                return;
        }
 
@@ -392,11 +341,7 @@ msg_print("
        {
                if (flush_failure) flush();
                /* Warning */
-#ifdef JP
-msg_print("£Í£Ð¤¬Â­¤ê¤Þ¤»¤ó¡£");
-#else
-               msg_print("You do not have enough mana to use this power.");
-#endif
+               msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
                msg_print(NULL);
                return;
        }
@@ -406,30 +351,31 @@ msg_print("
        /* Cast the spell */
        if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
 
-       /* Take a turn */
-       energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Use some mana */
        p_ptr->csp -= spell.smana;
 
        /* Limit */
        if (p_ptr->csp < 0) p_ptr->csp = 0;
-
-       /* Redraw mana */
        p_ptr->redraw |= (PR_MANA);
 
-       /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
 }
 
 
+/*!
+ * @brief 剣術コマンドの学習
+ * @return なし
+ */
 void do_cmd_gain_hissatsu(void)
 {
-       int item, i, j;
+       OBJECT_IDX item;
+       int i, j;
 
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
        bool gain = FALSE;
 
@@ -440,42 +386,23 @@ void do_cmd_gain_hissatsu(void)
 
        if (p_ptr->blind || no_lite())
        {
-#ifdef JP
-msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
-#else
-               msg_print("You cannot see!");
-#endif
-
+               msg_print(_("目が見えない!", "You cannot see!"));
                return;
        }
 
-       if (p_ptr->confused)
-       {
-#ifdef JP
-msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
-#else
-               msg_print("You are too confused!");
-#endif
-
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        if (!(p_ptr->new_spells))
        {
-#ifdef JP
-msg_print("¿·¤·¤¤É¬»¦µ»¤ò³Ð¤¨¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡ª");
-#else
-               msg_print("You cannot learn any new special attacks!");
-#endif
-
+               msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
                return;
        }
 
 #ifdef JP
        if( p_ptr->new_spells < 10 ){
-               msg_format("¤¢¤È %d ¤Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
+               msg_format("あと %d つの必殺技を学べる。", p_ptr->new_spells);
        }else{
-               msg_format("¤¢¤È %d ¸Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
+               msg_format("あと %d 個の必殺技を学べる。", p_ptr->new_spells);
        }
 #else
        msg_format("You can learn %d new special attack%s.", p_ptr->new_spells,
@@ -484,32 +411,11 @@ msg_print("
 
        item_tester_tval = TV_HISSATSU_BOOK;
 
-       /* Get an item */
-#ifdef JP
-q = "¤É¤Î½ñ¤«¤é³Ø¤Ó¤Þ¤¹¤«? ";
-#else
-       q = "Study which book? ";
-#endif
+       q = _("どの書から学びますか? ", "Study which book? ");
+       s = _("読める書がない。", "You have no books that you can read.");
 
-#ifdef JP
-s = "Æɤá¤ë½ñ¤¬¤Ê¤¤¡£";
-#else
-       s = "You have no books that you can read.";
-#endif
-
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return;
 
        for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
        {
@@ -518,11 +424,7 @@ s = "
 
                p_ptr->spell_learned1 |= (1L << i);
                p_ptr->spell_worked1 |= (1L << i);
-#ifdef JP
-               msg_format("%s¤Îµ»¤ò³Ð¤¨¤¿¡£", do_spell(REALM_HISSATSU, i, SPELL_NAME));
-#else
-               msg_format("You have learned the special attack of %s.", do_spell(REALM_HISSATSU, i, SPELL_NAME));
-#endif
+               msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
                for (j = 0; j < 64; j++)
                {
                        /* Stop at the first empty space */
@@ -534,24 +436,25 @@ s = "
 
        /* No gain ... */
        if (!gain)
-#ifdef JP
-               msg_print("²¿¤â³Ð¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡£");
-#else
-               msg_print("You were not able to learn any special attacks.");
-#endif
+               msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
 
-       /* Take a turn */
        else
-               energy_use = 100;
+               take_turn(p_ptr, 100);;
 
        p_ptr->update |= (PU_SPELLS);
 }
 
 
-/*
+/*!
+ * @brief 剣術のスレイ倍率計算を行う /
  * Calcurate magnification of hissatsu technics
+ * @param mult 剣術のスレイ効果以前に算出している多要素の倍率(/10倍)
+ * @param flgs 剣術に使用する武器のスレイフラグ配列
+ * @param m_ptr 目標となるモンスターの構造体参照ポインタ
+ * @param mode 剣術のスレイ型ID
+ * @return スレイの倍率(/10倍)
  */
-s16b mult_hissatsu(int mult, u32b *flgs, monster_type *m_ptr, int mode)
+MULTIPLY mult_hissatsu(MULTIPLY mult, BIT_FLAGS *flgs, monster_type *m_ptr, BIT_FLAGS mode)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -620,7 +523,7 @@ s16b mult_hissatsu(int mult, u32b *flgs, monster_type *m_ptr, int mode)
        /* Zammaken (Nonliving Evil) */
        if (mode == HISSATSU_ZANMA)
        {
-               if (!monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL))
+               if (!monster_living(m_ptr->r_idx) && (r_ptr->flags3 & RF3_EVIL))
                {
                        if (mult < 15) mult = 25;
                        else if (mult < 50) mult = MIN(50, mult+20);
@@ -703,9 +606,9 @@ s16b mult_hissatsu(int mult, u32b *flgs, monster_type *m_ptr, int mode)
        }
 
        /* Bloody Maelstrom */
-       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(r_ptr))
+       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(m_ptr->r_idx))
        {
-               int tmp = MIN(100, MAX(10, p_ptr->cut / 10));
+               MULTIPLY tmp = MIN(100, MAX(10, p_ptr->cut / 10));
                if (mult < tmp) mult = tmp;
        }