OSDN Git Service

[Refactor] #963 Moved calculate_upkeep() from player-status.h to pet-util.h
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Wed, 28 Apr 2021 15:41:36 +0000 (00:41 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Thu, 29 Apr 2021 09:39:41 +0000 (18:39 +0900)
src/dungeon/dungeon-processor.cpp
src/effect/effect-monster-charm.cpp
src/hpmp/hp-mp-processor.cpp
src/knowledge/knowledge-monsters.cpp
src/pet/pet-util.cpp
src/pet/pet-util.h
src/player/player-status.cpp
src/player/player-status.h
src/specific-object/monster-ball.cpp

index 42f4f02..7860c06 100644 (file)
@@ -29,6 +29,7 @@
 #include "monster/monster-processor.h"
 #include "monster/monster-status.h"
 #include "monster/monster-util.h"
+#include "pet/pet-util.h"
 #include "player/player-status.h"
 #include "player/special-defense-types.h"
 #include "realm/realm-song-numbers.h"
index 1cb5b8f..a477547 100644 (file)
@@ -17,8 +17,8 @@
 #include "monster/monster-status.h"
 #include "object-enchant/trc-types.h"
 #include "pet/pet-fall-off.h"
+#include "pet/pet-util.h"
 #include "player-info/avatar.h"
-#include "player/player-status.h"
 #include "player/player-status-flags.h"
 #include "util/bit-flags-calculator.h"
 #include "spell/spells-diceroll.h"
index d9cf3ed..01ee1ec 100644 (file)
@@ -16,6 +16,7 @@
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
 #include "object/object-flags.h"
+#include "pet/pet-util.h"
 #include "player-info/avatar.h"
 #include "player/attack-defense-types.h"
 #include "player/digestion-processor.h"
index c70c058..38a63d7 100644 (file)
@@ -25,7 +25,7 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
 #include "monster/smart-learn-types.h"
-#include "player/player-status.h"
+#include "pet/pet-util.h"
 #include "system/floor-type-definition.h"
 #include "system/monster-race-definition.h"
 #include "system/monster-type-definition.h"
index c339b77..468cc94 100644 (file)
@@ -2,8 +2,17 @@
 #include "core/player-update-types.h"
 #include "core/stuff-handler.h"
 #include "grid/grid.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags1.h"
+#include "monster-race/race-flags7.h"
 #include "monster/monster-info.h"
+#include "monster/monster-status.h"
+#include "player/player-class.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-race-definition.h"
+#include "system/monster-type-definition.h"
 #include "system/player-type-definition.h"
+#include "util/bit-flags-calculator.h"
 #include "world/world.h"
 
 int total_friends = 0;
@@ -49,3 +58,54 @@ bool can_player_ride_pet(player_type *creature_ptr, grid_type *g_ptr, bool now_r
     current_world_ptr->character_xtra = old_character_xtra;
     return p_can_enter;
 }
+
+/*!
+ * @brief ペットの維持コスト計算
+ * @return 維持コスト(%)
+ */
+PERCENTAGE calculate_upkeep(player_type *creature_ptr)
+{
+    MONSTER_IDX m_idx;
+    bool has_a_unique = FALSE;
+    DEPTH total_friend_levels = 0;
+
+    total_friends = 0;
+
+    for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
+        monster_type *m_ptr;
+        monster_race *r_ptr;
+
+        m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
+        if (!monster_is_valid(m_ptr))
+            continue;
+        r_ptr = &r_info[m_ptr->r_idx];
+
+        if (is_pet(m_ptr)) {
+            total_friends++;
+            if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
+                if (creature_ptr->pclass == CLASS_CAVALRY) {
+                    if (creature_ptr->riding == m_idx)
+                        total_friend_levels += (r_ptr->level + 5) * 2;
+                    else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
+                        total_friend_levels += (r_ptr->level + 5) * 7 / 2;
+                    else
+                        total_friend_levels += (r_ptr->level + 5) * 10;
+                    has_a_unique = TRUE;
+                } else
+                    total_friend_levels += (r_ptr->level + 5) * 10;
+            } else
+                total_friend_levels += r_ptr->level;
+        }
+    }
+
+    if (total_friends) {
+        int upkeep_factor;
+        upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
+        if (upkeep_factor < 0)
+            upkeep_factor = 0;
+        if (upkeep_factor > 1000)
+            upkeep_factor = 1000;
+        return upkeep_factor;
+    } else
+        return 0;
+}
index 78db99b..0bf145f 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "system/angband.h"
+
 enum pet_command {
        PET_DISMISS = 1, /*!< ペットに関するコマンド: ペットを離す */
     PET_TARGET = 2, /*!< ペットに関するコマンド: ペットのターゲットを指定 */
@@ -43,3 +45,4 @@ extern int total_friends;
 typedef struct grid_type grid_type;
 typedef struct player_type player_type;
 bool can_player_ride_pet(player_type *creature_ptr, grid_type *g_ptr, bool now_riding);
+PERCENTAGE calculate_upkeep(player_type *creature_ptr);
index 84b8546..67511eb 100644 (file)
@@ -3219,57 +3219,6 @@ void stop_mouth(player_type *caster_ptr)
         stop_hex_spell_all(caster_ptr);
 }
 
-/*!
- * @brief ペットの維持コスト計算
- * @return 維持コスト(%)
- */
-PERCENTAGE calculate_upkeep(player_type *creature_ptr)
-{
-    MONSTER_IDX m_idx;
-    bool has_a_unique = FALSE;
-    DEPTH total_friend_levels = 0;
-
-    total_friends = 0;
-
-    for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
-        monster_type *m_ptr;
-        monster_race *r_ptr;
-
-        m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
-        if (!monster_is_valid(m_ptr))
-            continue;
-        r_ptr = &r_info[m_ptr->r_idx];
-
-        if (is_pet(m_ptr)) {
-            total_friends++;
-            if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
-                if (creature_ptr->pclass == CLASS_CAVALRY) {
-                    if (creature_ptr->riding == m_idx)
-                        total_friend_levels += (r_ptr->level + 5) * 2;
-                    else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
-                        total_friend_levels += (r_ptr->level + 5) * 7 / 2;
-                    else
-                        total_friend_levels += (r_ptr->level + 5) * 10;
-                    has_a_unique = TRUE;
-                } else
-                    total_friend_levels += (r_ptr->level + 5) * 10;
-            } else
-                total_friend_levels += r_ptr->level;
-        }
-    }
-
-    if (total_friends) {
-        int upkeep_factor;
-        upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
-        if (upkeep_factor < 0)
-            upkeep_factor = 0;
-        if (upkeep_factor > 1000)
-            upkeep_factor = 1000;
-        return upkeep_factor;
-    } else
-        return 0;
-}
-
 bool music_singing(player_type *caster_ptr, int music_songs)
 {
     return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);
index 1a35eb8..2f6cb53 100644 (file)
@@ -49,7 +49,6 @@ bool is_echizen(player_type *creature_ptr);
 bool is_in_dungeon(player_type *creature_ptr);
 
 void stop_mouth(player_type *caster_ptr);
-PERCENTAGE calculate_upkeep(player_type *creature_ptr);
 bool music_singing(player_type *caster_ptr, int music_songs);
 bool music_singing_any(player_type *creature_ptr);
 
index 965a113..01c6b49 100644 (file)
@@ -8,7 +8,7 @@
 #include "monster/monster-info.h"
 #include "monster/monster-util.h"
 #include "object-activation/activation-util.h"
-#include "player/player-status.h"
+#include "pet/pet-util.h"
 #include "racial/racial-android.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell/spell-types.h"