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/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"
71 MONRACE_IDX battle_mon[4];
77 bool reinit_wilderness = FALSE;
78 MONSTER_IDX today_mon;
81 * @brief 町に関するヘルプを表示する / Display town history
82 * @param player_ptr プレーヤーへの参照ポインタ
85 static void town_history(player_type *player_ptr)
88 (void)show_file(player_ptr, TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
93 * @brief 施設の処理実行メインルーチン / Execute a building command
94 * @param player_ptr プレーヤーへの参照ポインタ
95 * @param bldg 施設構造体の参照ポインタ
96 * @param i 実行したい施設のサービステーブルの添字
99 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
105 if (is_owner(player_ptr, bldg))
106 bcost = bldg->member_costs[i];
108 bcost = bldg->other_costs[i];
110 /* action restrictions */
111 if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) ||
112 ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg)))
114 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
118 BACT_IDX bact = bldg->actions[i];
119 if ((bact != BACT_RECHARGE) &&
120 (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg)) ||
121 ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg))))
123 msg_print(_("お金が足りません!", "You do not have the gold!"));
133 case BACT_RESEARCH_ITEM:
134 paid = identify_fully(player_ptr, FALSE, 0);
136 case BACT_TOWN_HISTORY:
137 town_history(player_ptr);
139 case BACT_RACE_LEGENDS:
140 race_legends(player_ptr);
143 castle_quest(player_ptr);
145 case BACT_KING_LEGENDS:
146 case BACT_ARENA_LEGENDS:
148 show_highclass(player_ptr);
151 case BACT_ARENA_RULES:
153 arena_comm(player_ptr, bact);
155 case BACT_IN_BETWEEN:
157 case BACT_SPIN_WHEEL:
158 case BACT_DICE_SLOTS:
159 case BACT_GAMBLE_RULES:
161 gamble_comm(player_ptr, bact);
166 paid = inn_comm(player_ptr, bact);
168 case BACT_RESEARCH_MONSTER:
169 paid = research_mon(player_ptr);
171 case BACT_COMPARE_WEAPONS:
173 bcost = compare_weapons(player_ptr, bcost);
175 case BACT_ENCHANT_WEAPON:
176 item_tester_hook = object_allow_enchant_melee_weapon;
177 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
179 case BACT_ENCHANT_ARMOR:
180 item_tester_hook = object_is_armour;
181 enchant_item(player_ptr, bcost, 0, 0, 1, 0);
184 building_recharge(player_ptr);
186 case BACT_RECHARGE_ALL:
187 building_recharge_all(player_ptr);
190 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
191 identify_pack(player_ptr);
192 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
196 paid = ident_spell(player_ptr, FALSE, 0);
199 do_cmd_study(player_ptr);
202 paid = cure_critical_wounds(player_ptr, 200);
205 paid = restore_all_status(player_ptr);
207 case BACT_ENCHANT_ARROWS:
208 item_tester_hook = item_tester_hook_ammo;
209 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
211 case BACT_ENCHANT_BOW:
212 enchant_item(player_ptr, bcost, 1, 1, 0, TV_BOW);
216 if (recall_player(player_ptr, 1)) paid = TRUE;
219 case BACT_TELEPORT_LEVEL:
221 paid = free_level_recall(player_ptr);
224 case BACT_LOSE_MUTATION:
225 if (player_ptr->muta1 || player_ptr->muta2 || (player_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
226 (player_ptr->pseikaku != PERSONALITY_LUCKY && (player_ptr->muta3 & MUT3_GOOD_LUCK)))
228 while (!lose_mutation(player_ptr, 0));
233 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 get_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);
295 if (paid) player_ptr->au -= bcost;
300 * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
301 * @param プレーヤーへの参照ポインタ
304 void do_cmd_building(player_type *player_ptr)
306 if (player_ptr->wild_mode) return;
308 take_turn(player_ptr, 100);
310 if (!cave_have_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))
325 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
328 else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena)
330 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0)
332 prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed. The monster awaits!"), 0, 0);
336 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
337 player_ptr->current_floor_ptr->inside_arena = FALSE;
338 player_ptr->leaving = TRUE;
339 command_new = SPECIAL_KEY_BUILDING;
340 free_turn(player_ptr);
345 else if (player_ptr->phase_out)
347 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
348 player_ptr->leaving = TRUE;
349 player_ptr->phase_out = FALSE;
350 command_new = SPECIAL_KEY_BUILDING;
351 free_turn(player_ptr);
356 player_ptr->oldpy = player_ptr->y;
357 player_ptr->oldpx = player_ptr->x;
360 forget_lite(player_ptr->current_floor_ptr);
361 forget_view(player_ptr->current_floor_ptr);
362 current_world_ptr->character_icky++;
368 display_buikding_service(player_ptr, bldg);
369 player_ptr->leave_bldg = FALSE;
370 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
373 while (!player_ptr->leave_bldg)
378 building_prt_gold(player_ptr);
380 char command = inkey();
382 if (command == ESCAPE)
384 player_ptr->leave_bldg = TRUE;
385 player_ptr->current_floor_ptr->inside_arena = FALSE;
386 player_ptr->phase_out = FALSE;
391 for (i = 0; i < 8; i++)
393 if (bldg->letters[i] && (bldg->letters[i] == command))
400 if (validcmd) bldg_process_command(player_ptr, bldg, i);
402 handle_stuff(player_ptr);
405 select_floor_music(player_ptr);
410 if (reinit_wilderness) player_ptr->leaving = TRUE;
412 current_world_ptr->character_icky--;
415 player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
416 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
417 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);