OSDN Git Service

[Refactor] #1473 Replaced casting_hex_num() to get_casting_num()
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Sat, 11 Sep 2021 15:04:51 +0000 (00:04 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Tue, 14 Sep 2021 14:07:49 +0000 (23:07 +0900)
src/player-status/player-stealth.cpp
src/realm/realm-hex.cpp
src/spell-realm/spells-hex.cpp
src/spell-realm/spells-hex.h

index e103961..43b790e 100644 (file)
@@ -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;
 }
index c661749..8e213db 100644 (file)
@@ -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);
index eda85e0..226d5cc 100644 (file)
@@ -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];
+}
index ce06571..f99fcff 100644 (file)
@@ -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;