OSDN Git Service

[Refactor] #40014 Separated check_procection_rune() from place_monster_one()
authorHourier <hourier@users.sourceforge.jp>
Sat, 13 Jun 2020 03:04:36 +0000 (12:04 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 13 Jun 2020 03:04:36 +0000 (12:04 +0900)
src/monster-floor/one-monster-placer.c

index d9b36f0..ff2ed3f 100644 (file)
@@ -92,7 +92,7 @@ static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_i
  * @brief ユニークが生成可能か評価する
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param r_idx 生成モンスター種族
- * @return ユニークの生成が不可能ならFALSE、それ以外はTRUE
+ * @return ユニークの生成が不可能な条件ならFALSE、それ以外はTRUE
  */
 static bool check_unique_placeable(player_type *player_ptr, MONRACE_IDX r_idx)
 {
@@ -127,7 +127,7 @@ static bool check_unique_placeable(player_type *player_ptr, MONRACE_IDX r_idx)
  * @brief クエスト内に生成可能か評価する
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param r_idx 生成モンスター種族
- * @return 生成が不可能ならFALSE、それ以外はTRUE
+ * @return 生成が可能ならTRUE、不可能ならFALSE
  */
 static bool check_quest_placeable(player_type *player_ptr, MONRACE_IDX r_idx)
 {
@@ -155,6 +155,34 @@ static bool check_quest_placeable(player_type *player_ptr, MONRACE_IDX r_idx)
 }
 
 /*!
+ * @brief 守りのルーン上にモンスターの配置を試みる
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param r_idx 生成モンスター種族
+ * @param y 生成位置y座標
+ * @param x 生成位置x座標
+ * @return 生成が可能ならTRUE、不可能ならFALSE
+ */
+static bool check_procection_rune(player_type *player_ptr, MONRACE_IDX r_idx, POSITION y, POSITION x)
+{
+    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    if (!is_glyph_grid(g_ptr))
+        return TRUE;
+
+    monster_race *r_ptr = &r_info[r_idx];
+    if (randint1(BREAK_GLYPH) >= (r_ptr->level + 20))
+        return FALSE;
+
+    if (g_ptr->info & CAVE_MARK)
+        msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
+
+    g_ptr->info &= ~(CAVE_MARK);
+    g_ptr->info &= ~(CAVE_OBJECT);
+    g_ptr->mimic = 0;
+    note_spot(player_ptr, y, x);
+    return TRUE;
+}
+
+/*!
  * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param who 召喚を行ったモンスターID
@@ -193,20 +221,8 @@ bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
     if (!check_quest_placeable(player_ptr, r_idx))
         return FALSE;
 
-    if (is_glyph_grid(g_ptr)) {
-        if (randint1(BREAK_GLYPH) < (r_ptr->level + 20)) {
-            if (g_ptr->info & CAVE_MARK) {
-                msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
-            }
-
-            g_ptr->info &= ~(CAVE_MARK);
-            g_ptr->info &= ~(CAVE_OBJECT);
-            g_ptr->mimic = 0;
-
-            note_spot(player_ptr, y, x);
-        } else
-            return FALSE;
-    }
+    if (!check_procection_rune(player_ptr, r_idx, y, x))
+        return FALSE;
 
     msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
     if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10))