2 * @brief キー入力に応じてゲーム内コマンドを実行する
5 * @todo Ctrl+C がShift+Q に認識されている。仕様の可能性も高いが要確認
8 #include "io/input-key-processor.h"
9 #include "autopick/autopick-pref-processor.h"
10 #include "cmd-action/cmd-hissatsu.h"
11 #include "cmd-action/cmd-mane.h"
12 #include "cmd-action/cmd-mind.h"
13 #include "cmd-action/cmd-move.h"
14 #include "cmd-action/cmd-open-close.h"
15 #include "cmd-action/cmd-others.h"
16 #include "cmd-action/cmd-pet.h"
17 #include "cmd-action/cmd-racial.h"
18 #include "cmd-action/cmd-shoot.h"
19 #include "cmd-action/cmd-spell.h"
20 #include "cmd-action/cmd-travel.h"
21 #include "cmd-action/cmd-tunnel.h"
22 #include "cmd-building/cmd-building.h"
23 #include "cmd-io/cmd-autopick.h"
24 #include "cmd-io/cmd-diary.h"
25 #include "cmd-io/cmd-dump.h"
26 #include "cmd-io/cmd-floor.h"
27 #include "cmd-io/cmd-gameoption.h"
28 #include "cmd-io/cmd-help.h"
29 #include "cmd-io/cmd-knowledge.h"
30 #include "cmd-io/cmd-lore.h"
31 #include "cmd-io/cmd-macro.h"
32 #include "cmd-io/cmd-process-screen.h"
33 #include "cmd-io/cmd-save.h"
34 #include "cmd-item/cmd-destroy.h"
35 #include "cmd-item/cmd-eat.h"
36 #include "cmd-item/cmd-equipment.h"
37 #include "cmd-item/cmd-item.h"
38 #include "cmd-item/cmd-magiceat.h"
39 #include "cmd-item/cmd-quaff.h"
40 #include "cmd-item/cmd-read.h"
41 #include "cmd-item/cmd-refill.h"
42 #include "cmd-item/cmd-throw.h"
43 #include "cmd-item/cmd-usestaff.h"
44 #include "cmd-item/cmd-zaprod.h"
45 #include "cmd-item/cmd-zapwand.h"
46 #include "cmd-visual/cmd-draw.h"
47 #include "cmd-visual/cmd-map.h"
48 #include "cmd-visual/cmd-visuals.h"
49 #include "core/asking-player.h"
50 #include "core/player-redraw-types.h"
51 #include "core/player-update-types.h"
52 #include "core/special-internal-keys.h"
53 #include "dungeon/dungeon-flag-types.h"
54 #include "dungeon/dungeon.h"
55 #include "dungeon/quest.h" //!< @do_cmd_quest() がある。後で移設する.
56 #include "floor/wild.h"
57 #include "game-option/birth-options.h"
58 #include "game-option/disturbance-options.h"
59 #include "game-option/game-play-options.h"
60 #include "game-option/input-options.h"
61 #include "io-dump/random-art-info-dumper.h"
62 #include "io/command-repeater.h"
63 #include "io/files-util.h"
64 #include "io/input-key-requester.h" //!< @todo 相互依存している、後で何とかする.
65 #include "io/record-play-movie.h"
66 #include "io/write-diary.h"
67 #include "knowledge/knowledge-autopick.h"
68 #include "knowledge/knowledge-quests.h"
69 #include "main/sound-definitions-table.h"
70 #include "main/sound-of-music.h"
71 #include "mind/mind-blue-mage.h"
72 #include "mind/mind-elementalist.h"
73 #include "mind/mind-magic-eater.h"
74 #include "mind/mind-sniper.h"
75 #include "mind/mind-weaponsmith.h"
76 #include "mind/snipe-types.h"
77 #include "player-info/class-info.h"
78 #include "player-status/player-energy.h"
79 #include "player/attack-defense-types.h"
80 #include "player/digestion-processor.h"
81 #include "player/player-status.h"
82 #include "player/special-defense-types.h"
83 #include "status/action-setter.h"
84 #include "store/cmd-store.h"
85 #include "store/home.h"
86 #include "store/store-util.h"
87 #include "system/floor-type-definition.h"
88 #include "system/player-type-definition.h"
89 #include "term/screen-processor.h"
90 #include "util/int-char-converter.h"
91 #include "view/display-messages.h"
92 #include "window/display-sub-windows.h"
93 #include "wizard/cmd-wizard.h"
94 #include "world/world.h"
97 * @brief ウィザードモードへの導入処理
98 * / Verify use of "wizard" mode
99 * @param player_ptr プレイヤーへの参照ポインタ
100 * @return 実際にウィザードモードへ移行したらTRUEを返す。
102 bool enter_wizard_mode(player_type *player_ptr)
104 if (!current_world_ptr->noscore) {
105 if (!allow_debug_opts) {
106 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
110 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
111 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
113 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? "))) {
118 player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "gave up recording score to enter wizard mode."));
119 current_world_ptr->noscore |= 0x0002;
126 * @brief デバッグコマンドへの導入処理
127 * / Verify use of "debug" commands
128 * @param player_ptr プレイヤーへの参照ポインタ
129 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
131 static bool enter_debug_mode(player_type *player_ptr)
133 if (!current_world_ptr->noscore) {
134 if (!allow_debug_opts) {
135 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
139 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
140 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
142 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? "))) {
147 player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "gave up sending score to use debug commands."));
148 current_world_ptr->noscore |= 0x0008;
155 * @brief プレイヤーから受けた入力コマンドの分岐処理。
156 * / Parse and execute the current command Give "Warning" on illegal commands.
157 * @todo Make some "blocks"
159 void process_command(player_type *player_ptr)
161 COMMAND_CODE old_now_message = now_message;
164 if ((player_ptr->pclass == CLASS_SNIPER) && (player_ptr->concent))
165 player_ptr->reset_concent = true;
167 floor_type *floor_ptr = player_ptr->current_floor_ptr;
168 switch (command_cmd) {
177 if (current_world_ptr->wizard) {
178 current_world_ptr->wizard = false;
179 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
180 } else if (enter_wizard_mode(player_ptr)) {
181 current_world_ptr->wizard = true;
182 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
185 player_ptr->update |= (PU_MONSTERS);
186 player_ptr->redraw |= (PR_TITLE);
190 if (enter_debug_mode(player_ptr)) {
191 do_cmd_debug(player_ptr);
197 if (!player_ptr->wild_mode)
198 do_cmd_wield(player_ptr);
203 if (!player_ptr->wild_mode)
204 do_cmd_takeoff(player_ptr);
209 if (!player_ptr->wild_mode)
210 do_cmd_drop(player_ptr);
215 do_cmd_destroy(player_ptr);
219 do_cmd_equip(player_ptr);
223 do_cmd_inven(player_ptr);
227 do_cmd_observe(player_ptr);
232 toggle_inventory_equipment(player_ptr);
236 if (!player_ptr->wild_mode)
237 do_cmd_alter(player_ptr);
242 if (!player_ptr->wild_mode)
243 do_cmd_tunnel(player_ptr);
248 do_cmd_walk(player_ptr, false);
252 do_cmd_walk(player_ptr, true);
256 if (!player_ptr->wild_mode)
257 do_cmd_run(player_ptr);
262 do_cmd_stay(player_ptr, always_pickup);
266 do_cmd_stay(player_ptr, !always_pickup);
270 do_cmd_rest(player_ptr);
274 do_cmd_search(player_ptr);
278 if (player_ptr->action == ACTION_SEARCH)
279 set_action(player_ptr, ACTION_NONE);
281 set_action(player_ptr, ACTION_SEARCH);
285 case SPECIAL_KEY_STORE: {
286 do_cmd_store(player_ptr);
289 case SPECIAL_KEY_BUILDING: {
290 do_cmd_building(player_ptr);
293 case SPECIAL_KEY_QUEST: {
294 do_cmd_quest(player_ptr);
298 if (!player_ptr->wild_mode && !floor_ptr->dun_level && !floor_ptr->inside_arena && !floor_ptr->inside_quest) {
302 if (player_ptr->ambush_flag) {
303 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
307 if (player_ptr->food < PY_FOOD_WEAK) {
308 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
312 change_wild_mode(player_ptr, false);
314 do_cmd_go_up(player_ptr);
319 if (player_ptr->wild_mode)
320 change_wild_mode(player_ptr, false);
322 do_cmd_go_down(player_ptr);
327 do_cmd_open(player_ptr);
331 do_cmd_close(player_ptr);
335 do_cmd_spike(player_ptr);
339 do_cmd_bash(player_ptr);
343 do_cmd_disarm(player_ptr);
347 if (player_ptr->pclass == CLASS_SORCERER || player_ptr->pclass == CLASS_RED_MAGE || player_ptr->pclass == CLASS_ELEMENTALIST)
348 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
349 else if (player_ptr->pclass == CLASS_SAMURAI)
350 do_cmd_gain_hissatsu(player_ptr);
351 else if (player_ptr->pclass == CLASS_MAGIC_EATER)
352 import_magic_device(player_ptr);
354 do_cmd_study(player_ptr);
359 if ((player_ptr->pclass == CLASS_MINDCRAFTER) || (player_ptr->pclass == CLASS_BERSERKER) || (player_ptr->pclass == CLASS_NINJA)
360 || (player_ptr->pclass == CLASS_MIRROR_MASTER))
361 do_cmd_mind_browse(player_ptr);
362 else if (player_ptr->pclass == CLASS_ELEMENTALIST)
363 do_cmd_element_browse(player_ptr);
364 else if (player_ptr->pclass == CLASS_SMITH)
365 do_cmd_kaji(player_ptr, true);
366 else if (player_ptr->pclass == CLASS_MAGIC_EATER)
367 do_cmd_magic_eater(player_ptr, true, false);
368 else if (player_ptr->pclass == CLASS_SNIPER)
369 do_cmd_snipe_browse(player_ptr);
371 do_cmd_browse(player_ptr);
376 if (player_ptr->wild_mode) {
380 if ((player_ptr->pclass == CLASS_WARRIOR) || (player_ptr->pclass == CLASS_ARCHER) || (player_ptr->pclass == CLASS_CAVALRY)) {
381 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
385 if (floor_ptr->dun_level && d_info[player_ptr->dungeon_idx].flags.has(DF::NO_MAGIC) && (player_ptr->pclass != CLASS_BERSERKER)
386 && (player_ptr->pclass != CLASS_SMITH)) {
387 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
392 if (player_ptr->anti_magic && (player_ptr->pclass != CLASS_BERSERKER) && (player_ptr->pclass != CLASS_SMITH)) {
393 concptr which_power = _("魔法", "magic");
394 switch (player_ptr->pclass) {
395 case CLASS_MINDCRAFTER:
396 which_power = _("超能力", "psionic powers");
399 which_power = _("ものまね", "imitation");
402 which_power = _("必殺剣", "hissatsu");
404 case CLASS_MIRROR_MASTER:
405 which_power = _("鏡魔法", "mirror magic");
408 which_power = _("忍術", "ninjutsu");
410 case CLASS_ELEMENTALIST:
411 which_power = _("元素魔法", "magic");
414 if (mp_ptr->spell_book == TV_LIFE_BOOK)
415 which_power = _("祈り", "prayer");
419 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
420 PlayerEnergy(player_ptr).reset_player_turn();
424 if (is_shero(player_ptr) && (player_ptr->pclass != CLASS_BERSERKER)) {
425 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
426 PlayerEnergy(player_ptr).reset_player_turn();
430 if ((player_ptr->pclass == CLASS_MINDCRAFTER) || (player_ptr->pclass == CLASS_BERSERKER) || (player_ptr->pclass == CLASS_NINJA)
431 || (player_ptr->pclass == CLASS_MIRROR_MASTER))
432 do_cmd_mind(player_ptr);
433 else if (player_ptr->pclass == CLASS_ELEMENTALIST)
434 do_cmd_element(player_ptr);
435 else if (player_ptr->pclass == CLASS_IMITATOR)
436 do_cmd_mane(player_ptr, false);
437 else if (player_ptr->pclass == CLASS_MAGIC_EATER)
438 do_cmd_magic_eater(player_ptr, false, false);
439 else if (player_ptr->pclass == CLASS_SAMURAI)
440 do_cmd_hissatsu(player_ptr);
441 else if (player_ptr->pclass == CLASS_BLUE_MAGE)
442 do_cmd_cast_learned(player_ptr);
443 else if (player_ptr->pclass == CLASS_SMITH)
444 do_cmd_kaji(player_ptr, false);
445 else if (player_ptr->pclass == CLASS_SNIPER)
446 do_cmd_snipe(player_ptr);
448 (void)do_cmd_cast(player_ptr);
453 do_cmd_pet(player_ptr);
457 do_cmd_inscribe(player_ptr);
461 do_cmd_uninscribe(player_ptr);
465 do_cmd_activate(player_ptr);
469 do_cmd_eat_food(player_ptr);
473 do_cmd_refill(player_ptr);
477 do_cmd_fire(player_ptr, SP_NONE);
481 (void)ThrowCommand(player_ptr).do_cmd_throw(1, false, -1);
485 do_cmd_aim_wand(player_ptr);
489 if (use_command && rogue_like_commands) {
490 do_cmd_use(player_ptr);
492 do_cmd_zap_rod(player_ptr);
498 do_cmd_quaff_potion(player_ptr);
502 do_cmd_read_scroll(player_ptr);
506 if (use_command && !rogue_like_commands)
507 do_cmd_use(player_ptr);
509 do_cmd_use_staff(player_ptr);
514 do_cmd_racial_power(player_ptr);
518 do_cmd_view_map(player_ptr);
522 do_cmd_locate(player_ptr);
526 do_cmd_look(player_ptr);
530 do_cmd_target(player_ptr);
534 do_cmd_help(player_ptr);
538 do_cmd_query_symbol(player_ptr);
542 do_cmd_player_status(player_ptr);
550 do_cmd_pref(player_ptr);
554 do_cmd_reload_autopick(player_ptr);
558 do_cmd_edit_autopick(player_ptr);
562 do_cmd_macros(player_ptr);
566 do_cmd_visuals(player_ptr);
567 do_cmd_redraw(player_ptr);
571 do_cmd_colors(player_ptr);
572 do_cmd_redraw(player_ptr);
576 do_cmd_options(player_ptr);
577 (void)combine_and_reorder_home(player_ptr, STORE_HOME);
578 do_cmd_redraw(player_ptr);
590 do_cmd_feeling(player_ptr);
594 do_cmd_message_one();
598 do_cmd_messages(old_now_message);
602 do_cmd_checkquest(player_ptr);
606 now_message = old_now_message;
607 do_cmd_redraw(player_ptr);
611 do_cmd_save_game(player_ptr, false);
615 do_cmd_time(player_ptr);
619 case SPECIAL_KEY_QUIT: {
620 do_cmd_save_and_exit(player_ptr);
624 do_cmd_suicide(player_ptr);
628 do_cmd_diary(player_ptr);
632 do_cmd_knowledge(player_ptr);
636 do_cmd_load_screen();
640 do_cmd_save_screen(player_ptr);
644 prepare_movie_hooks(player_ptr);
648 spoil_random_artifact(player_ptr, "randifact.txt");
652 if (!player_ptr->wild_mode)
653 do_cmd_travel(player_ptr);
654 if (player_ptr->special_defense & KATA_MUSOU) {
655 set_action(player_ptr, ACTION_NONE);
665 sound(SOUND_ILLEGAL);
666 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
669 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
676 if (!player_ptr->energy_use && !now_message)
677 now_message = old_now_message;