OSDN Git Service

[Refactor] Moved jump_floor() from floor-leaver.cpp/h to wizard-special-process.cpp
[hengbandforosx/hengbandosx.git] / src / wizard / wizard-special-process.cpp
1 /*!
2  * @brief ウィザードモードの処理(特別処理中心) / Wizard commands
3  * @date 2014/09/07
4  * @author
5  * Copyright (c) 1997 Ben Harrison, and others<br>
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.<br>
9  * 2014 Deskull rearranged comment for Doxygen.<br>
10  */
11
12 #include "wizard/wizard-special-process.h"
13 #include "artifact/fixed-art-generator.h"
14 #include "artifact/fixed-art-types.h"
15 #include "birth/inventory-initializer.h"
16 #include "cmd-io/cmd-dump.h"
17 #include "cmd-io/cmd-help.h"
18 #include "cmd-io/cmd-save.h"
19 #include "cmd-visual/cmd-draw.h"
20 #include "core/asking-player.h"
21 #include "core/player-redraw-types.h"
22 #include "core/player-update-types.h"
23 #include "core/stuff-handler.h"
24 #include "core/window-redrawer.h"
25 #include "dungeon/quest.h"
26 #include "flavor/flavor-describer.h"
27 #include "flavor/object-flavor-types.h"
28 #include "flavor/object-flavor.h"
29 #include "floor/floor-leaver.h"
30 #include "floor/floor-mode-changer.h"
31 #include "floor/floor-object.h"
32 #include "game-option/birth-options.h"
33 #include "game-option/option-types-table.h"
34 #include "game-option/play-record-options.h"
35 #include "game-option/special-options.h"
36 #include "grid/feature.h"
37 #include "grid/grid.h"
38 #include "info-reader/fixed-map-parser.h"
39 #include "inventory/inventory-object.h"
40 #include "inventory/inventory-slot-types.h"
41 #include "io/files-util.h"
42 #include "io/input-key-requester.h"
43 #include "io/write-diary.h"
44 #include "market/arena.h"
45 #include "monster-floor/monster-remover.h"
46 #include "monster-floor/monster-summon.h"
47 #include "monster/monster-describer.h"
48 #include "monster/monster-description-types.h"
49 #include "monster/monster-info.h"
50 #include "monster/monster-status.h"
51 #include "monster/smart-learn-types.h"
52 #include "mutation/mutation-investor-remover.h"
53 #include "object-enchant/item-apply-magic.h"
54 #include "object-enchant/item-magic-applier.h"
55 #include "object-enchant/trc-types.h"
56 #include "object-enchant/trg-types.h"
57 #include "object/object-kind-hook.h"
58 #include "perception/object-perception.h"
59 #include "player-base/player-class.h"
60 #include "player-base/player-race.h"
61 #include "player-info/class-info.h"
62 #include "player-info/race-info.h"
63 #include "player-info/race-types.h"
64 #include "player-info/self-info.h"
65 #include "player-status/player-energy.h"
66 #include "player/digestion-processor.h"
67 #include "player/patron.h"
68 #include "player/player-skill.h"
69 #include "player/player-status-table.h"
70 #include "player/player-status.h"
71 #include "player/race-info-table.h"
72 #include "spell-kind/spells-detection.h"
73 #include "spell-kind/spells-sight.h"
74 #include "spell-kind/spells-teleport.h"
75 #include "spell-kind/spells-world.h"
76 #include "spell/spells-object.h"
77 #include "spell/spells-status.h"
78 #include "spell/spells-summon.h"
79 #include "status/bad-status-setter.h"
80 #include "status/experience.h"
81 #include "system/angband-version.h"
82 #include "system/artifact-type-definition.h"
83 #include "system/baseitem-info-definition.h"
84 #include "system/dungeon-info.h"
85 #include "system/floor-type-definition.h"
86 #include "system/grid-type-definition.h"
87 #include "system/monster-type-definition.h"
88 #include "system/object-type-definition.h"
89 #include "system/player-type-definition.h"
90 #include "system/terrain-type-definition.h"
91 #include "target/grid-selector.h"
92 #include "term/screen-processor.h"
93 #include "util/angband-files.h"
94 #include "util/bit-flags-calculator.h"
95 #include "util/enum-converter.h"
96 #include "util/int-char-converter.h"
97 #include "view/display-messages.h"
98 #include "wizard/spoiler-table.h"
99 #include "wizard/tval-descriptions-table.h"
100 #include "wizard/wizard-spells.h"
101 #include "wizard/wizard-spoiler.h"
102 #include "world/world.h"
103 #include <algorithm>
104 #include <optional>
105 #include <sstream>
106 #include <tuple>
107 #include <vector>
108
109 #define NUM_O_SET 8
110 #define NUM_O_BIT 32
111
112 /*!
113  * @brief プレイヤーを完全回復する
114  */
115 void wiz_cure_all(PlayerType *player_ptr)
116 {
117     (void)life_stream(player_ptr, false, false);
118     (void)restore_mana(player_ptr, true);
119     (void)set_food(player_ptr, PY_FOOD_MAX - 1);
120     BadStatusSetter bss(player_ptr);
121     (void)bss.set_fear(0);
122     (void)bss.set_deceleration(0, false);
123     msg_print("You're fully cured by wizard command.");
124 }
125
126 static std::optional<KIND_OBJECT_IDX> wiz_select_tval()
127 {
128     KIND_OBJECT_IDX list;
129     char ch;
130     for (list = 0; (list < 80) && (tvals[list].tval > ItemKindType::NONE); list++) {
131         auto row = 2 + (list % 20);
132         auto col = _(32, 24) * (list / 20);
133         ch = listsym[list];
134         prt(format("[%c] %s", ch, tvals[list].desc), row, col);
135     }
136
137     auto max_num = list;
138     if (!get_com(_("アイテム種別を選んで下さい", "Get what type of object? "), &ch, false)) {
139         return std::nullopt;
140     }
141
142     KIND_OBJECT_IDX selection;
143     for (selection = 0; selection < max_num; selection++) {
144         if (listsym[selection] == ch) {
145             break;
146         }
147     }
148
149     if ((selection < 0) || (selection >= max_num)) {
150         return std::nullopt;
151     }
152
153     return selection;
154 }
155
156 static KIND_OBJECT_IDX wiz_select_sval(const ItemKindType tval, concptr tval_description)
157 {
158     auto num = 0;
159     KIND_OBJECT_IDX choice[80]{};
160     char ch;
161     for (const auto &k_ref : baseitems_info) {
162         if (num >= 80) {
163             break;
164         }
165
166         if (k_ref.idx == 0 || k_ref.tval != tval) {
167             continue;
168         }
169
170         auto row = 2 + (num % 20);
171         auto col = _(30, 32) * (num / 20);
172         ch = listsym[num];
173         const auto buf = strip_name(k_ref.idx);
174         prt(format("[%c] %s", ch, buf.c_str()), row, col);
175         choice[num++] = k_ref.idx;
176     }
177
178     auto max_num = num;
179     if (!get_com(format(_("%s群の具体的なアイテムを選んで下さい", "What Kind of %s? "), tval_description), &ch, false)) {
180         return 0;
181     }
182
183     KIND_OBJECT_IDX selection;
184     for (selection = 0; selection < max_num; selection++) {
185         if (listsym[selection] == ch) {
186             break;
187         }
188     }
189
190     if ((selection < 0) || (selection >= max_num)) {
191         return 0;
192     }
193
194     return choice[selection];
195 }
196
197 /*!
198  * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
199  * Specify tval and sval (type and subtype of object) originally
200  * @return ベースアイテムID
201  * @details
202  * by RAK, heavily modified by -Bernd-
203  * This function returns the k_idx of an object type, or zero if failed
204  * List up to 50 choices in three columns
205  */
206 static KIND_OBJECT_IDX wiz_create_itemtype()
207 {
208     term_clear();
209     auto selection = wiz_select_tval();
210     if (!selection.has_value()) {
211         return 0;
212     }
213
214     auto tval = tvals[selection.value()].tval;
215     auto tval_description = tvals[selection.value()].desc;
216     term_clear();
217     return wiz_select_sval(tval, tval_description);
218 }
219
220 /*!
221  * @brief 任意のベースアイテム生成のメインルーチン /
222  * Wizard routine for creating objects          -RAK-
223  * @details
224  * Heavily modified to allow magification and artifactification  -Bernd-
225  *
226  * Note that wizards cannot create objects on top of other objects.
227  *
228  * Hack -- this routine always makes a "dungeon object", and applies
229  * magic to it, and attempts to decline cursed items.
230  */
231 void wiz_create_item(PlayerType *player_ptr)
232 {
233     screen_save();
234     OBJECT_IDX k_idx = wiz_create_itemtype();
235     screen_load();
236     if (!k_idx) {
237         return;
238     }
239
240     if (baseitems_info[k_idx].gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
241         for (const auto &[a_idx, a_ref] : artifacts_info) {
242             if ((a_idx == FixedArtifactId::NONE) || (a_ref.tval != baseitems_info[k_idx].tval) || (a_ref.sval != baseitems_info[k_idx].sval)) {
243                 continue;
244             }
245
246             (void)create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
247             msg_print("Allocated(INSTA_ART).");
248             return;
249         }
250     }
251
252     ObjectType forge;
253     ObjectType *q_ptr;
254     q_ptr = &forge;
255     q_ptr->prep(k_idx);
256     ItemMagicApplier(player_ptr, q_ptr, player_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART).execute();
257     (void)drop_near(player_ptr, q_ptr, -1, player_ptr->y, player_ptr->x);
258     msg_print("Allocated.");
259 }
260
261 /*!
262  * @brief 指定したIDの固定アーティファクトの名称を取得する
263  *
264  * @param a_idx 固定アーティファクトのID
265  * @return 固定アーティファクトの名称(Ex. ★ロング・ソード『リンギル』)を保持する std::string オブジェクト
266  */
267 static std::string wiz_make_named_artifact_desc(PlayerType *player_ptr, FixedArtifactId a_idx)
268 {
269     const auto &a_ref = artifacts_info.at(a_idx);
270     ObjectType obj;
271     obj.prep(lookup_kind(a_ref.tval, a_ref.sval));
272     obj.fixed_artifact_idx = a_idx;
273     object_known(&obj);
274     char buf[MAX_NLEN];
275     describe_flavor(player_ptr, buf, &obj, OD_NAME_ONLY);
276
277     return buf;
278 }
279
280 /**
281  * @brief 固定アーティファクトをリストから選択する
282  *
283  * @param a_idx_list 選択する候補となる固定アーティファクトのIDのリスト
284  * @return 選択した固定アーティファクトのIDを返す。但しキャンセルした場合は std::nullopt を返す。
285  */
286 static std::optional<FixedArtifactId> wiz_select_named_artifact(PlayerType *player_ptr, const std::vector<FixedArtifactId> &a_idx_list)
287 {
288     constexpr auto MAX_PER_PAGE = 20UL;
289     const auto page_max = (a_idx_list.size() - 1) / MAX_PER_PAGE + 1;
290     auto current_page = 0UL;
291
292     screen_save();
293
294     std::optional<FixedArtifactId> selected_a_idx;
295
296     while (!selected_a_idx.has_value()) {
297         const auto page_base_idx = current_page * MAX_PER_PAGE;
298         for (auto i = 0U; i < MAX_PER_PAGE + 1; ++i) {
299             term_erase(14, i + 1, 255);
300         }
301         const auto page_item_count = std::min(MAX_PER_PAGE, a_idx_list.size() - page_base_idx);
302         for (auto i = 0U; i < page_item_count; ++i) {
303             std::stringstream ss;
304             ss << I2A(i) << ") " << wiz_make_named_artifact_desc(player_ptr, a_idx_list[page_base_idx + i]);
305             put_str(ss.str().c_str(), i + 1, 15);
306         }
307         if (page_max > 1) {
308             put_str(format("-- more (%d/%d) --", current_page + 1, page_max), page_item_count + 1, 15);
309         }
310
311         char cmd = ESCAPE;
312         get_com("Which artifact: ", &cmd, false);
313         switch (cmd) {
314         case ESCAPE:
315             screen_load();
316             return selected_a_idx;
317         case ' ':
318             current_page++;
319             if (current_page >= page_max) {
320                 current_page = 0;
321             }
322             break;
323         default:
324             const auto select_idx = A2I(cmd) + page_base_idx;
325             if (select_idx < a_idx_list.size()) {
326                 selected_a_idx = a_idx_list[select_idx];
327             }
328             break;
329         }
330     }
331
332     screen_load();
333
334     return selected_a_idx;
335 }
336
337 /**
338  * @brief 指定したカテゴリの固定アーティファクトのIDのリストを得る
339  *
340  * @param group_artifact 固定アーティファクトのカテゴリ
341  * @return 該当のカテゴリの固定アーティファクトのIDのリスト
342  */
343 static std::vector<FixedArtifactId> wiz_collect_group_a_idx(const grouper &group_artifact)
344 {
345     const auto &[tval_list, name] = group_artifact;
346     std::vector<FixedArtifactId> a_idx_list;
347     for (auto tval : tval_list) {
348         for (const auto &[a_idx, a_ref] : artifacts_info) {
349             if (a_ref.tval == tval) {
350                 a_idx_list.push_back(a_idx);
351             }
352         }
353     }
354     return a_idx_list;
355 }
356
357 /*!
358  * @brief 固定アーティファクトを生成する / Create the artifact
359  */
360 void wiz_create_named_art(PlayerType *player_ptr)
361 {
362     screen_save();
363     for (auto i = 0U; i < group_artifact_list.size(); ++i) {
364         const auto &[tval_lit, name] = group_artifact_list[i];
365         std::stringstream ss;
366         ss << I2A(i) << ") " << name;
367         term_erase(14, i + 1, 255);
368         put_str(ss.str().c_str(), i + 1, 15);
369     }
370
371     std::optional<FixedArtifactId> create_a_idx;
372     while (!create_a_idx.has_value()) {
373         char cmd = ESCAPE;
374         get_com("Kind of artifact: ", &cmd, false);
375         switch (cmd) {
376         case ESCAPE:
377             screen_load();
378             return;
379         default:
380             if (auto idx = A2I(cmd); idx < group_artifact_list.size()) {
381                 const auto a_idx_list = wiz_collect_group_a_idx(group_artifact_list[idx]);
382                 create_a_idx = wiz_select_named_artifact(player_ptr, a_idx_list);
383             }
384         }
385     }
386
387     screen_load();
388     const auto a_idx = create_a_idx.value();
389     const auto it = artifacts_info.find(a_idx);
390     if (it == artifacts_info.end()) {
391         msg_print("The specified artifact is obsoleted for now.");
392         return;
393     }
394
395     auto &a_ref = it->second;
396     if (a_ref.is_generated) {
397         msg_print("It's already allocated.");
398         return;
399     }
400
401     (void)create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
402     msg_print("Allocated.");
403 }
404
405 /*!
406  * @brief プレイヤーの現能力値を調整する / Change various "permanent" player variables.
407  * @param player_ptr プレイヤーへの参照ポインタ
408  */
409 void wiz_change_status(PlayerType *player_ptr)
410 {
411     int tmp_int;
412     char tmp_val[160];
413     char ppp[80];
414     for (int i = 0; i < A_MAX; i++) {
415         sprintf(ppp, "%s (3-%d): ", stat_names[i], player_ptr->stat_max_max[i]);
416         sprintf(tmp_val, "%d", player_ptr->stat_max[i]);
417         if (!get_string(ppp, tmp_val, 3)) {
418             return;
419         }
420
421         tmp_int = atoi(tmp_val);
422         if (tmp_int > player_ptr->stat_max_max[i]) {
423             tmp_int = player_ptr->stat_max_max[i];
424         } else if (tmp_int < 3) {
425             tmp_int = 3;
426         }
427
428         player_ptr->stat_cur[i] = player_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
429     }
430
431     sprintf(tmp_val, "%d", PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));
432     if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 4)) {
433         return;
434     }
435
436     auto tmp_s16b = std::clamp(static_cast<SUB_EXP>(atoi(tmp_val)),
437         PlayerSkill::weapon_exp_at(PlayerSkillRank::UNSKILLED),
438         PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));
439
440     for (auto tval : TV_WEAPON_RANGE) {
441         for (int i = 0; i < 64; i++) {
442             player_ptr->weapon_exp[tval][i] = tmp_s16b;
443         }
444     }
445     PlayerSkill(player_ptr).limit_weapon_skills_by_max_value();
446
447     for (auto j : PLAYER_SKILL_KIND_TYPE_RANGE) {
448         player_ptr->skill_exp[j] = tmp_s16b;
449         auto short_pclass = enum2i(player_ptr->pclass);
450         if (player_ptr->skill_exp[j] > class_skills_info[short_pclass].s_max[j]) {
451             player_ptr->skill_exp[j] = class_skills_info[short_pclass].s_max[j];
452         }
453     }
454
455     int k;
456     for (k = 0; k < 32; k++) {
457         player_ptr->spell_exp[k] = std::min(PlayerSkill::spell_exp_at(PlayerSkillRank::MASTER), tmp_s16b);
458     }
459
460     for (; k < 64; k++) {
461         player_ptr->spell_exp[k] = std::min(PlayerSkill::spell_exp_at(PlayerSkillRank::EXPERT), tmp_s16b);
462     }
463
464     sprintf(tmp_val, "%ld", (long)(player_ptr->au));
465     if (!get_string("Gold: ", tmp_val, 9)) {
466         return;
467     }
468
469     long tmp_long = atol(tmp_val);
470     if (tmp_long < 0) {
471         tmp_long = 0L;
472     }
473
474     player_ptr->au = tmp_long;
475     sprintf(tmp_val, "%ld", (long)(player_ptr->max_exp));
476     if (!get_string("Experience: ", tmp_val, 9)) {
477         return;
478     }
479
480     tmp_long = atol(tmp_val);
481     if (tmp_long < 0) {
482         tmp_long = 0L;
483     }
484
485     if (PlayerRace(player_ptr).equals(PlayerRaceType::ANDROID)) {
486         return;
487     }
488
489     player_ptr->max_exp = tmp_long;
490     player_ptr->exp = tmp_long;
491     check_experience(player_ptr);
492     do_cmd_redraw(player_ptr);
493 }
494
495 /*!
496  * @brief 指定された地点の地形IDを変更する /
497  * Create desired feature
498  * @param creaturer_ptr プレイヤーへの参照ポインタ
499  */
500 void wiz_create_feature(PlayerType *player_ptr)
501 {
502     int f_val1, f_val2;
503     POSITION y, x;
504     if (!tgt_pt(player_ptr, &x, &y)) {
505         return;
506     }
507
508     grid_type *g_ptr;
509     g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
510
511     f_val1 = g_ptr->feat;
512     if (!get_value(_("実地形ID", "FeatureID"), 0, terrains_info.size() - 1, &f_val1)) {
513         return;
514     }
515
516     f_val2 = f_val1;
517     if (!get_value(_("偽装地形ID", "FeatureID"), 0, terrains_info.size() - 1, &f_val2)) {
518         return;
519     }
520
521     cave_set_feat(player_ptr, y, x, static_cast<FEAT_IDX>(f_val1));
522     g_ptr->mimic = (int16_t)f_val2;
523     TerrainType *f_ptr;
524     f_ptr = &terrains_info[g_ptr->get_feat_mimic()];
525
526     if (f_ptr->flags.has(TerrainCharacteristics::RUNE_PROTECTION) || f_ptr->flags.has(TerrainCharacteristics::RUNE_EXPLOSION)) {
527         g_ptr->info |= CAVE_OBJECT;
528     } else if (f_ptr->flags.has(TerrainCharacteristics::MIRROR)) {
529         g_ptr->info |= CAVE_GLOW | CAVE_OBJECT;
530     }
531
532     note_spot(player_ptr, y, x);
533     lite_spot(player_ptr, y, x);
534     player_ptr->update |= PU_FLOW;
535 }
536
537 /*
538  * @brief 選択したダンジョンの任意フロアを選択する
539  * @param player_ptr プレイヤーへの参照ポインタ
540  * @param dungeon_type ダンジョン番号
541  * @return フロアを選択したらtrue、キャンセルならfalse
542  * @details 0を指定すると地上に飛ぶが、元いた場所にしか飛ばない
543  * @todo 可能ならダンジョンの入口 (例:ルルイエなら大洋の真ん中)へ飛べるようにしたい
544  */
545 static bool select_debugging_floor(PlayerType *player_ptr, int dungeon_type)
546 {
547     auto max_depth = dungeons_info[dungeon_type].maxdepth;
548     if ((max_depth == 0) || (dungeon_type > static_cast<int>(dungeons_info.size()))) {
549         dungeon_type = DUNGEON_ANGBAND;
550     }
551
552     auto min_depth = (int)dungeons_info[dungeon_type].mindepth;
553     while (true) {
554         char ppp[80];
555         char tmp_val[160];
556         sprintf(ppp, "Jump to level (0, %d-%d): ", min_depth, max_depth);
557         sprintf(tmp_val, "%d", (int)player_ptr->current_floor_ptr->dun_level);
558         if (!get_string(ppp, tmp_val, 10)) {
559             return false;
560         }
561
562         auto tmp_command_arg = (COMMAND_ARG)atoi(tmp_val);
563         if (tmp_command_arg == 0) {
564             command_arg = tmp_command_arg;
565             break;
566         }
567
568         auto is_valid_floor = tmp_command_arg > 0;
569         is_valid_floor &= tmp_command_arg >= min_depth;
570         is_valid_floor &= tmp_command_arg <= max_depth;
571         if (is_valid_floor) {
572             command_arg = tmp_command_arg;
573             break;
574         }
575
576         msg_print("Invalid floor. Please re-input.");
577         continue;
578     }
579
580     return true;
581 }
582
583 /*!
584  * @brief デバッグ帰還のダンジョンを選ぶ
585  * @param player_ptr プレイヤーへの参照ポインタ
586  * @details 範囲外の値が選択されたら再入力を促す
587  */
588 static bool select_debugging_dungeon(PlayerType *player_ptr, DUNGEON_IDX *dungeon_type)
589 {
590     if (command_arg > 0) {
591         return true;
592     }
593
594     while (true) {
595         char ppp[80];
596         char tmp_val[160];
597         sprintf(ppp, "Jump which dungeon : ");
598         sprintf(tmp_val, "%d", player_ptr->dungeon_idx);
599         if (!get_string(ppp, tmp_val, 2)) {
600             return false;
601         }
602
603         *dungeon_type = (DUNGEON_IDX)atoi(tmp_val);
604         if ((*dungeon_type < DUNGEON_ANGBAND) || (*dungeon_type > DUNGEON_MAX)) {
605             msg_print("Invalid dungeon. Please re-input.");
606             continue;
607         }
608
609         return true;
610     }
611 }
612
613 /*!
614  * @brief 任意のダンジョン及び階層に飛ぶ
615  * Go to any level
616  */
617 static void jump_floor(PlayerType *player_ptr, DUNGEON_IDX dun_idx, DEPTH depth)
618 {
619     player_ptr->dungeon_idx = dun_idx;
620     auto &floor_ref = *player_ptr->current_floor_ptr;
621     floor_ref.dun_level = depth;
622     prepare_change_floor_mode(player_ptr, CFM_RAND_PLACE);
623     if (!floor_ref.is_in_dungeon()) {
624         player_ptr->dungeon_idx = 0;
625     }
626
627     floor_ref.inside_arena = false;
628     player_ptr->wild_mode = false;
629     leave_quest_check(player_ptr);
630     if (record_stair) {
631         exe_write_diary(player_ptr, DIARY_WIZ_TELE, 0, nullptr);
632     }
633
634     floor_ref.quest_number = QuestId::NONE;
635     PlayerEnergy(player_ptr).reset_player_turn();
636     player_ptr->energy_need = 0;
637     prepare_change_floor_mode(player_ptr, CFM_FIRST_FLOOR);
638     player_ptr->leaving = true;
639 }
640
641 /*!
642  * @brief 任意のダンジョン及び階層に飛ぶtための選択処理
643  * Go to any level
644  */
645 void wiz_jump_to_dungeon(PlayerType *player_ptr)
646 {
647     DUNGEON_IDX dungeon_type = 1;
648     if (!select_debugging_dungeon(player_ptr, &dungeon_type)) {
649         return;
650     }
651
652     if (!select_debugging_floor(player_ptr, dungeon_type)) {
653         return;
654     }
655
656     if (command_arg < dungeons_info[dungeon_type].mindepth) {
657         command_arg = 0;
658     }
659
660     if (command_arg > dungeons_info[dungeon_type].maxdepth) {
661         command_arg = (COMMAND_ARG)dungeons_info[dungeon_type].maxdepth;
662     }
663
664     msg_format("You jump to dungeon level %d.", command_arg);
665     if (autosave_l) {
666         do_cmd_save_game(player_ptr, true);
667     }
668
669     jump_floor(player_ptr, dungeon_type, command_arg);
670 }
671
672 /*!
673  * @brief 全ベースアイテムを鑑定済みにする /
674  * Become aware of a lot of objects
675  * @param player_ptr プレイヤーへの参照ポインタ
676  */
677 void wiz_learn_items_all(PlayerType *player_ptr)
678 {
679     ObjectType forge;
680     ObjectType *q_ptr;
681     for (const auto &k_ref : baseitems_info) {
682         if (k_ref.idx > 0 && k_ref.level <= command_arg) {
683             q_ptr = &forge;
684             q_ptr->prep(k_ref.idx);
685             object_aware(player_ptr, q_ptr);
686         }
687     }
688 }
689
690 /*!
691  * @brief プレイヤーの種族を変更する
692  */
693 void wiz_reset_race(PlayerType *player_ptr)
694 {
695     int val = enum2i<PlayerRaceType>(player_ptr->prace);
696     if (!get_value("RaceID", 0, MAX_RACES - 1, &val)) {
697         return;
698     }
699
700     player_ptr->prace = i2enum<PlayerRaceType>(val);
701     rp_ptr = &race_info[enum2i(player_ptr->prace)];
702
703     player_ptr->window_flags |= PW_PLAYER;
704     player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
705     player_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
706     handle_stuff(player_ptr);
707 }
708
709 /*!
710  * @brief プレイヤーの職業を変更する
711  * @todo 魔法領域の再選択などがまだ不完全、要実装。
712  */
713 void wiz_reset_class(PlayerType *player_ptr)
714 {
715     int val = enum2i<PlayerClassType>(player_ptr->pclass);
716     if (!get_value("ClassID", 0, PLAYER_CLASS_TYPE_MAX - 1, &val)) {
717         return;
718     }
719
720     player_ptr->pclass = i2enum<PlayerClassType>(val);
721     cp_ptr = &class_info[val];
722     mp_ptr = &class_magics_info[val];
723     PlayerClass(player_ptr).init_specific_data();
724     player_ptr->window_flags |= PW_PLAYER;
725     player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
726     player_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
727     handle_stuff(player_ptr);
728 }
729
730 /*!
731  * @brief プレイヤーの領域を変更する
732  * @todo 存在有無などは未判定。そのうちすべき。
733  */
734 void wiz_reset_realms(PlayerType *player_ptr)
735 {
736     int val1 = player_ptr->realm1;
737     if (!get_value("1st Realm (None=0)", 0, MAX_REALM - 1, &val1)) {
738         return;
739     }
740
741     int val2 = player_ptr->realm2;
742     if (!get_value("2nd Realm (None=0)", 0, MAX_REALM - 1, &val2)) {
743         return;
744     }
745
746     player_ptr->realm1 = static_cast<int16_t>(val1);
747     player_ptr->realm2 = static_cast<int16_t>(val2);
748     player_ptr->window_flags |= PW_PLAYER;
749     player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
750     player_ptr->redraw |= PR_BASIC;
751     handle_stuff(player_ptr);
752 }
753
754 /*!
755  * @brief 現在のオプション設定をダンプ出力する /
756  * @param player_ptr プレイヤーへの参照ポインタ
757  * Hack -- Dump option bits usage
758  */
759 void wiz_dump_options(void)
760 {
761     char buf[1024];
762     path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "opt_info.txt");
763     FILE *fff;
764     fff = angband_fopen(buf, "a");
765     if (fff == nullptr) {
766         msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
767         msg_print(nullptr);
768         return;
769     }
770
771     std::vector<std::vector<int>> exist(NUM_O_SET, std::vector<int>(NUM_O_BIT));
772
773     for (int i = 0; option_info[i].o_desc; i++) {
774         const option_type *ot_ptr = &option_info[i];
775         if (ot_ptr->o_var) {
776             exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
777         }
778     }
779
780     char title[200];
781     put_version(title);
782     fprintf(fff, "[Option bits usage on %s\n]", title);
783     fputs("Set - Bit (Page) Option Name\n", fff);
784     fputs("------------------------------------------------\n", fff);
785     for (int i = 0; i < NUM_O_SET; i++) {
786         for (int j = 0; j < NUM_O_BIT; j++) {
787             if (exist[i][j]) {
788                 const option_type *ot_ptr = &option_info[exist[i][j] - 1];
789                 fprintf(fff, "  %d -  %02d (%4d) %s\n", i, j, ot_ptr->o_page, ot_ptr->o_text);
790             } else {
791                 fprintf(fff, "  %d -  %02d\n", i, j);
792             }
793         }
794
795         fputc('\n', fff);
796     }
797
798     angband_fclose(fff);
799     msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
800 }
801
802 /*!
803  * @brief プレイ日数を変更する / Set gametime.
804  * @return 実際に変更を行ったらTRUEを返す
805  */
806 void set_gametime(void)
807 {
808     int game_time = 0;
809     if (!get_value("Dungeon Turn", 0, w_ptr->dungeon_turn_limit - 1, &game_time)) {
810         return;
811     }
812
813     w_ptr->dungeon_turn = w_ptr->game_turn = game_time;
814 }
815
816 /*!
817  * @brief プレイヤー近辺の全モンスターを消去する / Delete all nearby monsters
818  */
819 void wiz_zap_surrounding_monsters(PlayerType *player_ptr)
820 {
821     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
822         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
823         if (!m_ptr->is_valid() || (i == player_ptr->riding) || (m_ptr->cdis > MAX_SIGHT)) {
824             continue;
825         }
826
827         if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
828             GAME_TEXT m_name[MAX_NLEN];
829
830             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
831             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
832         }
833
834         delete_monster_idx(player_ptr, i);
835     }
836 }
837
838 /*!
839  * @brief フロアに存在する全モンスターを消去する / Delete all monsters
840  * @param player_ptr 術者の参照ポインタ
841  */
842 void wiz_zap_floor_monsters(PlayerType *player_ptr)
843 {
844     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
845         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
846         if (!m_ptr->is_valid() || (i == player_ptr->riding)) {
847             continue;
848         }
849
850         if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
851             GAME_TEXT m_name[MAX_NLEN];
852             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
853             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
854         }
855
856         delete_monster_idx(player_ptr, i);
857     }
858 }
859
860 void cheat_death(PlayerType *player_ptr)
861 {
862     if (player_ptr->sc) {
863         player_ptr->sc = player_ptr->age = 0;
864     }
865     player_ptr->age++;
866
867     w_ptr->noscore |= 0x0001;
868     msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
869     msg_print(nullptr);
870
871     player_ptr->is_dead = false;
872     (void)life_stream(player_ptr, false, false);
873     (void)restore_mana(player_ptr, true);
874     (void)recall_player(player_ptr, 0);
875     reserve_alter_reality(player_ptr, 0);
876
877     player_ptr->died_from = _("死の欺き", "Cheating death");
878     (void)set_food(player_ptr, PY_FOOD_MAX - 1);
879
880     auto *floor_ptr = player_ptr->current_floor_ptr;
881     floor_ptr->dun_level = 0;
882     floor_ptr->inside_arena = false;
883     player_ptr->phase_out = false;
884     leaving_quest = QuestId::NONE;
885     floor_ptr->quest_number = QuestId::NONE;
886     if (player_ptr->dungeon_idx) {
887         player_ptr->recall_dungeon = player_ptr->dungeon_idx;
888     }
889     player_ptr->dungeon_idx = 0;
890     if (lite_town || vanilla_town) {
891         player_ptr->wilderness_y = 1;
892         player_ptr->wilderness_x = 1;
893         if (vanilla_town) {
894             player_ptr->oldpy = 10;
895             player_ptr->oldpx = 34;
896         } else {
897             player_ptr->oldpy = 33;
898             player_ptr->oldpx = 131;
899         }
900     } else {
901         player_ptr->wilderness_y = 48;
902         player_ptr->wilderness_x = 5;
903         player_ptr->oldpy = 33;
904         player_ptr->oldpx = 131;
905     }
906
907     player_ptr->wild_mode = false;
908     player_ptr->leaving = true;
909
910     exe_write_diary(player_ptr, DIARY_DESCRIPTION, 1, _("                            しかし、生き返った。", "                            but revived."));
911     leave_floor(player_ptr);
912 }