5 * @details 通常のコマンドではないのでcmd-xxx/ ではなくwizard/ 以下に置く
8 #include "wizard/cmd-wizard.h"
9 #include "birth/inventory-initializer.h"
10 #include "cmd-io/cmd-help.h"
11 #include "core/asking-player.h"
12 #include "inventory/inventory-object.h"
13 #include "inventory/inventory-slot-types.h"
14 #include "io/input-key-requester.h"
15 #include "mutation/mutation-investor-remover.h"
16 #include "player-base/player-class.h"
17 #include "player/patron.h"
18 #include "spell-kind/spells-detection.h"
19 #include "spell-kind/spells-floor.h"
20 #include "spell-kind/spells-perception.h"
21 #include "spell-kind/spells-sight.h"
22 #include "spell-kind/spells-teleport.h"
23 #include "spell/spells-status.h"
24 #include "status/experience.h"
25 #include "system/floor-type-definition.h"
26 #include "system/grid-type-definition.h"
27 #include "system/item-entity.h"
28 #include "system/player-type-definition.h"
29 #include "term/screen-processor.h"
30 #include "util/int-char-converter.h"
31 #include "view/display-messages.h"
32 #include "wizard/wizard-game-modifier.h"
33 #include "wizard/wizard-item-modifier.h"
34 #include "wizard/wizard-player-modifier.h"
35 #include "wizard/wizard-special-process.h"
36 #include "wizard/wizard-spells.h"
37 #include "wizard/wizard-spoiler.h"
47 * 空き: A,B,E,I,J,k,K,L,M,q,Q,R,T,U,V,W,y,Y
49 constexpr std::array debug_menu_table = {
50 std::make_tuple('a', _("全状態回復", "Restore all status")),
51 std::make_tuple('b', _("現在のターゲットを引き寄せる", "Teleport target back")),
52 std::make_tuple('c', _("オブジェクト生成", "Create object")),
53 std::make_tuple('C', _("固定アーティファクト生成", "Create fixed artifact")),
54 std::make_tuple('d', _("全感知", "Detection all")),
55 std::make_tuple('D', _("次元の扉", "Dimension door")),
56 std::make_tuple('e', _("能力値変更", "Modify player status")),
57 std::make_tuple('E', _("青魔法を全取得/エッセンスを全取得", "Learn all blue magics / Obtain all essences")),
58 std::make_tuple('f', _("*鑑定*", "*Idenfity*")),
59 std::make_tuple('F', _("地形ID変更", "Modify feature type under player")),
60 std::make_tuple('G', _("ゲーム設定コマンドメニュー", "Modify game configurations")),
61 std::make_tuple('H', _("モンスターの群れ生成", "Summon monsters")),
62 std::make_tuple('i', _("鑑定", "Idenfity")),
63 std::make_tuple('I', _("アイテム設定コマンドメニュー", "Modify item configurations")),
64 std::make_tuple('j', _("指定ダンジョン階にワープ", "Jump to floor depth of target dungeon")),
65 std::make_tuple('k', _("指定ダメージ・半径0の指定属性のボールを自分に放つ", "Fire a zero ball to self")),
66 std::make_tuple('m', _("魔法の地図", "Magic mapping")),
67 std::make_tuple('n', _("指定モンスター生成", "Summon target monster")),
68 std::make_tuple('N', _("指定モンスターをペットとして生成", "Summon target monster as pet")),
69 std::make_tuple('o', _("オブジェクトの能力変更", "Modift object abilities")),
70 std::make_tuple('O', _("オプション設定をダンプ", "Dump current options")),
71 std::make_tuple('p', _("ショート・テレポート", "Phase door")),
72 std::make_tuple('P', _("プレイヤー設定変更メニュー", "Modify player configurations")),
73 std::make_tuple('r', _("カオスパトロンの報酬", "Get reward of chaos patron")),
74 std::make_tuple('s', _("フロア相当のモンスター生成", "Generate monster which be in target depth")),
75 std::make_tuple('S', _("フロア相当のモンスター召喚", "Summon monster which be in target depth")),
76 std::make_tuple('t', _("テレポート", "Teleport self")),
77 std::make_tuple('u', _("啓蒙(忍者以外)", "Wiz-lite all floor except Ninja")),
78 std::make_tuple('w', _("啓蒙(忍者配慮)", "Wiz-lite all floor")),
79 std::make_tuple('x', _("経験値を得る(指定可)", "Get experience")),
80 std::make_tuple('X', _("所持品を初期状態に戻す", "Return inventory to initial")),
81 std::make_tuple('y', _("ダメージ100万・半径0の射撃のボールを放つ", "Cast missile ball had power a million")),
82 std::make_tuple('Y', _("指定ダメージ・半径0の指定属性のボールを放つ", "Cast zero ball had power a thousand")),
83 std::make_tuple('z', _("近隣のモンスター消去", "Terminate near monsters")),
84 std::make_tuple('Z', _("フロアの全モンスター消去", "Terminate all monsters in floor")),
85 std::make_tuple('@', _("特殊スペルの発動", "Activate specified spells")),
86 std::make_tuple('"', _("スポイラーのダンプ", "Dump spoiler")),
87 std::make_tuple('?', _("ヘルプ表示", "Help")),
91 * @brief デバグコマンドの一覧を表示する
93 * @param max_page ページ数
94 * @param page_size 1ページ行数
95 * @param max_line コマンド数
97 void display_debug_menu(int page, int max_page, int page_size, int max_line)
99 for (int y = 1; y < page_size + 3; y++) {
100 term_erase(14, y, 64);
105 for (int i = 0; i < page_size; i++) {
106 int pos = page * page_size + i;
107 if (pos >= max_line) {
111 std::stringstream ss;
112 const auto &[symbol, desc] = debug_menu_table[pos];
113 std::stringstream debug_cmd;
114 if (!(symbol & ~0x1F)) { // CTRL+Ch = Ch & 0x1F のため0x1Fが含まれていなければCTRLと組み合わせたキー
115 debug_cmd << '^' << static_cast<char>(symbol | ('A' & ~KTRL('A'))); // 大文字はAからZで順番通りに並んでいるためこの式で変換する
117 debug_cmd << ' ' << symbol;
119 ss << debug_cmd.str() << ") " << desc;
120 put_str(ss.str(), r++, c);
123 put_str("-- more --", r++, c);
128 * @brief デバッグコマンド選択処理への分岐
129 * @param player_ptr プレイヤーへの参照ポインタ
131 * @return コマンド終了ならTRUE、ページ送りならFALSE
133 bool exe_cmd_debug(PlayerType *player_ptr, char cmd)
146 wiz_cure_all(player_ptr);
149 wiz_teleport_back(player_ptr);
152 wiz_create_item(player_ptr);
155 wiz_create_named_art(player_ptr);
158 detect_all(player_ptr, DETECT_RAD_ALL * 3);
161 wiz_dimension_door(player_ptr);
164 wiz_change_status(player_ptr);
167 switch (player_ptr->pclass) {
168 case PlayerClassType::BLUE_MAGE:
169 wiz_learn_blue_magic_all(player_ptr);
171 case PlayerClassType::SMITH:
172 wiz_fillup_all_smith_essences(player_ptr);
180 identify_fully(player_ptr, false);
183 wiz_create_feature(player_ptr);
186 wizard_game_modifier(player_ptr);
189 wiz_summon_horde(player_ptr);
192 (void)ident_spell(player_ptr, false);
195 wizard_item_modifier(player_ptr);
198 wiz_jump_to_dungeon(player_ptr);
201 wiz_kill_target(player_ptr, 0, (AttributeType)command_arg, true);
204 map_area(player_ptr, DETECT_RAD_ALL * 3);
207 wiz_summon_specific_monster(player_ptr, i2enum<MonsterRaceId>(command_arg));
210 wiz_summon_pet(player_ptr, i2enum<MonsterRaceId>(command_arg));
213 wiz_modify_item(player_ptr);
219 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
222 wizard_player_modifier(player_ptr);
225 patron_list[player_ptr->chaos_patron].gain_level_reward(player_ptr, command_arg);
228 command_arg = std::clamp<short>(command_arg, 1, 999);
229 wiz_generate_random_monster(player_ptr, command_arg);
232 command_arg = std::clamp<short>(command_arg, 1, 999);
233 wiz_summon_random_monster(player_ptr, command_arg);
236 teleport_player(player_ptr, 100, TELEPORT_SPONTANEOUS);
239 for (int y = 0; y < player_ptr->current_floor_ptr->height; y++) {
240 for (int x = 0; x < player_ptr->current_floor_ptr->width; x++) {
241 player_ptr->current_floor_ptr->grid_array[y][x].info |= CAVE_GLOW | CAVE_MARK;
245 wiz_lite(player_ptr, false);
248 wiz_lite(player_ptr, PlayerClass(player_ptr).equals(PlayerClassType::NINJA));
251 gain_exp(player_ptr, command_arg ? command_arg : (player_ptr->exp + 1));
254 for (INVENTORY_IDX i = INVEN_TOTAL - 1; i >= 0; i--) {
255 if (player_ptr->inventory_list[i].is_valid()) {
256 drop_from_inventory(player_ptr, i, 999);
260 player_outfit(player_ptr);
263 wiz_kill_target(player_ptr);
266 wiz_kill_target(player_ptr, 0, (AttributeType)command_arg);
269 wiz_zap_surrounding_monsters(player_ptr);
272 wiz_zap_floor_monsters(player_ptr);
278 wiz_debug_spell(player_ptr);
281 exe_output_spoilers();
284 do_cmd_help(player_ptr);
287 msg_print("That is not a valid debug command.");
293 * @brief デバッグコマンドを選択する処理のメインルーチン /
294 * Ask for and parse a "debug command"
295 * The "command_arg" may have been set.
296 * @param player_ptr プレイヤーへの参照ポインタ
298 * 番号を指定するには、それをN及びデバッグコマンドをXとしてとして「0N^aX」とする
300 void do_cmd_debug(PlayerType *player_ptr)
302 const auto &[wid, hgt] = term_get_size();
303 const auto max_line = debug_menu_table.size();
304 const auto page_size = hgt - 5;
305 const auto max_page = max_line / page_size + 1;
309 display_debug_menu(page, max_page, page_size, max_line);
310 const auto command = input_command("Debug Command: ");
312 if (exe_cmd_debug(player_ptr, command.value_or(ESCAPE))) {
316 page = (page + 1) % max_page;