OSDN Git Service

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