OSDN Git Service

[Refactor] #37353 賭け闘技場に関する定義を bldg.c/h へ移動.
[hengband/hengband.git] / src / bldg.c
index 6d5cd4a..47eab3d 100644 (file)
 #include "angband.h"
 #include "util.h"
 
+#include "core.h"
+#include "cmd-dump.h"
 #include "floor.h"
 #include "floor-events.h"
 #include "floor-save.h"
+#include "autopick.h"
+#include "objectkind.h"
 #include "object-boost.h"
 #include "object-flavor.h"
 #include "object-hook.h"
@@ -30,6 +34,7 @@
 
 #include "avatar.h"
 #include "bldg.h"
+#include "dungeon.h"
 #include "mutation.h"
 #include "quest.h"
 #include "artifact.h"
 #include "scores.h"
 #include "shoot.h"
 #include "view-mainwindow.h"
+#include "monsterrace.h"
+#include "autopick.h"
+
+
+/*
+ * Buildings
+ */
+building_type building[MAX_BLDG];
+
+MONRACE_IDX battle_mon[4];
+u32b mon_odds[4];
+int battle_odds;
+PRICE kakekin;
+int sel_monster;
 
 /*!
  * @brief 闘技場のモンスターID及び報酬アイテムテーブル
@@ -97,12 +116,6 @@ const arena_type arena_info[MAX_ARENA_MONS + 2] =
        { MON_HAGURE,        TV_SCROLL, SV_SCROLL_ARTIFACT            },
 };
 
-
-/*!
- * ループ中で / hack as in leave_store in store.c
- */
-bool leave_bldg = FALSE;
-
 /*!
  * @brief 施設毎に設定された種族、職業、魔法領域フラグがプレイヤーと一致するかを判定する。
  * @details 各種ギルドや寺院など、特定の職業ならば優遇措置を得られる施設、
@@ -335,7 +348,7 @@ static void arena_comm(int cmd)
 
                                                p_ptr->inside_arena = TRUE;
                                                p_ptr->leaving = TRUE;
-                                               leave_bldg = TRUE;
+                                               p_ptr->leave_bldg = TRUE;
                                        }
                                        else
                                        {
@@ -365,7 +378,7 @@ static void arena_comm(int cmd)
 
                                p_ptr->inside_arena = TRUE;
                                p_ptr->leaving = TRUE;
-                               leave_bldg = TRUE;
+                               p_ptr->leave_bldg = TRUE;
                        }
                        break;
                case BACT_POSTER:
@@ -1644,7 +1657,7 @@ static bool kakutoujou(void)
                        p_ptr->inside_battle = TRUE;
                        p_ptr->leaving = TRUE;
 
-                       leave_bldg = TRUE;
+                       p_ptr->leave_bldg = TRUE;
                        screen_load();
 
                        return (TRUE);
@@ -1779,10 +1792,10 @@ static bool kankin(void)
        GAME_TEXT o_name[MAX_NLEN];
        object_type *o_ptr;
 
-       /* Loop for inventory and right/left arm */
+       /* Loop for p_ptr->inventory_list and right/left arm */
        for (i = 0; i <= INVEN_LARM; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                /* Living Tsuchinoko worthes $1000000 */
                if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
@@ -1805,7 +1818,7 @@ static bool kankin(void)
 
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                /* Corpse of Tsuchinoko worthes $200000 */
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
@@ -1828,7 +1841,7 @@ static bool kankin(void)
 
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                /* Bones of Tsuchinoko worthes $100000 */
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
@@ -1851,7 +1864,7 @@ static bool kankin(void)
 
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
                        char buf[MAX_NLEN+20];
@@ -1872,7 +1885,7 @@ static bool kankin(void)
 
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
@@ -1897,7 +1910,7 @@ static bool kankin(void)
                /* Need reverse order --- Positions will be changed in the loop */
                for (i = INVEN_PACK-1; i >= 0; i--)
                {
-                       o_ptr = &inventory[i];
+                       o_ptr = &p_ptr->inventory_list[i];
                        if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval == current_world_ptr->bounty_r_idx[j]))
                        {
                                char buf[MAX_NLEN+20];
@@ -2631,7 +2644,7 @@ static PRICE compare_weapons(PRICE bcost)
        clear_bldg(0, 22);
 
        /* Store copy of original wielded weapon */
-       i_ptr = &inventory[INVEN_RARM];
+       i_ptr = &p_ptr->inventory_list[INVEN_RARM];
        object_copy(&orig_weapon, i_ptr);
 
        item_tester_hook = item_tester_hook_orthodox_melee_weapons;
@@ -3479,7 +3492,7 @@ static void building_recharge_all(void)
        /* Calculate cost */
        for ( i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
                                
                /* skip non magic device */
                if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
@@ -3543,7 +3556,7 @@ static void building_recharge_all(void)
        
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
                k_ptr = &k_info[o_ptr->k_idx];
 
                /* skip non magic device */
@@ -3794,7 +3807,6 @@ static bool research_mon(void)
                                old_i = i;
                        }
 
-                       /* Command */
                        query = inkey();
 
                        /* Normal commands */
@@ -4087,7 +4099,7 @@ void do_cmd_bldg(void)
        }
        else if ((which == 2) && p_ptr->inside_arena)
        {
-               if (!p_ptr->exit_bldg && m_cnt > 0)
+               if (!p_ptr->exit_bldg && current_floor_ptr->m_cnt > 0)
                {
                        prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed.  The monster awaits!"), 0, 0);
                }
@@ -4141,11 +4153,11 @@ void do_cmd_bldg(void)
        command_new = 0;
 
        show_building(bldg);
-       leave_bldg = FALSE;
+       p_ptr->leave_bldg = FALSE;
 
        play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
 
-       while (!leave_bldg)
+       while (!p_ptr->leave_bldg)
        {
                validcmd = FALSE;
                prt("", 1, 0);
@@ -4156,7 +4168,7 @@ void do_cmd_bldg(void)
 
                if (command == ESCAPE)
                {
-                       leave_bldg = TRUE;
+                       p_ptr->leave_bldg = TRUE;
                        p_ptr->inside_arena = FALSE;
                        p_ptr->inside_battle = FALSE;
                        break;
@@ -4199,3 +4211,96 @@ void do_cmd_bldg(void)
        p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
+
+
+/*!
+ * @brief 今日の賞金首を確定する / Determine today's bounty monster
+ * @return なし
+ * @note conv_old is used if loaded 0.0.3 or older save file
+ */
+void determine_today_mon(bool conv_old)
+{
+       int max_dl = 3, i;
+       bool old_inside_battle = p_ptr->inside_battle;
+       monster_race *r_ptr;
+
+       if (!conv_old)
+       {
+               for (i = 0; i < 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);
+
+       p_ptr->inside_battle = TRUE;
+       get_mon_num_prep(NULL, NULL);
+
+       while (1)
+       {
+               today_mon = get_mon_num(max_dl);
+               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;
+       }
+
+       p_ptr->today_mon = 0;
+       p_ptr->inside_battle = old_inside_battle;
+}
+
+
+
+/*!
+ * @brief 賞金首となるユニークを確定する / Determine bounty uniques
+ * @return なし
+ */
+void determine_bounty_uniques(void)
+{
+       int i, j;
+       MONRACE_IDX tmp;
+       monster_race *r_ptr;
+
+       get_mon_num_prep(NULL, NULL);
+       for (i = 0; i < MAX_KUBI; i++)
+       {
+               while (1)
+               {
+                       current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
+                       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;
+
+                       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;
+               }
+       }
+
+       /* Sort them */
+       for (i = 0; i < MAX_KUBI - 1; i++)
+       {
+               for (j = i; j < MAX_KUBI; j++)
+               {
+                       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;
+                       }
+               }
+       }
+}