OSDN Git Service

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