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-mode-changer.h"
28 #include "floor/floor-events.h"
29 #include "floor/wild.h"
30 #include "grid/feature.h"
31 #include "grid/grid.h"
32 #include "io/input-key-acceptor.h"
33 #include "io/input-key-requester.h"
34 #include "main/music-definitions-table.h"
35 #include "main/sound-of-music.h"
36 #include "market/arena.h"
37 #include "market/bounty.h"
38 #include "market/building-actions-table.h"
39 #include "market/building-craft-armor.h"
40 #include "market/building-craft-fix.h"
41 #include "market/building-craft-weapon.h"
42 #include "market/building-enchanter.h"
43 #include "market/building-monster.h"
44 #include "market/building-quest.h"
45 #include "market/building-recharger.h"
46 #include "market/building-service.h"
47 #include "market/building-util.h"
48 #include "market/play-gamble.h"
49 #include "market/poker.h"
50 #include "monster-race/monster-race.h"
51 #include "mutation/mutation-flag-types.h"
52 #include "mutation/mutation-investor-remover.h"
53 #include "object-hook/hook-armor.h"
54 #include "object-hook/hook-bow.h"
55 #include "object-hook/hook-weapon.h"
56 #include "object/item-tester-hooker.h"
57 #include "player-info/avatar.h"
58 #include "player/player-personalities-types.h"
59 #include "player/player-status.h"
60 #include "spell-kind/spells-perception.h"
61 #include "spell-kind/spells-world.h"
62 #include "spell/spells-status.h"
63 #include "system/building-type-definition.h"
64 #include "system/floor-type-definition.h"
65 #include "term/screen-processor.h"
66 #include "util/bit-flags-calculator.h"
67 #include "util/int-char-converter.h"
68 #include "view/display-messages.h"
69 #include "world/world.h"
76 bool reinit_wilderness = FALSE;
77 MONSTER_IDX today_mon;
80 * @brief 町に関するヘルプを表示する / Display town history
81 * @param player_ptr プレーヤーへの参照ポインタ
84 static void town_history(player_type *player_ptr)
87 (void)show_file(player_ptr, TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
92 * @brief 施設の処理実行メインルーチン / Execute a building command
93 * @param player_ptr プレーヤーへの参照ポインタ
94 * @param bldg 施設構造体の参照ポインタ
95 * @param i 実行したい施設のサービステーブルの添字
98 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
104 if (is_owner(player_ptr, bldg))
105 bcost = bldg->member_costs[i];
107 bcost = bldg->other_costs[i];
109 /* action restrictions */
110 if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) ||
111 ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg)))
113 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
117 BACT_IDX bact = bldg->actions[i];
118 if ((bact != BACT_RECHARGE) &&
119 (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg)) ||
120 ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg))))
122 msg_print(_("お金が足りません!", "You do not have the gold!"));
132 case BACT_RESEARCH_ITEM:
133 paid = identify_fully(player_ptr, FALSE, 0);
135 case BACT_TOWN_HISTORY:
136 town_history(player_ptr);
138 case BACT_RACE_LEGENDS:
139 race_legends(player_ptr);
142 castle_quest(player_ptr);
144 case BACT_KING_LEGENDS:
145 case BACT_ARENA_LEGENDS:
147 show_highclass(player_ptr);
150 case BACT_ARENA_RULES:
152 arena_comm(player_ptr, bact);
154 case BACT_IN_BETWEEN:
156 case BACT_SPIN_WHEEL:
157 case BACT_DICE_SLOTS:
158 case BACT_GAMBLE_RULES:
160 gamble_comm(player_ptr, bact);
165 paid = inn_comm(player_ptr, bact);
167 case BACT_RESEARCH_MONSTER:
168 paid = research_mon(player_ptr);
170 case BACT_COMPARE_WEAPONS:
172 bcost = compare_weapons(player_ptr, bcost);
174 case BACT_ENCHANT_WEAPON:
175 item_tester_hook = object_allow_enchant_melee_weapon;
176 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
178 case BACT_ENCHANT_ARMOR:
179 item_tester_hook = object_is_armour;
180 enchant_item(player_ptr, bcost, 0, 0, 1, 0);
183 building_recharge(player_ptr);
185 case BACT_RECHARGE_ALL:
186 building_recharge_all(player_ptr);
189 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
190 identify_pack(player_ptr);
191 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
195 paid = ident_spell(player_ptr, FALSE, 0);
198 do_cmd_study(player_ptr);
201 paid = cure_critical_wounds(player_ptr, 200);
204 paid = restore_all_status(player_ptr);
206 case BACT_ENCHANT_ARROWS:
207 item_tester_hook = item_tester_hook_ammo;
208 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
210 case BACT_ENCHANT_BOW:
211 enchant_item(player_ptr, bcost, 1, 1, 0, TV_BOW);
215 if (recall_player(player_ptr, 1)) paid = TRUE;
218 case BACT_TELEPORT_LEVEL:
220 paid = free_level_recall(player_ptr);
223 case BACT_LOSE_MUTATION:
224 if (player_ptr->muta1 || player_ptr->muta2 || (player_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
225 (player_ptr->pseikaku != PERSONALITY_LUCKY && (player_ptr->muta3 & MUT3_GOOD_LUCK)))
227 while (!lose_mutation(player_ptr, 0));
232 msg_print(_("治すべき突然変異が無い。", "You have no mutations."));
237 monster_arena_comm(player_ptr);
240 case BACT_TSUCHINOKO:
249 today_target(player_ptr);
253 exchange_cash(player_ptr);
257 msg_print(_("平衡化の儀式を行なった。", "You received an equalization ritual."));
258 set_virtue(player_ptr, V_COMPASSION, 0);
259 set_virtue(player_ptr, V_HONOUR, 0);
260 set_virtue(player_ptr, V_JUSTICE, 0);
261 set_virtue(player_ptr, V_SACRIFICE, 0);
262 set_virtue(player_ptr, V_KNOWLEDGE, 0);
263 set_virtue(player_ptr, V_FAITH, 0);
264 set_virtue(player_ptr, V_ENLIGHTEN, 0);
265 set_virtue(player_ptr, V_ENCHANT, 0);
266 set_virtue(player_ptr, V_CHANCE, 0);
267 set_virtue(player_ptr, V_NATURE, 0);
268 set_virtue(player_ptr, V_HARMONY, 0);
269 set_virtue(player_ptr, V_VITALITY, 0);
270 set_virtue(player_ptr, V_UNLIFE, 0);
271 set_virtue(player_ptr, V_PATIENCE, 0);
272 set_virtue(player_ptr, V_TEMPERANCE, 0);
273 set_virtue(player_ptr, V_DILIGENCE, 0);
274 set_virtue(player_ptr, V_VALOUR, 0);
275 set_virtue(player_ptr, V_INDIVIDUALISM, 0);
276 get_virtues(player_ptr);
281 paid = tele_town(player_ptr);
285 paid = eval_ac(player_ptr->dis_ac + player_ptr->dis_to_a);
288 case BACT_BROKEN_WEAPON:
290 bcost = repair_broken_weapon(player_ptr, bcost);
294 if (paid) player_ptr->au -= bcost;
299 * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
300 * @param プレーヤーへの参照ポインタ
303 void do_cmd_building(player_type *player_ptr)
305 if (player_ptr->wild_mode) return;
307 take_turn(player_ptr, 100);
309 if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_BLDG))
311 msg_print(_("ここには建物はない。", "You see no building here."));
315 int which = f_info[player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
318 bldg = &building[which];
320 reinit_wilderness = FALSE;
322 if ((which == 2) && (player_ptr->arena_number < 0))
324 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
327 else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena)
329 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0)
331 prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed. The monster awaits!"), 0, 0);
335 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
336 player_ptr->current_floor_ptr->inside_arena = FALSE;
337 player_ptr->leaving = TRUE;
338 command_new = SPECIAL_KEY_BUILDING;
339 free_turn(player_ptr);
344 else if (player_ptr->phase_out)
346 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
347 player_ptr->leaving = TRUE;
348 player_ptr->phase_out = FALSE;
349 command_new = SPECIAL_KEY_BUILDING;
350 free_turn(player_ptr);
355 player_ptr->oldpy = player_ptr->y;
356 player_ptr->oldpx = player_ptr->x;
359 forget_lite(player_ptr->current_floor_ptr);
360 forget_view(player_ptr->current_floor_ptr);
361 current_world_ptr->character_icky++;
367 display_buikding_service(player_ptr, bldg);
368 player_ptr->leave_bldg = FALSE;
369 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
372 while (!player_ptr->leave_bldg)
377 building_prt_gold(player_ptr);
379 char command = inkey();
381 if (command == ESCAPE)
383 player_ptr->leave_bldg = TRUE;
384 player_ptr->current_floor_ptr->inside_arena = FALSE;
385 player_ptr->phase_out = FALSE;
390 for (i = 0; i < 8; i++)
392 if (bldg->letters[i] && (bldg->letters[i] == command))
399 if (validcmd) bldg_process_command(player_ptr, bldg, i);
401 handle_stuff(player_ptr);
404 select_floor_music(player_ptr);
409 if (reinit_wilderness) player_ptr->leaving = TRUE;
411 current_world_ptr->character_icky--;
414 player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
415 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
416 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);