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 "system/angband.h"
15 #include "cmd-building/cmd-building.h"
16 #include "cmd-action/cmd-spell.h"
17 #include "cmd-io/cmd-dump.h"
18 #include "cmd-building/cmd-inn.h"
19 #include "core/scores.h"
20 #include "core/show-file.h"
21 #include "core/special-internal-keys.h"
22 #include "core/stuff-handler.h"
23 #include "floor/floor-events.h"
24 #include "floor/floor-save.h"
25 #include "floor/floor.h"
26 #include "floor/wild.h"
27 #include "io/files-util.h"
28 #include "io/input-key-acceptor.h"
29 #include "main/music-definitions-table.h"
30 #include "main/sound-of-music.h"
31 #include "market/arena.h"
32 #include "market/bounty.h"
33 #include "market/building-actions-table.h"
34 #include "market/building-craft-armor.h"
35 #include "market/building-craft-fix.h"
36 #include "market/building-craft-weapon.h"
37 #include "market/building-enchanter.h"
38 #include "market/building-monster.h"
39 #include "market/building-quest.h"
40 #include "market/building-recharger.h"
41 #include "market/building-service.h"
42 #include "market/building-util.h"
43 #include "market/play-gamble.h"
44 #include "market/poker.h"
45 #include "monster-race/monster-race.h"
46 #include "mutation/mutation.h"
47 #include "object/object-flavor.h"
48 #include "object/object-hook.h"
49 #include "player/avatar.h"
50 #include "player/player-personalities-types.h"
51 #include "player/player-status.h"
52 #include "spell/spells-status.h"
53 #include "spell-kind/spells-teleport.h"
54 #include "spell/spells3.h"
55 #include "system/building-type-definition.h"
56 #include "world/world.h"
58 MONRACE_IDX battle_mon[4];
64 bool reinit_wilderness = FALSE;
65 MONSTER_IDX today_mon;
68 * @brief 町に関するヘルプを表示する / Display town history
69 * @param player_ptr プレーヤーへの参照ポインタ
72 static void town_history(player_type *player_ptr)
75 (void)show_file(player_ptr, TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
80 * @brief 施設の処理実行メインルーチン / Execute a building command
81 * @param player_ptr プレーヤーへの参照ポインタ
82 * @param bldg 施設構造体の参照ポインタ
83 * @param i 実行したい施設のサービステーブルの添字
86 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
92 if (is_owner(player_ptr, bldg))
93 bcost = bldg->member_costs[i];
95 bcost = bldg->other_costs[i];
97 /* action restrictions */
98 if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) ||
99 ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg)))
101 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
105 BACT_IDX bact = bldg->actions[i];
106 if ((bact != BACT_RECHARGE) &&
107 (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg)) ||
108 ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg))))
110 msg_print(_("お金が足りません!", "You do not have the gold!"));
120 case BACT_RESEARCH_ITEM:
121 paid = identify_fully(player_ptr, FALSE, 0);
123 case BACT_TOWN_HISTORY:
124 town_history(player_ptr);
126 case BACT_RACE_LEGENDS:
127 race_legends(player_ptr);
130 castle_quest(player_ptr);
132 case BACT_KING_LEGENDS:
133 case BACT_ARENA_LEGENDS:
135 show_highclass(player_ptr);
138 case BACT_ARENA_RULES:
140 arena_comm(player_ptr, bact);
142 case BACT_IN_BETWEEN:
144 case BACT_SPIN_WHEEL:
145 case BACT_DICE_SLOTS:
146 case BACT_GAMBLE_RULES:
148 gamble_comm(player_ptr, bact);
153 paid = inn_comm(player_ptr, bact);
155 case BACT_RESEARCH_MONSTER:
156 paid = research_mon(player_ptr);
158 case BACT_COMPARE_WEAPONS:
160 bcost = compare_weapons(player_ptr, bcost);
162 case BACT_ENCHANT_WEAPON:
163 item_tester_hook = object_allow_enchant_melee_weapon;
164 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
166 case BACT_ENCHANT_ARMOR:
167 item_tester_hook = object_is_armour;
168 enchant_item(player_ptr, bcost, 0, 0, 1, 0);
171 building_recharge(player_ptr);
173 case BACT_RECHARGE_ALL:
174 building_recharge_all(player_ptr);
177 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
178 identify_pack(player_ptr);
179 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
183 paid = ident_spell(player_ptr, FALSE, 0);
186 do_cmd_study(player_ptr);
189 paid = cure_critical_wounds(player_ptr, 200);
192 paid = restore_all_status(player_ptr);
194 case BACT_ENCHANT_ARROWS:
195 item_tester_hook = item_tester_hook_ammo;
196 enchant_item(player_ptr, bcost, 1, 1, 0, 0);
198 case BACT_ENCHANT_BOW:
199 enchant_item(player_ptr, bcost, 1, 1, 0, TV_BOW);
203 if (recall_player(player_ptr, 1)) paid = TRUE;
206 case BACT_TELEPORT_LEVEL:
208 paid = free_level_recall(player_ptr);
211 case BACT_LOSE_MUTATION:
212 if (player_ptr->muta1 || player_ptr->muta2 || (player_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
213 (player_ptr->pseikaku != PERSONALITY_LUCKY && (player_ptr->muta3 & MUT3_GOOD_LUCK)))
215 while (!lose_mutation(player_ptr, 0));
220 msg_print(_("治すべき突然変異が無い。", "You have no mutations."));
225 monster_arena_comm(player_ptr);
228 case BACT_TSUCHINOKO:
237 today_target(player_ptr);
241 exchange_cash(player_ptr);
245 msg_print(_("平衡化の儀式を行なった。", "You received an equalization ritual."));
246 set_virtue(player_ptr, V_COMPASSION, 0);
247 set_virtue(player_ptr, V_HONOUR, 0);
248 set_virtue(player_ptr, V_JUSTICE, 0);
249 set_virtue(player_ptr, V_SACRIFICE, 0);
250 set_virtue(player_ptr, V_KNOWLEDGE, 0);
251 set_virtue(player_ptr, V_FAITH, 0);
252 set_virtue(player_ptr, V_ENLIGHTEN, 0);
253 set_virtue(player_ptr, V_ENCHANT, 0);
254 set_virtue(player_ptr, V_CHANCE, 0);
255 set_virtue(player_ptr, V_NATURE, 0);
256 set_virtue(player_ptr, V_HARMONY, 0);
257 set_virtue(player_ptr, V_VITALITY, 0);
258 set_virtue(player_ptr, V_UNLIFE, 0);
259 set_virtue(player_ptr, V_PATIENCE, 0);
260 set_virtue(player_ptr, V_TEMPERANCE, 0);
261 set_virtue(player_ptr, V_DILIGENCE, 0);
262 set_virtue(player_ptr, V_VALOUR, 0);
263 set_virtue(player_ptr, V_INDIVIDUALISM, 0);
264 get_virtues(player_ptr);
269 paid = tele_town(player_ptr);
273 paid = eval_ac(player_ptr->dis_ac + player_ptr->dis_to_a);
276 case BACT_BROKEN_WEAPON:
278 bcost = repair_broken_weapon(player_ptr, bcost);
282 if (paid) player_ptr->au -= bcost;
287 * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
288 * @param プレーヤーへの参照ポインタ
291 void do_cmd_building(player_type *player_ptr)
293 if (player_ptr->wild_mode) return;
295 take_turn(player_ptr, 100);
297 if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_BLDG))
299 msg_print(_("ここには建物はない。", "You see no building here."));
303 int which = f_info[player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
306 bldg = &building[which];
308 reinit_wilderness = FALSE;
310 if ((which == 2) && (player_ptr->arena_number < 0))
312 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
315 else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena)
317 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0)
319 prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed. The monster awaits!"), 0, 0);
323 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
324 player_ptr->current_floor_ptr->inside_arena = FALSE;
325 player_ptr->leaving = TRUE;
326 command_new = SPECIAL_KEY_BUILDING;
327 free_turn(player_ptr);
332 else if (player_ptr->phase_out)
334 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
335 player_ptr->leaving = TRUE;
336 player_ptr->phase_out = FALSE;
337 command_new = SPECIAL_KEY_BUILDING;
338 free_turn(player_ptr);
343 player_ptr->oldpy = player_ptr->y;
344 player_ptr->oldpx = player_ptr->x;
347 forget_lite(player_ptr->current_floor_ptr);
348 forget_view(player_ptr->current_floor_ptr);
349 current_world_ptr->character_icky++;
355 display_buikding_service(player_ptr, bldg);
356 player_ptr->leave_bldg = FALSE;
357 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
360 while (!player_ptr->leave_bldg)
365 building_prt_gold(player_ptr);
367 char command = inkey();
369 if (command == ESCAPE)
371 player_ptr->leave_bldg = TRUE;
372 player_ptr->current_floor_ptr->inside_arena = FALSE;
373 player_ptr->phase_out = FALSE;
378 for (i = 0; i < 8; i++)
380 if (bldg->letters[i] && (bldg->letters[i] == command))
387 if (validcmd) bldg_process_command(player_ptr, bldg, i);
389 handle_stuff(player_ptr);
392 select_floor_music(player_ptr);
397 if (reinit_wilderness) player_ptr->leaving = TRUE;
399 current_world_ptr->character_icky--;
402 player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
403 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
404 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);