OSDN Git Service

[Refactor] #37353 知識の石の処理を perilous_secrets() に分離。 / Separate Stone of Lore to perilo...
authordeskull <deskull@users.sourceforge.jp>
Sun, 24 Feb 2019 15:12:53 +0000 (00:12 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 24 Feb 2019 15:12:53 +0000 (00:12 +0900)
src/cmd-activate.c
src/spells-object.c
src/spells-object.h

index 4f724d1..a6c8d7f 100644 (file)
@@ -1738,45 +1738,9 @@ bool activate_artifact(object_type *o_ptr)
        }
 
        case ACT_LORE:
-       {
                msg_print(_("石が隠された秘密を写し出した...", "The stone reveals hidden mysteries..."));
-               if (!ident_spell(FALSE)) return FALSE;
-
-               if (mp_ptr->spell_book)
-               {
-                       /* Sufficient mana */
-                       if (20 <= p_ptr->csp)
-                       {
-                               /* Use some mana */
-                               p_ptr->csp -= 20;
-                       }
-
-                       /* Over-exert the player */
-                       else
-                       {
-                               int oops = 20 - p_ptr->csp;
-
-                               /* No mana left */
-                               p_ptr->csp = 0;
-                               p_ptr->csp_frac = 0;
-
-                               msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
-                               /* Hack -- Bypass free action */
-                               (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
-
-                               /* Confusing. */
-                               (void)set_confused(p_ptr->confused + randint1(5 * oops + 1));
-                       }
-                       p_ptr->redraw |= (PR_MANA);
-               }
-               take_hit(DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
-               /* Confusing. */
-               if (one_in_(5)) (void)set_confused(p_ptr->confused + randint1(10));
-
-               /* Exercise a little care... */
-               if (one_in_(20)) take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
+               if(!perilous_secrets(p_ptr)) return FALSE;
                break;
-       }
 
        case ACT_SHIKOFUMI:
        {
index 67463fe..c1bdde9 100644 (file)
@@ -796,3 +796,44 @@ bool brand_bolts(void)
        return (TRUE);
 }
 
+
+bool perilous_secrets(player_type *creature_ptr)
+{
+       if (!ident_spell(FALSE)) return FALSE;
+
+       if (mp_ptr->spell_book)
+       {
+               /* Sufficient mana */
+               if (20 <= p_ptr->csp)
+               {
+                       /* Use some mana */
+                       p_ptr->csp -= 20;
+               }
+
+               /* Over-exert the player */
+               else
+               {
+                       int oops = 20 - p_ptr->csp;
+
+                       /* No mana left */
+                       p_ptr->csp = 0;
+                       p_ptr->csp_frac = 0;
+
+                       msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
+                       /* Hack -- Bypass free action */
+                       (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
+
+                       /* Confusing. */
+                       (void)set_confused(p_ptr->confused + randint1(5 * oops + 1));
+               }
+               p_ptr->redraw |= (PR_MANA);
+       }
+       take_hit(DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
+       /* Confusing. */
+       if (one_in_(5)) (void)set_confused(p_ptr->confused + randint1(10));
+
+       /* Exercise a little care... */
+       if (one_in_(20)) take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
+       return TRUE;
+
+}
\ No newline at end of file
index 32cd84c..42e2957 100644 (file)
@@ -10,3 +10,4 @@ extern bool curse_weapon_object(bool force, object_type *o_ptr);
 extern bool curse_weapon(bool force, int slot);
 extern bool rustproof(void);
 extern bool brand_bolts(void);
+extern bool perilous_secrets(player_type *creature_ptr);