OSDN Git Service

[Fix] デバグコマンドの数字の入力に関する修正 / [Feature] 領域変更の追加
[hengbandforosx/hengbandosx.git] / src / wizard / cmd-wizard.cpp
1 /*!
2  * @brief デバッグコマンドの分岐実装
3  * @date 2020/08/01
4  * @author Hourier
5  * @details 通常のコマンドではないのでcmd-xxx/ ではなくwizard/ 以下に置く
6  */
7
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 "grid/grid.h"
13 #include "inventory/inventory-object.h"
14 #include "inventory/inventory-slot-types.h"
15 #include "io/input-key-requester.h"
16 #include "mutation/mutation-investor-remover.h"
17 #include "player/patron.h"
18 #include "spell-kind/spells-detection.h"
19 #include "spell-kind/spells-perception.h"
20 #include "spell-kind/spells-floor.h"
21 #include "spell-kind/spells-sight.h"
22 #include "spell-kind/spells-teleport.h"
23 #include "spell/spells-object.h"
24 #include "spell/spells-status.h"
25 #include "status/experience.h"
26 #include "system/floor-type-definition.h"
27 #include "system/object-type-definition.h"
28 #include "term/screen-processor.h"
29 #include "util/int-char-converter.h"
30 #include "view/display-messages.h"
31 #include "wizard/wizard-item-modifier.h"
32 #include "wizard/wizard-game-modifier.h"
33 #include "wizard/wizard-player-modifier.h"
34 #include "wizard/wizard-special-process.h"
35 #include "wizard/wizard-spells.h"
36 #include "wizard/wizard-spoiler.h"
37 #include <string>
38 #include <vector>
39 #include <sstream>
40
41 /*!
42  * @brief デバグコマンド一覧表
43  * @detail
44  * 空き: A,B,E,I,J,k,K,L,M,q,Q,R,T,U,V,W,y,Y
45  */
46 std::vector<std::vector<std::string>> debug_menu_table = {
47     { "a", _("全状態回復", "Restore all status") },
48     { "b", _("現在のターゲットを引き寄せる", "Teleport target back") },
49     { "c", _("オブジェクト生成", "Create object") },
50     { "C", _("固定アーティファクト生成", "Create fixed artifact") },
51     { "d", _("全感知", "Detection all") },
52     { "D", _("次元の扉", "Dimension door") },
53     { "e", _("能力値変更", "Modify player status") },
54     { "f", _("*鑑定*", "*Idenfity*") },
55     { "F", _("地形ID変更", "Modify feature type under player") },
56     { "g", _("上質なアイテムドロップ", "Drop good object") },
57     { "G", _("ゲームの設定を変更", "Modify game configurations") },
58     { "H", _("モンスターの群れ生成", "Summon monsters") },
59     { "i", _("鑑定", "Idenfity") },
60     { "j", _("指定ダンジョン階にワープ", "Jump to floor depth of target dungeon") },
61     { "l", _("指定アイテム番号まで一括鑑定", "Make objects idenfified to target object id") },
62     { "m", _("魔法の地図", "Magic mapping") },
63     { "n", _("指定モンスター生成", "Summon target monster") },
64     { "N", _("指定モンスターをペットとして生成", "Summon target monster as pet") },
65     { "o", _("オブジェクトの能力変更", "Modift object abilities") },
66     { "O", _("オプション設定をダンプ", "Dump current options") },
67     { "p", _("ショート・テレポート", "Phase door") },
68     { "P", _("プレイヤーの属性を変更", "Modify player configurations") },
69     { "r", _("カオスパトロンの報酬", "Get reward of chaos patron") },
70     { "s", _("フロア相当のモンスター召喚", "Summon monster which be in target depth") },
71     { "S", _("高級品獲得ドロップ", "Drop excellent object") },
72     { "t", _("テレポート", "Teleport self") },
73     { "u", _("啓蒙(忍者以外)", "Wiz-lite all floor except Ninja") },
74     { "v", _("特別品獲得ドロップ", "Drop special object") },
75     { "w", _("啓蒙(忍者配慮)", "Wiz-lite all floor") },
76     { "W", _("願い", "Wishing") },
77     { "x", _("経験値を得る(指定可)", "Get experience") },
78     { "X", _("所持品を初期状態に戻す", "Return inventory to initial") },
79     { "y", _("ダメージ100万・半径0の弱魔力のボールを放つ", "Cast missile ball had power a million") },
80     { "z", _("近隣のモンスター消去", "Terminate near monsters") },
81     { "Z", _("フロアの全モンスター消去", "Terminate all monsters in floor") },
82     { "@", _("特殊スペルの発動", "Activate specified spells") },
83     { "\"", _("スポイラーのダンプ", "Dump spoiler") },
84     { "?", _("ヘルプ表示", "Help") },
85 };
86
87 /*!
88  * @brief デバグコマンドの一覧を表示する
89  * @param page ページ番号
90  * @param max_page ページ数
91  * @param page_size 1ページ行数
92  * @param max_line コマンド数
93  * @return なし
94  */
95 void display_debug_menu(int page, int max_page, int page_size, int max_line)
96 {
97     for (int y = 1; y < page_size + 3 ; y++)
98         term_erase(14, y, 64);
99
100     int r = 1;
101     int c = 15;
102     for (int i = 0; i < page_size; i++) {
103         int pos = page * page_size + i;
104         if (pos >= max_line)
105             break;
106
107         std::stringstream ss;
108         ss << debug_menu_table[pos][0] << ") " << debug_menu_table[pos][1];
109         put_str(ss.str().c_str(), r++, c);
110     }
111     if (max_page > 0)
112         put_str("-- more --", r++, c);
113 }
114
115 /*!
116  * @brief デバッグコマンド選択処理への分岐
117  * @param creature_ptr プレーヤーへの参照ポインタ
118  * @param cmd コマンドキー
119  * @return コマンド終了ならTRUE、ページ送りならFALSE
120  */
121 bool exe_cmd_debug(player_type *creature_ptr, char cmd)
122 {
123     switch (cmd) {
124     case ' ':
125     case '<':
126     case '>':
127     case KTRL('a'):
128         return FALSE;
129     case ESCAPE:
130     case '\n':
131     case '\r':
132         break;
133     case 'a':
134         wiz_cure_all(creature_ptr);
135         break;
136     case 'b':
137         wiz_teleport_back(creature_ptr);
138         break;
139     case 'c':
140         wiz_create_item(creature_ptr);
141         break;
142     case 'C':
143         wiz_create_named_art(creature_ptr, command_arg);
144         break;
145     case 'd':
146         detect_all(creature_ptr, DETECT_RAD_ALL * 3);
147         break;
148     case 'D':
149         wiz_dimension_door(creature_ptr);
150         break;
151     case 'e':
152         wiz_change_status(creature_ptr);
153         break;
154     case 'E':
155         if (creature_ptr->pclass == CLASS_BLUE_MAGE)
156             wiz_learn_blue_magic_all(creature_ptr);
157
158         break;
159     case 'f':
160         identify_fully(creature_ptr, FALSE, TV_NONE);
161         break;
162     case 'F':
163         wiz_create_feature(creature_ptr);
164         break;
165     case 'g':
166         if (command_arg <= 0)
167             command_arg = 1;
168
169         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE);
170         break;
171     case 'G':
172         wizard_game_modifier(creature_ptr);
173         break;
174     case 'H':
175         wiz_summon_horde(creature_ptr);
176         break;
177     case 'i':
178         (void)ident_spell(creature_ptr, FALSE, TV_NONE);
179         break;
180     case 'j':
181         wiz_jump_to_dungeon(creature_ptr);
182         break;
183     case 'l':
184         wiz_learn_items_all(creature_ptr);
185         break;
186     case 'm':
187         map_area(creature_ptr, DETECT_RAD_ALL * 3);
188         break;
189     case 'r':
190         gain_level_reward(creature_ptr, command_arg);
191         break;
192     case 'N':
193         wiz_summon_pet(creature_ptr, command_arg);
194         break;
195     case 'n':
196         wiz_summon_specific_enemy(creature_ptr, command_arg);
197         break;
198     case 'O':
199         wiz_dump_options();
200         break;
201     case 'o':
202         wiz_modify_item(creature_ptr);
203         break;
204     case 'p':
205         teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
206         break;
207     case 'P':
208         wizard_player_modifier(creature_ptr);
209         break;
210     case 's':
211         if (command_arg <= 0)
212             command_arg = 1;
213
214         wiz_summon_random_enemy(creature_ptr, command_arg);
215         break;
216     case 'S':
217         if (command_arg <= 0)
218             command_arg = 1;
219
220         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE);
221         break;
222     case 't':
223         teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
224         break;
225     case 'u':
226         for (int y = 0; y < creature_ptr->current_floor_ptr->height; y++)
227             for (int x = 0; x < creature_ptr->current_floor_ptr->width; x++)
228                 creature_ptr->current_floor_ptr->grid_array[y][x].info |= CAVE_GLOW | CAVE_MARK;
229
230         wiz_lite(creature_ptr, FALSE);
231         break;
232     case 'v':
233         if (command_arg <= 0)
234             command_arg = 1;
235
236         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE);
237         break;
238     case 'w':
239         wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
240         break;
241     case 'W':
242         do_cmd_wishing(creature_ptr, -1, TRUE, TRUE, TRUE);
243         break;
244     case 'x':
245         gain_exp(creature_ptr, command_arg ? command_arg : (creature_ptr->exp + 1));
246         break;
247     case 'X':
248         for (INVENTORY_IDX i = INVEN_TOTAL - 1; i >= 0; i--)
249             if (creature_ptr->inventory_list[i].k_idx)
250                 drop_from_inventory(creature_ptr, i, 999);
251
252         player_outfit(creature_ptr);
253         break;
254     case 'y':
255         wiz_kill_enemy(creature_ptr);
256         break;
257     case 'z':
258         wiz_zap_surrounding_monsters(creature_ptr);
259         break;
260     case 'Z':
261         wiz_zap_floor_monsters(creature_ptr);
262         break;
263     case '_':
264         probing(creature_ptr);
265         break;
266     case '@':
267         wiz_debug_spell(creature_ptr);
268         break;
269     case '"':
270         exe_output_spoilers();
271         break;
272     case '?':
273         do_cmd_help(creature_ptr);
274         break;
275     default:
276         msg_print("That is not a valid debug command.");
277         break;
278     }
279
280     return TRUE;
281 }
282
283 /*!
284  * @brief デバッグコマンドを選択する処理のメインルーチン /
285  * Ask for and parse a "debug command"
286  * The "command_arg" may have been set.
287  * @param creature_ptr プレーヤーへの参照ポインタ
288  * @return なし
289  * @details
290  * 番号を指定するには、それをN及びデバッグコマンドをXとしてとして「0N^aX」とする
291  */
292 void do_cmd_debug(player_type *creature_ptr)
293 {
294     TERM_LEN hgt, wid;
295     term_get_size(&wid, &hgt);
296
297     size_t max_line = debug_menu_table.size();
298     int page_size = hgt - 5;
299     int max_page = max_line / page_size + 1;
300     int page = 0;
301     char cmd;
302
303     while (TRUE) {
304         screen_save();
305         display_debug_menu(page, max_page, page_size, max_line);
306         get_com("Debug Command: ", &cmd, FALSE);
307         screen_load();
308
309         if (exe_cmd_debug(creature_ptr, cmd))
310             break;
311
312         page = (page + 1) % max_page;
313     }
314 }