OSDN Git Service

[Refactor] モンスターの限界最大HP(30000)がマジックナンバーになっていたのを constexpr int に変更
authorDeskull <61610939+sikabane-works@users.noreply.github.com>
Sat, 23 Oct 2021 13:10:17 +0000 (22:10 +0900)
committerDeskull <61610939+sikabane-works@users.noreply.github.com>
Sun, 31 Oct 2021 08:49:48 +0000 (17:49 +0900)
src/effect/effect-monster-oldies.cpp
src/load/old/load-v1-5-0.cpp
src/monster-floor/one-monster-placer.cpp
src/monster/monster-list.cpp
src/monster/monster-status.cpp
src/mspell/mspell-damage-calculator.cpp
src/system/monster-type-definition.h
src/view/display-lore-status.cpp

index a505a32..644ca85 100644 (file)
@@ -129,9 +129,6 @@ static void effect_monster_old_heal_recovery(player_type *player_ptr, effect_mon
     }
 }
 
-/*!
- * @todo サーペントのHPがマジックナンバー扱いになっている
- */
 process_result effect_monster_old_heal(player_type *player_ptr, effect_monster_type *em_ptr)
 {
     if (em_ptr->seen)
@@ -140,7 +137,7 @@ process_result effect_monster_old_heal(player_type *player_ptr, effect_monster_t
     /* Wake up */
     (void)set_monster_csleep(player_ptr, em_ptr->g_ptr->m_idx, 0);
     effect_monster_old_heal_recovery(player_ptr, em_ptr);
-    if (em_ptr->m_ptr->hp < 30000)
+    if (em_ptr->m_ptr->hp < MONSTER_MAXHP)
         em_ptr->m_ptr->hp += em_ptr->dam;
     if (em_ptr->m_ptr->hp > em_ptr->m_ptr->maxhp)
         em_ptr->m_ptr->hp = em_ptr->m_ptr->maxhp;
index 86fdeb3..bb003fe 100644 (file)
@@ -253,7 +253,7 @@ void rd_item_old(object_type *o_ptr)
             else
                 o_ptr->xtra5 = damroll(r_info[o_ptr->pval].hdice, r_info[o_ptr->pval].hside);
             if (ironman_nightmare) {
-                o_ptr->xtra5 = std::min<short>(30000, o_ptr->xtra5 * 2L);
+                o_ptr->xtra5 = std::min<short>(MONSTER_MAXHP, o_ptr->xtra5 * 2L);
             }
             o_ptr->xtra4 = o_ptr->xtra5;
         }
index 822cfc6..10b4465 100644 (file)
@@ -342,7 +342,7 @@ bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
 
     if (ironman_nightmare) {
         auto hp = m_ptr->max_maxhp * 2;
-        m_ptr->max_maxhp = std::min(30000, hp);
+        m_ptr->max_maxhp = std::min(MONSTER_MAXHP, hp);
     }
 
     m_ptr->maxhp = m_ptr->max_maxhp;
index d951aa9..7157cc5 100644 (file)
@@ -361,7 +361,7 @@ void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, M
 
     if (ironman_nightmare) {
         auto hp = m_ptr->max_maxhp * 2;
-        m_ptr->max_maxhp = std::min(30000, hp);
+        m_ptr->max_maxhp = std::min(MONSTER_MAXHP, hp);
     }
 
     m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
index 62ffceb..d1a644d 100644 (file)
@@ -455,7 +455,7 @@ void monster_gain_exp(player_type *player_ptr, MONSTER_IDX m_idx, MONRACE_IDX s_
     m_ptr->max_maxhp = any_bits(r_ptr->flags1, RF1_FORCE_MAXHP) ? maxroll(r_ptr->hdice, r_ptr->hside) : damroll(r_ptr->hdice, r_ptr->hside);
     if (ironman_nightmare) {
         auto hp = m_ptr->max_maxhp * 2;
-        m_ptr->max_maxhp = std::min(30000, hp);
+        m_ptr->max_maxhp = std::min(MONSTER_MAXHP, hp);
     }
 
     m_ptr->maxhp = m_ptr->max_maxhp;
index 842ab8b..ff5643b 100644 (file)
@@ -480,7 +480,7 @@ HIT_POINT monspell_race_damage(player_type *player_ptr, RF_ABILITY ms_type, MONR
     int shoot_dd, shoot_ds;
 
     monspell_shoot_dice(r_ptr, &shoot_dd, &shoot_ds);
-    return monspell_damage_base(player_ptr, ms_type, std::min(30000, hp), rlev, powerful, shoot_dd, shoot_ds, 0, TYPE);
+    return monspell_damage_base(player_ptr, ms_type, std::min(MONSTER_MAXHP, hp), rlev, powerful, shoot_dd, shoot_ds, 0, TYPE);
 }
 
 /*!
index c301ef8..90e9ece 100644 (file)
@@ -13,6 +13,8 @@
  * The "hold_o_idx" field points to the first object of a stack
  * of objects (if any) being carried by the monster (see above).
  */
+constexpr int MONSTER_MAXHP = 30000; //!< モンスターの最大HP
+
 struct floor_type;
 struct monster_race;
 typedef struct monster_type {
index 6bcffec..4c83d04 100644 (file)
@@ -9,6 +9,7 @@
 #include "monster-race/race-flags3.h"
 #include "monster-race/race-flags7.h"
 #include "system/monster-race-definition.h"
+#include "system/monster-type-definition.h"
 #include "term/term-color-types.h"
 
 void display_monster_hp_ac(lore_type *lore_ptr)
@@ -19,7 +20,7 @@ void display_monster_hp_ac(lore_type *lore_ptr)
     hooked_roff(format(_("%^sは AC%d の防御力と", "%^s has an armor rating of %d"), Who::who(lore_ptr->msex), lore_ptr->r_ptr->ac));
     if ((lore_ptr->flags1 & RF1_FORCE_MAXHP) || (lore_ptr->r_ptr->hside == 1)) {
         auto hp = lore_ptr->r_ptr->hdice * (lore_ptr->nightmare ? 2 : 1) * lore_ptr->r_ptr->hside;
-        hooked_roff(format(_(" %d の体力がある。", " and a life rating of %d.  "), std::min(30000, hp)));
+        hooked_roff(format(_(" %d の体力がある。", " and a life rating of %d.  "), std::min(MONSTER_MAXHP, hp)));
     } else {
         hooked_roff(format(
             _(" %dd%d の体力がある。", " and a life rating of %dd%d.  "), lore_ptr->r_ptr->hdice * (lore_ptr->nightmare ? 2 : 1), lore_ptr->r_ptr->hside));