OSDN Git Service

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

index 8e213db..d6cf9d6 100644 (file)
@@ -592,8 +592,9 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m
 
             if ((!o_ptr->k_idx) || (!o_ptr->is_cursed())) {
                 exe_spell(player_ptr, REALM_HEX, spell, SPELL_STOP);
-                SpellHex(player_ptr).reset_casting_flag(spell);
-                casting_hex_num(player_ptr)--;
+                SpellHex spell_hex(player_ptr);
+                spell_hex.reset_casting_flag(spell);
+                spell_hex.add_casting_num(false);
                 if (get_singing_song_id(player_ptr) == 0)
                     set_action(player_ptr, ACTION_NONE);
             }
@@ -682,7 +683,7 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m
                 SpellHex spell_hex(player_ptr);
                 spell_hex.reset_casting_flag(HEX_RESTORE);
                 if (cont) {
-                    casting_hex_num(player_ptr)--;
+                    spell_hex.add_casting_num(false);
                 }
 
                 if (spell_hex.get_casting_num() > 0) {
@@ -887,7 +888,7 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m
     if (cast && add) {
         SpellHex spell_hex(player_ptr);
         spell_hex.set_casting_flag(spell);
-        casting_hex_num(player_ptr)++;
+        spell_hex.add_casting_num(true);
 
         if (player_ptr->action != ACTION_SPELL)
             set_action(player_ptr, ACTION_SPELL);
index 226d5cc..c60c488 100644 (file)
@@ -103,7 +103,7 @@ bool SpellHex::stop_one_spell()
         auto n = this->casting_spells[A2I(choice)];
         exe_spell(this->player_ptr, REALM_HEX, n, SPELL_STOP);
         this->reset_casting_flag(static_cast<spell_hex_type>(n));
-        casting_hex_num(this->player_ptr)--;
+        this->add_casting_num(false);
     }
 
     this->player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
@@ -455,3 +455,16 @@ int32_t SpellHex::get_casting_num() const
 {
     return this->player_ptr->magic_num2[0];
 }
+
+/*!
+ * @brief 詠唱番号の加減算を行う
+ * @param is_incremental 加算ならtrue、減算ならfalse
+ */
+void SpellHex::add_casting_num(bool is_incremental)
+{
+    if (is_incremental) {
+        this->player_ptr->magic_num2[0]++;
+    } else {
+        this->player_ptr->magic_num2[0]--;
+    }
+}
index f99fcff..53aedae 100644 (file)
@@ -26,6 +26,7 @@ public:
     void set_casting_flag(spell_hex_type type);
     void reset_casting_flag(spell_hex_type type);
     int32_t get_casting_num() const;
+    void add_casting_num(bool is_incremental);
 
 private:
     player_type *player_ptr;
@@ -43,7 +44,6 @@ private:
     void gain_exp_master(const int spell);
 };
 
-#define casting_hex_num(P_PTR) ((P_PTR)->magic_num2[0])
 #define hex_revenge_power(P_PTR) ((P_PTR)->magic_num1[2])
 #define hex_revenge_turn(P_PTR) ((P_PTR)->magic_num2[2])
 #define hex_revenge_type(P_PTR) ((P_PTR)->magic_num2[1])