OSDN Git Service

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