2 * @brief その他の小さなコマンド処理群 (探索、汎用グリッド処理、自殺/引退/切腹)
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 #include "cmd-action/cmd-others.h"
13 #include "action/open-close-execution.h"
14 #include "action/tunnel-execution.h"
15 #include "cmd-action/cmd-attack.h"
16 #include "core/asking-player.h"
17 #include "core/disturbance.h"
18 #include "core/player-redraw-types.h"
19 #include "floor/geometry.h"
20 #include "game-option/game-play-options.h"
21 #include "grid/feature.h"
22 #include "grid/grid.h"
23 #include "io/input-key-acceptor.h"
24 #include "io/input-key-requester.h"
25 #include "io/write-diary.h"
26 #include "main/music-definitions-table.h"
27 #include "main/sound-of-music.h"
28 #include "player-status/player-energy.h"
29 #include "player/attack-defense-types.h"
30 #include "player/player-move.h"
31 #include "player/special-defense-types.h"
32 #include "status/action-setter.h"
33 #include "system/floor-type-definition.h"
34 #include "system/grid-type-definition.h"
35 #include "system/player-type-definition.h"
36 #include "target/target-getter.h"
37 #include "term/screen-processor.h"
38 #include "util/bit-flags-calculator.h"
39 #include "view/display-messages.h"
40 #include "world/world.h"
43 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
45 void do_cmd_search(player_type *creature_ptr)
48 command_rep = command_arg - 1;
49 creature_ptr->redraw |= PR_STATE;
53 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
56 if (creature_ptr->action == ACTION_SEARCH)
60 static bool exe_alter(player_type *creature_ptr)
63 if (!get_rep_dir(creature_ptr, &dir, true))
66 POSITION y = creature_ptr->y + ddy[dir];
67 POSITION x = creature_ptr->x + ddx[dir];
69 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
70 FEAT_IDX feat = g_ptr->get_feat_mimic();
72 f_ptr = &f_info[feat];
73 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
75 do_cmd_attack(creature_ptr, y, x, HISSATSU_NONE);
79 if (f_ptr->flags.has(FF::OPEN))
80 return exe_open(creature_ptr, y, x);
82 if (f_ptr->flags.has(FF::BASH))
83 return exe_bash(creature_ptr, y, x, dir);
85 if (f_ptr->flags.has(FF::TUNNEL))
86 return exe_tunnel(creature_ptr, y, x);
88 if (f_ptr->flags.has(FF::CLOSE))
89 return exe_close(creature_ptr, y, x);
91 if (f_ptr->flags.has(FF::DISARM))
92 return exe_disarm(creature_ptr, y, x, dir);
94 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
99 * @brief 特定のマスに影響を及ぼすための汎用的コマンド / Manipulate an adjacent grid in some way
102 void do_cmd_alter(player_type *creature_ptr)
104 if (creature_ptr->special_defense & KATA_MUSOU)
105 set_action(creature_ptr, ACTION_NONE);
108 command_rep = command_arg - 1;
109 creature_ptr->redraw |= PR_STATE;
113 if (!exe_alter(creature_ptr))
114 disturb(creature_ptr, false, false);
120 * @return 自殺/引退/切腹を実施するならTRUE、キャンセルならFALSE
122 static bool decide_suicide(void)
124 if (current_world_ptr->noscore)
127 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
134 static void accept_winner_message(player_type *creature_ptr)
136 if (!current_world_ptr->total_winner || !last_words)
140 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
142 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof(buf)))
144 } while (!get_check_strict(creature_ptr, _("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
147 creature_ptr->last_message = string_make(buf);
148 msg_print(creature_ptr->last_message);
153 * @brief 自殺するコマンドのメインルーチン
157 void do_cmd_suicide(player_type *creature_ptr)
160 if (current_world_ptr->total_winner) {
161 if (!get_check_strict(creature_ptr, _("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY))
164 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? ")))
168 if (!decide_suicide())
171 if (creature_ptr->last_message)
172 string_free(creature_ptr->last_message);
174 creature_ptr->last_message = NULL;
175 creature_ptr->playing = false;
176 creature_ptr->is_dead = true;
177 creature_ptr->leaving = true;
178 if (current_world_ptr->total_winner) {
179 accept_winner_message(creature_ptr);
180 add_retired_class(creature_ptr->pclass);
182 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
183 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
184 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
185 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
188 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));