From 9928222d61411861fe381b3e6fbf423a131a3931 Mon Sep 17 00:00:00 2001 From: Hourier Date: Tue, 30 Jun 2020 20:48:27 +0900 Subject: [PATCH] [Refactpr] #40466 Moved set_tim_sh_force() from player-effects.c/h to mind-force-trainer.c/h --- src/core/magic-effects-timeout-reducer.c | 3 ++- src/mind/mind-force-trainer.c | 41 ++++++++++++++++++++++++++++++ src/mind/mind-force-trainer.h | 1 + src/mind/mind.c | 2 +- src/player/player-effects.c | 43 +------------------------------- src/player/player-effects.h | 1 - 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/core/magic-effects-timeout-reducer.c b/src/core/magic-effects-timeout-reducer.c index 76638ecf9..6df5d3cb9 100644 --- a/src/core/magic-effects-timeout-reducer.c +++ b/src/core/magic-effects-timeout-reducer.c @@ -1,5 +1,6 @@ #include "core/magic-effects-timeout-reducer.h" #include "game-option/birth-options.h" +#include "mind/mind-force-trainer.h" #include "mind/mind-mirror-master.h" #include "mind/racial-kutar.h" #include "player/player-effects.h" @@ -68,7 +69,7 @@ void reduce_magic_effects_timeout(player_type *creature_ptr) } if (creature_ptr->tim_sh_touki) { - (void)set_tim_sh_touki(creature_ptr, creature_ptr->tim_sh_touki - 1, TRUE); + (void)set_tim_sh_force(creature_ptr, creature_ptr->tim_sh_touki - 1, TRUE); } if (creature_ptr->tim_sh_fire) { diff --git a/src/mind/mind-force-trainer.c b/src/mind/mind-force-trainer.c index 118cd950b..f79880548 100644 --- a/src/mind/mind-force-trainer.c +++ b/src/mind/mind-force-trainer.c @@ -96,3 +96,44 @@ void set_lightspeed(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) creature_ptr->update |= (PU_BONUS); handle_stuff(creature_ptr); } + +/*! + * @brief 一時的闘気のオーラの継続時間をセットする / Set "tim_sh_touki", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_tim_sh_force(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + + if (creature_ptr->is_dead) + return FALSE; + + if (v) { + if (creature_ptr->tim_sh_touki && !do_dec) { + if (creature_ptr->tim_sh_touki > v) + return FALSE; + } else if (!creature_ptr->tim_sh_touki) { + msg_print(_("体が闘気のオーラで覆われた。", "You are enveloped by an aura of the Force!")); + notice = TRUE; + } + } else { + if (creature_ptr->tim_sh_touki) { + msg_print(_("闘気が消えた。", "The aura of the Force disappeared.")); + notice = TRUE; + } + } + + creature_ptr->tim_sh_touki = v; + creature_ptr->redraw |= (PR_STATUS); + + if (!notice) + return FALSE; + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} diff --git a/src/mind/mind-force-trainer.h b/src/mind/mind-force-trainer.h index 1530296d5..800c7d318 100644 --- a/src/mind/mind-force-trainer.h +++ b/src/mind/mind-force-trainer.h @@ -6,3 +6,4 @@ MAGIC_NUM1 get_current_ki(player_type *caster_ptr); void set_current_ki(player_type *caster_ptr, bool is_reset, MAGIC_NUM1 ki); bool clear_mind(player_type *creature_ptr); void set_lightspeed(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_tim_sh_force(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); diff --git a/src/mind/mind.c b/src/mind/mind.c index d156aa99a..b45e706d0 100644 --- a/src/mind/mind.c +++ b/src/mind/mind.c @@ -1260,7 +1260,7 @@ static bool cast_force_spell(player_type *caster_ptr, int spell) else return TRUE; break; case 6: - set_tim_sh_touki(caster_ptr, randint1(plev / 2) + 15 + boost / 7, FALSE); + set_tim_sh_force(caster_ptr, randint1(plev / 2) + 15 + boost / 7, FALSE); break; case 7: return shock_power(caster_ptr); diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 8704af7c3..14850b468 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -199,7 +199,7 @@ void dispel_player(player_type *creature_ptr) (void)set_tim_regen(creature_ptr, 0, TRUE); (void)set_tim_stealth(creature_ptr, 0, TRUE); (void)set_tim_levitation(creature_ptr, 0, TRUE); - (void)set_tim_sh_touki(creature_ptr, 0, TRUE); + (void)set_tim_sh_force(creature_ptr, 0, TRUE); (void)set_tim_sh_fire(creature_ptr, 0, TRUE); (void)set_tim_sh_holy(creature_ptr, 0, TRUE); (void)set_tim_eyeeye(creature_ptr, 0, TRUE); @@ -529,47 +529,6 @@ bool set_tim_regen(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) } /*! - * @brief 一時的闘気のオーラの継続時間をセットする / Set "tim_sh_touki", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_tim_sh_touki(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - - if (creature_ptr->is_dead) - return FALSE; - - if (v) { - if (creature_ptr->tim_sh_touki && !do_dec) { - if (creature_ptr->tim_sh_touki > v) - return FALSE; - } else if (!creature_ptr->tim_sh_touki) { - msg_print(_("体が闘気のオーラで覆われた。", "You are enveloped by an aura of the Force!")); - notice = TRUE; - } - } else { - if (creature_ptr->tim_sh_touki) { - msg_print(_("闘気が消えた。", "The aura of the Force disappeared.")); - notice = TRUE; - } - } - - creature_ptr->tim_sh_touki = v; - creature_ptr->redraw |= (PR_STATUS); - - if (!notice) - return FALSE; - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! * @brief 一時的火炎のオーラの継続時間をセットする / Set "tim_sh_fire", notice observable changes * @param v 継続時間 * @param do_dec 現在の継続時間より長い値のみ上書きする diff --git a/src/player/player-effects.h b/src/player/player-effects.h index b19a62df4..bccf6cdb9 100644 --- a/src/player/player-effects.h +++ b/src/player/player-effects.h @@ -9,7 +9,6 @@ bool set_shero(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_protevil(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_invuln(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_regen(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_tim_sh_touki(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_sh_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_sh_holy(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_eyeeye(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -- 2.11.0