From b140fe5c6fd87e26cf2c639ded45d25c3c7861df Mon Sep 17 00:00:00 2001 From: dis- Date: Tue, 27 Apr 2021 18:31:36 +0900 Subject: [PATCH 1/1] =?utf8?q?[Refactor]=20=E8=B5=A4=E5=A4=96=E7=B7=9A?= =?utf8?q?=E8=A6=96=E5=8A=9B=E7=AE=A1=E7=90=86=E3=82=AF=E3=83=A9=E3=82=B9?= =?utf8?q?=20PlayerInfravision=E3=81=AE=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PlayerStatusBaseの派生クラスの実装を進める。 赤外線視力の処理を分離。 --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 +++ src/Makefile.am | 2 + src/player-status/player-infravision.cpp | 67 ++++++++++++++++++++++++++++++ src/player-status/player-infravision.h | 14 +++++++ src/player/player-status-flags.cpp | 36 ++-------------- src/player/player-status.cpp | 53 ++--------------------- 7 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 src/player-status/player-infravision.cpp create mode 100644 src/player-status/player-infravision.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 64d46d709..cee6806ad 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -421,6 +421,7 @@ + @@ -1109,6 +1110,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 73c5590f1..6a40f6ce7 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2189,6 +2189,9 @@ player-status + + player-status + player-status @@ -4763,6 +4766,9 @@ player-status + + player-status + player-status diff --git a/src/Makefile.am b/src/Makefile.am index 0197dcd2b..c1184b2e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -636,6 +636,7 @@ hengband_SOURCES = \ player-status/player-status-base.h \ player-status/player-speed.h \ player-status/player-stealth.h \ + player-status/player-infravision.h \ player-status/player-basic-statistics.h \ player-status/player-strength.h \ player-status/player-intelligence.h \ @@ -646,6 +647,7 @@ hengband_SOURCES = \ player-status/player-status-base.cpp \ player-status/player-speed.cpp \ player-status/player-stealth.cpp \ + player-status/player-infravision.cpp \ player-status/player-basic-statistics.cpp \ player-status/player-strength.cpp \ player-status/player-intelligence.cpp \ diff --git a/src/player-status/player-infravision.cpp b/src/player-status/player-infravision.cpp new file mode 100644 index 000000000..9ced307a6 --- /dev/null +++ b/src/player-status/player-infravision.cpp @@ -0,0 +1,67 @@ +#include "player-status/player-infravision.h" +#include "mutation/mutation-flag-types.h" +#include "player/mimic-info-table.h" +#include "player/player-race-types.h" +#include "player/race-info-table.h" +#include "system/player-type-definition.h" +/* + * @brief 赤外線視力 - 初期値、下限、上限 + */ +void PlayerInfravision::set_locals() +{ + this->default_value = 0; + this->min_value = 0; + this->max_value = 20; + this->tr_flag = TR_INFRA; + this->tr_bad_flag = TR_INFRA; +} + +/*! + * @brief 赤外線視力計算 - 種族 + * @return 赤外線視力の増分 + * @details + * * 種族による加算 + */ +s16b PlayerInfravision::race_value() +{ + const player_race *tmp_rp_ptr; + + if (this->owner_ptr->mimic_form) + tmp_rp_ptr = &mimic_info[this->owner_ptr->mimic_form]; + else + tmp_rp_ptr = &race_info[this->owner_ptr->prace]; + + return tmp_rp_ptr->infra; +} + +/*! + * @brief 赤外線視力計算 - 変異 + * @return 赤外線視力の増分 + * @details + * * 変異MUT3_INFRAVISによる加算(+3) + */ +s16b PlayerInfravision::mutation_value() +{ + s16b result = 0; + if (this->owner_ptr->muta.has(MUTA::INFRAVIS)) { + result += 3; + } + + return result; +} + +/*! + * @brief 赤外線視力計算 - 一時効果 + * @return 赤外線視力の増分 + * @details + * * 魔法効果tim_infraによる加算(+3) + */ +s16b PlayerInfravision::time_effect_value() +{ + s16b result = 0; + if (this->owner_ptr->tim_infra) { + result += 3; + } + + return result; +} diff --git a/src/player-status/player-infravision.h b/src/player-status/player-infravision.h new file mode 100644 index 000000000..5bc2344bb --- /dev/null +++ b/src/player-status/player-infravision.h @@ -0,0 +1,14 @@ +#pragma once +#include "player-status/player-status-base.h" + +class PlayerInfravision : public PlayerStatusBase { +public: + using PlayerStatusBase::PlayerStatusBase; + PlayerInfravision() = delete; + +protected: + void set_locals() override; + s16b race_value() override; + s16b time_effect_value() override; + s16b mutation_value() override; +}; diff --git a/src/player/player-status-flags.cpp b/src/player/player-status-flags.cpp index 560b77440..f3c34ad9c 100644 --- a/src/player/player-status-flags.cpp +++ b/src/player/player-status-flags.cpp @@ -14,6 +14,7 @@ #include "object-hook/hook-weapon.h" #include "object/object-flags.h" #include "player-status/player-basic-statistics.h" +#include "player-status/player-infravision.h" #include "player-status/player-speed.h" #include "player-status/player-stealth.h" #include "player/attack-defense-types.h" @@ -172,7 +173,7 @@ BIT_FLAGS get_player_flags(player_type *creature_ptr, tr_type tr_flag) case TR_SEARCH: return 0; case TR_INFRA: - return has_infra_vision(creature_ptr); + return PlayerInfravision(creature_ptr).get_all_flags(); case TR_TUNNEL: return 0; case TR_SPEED: @@ -273,7 +274,7 @@ BIT_FLAGS get_player_flags(player_type *creature_ptr, tr_type tr_flag) return has_resist_time(creature_ptr); case TR_RES_WATER: return has_resist_water(creature_ptr); - case TR_RES_CURSE : + case TR_RES_CURSE: return has_resist_curse(creature_ptr); case TR_SH_FIRE: @@ -480,35 +481,6 @@ BIT_FLAGS has_xtra_might(player_type *creature_ptr) } /*! - * @brief クリーチャーが赤外線視力修正を持っているかを返す。 - * @param creature_ptr 判定対象のクリーチャー参照ポインタ - * @return 持っていたら所持前提ビットフラグを返す。 - * @details 種族修正は0より大きければTRUEとする。 - */ -BIT_FLAGS has_infra_vision(player_type *creature_ptr) -{ - BIT_FLAGS result = 0L; - const player_race *tmp_rp_ptr; - - if (creature_ptr->mimic_form) - tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form]; - else - tmp_rp_ptr = &race_info[creature_ptr->prace]; - - if (tmp_rp_ptr->infra > 0) - result |= FLAG_CAUSE_RACE; - - if (creature_ptr->muta.has(MUTA::INFRAVIS)) - result |= FLAG_CAUSE_MUTATION; - - if (creature_ptr->tim_infra) - result |= FLAG_CAUSE_MAGIC_TIME_EFFECT; - - result |= check_equipment_flags(creature_ptr, TR_INFRA); - return result; -} - -/*! * @brief クリーチャーが邪悪感知を持っているかを返す。 * @param creature_ptr 判定対象のクリーチャー参照ポインタ * @return 持っていたら所持前提ビットフラグを返す。 @@ -1597,7 +1569,7 @@ BIT_FLAGS has_resist_dark(player_type *creature_ptr) BIT_FLAGS result = 0L; if (player_race_has_flag(creature_ptr, TR_RES_DARK)) - result |= FLAG_CAUSE_RACE; + result |= FLAG_CAUSE_RACE; if (creature_ptr->special_defense & KATA_MUSOU) { result |= FLAG_CAUSE_BATTLE_FORM; diff --git a/src/player/player-status.cpp b/src/player/player-status.cpp index 7eea6c347..6b5e068f6 100644 --- a/src/player/player-status.cpp +++ b/src/player/player-status.cpp @@ -62,6 +62,7 @@ #include "pet/pet-util.h" #include "player-info/avatar.h" #include "player-status/player-basic-statistics.h" +#include "player-status/player-infravision.h" #include "player-status/player-speed.h" #include "player-status/player-stealth.h" #include "player/attack-defense-types.h" @@ -96,9 +97,9 @@ #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/floor-type-definition.h" -#include "system/object-type-definition.h" #include "system/monster-race-definition.h" #include "system/monster-type-definition.h" +#include "system/object-type-definition.h" #include "system/player-type-definition.h" #include "term/screen-processor.h" #include "util/bit-flags-calculator.h" @@ -109,7 +110,6 @@ static bool is_martial_arts_mode(player_type *creature_ptr); -static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr); static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr); static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr); static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr); @@ -427,7 +427,7 @@ static void update_bonuses(player_type *creature_ptr) } creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value(); - creature_ptr->see_infra = calc_intra_vision(creature_ptr); + creature_ptr->see_infra = PlayerInfravision(creature_ptr).get_value(); creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value(); creature_ptr->skill_dis = calc_disarming(creature_ptr); creature_ptr->skill_dev = calc_device_ability(creature_ptr); @@ -1027,7 +1027,7 @@ static void update_max_mana(player_type *creature_ptr) case CLASS_MAGE: case CLASS_HIGH_MAGE: case CLASS_BLUE_MAGE: - case CLASS_ELEMENTALIST: { + case CLASS_ELEMENTALIST: { msp -= msp * (cur_wgt - max_wgt) / 600; break; } @@ -1175,50 +1175,6 @@ s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr) } /*! - * @brief 赤外線視力計算 - * @param creature_ptr 計算するクリーチャーの参照ポインタ - * @return 赤外線視力 - * @details - * * 種族による加算 - * * 変異MUT3_INFRAVISによる加算(+3) - * * 魔法効果tim_infraによる加算(+3) - * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1) - */ -static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr) -{ - ACTION_SKILL_POWER pow; - const player_race *tmp_rp_ptr; - - if (creature_ptr->mimic_form) - tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form]; - else - tmp_rp_ptr = &race_info[creature_ptr->prace]; - - pow = tmp_rp_ptr->infra; - - if (creature_ptr->muta.has(MUTA::INFRAVIS)) { - pow += 3; - } - - if (creature_ptr->tim_infra) { - pow += 3; - } - - for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) { - object_type *o_ptr; - BIT_FLAGS flgs[TR_FLAG_SIZE]; - o_ptr = &creature_ptr->inventory_list[i]; - if (!o_ptr->k_idx) - continue; - object_flags(creature_ptr, o_ptr, flgs); - if (has_flag(flgs, TR_INFRA)) - pow += o_ptr->pval; - } - - return pow; -} - -/*! * @brief 解除能力計算 * @param creature_ptr 計算するクリーチャーの参照ポインタ * @return 解除能力 @@ -1993,7 +1949,6 @@ s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot) return (s16b)penalty; } - static bool is_riding_two_hands(player_type *creature_ptr) { if (!creature_ptr->riding) { -- 2.11.0