From 979e3008222042869b9f3e33c5b27ae4b012ca2e Mon Sep 17 00:00:00 2001 From: Hourier Date: Tue, 30 Jun 2020 20:42:02 +0900 Subject: [PATCH] [Refactpr] #40466 Separated temporary-resistance.c/h player-effects.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 ++ src/Makefile.am | 1 + src/cmd-item/cmd-activate.c | 1 + src/core/magic-effects-timeout-reducer.c | 1 + src/mind/mind.c | 1 + src/player/player-effects.c | 153 +--------------------------- src/player/player-effects.h | 4 - src/realm/realm-demon.c | 1 + src/realm/realm-life.c | 1 + src/status/temporary-resistance.c | 158 +++++++++++++++++++++++++++++ src/status/temporary-resistance.h | 8 ++ 12 files changed, 181 insertions(+), 156 deletions(-) create mode 100644 src/status/temporary-resistance.c create mode 100644 src/status/temporary-resistance.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index c8143ce6a..f2f798b6f 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -237,6 +237,7 @@ + @@ -667,6 +668,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 6f1630d94..ce7de4790 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1520,6 +1520,9 @@ status + + status + @@ -3331,6 +3334,9 @@ status + + status + diff --git a/src/Makefile.am b/src/Makefile.am index 2968d00b8..ed41de079 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -558,6 +558,7 @@ hengband_SOURCES = \ status/buff-setter.c status/buff-setter.h \ status/element-resistance.c status/element-resistance.h \ status/sight-setter.c status/sight-setter.h \ + status/temporary-resistance.c status/temporary-resistance.h \ \ store/store.c store/store.h \ store/black-market.c store/black-market.h \ diff --git a/src/cmd-item/cmd-activate.c b/src/cmd-item/cmd-activate.c index 2fecd38e0..3c1ac5a49 100644 --- a/src/cmd-item/cmd-activate.c +++ b/src/cmd-item/cmd-activate.c @@ -80,6 +80,7 @@ #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" +#include "status/temporary-resistance.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-ring-types.h" #include "term/screen-processor.h" diff --git a/src/core/magic-effects-timeout-reducer.c b/src/core/magic-effects-timeout-reducer.c index 4893ed953..76638ecf9 100644 --- a/src/core/magic-effects-timeout-reducer.c +++ b/src/core/magic-effects-timeout-reducer.c @@ -9,6 +9,7 @@ #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" +#include "status/temporary-resistance.h" /*! * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理 diff --git a/src/mind/mind.c b/src/mind/mind.c index a1fdc625a..d156aa99a 100644 --- a/src/mind/mind.c +++ b/src/mind/mind.c @@ -66,6 +66,7 @@ #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" +#include "status/temporary-resistance.h" #include "term/screen-processor.h" #include "util/buffer-shaper.h" #include "util/int-char-converter.h" diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 18ff33791..8704af7c3 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -69,6 +69,7 @@ #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" +#include "status/temporary-resistance.h" #include "sv-definition/sv-armor-types.h" #include "sv-definition/sv-protector-types.h" #include "sv-definition/sv-weapon-types.h" @@ -528,48 +529,6 @@ bool set_tim_regen(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) } /*! - * @brief 一時的浮遊の継続時間をセットする / Set "tim_levitation", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_tim_levitation(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_levitation && !do_dec) { - if (creature_ptr->tim_levitation > v) - return FALSE; - } else if (!creature_ptr->tim_levitation) { - msg_print(_("体が宙に浮き始めた。", "You begin to fly!")); - notice = TRUE; - } - } else { - if (creature_ptr->tim_levitation) { - msg_print(_("もう宙に浮かべなくなった。", "You stop flying.")); - notice = TRUE; - } - } - - creature_ptr->tim_levitation = v; - creature_ptr->redraw |= (PR_STATUS); - - if (!notice) - return FALSE; - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - creature_ptr->update |= (PU_BONUS); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! * @brief 一時的闘気のオーラの継続時間をセットする / Set "tim_sh_touki", notice observable changes * @param v 継続時間 * @param do_dec 現在の継続時間より長い値のみ上書きする @@ -1581,113 +1540,3 @@ bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_pr return TRUE; } -bool set_ultimate_res(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->ult_res && !do_dec) { - if (creature_ptr->ult_res > v) - return FALSE; - } else if (!creature_ptr->ult_res) { - msg_print(_("あらゆることに対して耐性がついた気がする!", "You feel resistant!")); - notice = TRUE; - } - } - - else { - if (creature_ptr->ult_res) { - msg_print(_("あらゆることに対する耐性が薄れた気がする。", "You feel less resistant")); - notice = TRUE; - } - } - - creature_ptr->ult_res = v; - creature_ptr->redraw |= (PR_STATUS); - - if (!notice) - return FALSE; - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - creature_ptr->update |= (PU_BONUS); - handle_stuff(creature_ptr); - - return TRUE; -} - -bool set_tim_res_nether(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_res_nether && !do_dec) { - if (creature_ptr->tim_res_nether > v) - return FALSE; - } else if (!creature_ptr->tim_res_nether) { - msg_print(_("地獄の力に対して耐性がついた気がする!", "You feel nether resistant!")); - notice = TRUE; - } - } - - else { - if (creature_ptr->tim_res_nether) { - msg_print(_("地獄の力に対する耐性が薄れた気がする。", "You feel less nether resistant")); - notice = TRUE; - } - } - - creature_ptr->tim_res_nether = v; - creature_ptr->redraw |= (PR_STATUS); - - if (!notice) - return FALSE; - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - creature_ptr->update |= (PU_BONUS); - handle_stuff(creature_ptr); - return TRUE; -} - -bool set_tim_res_time(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_res_time && !do_dec) { - if (creature_ptr->tim_res_time > v) - return FALSE; - } else if (!creature_ptr->tim_res_time) { - msg_print(_("時間逆転の力に対して耐性がついた気がする!", "You feel time resistant!")); - notice = TRUE; - } - } else { - if (creature_ptr->tim_res_time) { - msg_print(_("時間逆転の力に対する耐性が薄れた気がする。", "You feel less time resistant")); - notice = TRUE; - } - } - - creature_ptr->tim_res_time = v; - creature_ptr->redraw |= (PR_STATUS); - if (!notice) - return FALSE; - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - creature_ptr->update |= (PU_BONUS); - handle_stuff(creature_ptr); - return TRUE; -} diff --git a/src/player/player-effects.h b/src/player/player-effects.h index a16368903..b19a62df4 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_levitation(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); @@ -33,9 +32,6 @@ void calc_android_exp(player_type *creature_ptr); void lose_exp(player_type *creature_ptr, s32b amount); bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_prob); void do_poly_self(player_type *creature_ptr); -bool set_ultimate_res(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_tim_res_nether(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_tim_res_time(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_wraith_form(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); void do_poly_wounds(player_type *creature_ptr); void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg); diff --git a/src/realm/realm-demon.c b/src/realm/realm-demon.c index 9322444e3..0c16da37e 100644 --- a/src/realm/realm-demon.c +++ b/src/realm/realm-demon.c @@ -22,6 +22,7 @@ #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" +#include "status/temporary-resistance.h" #include "view/display-messages.h" /*! diff --git a/src/realm/realm-life.c b/src/realm/realm-life.c index f8f1ddce8..6646f71d6 100644 --- a/src/realm/realm-life.c +++ b/src/realm/realm-life.c @@ -21,6 +21,7 @@ #include "status/bad-status-setter.h" #include "status/buff-setter.h" #include "status/element-resistance.h" +#include "status/temporary-resistance.h" /*! * @brief 生命領域魔法の各処理を行う diff --git a/src/status/temporary-resistance.c b/src/status/temporary-resistance.c new file mode 100644 index 000000000..647edd670 --- /dev/null +++ b/src/status/temporary-resistance.c @@ -0,0 +1,158 @@ +#include "status/temporary-resistance.h" +#include "core/stuff-handler.h" +#include "game-option/disturbance-options.h" +#include "player/player-move.h" +#include "view/display-messages.h" + +/*! + * @brief 一時的浮遊の継続時間をセットする / Set "tim_levitation", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_tim_levitation(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_levitation && !do_dec) { + if (creature_ptr->tim_levitation > v) + return FALSE; + } else if (!creature_ptr->tim_levitation) { + msg_print(_("体が宙に浮き始めた。", "You begin to fly!")); + notice = TRUE; + } + } else { + if (creature_ptr->tim_levitation) { + msg_print(_("もう宙に浮かべなくなった。", "You stop flying.")); + notice = TRUE; + } + } + + creature_ptr->tim_levitation = v; + creature_ptr->redraw |= (PR_STATUS); + + if (!notice) + return FALSE; + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + creature_ptr->update |= (PU_BONUS); + handle_stuff(creature_ptr); + return TRUE; +} + +bool set_ultimate_res(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->ult_res && !do_dec) { + if (creature_ptr->ult_res > v) + return FALSE; + } else if (!creature_ptr->ult_res) { + msg_print(_("あらゆることに対して耐性がついた気がする!", "You feel resistant!")); + notice = TRUE; + } + } + + else { + if (creature_ptr->ult_res) { + msg_print(_("あらゆることに対する耐性が薄れた気がする。", "You feel less resistant")); + notice = TRUE; + } + } + + creature_ptr->ult_res = v; + creature_ptr->redraw |= (PR_STATUS); + + if (!notice) + return FALSE; + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + creature_ptr->update |= (PU_BONUS); + handle_stuff(creature_ptr); + + return TRUE; +} + +bool set_tim_res_nether(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_res_nether && !do_dec) { + if (creature_ptr->tim_res_nether > v) + return FALSE; + } else if (!creature_ptr->tim_res_nether) { + msg_print(_("地獄の力に対して耐性がついた気がする!", "You feel nether resistant!")); + notice = TRUE; + } + } + + else { + if (creature_ptr->tim_res_nether) { + msg_print(_("地獄の力に対する耐性が薄れた気がする。", "You feel less nether resistant")); + notice = TRUE; + } + } + + creature_ptr->tim_res_nether = v; + creature_ptr->redraw |= (PR_STATUS); + + if (!notice) + return FALSE; + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + creature_ptr->update |= (PU_BONUS); + handle_stuff(creature_ptr); + return TRUE; +} + +bool set_tim_res_time(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_res_time && !do_dec) { + if (creature_ptr->tim_res_time > v) + return FALSE; + } else if (!creature_ptr->tim_res_time) { + msg_print(_("時間逆転の力に対して耐性がついた気がする!", "You feel time resistant!")); + notice = TRUE; + } + } else { + if (creature_ptr->tim_res_time) { + msg_print(_("時間逆転の力に対する耐性が薄れた気がする。", "You feel less time resistant")); + notice = TRUE; + } + } + + creature_ptr->tim_res_time = v; + creature_ptr->redraw |= (PR_STATUS); + if (!notice) + return FALSE; + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + creature_ptr->update |= (PU_BONUS); + handle_stuff(creature_ptr); + return TRUE; +} diff --git a/src/status/temporary-resistance.h b/src/status/temporary-resistance.h new file mode 100644 index 000000000..67182647c --- /dev/null +++ b/src/status/temporary-resistance.h @@ -0,0 +1,8 @@ +#pragma once + +#include "system/angband.h" + +bool set_tim_levitation(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_ultimate_res(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_tim_res_nether(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_tim_res_time(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -- 2.11.0