From 4d909d9b3067082f7c13f297f0d56103d2eb21b8 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 12 Sep 2021 00:04:51 +0900 Subject: [PATCH] [Refactor] #1473 Replaced casting_hex_num() to get_casting_num() --- src/player-status/player-stealth.cpp | 11 ++++++++--- src/realm/realm-hex.cpp | 10 +++++++--- src/spell-realm/spells-hex.cpp | 5 +++++ src/spell-realm/spells-hex.h | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/player-status/player-stealth.cpp b/src/player-status/player-stealth.cpp index e103961af..43b790e09 100644 --- a/src/player-status/player-stealth.cpp +++ b/src/player-status/player-stealth.cpp @@ -113,14 +113,19 @@ int16_t PlayerStealth::time_effect_value() { int16_t result = 0; if (this->player_ptr->realm1 == REALM_HEX) { - if (SpellHex(this->player_ptr).is_spelling_any()) - result -= (1 + casting_hex_num(this->player_ptr)); + SpellHex spell_hex(this->player_ptr); + if (spell_hex.is_spelling_any()) { + result -= spell_hex.get_casting_num() + 1; + } } + if (is_shero(this->player_ptr)) { result -= 7; } - if (is_time_limit_stealth(this->player_ptr)) + + if (is_time_limit_stealth(this->player_ptr)) { result += 999; + } return result; } diff --git a/src/realm/realm-hex.cpp b/src/realm/realm-hex.cpp index c661749b2..8e213dbff 100644 --- a/src/realm/realm-hex.cpp +++ b/src/realm/realm-hex.cpp @@ -679,11 +679,15 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m if (!flag) { msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(player_ptr, REALM_HEX, HEX_RESTORE, SPELL_NAME)); - SpellHex(player_ptr).reset_casting_flag(HEX_RESTORE); - if (cont) + SpellHex spell_hex(player_ptr); + spell_hex.reset_casting_flag(HEX_RESTORE); + if (cont) { casting_hex_num(player_ptr)--; - if (casting_hex_num(player_ptr)) + } + + if (spell_hex.get_casting_num() > 0) { player_ptr->action = ACTION_NONE; + } player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); player_ptr->redraw |= (PR_EXTRA); diff --git a/src/spell-realm/spells-hex.cpp b/src/spell-realm/spells-hex.cpp index eda85e0ef..226d5cc14 100644 --- a/src/spell-realm/spells-hex.cpp +++ b/src/spell-realm/spells-hex.cpp @@ -450,3 +450,8 @@ void SpellHex::reset_casting_flag(spell_hex_type type) reset_bits(value, 1U << type); this->player_ptr->magic_num1[0] = value; } + +int32_t SpellHex::get_casting_num() const +{ + return this->player_ptr->magic_num2[0]; +} diff --git a/src/spell-realm/spells-hex.h b/src/spell-realm/spells-hex.h index ce0657130..f99fcff25 100644 --- a/src/spell-realm/spells-hex.h +++ b/src/spell-realm/spells-hex.h @@ -25,6 +25,7 @@ public: void thief_teleport(); void set_casting_flag(spell_hex_type type); void reset_casting_flag(spell_hex_type type); + int32_t get_casting_num() const; private: player_type *player_ptr; -- 2.11.0