OSDN Git Service

[Refactor] #37353 魔法戦士の変換能力を convert_hp_to_mp()/convert_mp_to_hp() に分離。 / Separate...
authorDeskull <deskull@users.sourceforge.jp>
Wed, 23 Jan 2019 13:57:57 +0000 (22:57 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Wed, 23 Jan 2019 13:57:57 +0000 (22:57 +0900)
src/externs.h
src/racial.c
src/spells2.c

index b17d714..288a4b7 100644 (file)
@@ -994,6 +994,8 @@ extern bool android_inside_weapon(player_type *creature_ptr);
 extern bool create_ration(player_type *crature_ptr);
 extern void hayagake(player_type *creature_ptr);
 extern bool double_attack(player_type *creature_ptr);
+extern bool comvert_hp_to_mp(player_type *creature_ptr);
+extern bool comvert_mp_to_hp(player_type *creature_ptr);
 
 /* spells3.c */
 extern bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode);
index f942773..1d4f3d9 100644 (file)
@@ -486,37 +486,12 @@ static bool cmd_racial_power_aux(s32b command)
                {
                        if (command == -3)
                        {
-                               int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, _("HPからMPへの無謀な変換", "thoughtless convertion from HP to SP"), -1) / 5;
-                               if (gain_sp)
-                               {
-                                       p_ptr->csp += gain_sp;
-                                       if (p_ptr->csp > p_ptr->msp)
-                                       {
-                                               p_ptr->csp = p_ptr->msp;
-                                               p_ptr->csp_frac = 0;
-                                       }
-                               }
-                               else
-                               {
-                                       msg_print(_("変換に失敗した。", "You failed to convert."));
-                               }
+                               return comvert_hp_to_mp(p_ptr);
                        }
                        else if (command == -4)
                        {
-                               if (p_ptr->csp >= p_ptr->lev / 5)
-                               {
-                                       p_ptr->csp -= p_ptr->lev / 5;
-                                       hp_player(p_ptr->lev);
-                               }
-                               else
-                               {
-                                       msg_print(_("変換に失敗した。", "You failed to convert."));
-                               }
+                               return comvert_mp_to_hp(p_ptr);
                        }
-
-                       /* Redraw mana and hp */
-                       p_ptr->redraw |= (PR_HP | PR_MANA);
-
                        break;
                }
                case CLASS_CHAOS_WARRIOR:
index d8dbc4c..9e2dd03 100644 (file)
@@ -5225,3 +5225,39 @@ bool double_attack(player_type *creature_ptr)
        }
        return TRUE;
 }
+
+bool comvert_hp_to_mp(player_type *creature_ptr)
+{
+       int gain_sp = take_hit(DAMAGE_USELIFE, creature_ptr->lev, _("HPからMPへの無謀な変換", "thoughtless convertion from HP to SP"), -1) / 5;
+       if (gain_sp)
+       {
+               creature_ptr->csp += gain_sp;
+               if (creature_ptr->csp > creature_ptr->msp)
+               {
+                       creature_ptr->csp = creature_ptr->msp;
+                       creature_ptr->csp_frac = 0;
+               }
+       }
+       else
+       {
+               msg_print(_("変換に失敗した。", "You failed to convert."));
+       }
+       creature_ptr->redraw |= (PR_HP | PR_MANA);
+       return TRUE;
+}
+
+bool comvert_mp_to_hp(player_type *creature_ptr)
+{
+       if (creature_ptr->csp >= creature_ptr->lev / 5)
+       {
+               creature_ptr->csp -= creature_ptr->lev / 5;
+               hp_player(creature_ptr->lev);
+       }
+       else
+       {
+               msg_print(_("変換に失敗した。", "You failed to convert."));
+       }
+       /* Redraw mana and hp */
+       creature_ptr->redraw |= (PR_HP | PR_MANA);
+       return TRUE;
+}
\ No newline at end of file