2 * @brief 町の施設処理 / Building commands
5 * Created by Ken Wigle for Kangband - a variant of Angband 2.8.3
8 * Rewritten for Kangband 2.8.3i using Kamband's version of
9 * building.c as written by Ivan Tkatchev
11 * Changed for ZAngband by Robert Ruehlmann
14 #include "cmd-building/cmd-building.h"
15 #include "cmd-action/cmd-spell.h"
16 #include "cmd-building/cmd-inn.h"
17 #include "cmd-io/cmd-dump.h"
18 #include "core/asking-player.h"
19 #include "core/player-redraw-types.h"
20 #include "core/player-update-types.h"
21 #include "core/scores.h"
22 #include "core/show-file.h"
23 #include "core/special-internal-keys.h"
24 #include "core/stuff-handler.h"
25 #include "core/window-redrawer.h"
26 #include "floor/cave.h"
27 #include "floor/floor-events.h"
28 #include "floor/floor-mode-changer.h"
29 #include "floor/wild.h"
30 #include "grid/feature.h"
31 #include "io/input-key-acceptor.h"
32 #include "io/input-key-requester.h"
33 #include "main/music-definitions-table.h"
34 #include "main/sound-of-music.h"
35 #include "market/arena.h"
36 #include "market/bounty.h"
37 #include "market/building-actions-table.h"
38 #include "market/building-craft-armor.h"
39 #include "market/building-craft-fix.h"
40 #include "market/building-craft-weapon.h"
41 #include "market/building-enchanter.h"
42 #include "market/building-monster.h"
43 #include "market/building-quest.h"
44 #include "market/building-recharger.h"
45 #include "market/building-service.h"
46 #include "market/building-util.h"
47 #include "market/play-gamble.h"
48 #include "market/poker.h"
49 #include "monster-race/monster-race.h"
50 #include "mutation/mutation-flag-types.h"
51 #include "mutation/mutation-investor-remover.h"
52 #include "object-hook/hook-armor.h"
53 #include "object-hook/hook-bow.h"
54 #include "object-hook/hook-weapon.h"
55 #include "object/item-tester-hooker.h"
56 #include "player-info/avatar.h"
57 #include "player-status/player-energy.h"
58 #include "player/player-personality-types.h"
59 #include "spell-kind/spells-perception.h"
60 #include "spell-kind/spells-world.h"
61 #include "spell/spells-status.h"
62 #include "system/building-type-definition.h"
63 #include "system/floor-type-definition.h"
64 #include "system/grid-type-definition.h"
65 #include "system/player-type-definition.h"
66 #include "term/screen-processor.h"
67 #include "util/bit-flags-calculator.h"
68 #include "util/int-char-converter.h"
69 #include "view/display-messages.h"
70 #include "world/world.h"
77 bool reinit_wilderness = false;
80 * @brief 町に関するヘルプを表示する / Display town history
81 * @param player_ptr プレーヤーへの参照ポインタ
83 static void town_history(player_type *player_ptr)
86 (void)show_file(player_ptr, true, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
91 * @brief 施設の処理実行メインルーチン / Execute a building command
92 * @param player_ptr プレーヤーへの参照ポインタ
93 * @param bldg 施設構造体の参照ポインタ
94 * @param i 実行したい施設のサービステーブルの添字
96 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
102 if (is_owner(player_ptr, bldg))
103 bcost = bldg->member_costs[i];
105 bcost = bldg->other_costs[i];
107 /* action restrictions */
108 if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) || ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg))) {
109 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
113 BACT_IDX bact = bldg->actions[i];
114 if ((bact != BACT_RECHARGE)
115 && (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg))
116 || ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg)))) {
117 msg_print(_("お金が足りません!", "You do not have the gold!"));
126 case BACT_RESEARCH_ITEM:
127 paid = identify_fully(player_ptr, false, TV_NONE);
129 case BACT_TOWN_HISTORY:
130 town_history(player_ptr);
132 case BACT_RACE_LEGENDS:
133 race_legends(player_ptr);
136 castle_quest(player_ptr);
138 case BACT_KING_LEGENDS:
139 case BACT_ARENA_LEGENDS:
141 show_highclass(player_ptr);
144 case BACT_ARENA_RULES:
146 arena_comm(player_ptr, bact);
148 case BACT_IN_BETWEEN:
150 case BACT_SPIN_WHEEL:
151 case BACT_DICE_SLOTS:
152 case BACT_GAMBLE_RULES:
154 gamble_comm(player_ptr, bact);
159 paid = inn_comm(player_ptr, bact);
161 case BACT_RESEARCH_MONSTER:
162 paid = research_mon(player_ptr);
164 case BACT_COMPARE_WEAPONS:
166 bcost = compare_weapons(player_ptr, bcost);
168 case BACT_ENCHANT_WEAPON:
169 item_tester_hook = object_allow_enchant_melee_weapon;
170 enchant_item(player_ptr, bcost, 1, 1, 0, TV_NONE);
172 case BACT_ENCHANT_ARMOR:
173 item_tester_hook = object_is_armour;
174 enchant_item(player_ptr, bcost, 0, 0, 1, TV_NONE);
177 building_recharge(player_ptr);
179 case BACT_RECHARGE_ALL:
180 building_recharge_all(player_ptr);
183 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay to identify all your possession? ")))
185 identify_pack(player_ptr);
186 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
190 paid = ident_spell(player_ptr, false, TV_NONE);
193 do_cmd_study(player_ptr);
196 paid = cure_critical_wounds(player_ptr, 200);
199 paid = restore_all_status(player_ptr);
201 case BACT_ENCHANT_ARROWS:
202 item_tester_hook = item_tester_hook_ammo;
203 enchant_item(player_ptr, bcost, 1, 1, 0, TV_NONE);
205 case BACT_ENCHANT_BOW:
206 enchant_item(player_ptr, bcost, 1, 1, 0, TV_BOW);
210 if (recall_player(player_ptr, 1))
214 case BACT_TELEPORT_LEVEL:
216 paid = free_level_recall(player_ptr);
219 case BACT_LOSE_MUTATION: {
220 auto muta = player_ptr->muta;
221 if (player_ptr->pseikaku == PERSONALITY_LUCKY) {
222 // ラッキーマンの白オーラは突然変異治療の対象外
223 muta.reset(MUTA::GOOD_LUCK);
226 while (!lose_mutation(player_ptr, 0))
232 msg_print(_("治すべき突然変異が無い。", "You have no mutations."));
238 monster_arena_comm(player_ptr);
241 case BACT_TSUCHINOKO:
250 today_target(player_ptr);
254 exchange_cash(player_ptr);
258 msg_print(_("平衡化の儀式を行なった。", "You received an equalization ritual."));
259 set_virtue(player_ptr, V_COMPASSION, 0);
260 set_virtue(player_ptr, V_HONOUR, 0);
261 set_virtue(player_ptr, V_JUSTICE, 0);
262 set_virtue(player_ptr, V_SACRIFICE, 0);
263 set_virtue(player_ptr, V_KNOWLEDGE, 0);
264 set_virtue(player_ptr, V_FAITH, 0);
265 set_virtue(player_ptr, V_ENLIGHTEN, 0);
266 set_virtue(player_ptr, V_ENCHANT, 0);
267 set_virtue(player_ptr, V_CHANCE, 0);
268 set_virtue(player_ptr, V_NATURE, 0);
269 set_virtue(player_ptr, V_HARMONY, 0);
270 set_virtue(player_ptr, V_VITALITY, 0);
271 set_virtue(player_ptr, V_UNLIFE, 0);
272 set_virtue(player_ptr, V_PATIENCE, 0);
273 set_virtue(player_ptr, V_TEMPERANCE, 0);
274 set_virtue(player_ptr, V_DILIGENCE, 0);
275 set_virtue(player_ptr, V_VALOUR, 0);
276 set_virtue(player_ptr, V_INDIVIDUALISM, 0);
277 initialize_virtues(player_ptr);
282 paid = tele_town(player_ptr);
286 paid = eval_ac(player_ptr->dis_ac + player_ptr->dis_to_a);
289 case BACT_BROKEN_WEAPON:
291 bcost = repair_broken_weapon(player_ptr, bcost);
296 player_ptr->au -= bcost;
300 * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
301 * @param プレーヤーへの参照ポインタ
303 void do_cmd_building(player_type *player_ptr)
305 if (player_ptr->wild_mode)
308 PlayerEnergy energy(player_ptr);
309 energy.set_player_turn_energy(100);
311 if (!cave_has_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_BLDG)) {
312 msg_print(_("ここには建物はない。", "You see no building here."));
316 int which = f_info[player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
319 bldg = &building[which];
321 reinit_wilderness = false;
323 if ((which == 2) && (player_ptr->arena_number < 0)) {
324 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
326 } else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena) {
327 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0) {
328 prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed. The monster awaits!"), 0, 0);
330 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
331 player_ptr->current_floor_ptr->inside_arena = false;
332 player_ptr->leaving = true;
333 command_new = SPECIAL_KEY_BUILDING;
334 energy.reset_player_turn();
338 } else if (player_ptr->phase_out) {
339 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
340 player_ptr->leaving = true;
341 player_ptr->phase_out = false;
342 command_new = SPECIAL_KEY_BUILDING;
343 energy.reset_player_turn();
346 player_ptr->oldpy = player_ptr->y;
347 player_ptr->oldpx = player_ptr->x;
350 forget_lite(player_ptr->current_floor_ptr);
351 forget_view(player_ptr->current_floor_ptr);
352 current_world_ptr->character_icky_depth++;
358 display_buikding_service(player_ptr, bldg);
359 player_ptr->leave_bldg = false;
360 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
363 while (!player_ptr->leave_bldg) {
367 building_prt_gold(player_ptr);
369 char command = inkey();
371 if (command == ESCAPE) {
372 player_ptr->leave_bldg = true;
373 player_ptr->current_floor_ptr->inside_arena = false;
374 player_ptr->phase_out = false;
379 for (i = 0; i < 8; i++) {
380 if (bldg->letters[i] && (bldg->letters[i] == command)) {
387 bldg_process_command(player_ptr, bldg, i);
389 handle_stuff(player_ptr);
392 select_floor_music(player_ptr);
397 if (reinit_wilderness)
398 player_ptr->leaving = true;
400 current_world_ptr->character_icky_depth--;
403 player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
404 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
405 player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);