OSDN Git Service

[Refactor] #40275 Moved bounty-related functions from building.c/h to bounty.c/h
authorHourier <hourier@users.sourceforge.jp>
Wed, 20 May 2020 11:14:51 +0000 (20:14 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 20 May 2020 11:14:51 +0000 (20:14 +0900)
src/core/game-play.c
src/io/load.c
src/market/bounty.c
src/market/bounty.h
src/market/building.c
src/market/building.h
src/world/world-turn-processor.c

index 3e2ed71..01c80e9 100644 (file)
@@ -29,7 +29,7 @@
 #include "grid/grid.h"
 #include "io/write-diary.h"
 #include "market/arena-info-table.h"
-#include "market/building.h"
+#include "market/bounty.h"
 #include "market/store-util.h"
 #include "market/store.h"
 #include "object/object-flavor.h"
index aa1965b..09ec420 100644 (file)
@@ -87,6 +87,7 @@
 #include "cmd-smith.h"
 #include "birth/quick-start.h"
 #include "player/player-races-table.h"
+#include "market/bounty.h"
 
  /*
   * Maximum number of tries for selection of a proper quest monster
index 064868a..b3934e3 100644 (file)
@@ -6,6 +6,10 @@
 #include "object/object-flavor.h"
 #include "autopick/autopick.h"
 #include "core/stuff-handler.h"
+#include "term/gameterm.h"
+#include "market/building-util.h"
+#include "dungeon/dungeon.h"
+#include "monster/monsterrace-hook.h"
 
 /*!
  * @brief 賞金首の引き換え処理 / Get prize
@@ -159,3 +163,167 @@ bool exchange_cash(player_type *player_ptr)
     msg_print(NULL);
     return FALSE;
 }
+
+/*!
+ * @brief 本日の賞金首情報を表示する。
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void today_target(player_type *player_ptr)
+{
+    char buf[160];
+    monster_race *r_ptr = &r_info[today_mon];
+
+    clear_bldg(4, 18);
+    c_put_str(TERM_YELLOW, _("本日の賞金首", "Wanted monster that changes from day to day"), 5, 10);
+    sprintf(buf, _("ターゲット: %s", "target: %s"), r_name + r_ptr->name);
+    c_put_str(TERM_YELLOW, buf, 6, 10);
+    sprintf(buf, _("死体 ---- $%d", "corpse   ---- $%d"), (int)r_ptr->level * 50 + 100);
+    prt(buf, 8, 10);
+    sprintf(buf, _("骨   ---- $%d", "skeleton ---- $%d"), (int)r_ptr->level * 30 + 60);
+    prt(buf, 9, 10);
+    player_ptr->today_mon = today_mon;
+}
+
+/*!
+ * @brief ツチノコの賞金首情報を表示する。
+ * @return なし
+ */
+void tsuchinoko(void)
+{
+    clear_bldg(4, 18);
+    c_put_str(TERM_YELLOW, _("一獲千金の大チャンス!!!", "Big chance for quick money!!!"), 5, 10);
+    c_put_str(TERM_YELLOW, _("ターゲット:幻の珍獣「ツチノコ」", "target: the rarest animal 'Tsuchinoko'"), 6, 10);
+    c_put_str(TERM_WHITE, _("生け捕り ---- $1,000,000", "catch alive ---- $1,000,000"), 8, 10);
+    c_put_str(TERM_WHITE, _("死体     ----   $200,000", "corpse      ----   $200,000"), 9, 10);
+    c_put_str(TERM_WHITE, _("骨       ----   $100,000", "bones       ----   $100,000"), 10, 10);
+}
+
+/*!
+ * @brief 通常の賞金首情報を表示する。
+ * @return なし
+ */
+void show_bounty(void)
+{
+    TERM_LEN y = 0;
+
+    clear_bldg(4, 18);
+    prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"), 4, 10);
+    c_put_str(TERM_YELLOW, _("現在の賞金首", "Wanted monsters"), 6, 10);
+
+    for (int i = 0; i < MAX_BOUNTY; i++) {
+        byte color;
+        concptr done_mark;
+        monster_race *r_ptr = &r_info[(current_world_ptr->bounty_r_idx[i] > 10000 ? current_world_ptr->bounty_r_idx[i] - 10000 : current_world_ptr->bounty_r_idx[i])];
+
+        if (current_world_ptr->bounty_r_idx[i] > 10000) {
+            color = TERM_RED;
+            done_mark = _("(済)", "(done)");
+        } else {
+            color = TERM_WHITE;
+            done_mark = "";
+        }
+
+        c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y + 7, 10);
+
+        y = (y + 1) % 10;
+        if (!y && (i < MAX_BOUNTY - 1)) {
+            prt(_("何かキーを押してください", "Hit any key."), 0, 0);
+            (void)inkey();
+            prt("", 0, 0);
+            clear_bldg(7, 18);
+        }
+    }
+}
+
+/*!
+ * @brief 今日の賞金首を確定する / Determine today's bounty monster
+ * @param player_type プレーヤーへの参照ポインタ
+ * @return なし
+ * @note conv_old is used if loaded 0.0.3 or older save file
+ */
+void determine_daily_bounty(player_type *player_ptr, bool conv_old)
+{
+    int max_dl = 3, i;
+    if (!conv_old) {
+        for (i = 0; i < current_world_ptr->max_d_idx; i++) {
+            if (max_dlv[i] < d_info[i].mindepth)
+                continue;
+            if (max_dl < max_dlv[i])
+                max_dl = max_dlv[i];
+        }
+    } else {
+        max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
+    }
+
+    get_mon_num_prep(player_ptr, NULL, NULL);
+
+    while (TRUE) {
+        today_mon = get_mon_num(player_ptr, max_dl, GMN_ARENA);
+        monster_race *r_ptr;
+        r_ptr = &r_info[today_mon];
+
+        if (r_ptr->flags1 & RF1_UNIQUE)
+            continue;
+        if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2))
+            continue;
+        if (r_ptr->flags2 & RF2_MULTIPLY)
+            continue;
+        if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON))
+            continue;
+        if (r_ptr->level < MIN(max_dl / 2, 40))
+            continue;
+        if (r_ptr->rarity > 10)
+            continue;
+        break;
+    }
+}
+
+/*!
+ * @brief 賞金首となるユニークを確定する / Determine bounty uniques
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void determine_bounty_uniques(player_type *player_ptr)
+{
+    get_mon_num_prep(player_ptr, NULL, NULL);
+    for (int i = 0; i < MAX_BOUNTY; i++) {
+        while (TRUE) {
+            current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1, GMN_ARENA);
+            monster_race *r_ptr;
+            r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
+
+            if (!(r_ptr->flags1 & RF1_UNIQUE))
+                continue;
+
+            if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)))
+                continue;
+
+            if (r_ptr->rarity > 100)
+                continue;
+
+            if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i]))
+                continue;
+
+            int j;
+            for (j = 0; j < i; j++) {
+                if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j])
+                    break;
+            }
+
+            if (j == i)
+                break;
+        }
+    }
+
+    for (int i = 0; i < MAX_BOUNTY - 1; i++) {
+        for (int j = i; j < MAX_BOUNTY; j++) {
+            MONRACE_IDX tmp;
+            if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level) {
+                tmp = current_world_ptr->bounty_r_idx[i];
+                current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
+                current_world_ptr->bounty_r_idx[j] = tmp;
+            }
+        }
+    }
+}
index 7305ae8..6b2f481 100644 (file)
@@ -1,3 +1,8 @@
 #pragma once
 
 bool exchange_cash(player_type *player_ptr);
+void today_target(player_type *player_ptr);
+void tsuchinoko(void);
+void show_bounty(void);
+void determine_daily_bounty(player_type *player_ptr, bool conv_old);
+void determine_bounty_uniques(player_type *player_ptr);
index ec53009..ec1d9be 100644 (file)
@@ -32,7 +32,6 @@
 #include "object/object-flavor.h"
 #include "object/object-hook.h"
 #include "monster/monster.h"
-#include "monster/monsterrace-hook.h"
 #include "melee.h"
 #include "floor/wild.h"
 #include "world/world.h"
@@ -264,86 +263,6 @@ static void show_building(player_type *player_ptr, building_type* bldg)
 
 
 /*!
- * @brief 本日の賞金首情報を表示する。
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void today_target(player_type *player_ptr)
-{
-       char buf[160];
-       monster_race *r_ptr = &r_info[today_mon];
-
-       clear_bldg(4, 18);
-       c_put_str(TERM_YELLOW, _("本日の賞金首", "Wanted monster that changes from day to day"), 5, 10);
-       sprintf(buf, _("ターゲット: %s", "target: %s"), r_name + r_ptr->name);
-       c_put_str(TERM_YELLOW, buf, 6, 10);
-       sprintf(buf, _("死体 ---- $%d", "corpse   ---- $%d"), (int)r_ptr->level * 50 + 100);
-       prt(buf, 8, 10);
-       sprintf(buf, _("骨   ---- $%d", "skeleton ---- $%d"), (int)r_ptr->level * 30 + 60);
-       prt(buf, 9, 10);
-       player_ptr->today_mon = today_mon;
-}
-
-
-/*!
- * @brief ツチノコの賞金首情報を表示する。
- * @return なし
- */
-static void tsuchinoko(void)
-{
-       clear_bldg(4, 18);
-       c_put_str(TERM_YELLOW, _("一獲千金の大チャンス!!!", "Big chance for quick money!!!"), 5, 10);
-       c_put_str(TERM_YELLOW, _("ターゲット:幻の珍獣「ツチノコ」", "target: the rarest animal 'Tsuchinoko'"), 6, 10);
-       c_put_str(TERM_WHITE, _("生け捕り ---- $1,000,000", "catch alive ---- $1,000,000"), 8, 10);
-       c_put_str(TERM_WHITE, _("死体     ----   $200,000", "corpse      ----   $200,000"), 9, 10);
-       c_put_str(TERM_WHITE, _("骨       ----   $100,000", "bones       ----   $100,000"), 10, 10);
-}
-
-
-/*!
- * @brief 通常の賞金首情報を表示する。
- * @return なし
- */
-static void show_bounty(void)
-{
-       TERM_LEN y = 0;
-
-       clear_bldg(4, 18);
-       prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"), 4, 10);
-       c_put_str(TERM_YELLOW, _("現在の賞金首", "Wanted monsters"), 6, 10);
-
-       for (int i = 0; i < MAX_BOUNTY; i++)
-       {
-               byte color;
-               concptr done_mark;
-               monster_race *r_ptr = &r_info[(current_world_ptr->bounty_r_idx[i] > 10000 ? current_world_ptr->bounty_r_idx[i] - 10000 : current_world_ptr->bounty_r_idx[i])];
-
-               if (current_world_ptr->bounty_r_idx[i] > 10000)
-               {
-                       color = TERM_RED;
-                       done_mark = _("(済)", "(done)");
-               }
-               else
-               {
-                       color = TERM_WHITE;
-                       done_mark = "";
-               }
-
-               c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y + 7, 10);
-
-               y = (y + 1) % 10;
-               if (!y && (i < MAX_BOUNTY - 1))
-               {
-                       prt(_("何かキーを押してください", "Hit any key."), 0, 0);
-                       (void)inkey();
-                       prt("", 0, 0);
-                       clear_bldg(7, 18);
-               }
-       }
-}
-
-
-/*!
  * @brief クエスト情報を表示しつつ処理する。/ Display quest information
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param questnum クエストのID
@@ -2185,97 +2104,3 @@ void do_cmd_bldg(player_type *player_ptr)
        player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
        player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
-
-
-/*!
- * @brief 今日の賞金首を確定する / Determine today's bounty monster
- * @param player_type プレーヤーへの参照ポインタ
- * @return なし
- * @note conv_old is used if loaded 0.0.3 or older save file
- */
-void determine_daily_bounty(player_type *player_ptr, bool conv_old)
-{
-       int max_dl = 3, i;
-       if (!conv_old)
-       {
-               for (i = 0; i < current_world_ptr->max_d_idx; i++)
-               {
-                       if (max_dlv[i] < d_info[i].mindepth) continue;
-                       if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
-               }
-       }
-       else
-       {
-               max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
-       }
-
-       get_mon_num_prep(player_ptr, NULL, NULL);
-
-       while (TRUE)
-       {
-               today_mon = get_mon_num(player_ptr, max_dl, GMN_ARENA);
-               monster_race *r_ptr;
-               r_ptr = &r_info[today_mon];
-
-               if (r_ptr->flags1 & RF1_UNIQUE) continue;
-               if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
-               if (r_ptr->flags2 & RF2_MULTIPLY) continue;
-               if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
-               if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
-               if (r_ptr->rarity > 10) continue;
-               break;
-       }
-}
-
-
-/*!
- * @brief 賞金首となるユニークを確定する / Determine bounty uniques
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-void determine_bounty_uniques(player_type *player_ptr)
-{
-       get_mon_num_prep(player_ptr, NULL, NULL);
-       for (int i = 0; i < MAX_BOUNTY; i++)
-       {
-               while (TRUE)
-               {
-                       current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1, GMN_ARENA);
-                       monster_race *r_ptr;
-                       r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
-
-                       if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
-
-                       if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)))
-                               continue;
-
-                       if (r_ptr->rarity > 100) continue;
-
-                       if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i]))
-                               continue;
-
-                       int j;
-                       for (j = 0; j < i; j++)
-                       {
-                               if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j])
-                                       break;
-                       }
-
-                       if (j == i) break;
-               }
-       }
-
-       for (int i = 0; i < MAX_BOUNTY - 1; i++)
-       {
-               for (int j = i; j < MAX_BOUNTY; j++)
-               {
-                       MONRACE_IDX tmp;
-                       if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
-                       {
-                               tmp = current_world_ptr->bounty_r_idx[i];
-                               current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
-                               current_world_ptr->bounty_r_idx[j] = tmp;
-                       }
-               }
-       }
-}
index 7ca3270..ceae492 100644 (file)
@@ -117,6 +117,3 @@ typedef struct
 } arena_type;
 
 extern void do_cmd_bldg(player_type *player_ptr);
-
-extern void determine_daily_bounty(player_type *player_ptr, bool conv_old);
-extern void determine_bounty_uniques(player_type *player_ptr);
index a4abfd2..46c4f0c 100644 (file)
@@ -21,6 +21,7 @@
 #include "inventory/simple-appraiser.h"
 #include "world/world-movement-processor.h"
 #include "market/arena.h"
+#include "market/bounty.h"
 
 /*!
  * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。