1 #include "market/bounty.h"
2 #include "autopick/autopick.h"
3 #include "avatar/avatar.h"
4 #include "cmd-building/cmd-building.h"
5 #include "core/asking-player.h"
6 #include "core/player-redraw-types.h"
7 #include "core/stuff-handler.h"
8 #include "dungeon/dungeon.h"
9 #include "flavor/flavor-describer.h"
10 #include "game-option/cheat-options.h"
11 #include "inventory/inventory-object.h"
12 #include "inventory/inventory-slot-types.h"
13 #include "io/input-key-acceptor.h"
14 #include "market/bounty-prize-table.h"
15 #include "market/building-util.h"
16 #include "monster-race/monster-race-hook.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster-race/race-flags2.h"
20 #include "monster-race/race-flags7.h"
21 #include "monster-race/race-indice-types.h"
22 #include "monster/monster-list.h"
23 #include "monster/monster-util.h"
24 #include "object-enchant/apply-magic.h"
25 #include "object-enchant/item-apply-magic.h"
26 #include "object/object-info.h"
27 #include "object/object-kind-hook.h"
28 #include "perception/object-perception.h"
29 #include "sv-definition/sv-other-types.h"
30 #include "system/floor-type-definition.h"
31 #include "system/monster-race-definition.h"
32 #include "system/object-type-definition.h"
33 #include "system/player-type-definition.h"
34 #include "term/screen-processor.h"
35 #include "term/term-color-types.h"
36 #include "util/bit-flags-calculator.h"
37 #include "view/display-messages.h"
38 #include "world/world.h"
42 * @brief 賞金首の引き換え処理 / Get prize
43 * @param player_ptr プレイヤーへの参照ポインタ
44 * @return 各種賞金首のいずれかでも換金が行われたか否か。
46 bool exchange_cash(PlayerType *player_ptr)
49 GAME_TEXT o_name[MAX_NLEN];
52 for (INVENTORY_IDX i = 0; i <= INVEN_SUB_HAND; i++) {
53 o_ptr = &player_ptr->inventory_list[i];
54 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
56 if ((o_ptr->tval == ItemKindType::CAPTURE) && (r_idx_of_item == MonsterRaceId::TSUCHINOKO)) {
57 char buf[MAX_NLEN + 32];
58 describe_flavor(player_ptr, o_name, o_ptr, 0);
59 sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
61 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(1000000L * o_ptr->number));
62 player_ptr->au += 1000000L * o_ptr->number;
63 player_ptr->redraw |= (PR_GOLD);
64 vary_item(player_ptr, i, -o_ptr->number);
71 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
72 o_ptr = &player_ptr->inventory_list[i];
73 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
75 if ((o_ptr->tval == ItemKindType::CORPSE) && (o_ptr->sval == SV_CORPSE) && (r_idx_of_item == MonsterRaceId::TSUCHINOKO)) {
76 char buf[MAX_NLEN + 32];
77 describe_flavor(player_ptr, o_name, o_ptr, 0);
78 sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
80 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(200000L * o_ptr->number));
81 player_ptr->au += 200000L * o_ptr->number;
82 player_ptr->redraw |= (PR_GOLD);
83 vary_item(player_ptr, i, -o_ptr->number);
90 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
91 o_ptr = &player_ptr->inventory_list[i];
92 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
94 if ((o_ptr->tval == ItemKindType::CORPSE) && (o_ptr->sval == SV_SKELETON) && (r_idx_of_item == MonsterRaceId::TSUCHINOKO)) {
95 char buf[MAX_NLEN + 32];
96 describe_flavor(player_ptr, o_name, o_ptr, 0);
97 sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
99 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(100000L * o_ptr->number));
100 player_ptr->au += 100000L * o_ptr->number;
101 player_ptr->redraw |= (PR_GOLD);
102 vary_item(player_ptr, i, -o_ptr->number);
109 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
110 o_ptr = &player_ptr->inventory_list[i];
111 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
113 if ((o_ptr->tval == ItemKindType::CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_info[r_idx_of_item].name.c_str(), r_info[w_ptr->today_mon].name.c_str()))) {
114 char buf[MAX_NLEN + 32];
115 describe_flavor(player_ptr, o_name, o_ptr, 0);
116 sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
117 if (get_check(buf)) {
119 _("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[w_ptr->today_mon].level * 50 + 100) * o_ptr->number));
120 player_ptr->au += (r_info[w_ptr->today_mon].level * 50 + 100) * o_ptr->number;
121 player_ptr->redraw |= (PR_GOLD);
122 vary_item(player_ptr, i, -o_ptr->number);
129 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
130 o_ptr = &player_ptr->inventory_list[i];
131 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
133 if ((o_ptr->tval == ItemKindType::CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_info[r_idx_of_item].name.c_str(), r_info[w_ptr->today_mon].name.c_str()))) {
134 char buf[MAX_NLEN + 32];
135 describe_flavor(player_ptr, o_name, o_ptr, 0);
136 sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
137 if (get_check(buf)) {
138 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[w_ptr->today_mon].level * 30 + 60) * o_ptr->number));
139 player_ptr->au += (r_info[w_ptr->today_mon].level * 30 + 60) * o_ptr->number;
140 player_ptr->redraw |= (PR_GOLD);
141 vary_item(player_ptr, i, -o_ptr->number);
148 for (auto &[r_idx, is_achieved] : w_ptr->bounties) {
153 for (INVENTORY_IDX i = INVEN_PACK - 1; i >= 0; i--) {
154 o_ptr = &player_ptr->inventory_list[i];
155 const auto r_idx_of_item = static_cast<MonsterRaceId>(o_ptr->pval);
157 if ((o_ptr->tval != ItemKindType::CORPSE) || (r_idx_of_item != r_idx)) {
161 char buf[MAX_NLEN + 20];
162 INVENTORY_IDX item_new;
165 describe_flavor(player_ptr, o_name, o_ptr, 0);
166 sprintf(buf, _("%sを渡しますか?", "Hand %s over? "), o_name);
167 if (!get_check(buf)) {
171 vary_item(player_ptr, i, -o_ptr->number);
172 chg_virtue(player_ptr, V_JUSTICE, 5);
175 auto num = std::count_if(std::begin(w_ptr->bounties), std::end(w_ptr->bounties),
176 [](const auto &b_ref) { return b_ref.is_achieved; });
178 msg_format(_("これで合計 %d ポイント獲得しました。", "You earned %d point%s total."), num, (num > 1 ? "s" : ""));
180 (&forge)->prep(lookup_kind(prize_list[num - 1].tval, prize_list[num - 1].sval));
181 apply_magic_to_object(player_ptr, &forge, player_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART);
183 object_aware(player_ptr, &forge);
184 object_known(&forge);
187 * Hand it --- Assume there is an empty slot.
188 * Since a corpse is handed at first,
189 * there is at least one empty slot.
191 item_new = store_item_to_inventory(player_ptr, &forge);
192 describe_flavor(player_ptr, o_name, &forge, 0);
193 msg_format(_("%s(%c)を貰った。", "You get %s (%c). "), o_name, index_to_label(item_new));
195 autopick_alter_item(player_ptr, item_new, false);
196 handle_stuff(player_ptr);
205 msg_print(_("賞金を得られそうなものは持っていなかった。", "You have nothing."));
211 * @brief 本日の賞金首情報を表示する。
212 * @param player_ptr プレイヤーへの参照ポインタ
214 void today_target(PlayerType *player_ptr)
217 auto *r_ptr = &r_info[w_ptr->today_mon];
220 c_put_str(TERM_YELLOW, _("本日の賞金首", "Wanted monster that changes from day to day"), 5, 10);
221 sprintf(buf, _("ターゲット: %s", "target: %s"), r_ptr->name.c_str());
222 c_put_str(TERM_YELLOW, buf, 6, 10);
223 sprintf(buf, _("死体 ---- $%d", "corpse ---- $%d"), (int)r_ptr->level * 50 + 100);
225 sprintf(buf, _("骨 ---- $%d", "skeleton ---- $%d"), (int)r_ptr->level * 30 + 60);
227 player_ptr->knows_daily_bounty = true;
231 * @brief ツチノコの賞金首情報を表示する。
233 void tsuchinoko(void)
236 c_put_str(TERM_YELLOW, _("一獲千金の大チャンス!!!", "Big chance for quick money!!!"), 5, 10);
237 c_put_str(TERM_YELLOW, _("ターゲット:幻の珍獣「ツチノコ」", "target: the rarest animal 'Tsuchinoko'"), 6, 10);
238 c_put_str(TERM_WHITE, _("生け捕り ---- $1,000,000", "catch alive ---- $1,000,000"), 8, 10);
239 c_put_str(TERM_WHITE, _("死体 ---- $200,000", "corpse ---- $200,000"), 9, 10);
240 c_put_str(TERM_WHITE, _("骨 ---- $100,000", "bones ---- $100,000"), 10, 10);
244 * @brief 通常の賞金首情報を表示する。
246 void show_bounty(void)
251 prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"), 4, 10);
252 c_put_str(TERM_YELLOW, _("現在の賞金首", "Wanted monsters"), 6, 10);
254 for (auto i = 0U; i < std::size(w_ptr->bounties); i++) {
255 const auto &[r_idx, is_achieved] = w_ptr->bounties[i];
256 monster_race *r_ptr = &r_info[r_idx];
258 auto color = is_achieved ? TERM_RED : TERM_WHITE;
259 auto done_mark = is_achieved ? _("(済)", "(done)") : "";
261 c_prt(color, format("%s %s", r_ptr->name.c_str(), done_mark), y + 7, 10);
264 if (!y && (i < std::size(w_ptr->bounties) - 1)) {
265 prt(_("何かキーを押してください", "Hit any key."), 0, 0);
274 * @brief 今日の賞金首を確定する / Determine today's bounty monster
275 * @param PlayerType プレイヤーへの参照ポインタ
276 * @note conv_old is used if loaded 0.0.3 or older save file
278 void determine_daily_bounty(PlayerType *player_ptr, bool conv_old)
282 for (const auto &d_ref : d_info) {
283 if (max_dlv[d_ref.idx] < d_ref.mindepth) {
286 if (max_dl < max_dlv[d_ref.idx]) {
287 max_dl = max_dlv[d_ref.idx];
291 max_dl = std::max(max_dlv[DUNGEON_ANGBAND], 3);
294 get_mon_num_prep_bounty(player_ptr);
297 w_ptr->today_mon = get_mon_num(player_ptr, std::min(max_dl / 2, 40), max_dl, GMN_ARENA);
299 r_ptr = &r_info[w_ptr->today_mon];
302 msg_format("日替わり候補: %s ", r_ptr->name.c_str());
305 if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
308 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) {
311 if (r_ptr->flags2 & RF2_MULTIPLY) {
314 if (!r_ptr->drop_flags.has_all_of({ MonsterDropType::DROP_CORPSE, MonsterDropType::DROP_SKELETON })) {
317 if (r_ptr->rarity > 10) {
323 player_ptr->knows_daily_bounty = false;
327 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
328 * @param player_ptr プレイヤーへの参照ポインタ
330 void determine_bounty_uniques(PlayerType *player_ptr)
332 get_mon_num_prep_bounty(player_ptr);
334 auto is_suitable_for_bounty = [](MonsterRaceId r_idx) {
335 const auto &r_ref = r_info[r_idx];
336 bool is_suitable = r_ref.kind_flags.has(MonsterKindType::UNIQUE);
337 is_suitable &= r_ref.drop_flags.has_any_of({ MonsterDropType::DROP_CORPSE, MonsterDropType::DROP_SKELETON });
338 is_suitable &= r_ref.rarity <= 100;
339 is_suitable &= !no_questor_or_bounty_uniques(r_idx);
343 // 賞金首とするモンスターの種族IDのリストを生成
344 std::vector<MonsterRaceId> bounty_r_idx_list;
345 while (bounty_r_idx_list.size() < std::size(w_ptr->bounties)) {
346 auto r_idx = get_mon_num(player_ptr, 0, MAX_DEPTH - 1, GMN_ARENA);
347 if (!is_suitable_for_bounty(r_idx)) {
351 auto is_already_selected = std::any_of(bounty_r_idx_list.begin(), bounty_r_idx_list.end(),
352 [r_idx](MonsterRaceId bounty_r_idx) { return r_idx == bounty_r_idx; });
353 if (!is_already_selected) {
354 bounty_r_idx_list.push_back(r_idx);
359 std::sort(bounty_r_idx_list.begin(), bounty_r_idx_list.end(),
360 [](MonsterRaceId r_idx1, MonsterRaceId r_idx2) {
361 return r_info[r_idx1].level < r_info[r_idx2].level;
365 std::transform(bounty_r_idx_list.begin(), bounty_r_idx_list.end(), std::begin(w_ptr->bounties),
366 [](MonsterRaceId r_idx) -> bounty_type {
367 return { r_idx, false };