OSDN Git Service

Change the KWD_* macros to be constant string pointers with definitions in cmd-spell...
[hengbandforosx/hengbandosx.git] / src / cmd-spell.c
index 04a37dd..f983add 100644 (file)
 #include "player-status.h"
 #include "object-hook.h"
 
+/*
+ * Define these here, rather than use preprocessor macros set in cmd-spell.h,
+ * so that the preprocessing done to switch character encoding works on the
+ * platforms that use configure/automake.
+ */
+concptr KWD_DAM = _("損傷:", "dam ");
+concptr KWD_RANGE = _("射程:", "rng ");
+concptr KWD_DURATION = _("期間:", "dur ");
+concptr KWD_SPHERE = _("範囲:", "range ");
+concptr KWD_HEAL = _("回復:", "heal ");
+concptr KWD_RANDOM = _("ランダム", "random");
+
 /*!
  * @brief
  * 魔法の効果を「キャプション:ダイス+定数値」のフォーマットで出力する / Generate dice info string such as "foo 2d10"
@@ -183,6 +195,60 @@ concptr info_weight(WEIGHT weight)
 }
 
 /*!
+ * @brief 魔法が利用可能かどうかを返す /
+ * Determine if a spell is "okay" for the player to cast or study
+ * The spell must be legible, not forgotten, and also, to cast,
+ * it must be known, and to study, it must not be known.
+ * @param spell 呪文ID
+ * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
+ * @param study_pray 祈りの学習判定目的ならばTRUE
+ * @param use_realm 魔法領域ID
+ * @return 失敗率(%)
+ */
+static bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
+{
+       const magic_type *s_ptr;
+
+       /* Access the spell */
+       if (!is_magic(use_realm))
+       {
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
+       }
+       else
+       {
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
+       }
+
+       /* Spell is illegal */
+       if (s_ptr->slevel > p_ptr->lev) return (FALSE);
+
+       /* Spell is forgotten */
+       if ((use_realm == p_ptr->realm2) ?
+               (p_ptr->spell_forgotten2 & (1L << spell)) :
+               (p_ptr->spell_forgotten1 & (1L << spell)))
+       {
+               /* Never okay */
+               return (FALSE);
+       }
+
+       if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
+       if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
+
+       /* Spell is learned */
+       if ((use_realm == p_ptr->realm2) ?
+               (p_ptr->spell_learned2 & (1L << spell)) :
+               (p_ptr->spell_learned1 & (1L << spell)))
+       {
+               /* Always true */
+               return (!study_pray);
+       }
+
+       /* Okay to study, not to cast */
+       return (!learned);
+}
+
+
+/*!
  * @brief 魔法処理のメインルーチン
  * @param realm 魔法領域のID
  * @param spell 各領域の魔法ID
@@ -314,8 +380,6 @@ static int get_spell(SPELL_IDX *sn, concptr prompt, OBJECT_SUBTYPE_VALUE sval, b
                p, I2A(0), I2A(num - 1), prompt, p);
 #endif
 
-       /* Get a spell from the user */
-
        choice = (always_show_list || use_menu) ? ESCAPE : 1;
        while (!flag)
        {
@@ -371,7 +435,6 @@ static int get_spell(SPELL_IDX *sn, concptr prompt, OBJECT_SUBTYPE_VALUE sval, b
                                /* Show the list */
                                if (!redraw)
                                {
-                                       /* Show list */
                                        redraw = TRUE;
                                        screen_save();
 
@@ -691,7 +754,7 @@ static void change_realm2(CHARACTER_IDX next_realm)
        p_ptr->spell_worked2 = 0L;
        p_ptr->spell_forgotten2 = 0L;
 
-       sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
+       sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "changed magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
        p_ptr->old_realm |= 1 << (p_ptr->realm2 - 1);
        p_ptr->realm2 = next_realm;
@@ -1006,7 +1069,7 @@ void do_cmd_cast(void)
                if (hex_spell_fully())
                {
                        bool flag = FALSE;
-                       msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
+                       msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not cast more spells."));
                        flush();
                        if (p_ptr->lev >= 35) flag = stop_hex_spell();
                        if (!flag) return;