From e7b9f5164a2c2548a9b41ddae445829e750f9f6d Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Mon, 10 Oct 2022 23:28:35 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#2711=20choose=5Fdungeon()=20?= =?utf8?q?=E3=82=92dungeon.cpp/h=20=E3=81=8B=E3=82=89=20spells-world.cpp/h?= =?utf8?q?=20=E3=81=B8=E7=A7=BB=E5=8B=95=E3=81=95=E3=81=9B=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/dungeon/dungeon.cpp | 84 ----------------------------------------- src/dungeon/dungeon.h | 3 -- src/spell-kind/spells-world.cpp | 84 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 77 insertions(+), 94 deletions(-) diff --git a/src/dungeon/dungeon.cpp b/src/dungeon/dungeon.cpp index d0f01f7ad..5521c6784 100644 --- a/src/dungeon/dungeon.cpp +++ b/src/dungeon/dungeon.cpp @@ -1,16 +1,4 @@ #include "dungeon/dungeon.h" -#include "game-option/birth-options.h" -#include "grid/feature.h" -#include "io/input-key-acceptor.h" -#include "main/sound-of-music.h" -#include "monster-race/monster-race.h" -#include "system/floor-type-definition.h" -#include "system/monster-race-definition.h" -#include "system/player-type-definition.h" -#include "term/screen-processor.h" -#include "util/int-char-converter.h" -#include "view/display-messages.h" -#include "world/world.h" /* * The dungeon arrays @@ -21,75 +9,3 @@ std::vector dungeons_info; * Maximum number of dungeon in DungeonDefinitions.txt */ std::vector max_dlv; - -/*! - * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。 - * @param note ダンジョンに施す処理記述 - * @param y コンソールY座標 - * @param x コンソールX座標 - * @return 選択されたダンジョンID - */ -DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x) -{ - DUNGEON_IDX select_dungeon; - - /* Hack -- No need to choose dungeon in some case */ - if (lite_town || vanilla_town || ironman_downward) { - if (max_dlv[DUNGEON_ANGBAND]) { - return DUNGEON_ANGBAND; - } else { - msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), dungeons_info[DUNGEON_ANGBAND].name.c_str()); - msg_print(nullptr); - return 0; - } - } - - std::vector dun; - - screen_save(); - for (const auto &d_ref : dungeons_info) { - char buf[80]; - bool seiha = false; - - if (d_ref.idx == 0 || !d_ref.maxdepth) { - continue; - } - if (!max_dlv[d_ref.idx]) { - continue; - } - if (MonsterRace(d_ref.final_guardian).is_valid()) { - if (!monraces_info[d_ref.final_guardian].max_num) { - seiha = true; - } - } else if (max_dlv[d_ref.idx] == d_ref.maxdepth) { - seiha = true; - } - - sprintf(buf, _(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"), - static_cast('a' + dun.size()), seiha ? '!' : ' ', d_ref.name.c_str(), (int)max_dlv[d_ref.idx]); - prt(buf, y + dun.size(), x); - dun.push_back(d_ref.idx); - } - - if (dun.empty()) { - prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x); - } - - prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0); - while (true) { - auto i = inkey(); - if ((i == ESCAPE) || dun.empty()) { - screen_load(); - return 0; - } - if (i >= 'a' && i < static_cast('a' + dun.size())) { - select_dungeon = dun[i - 'a']; - break; - } else { - bell(); - } - } - screen_load(); - - return select_dungeon; -} diff --git a/src/dungeon/dungeon.h b/src/dungeon/dungeon.h index d3e4d8a16..d71fc9631 100644 --- a/src/dungeon/dungeon.h +++ b/src/dungeon/dungeon.h @@ -108,6 +108,3 @@ struct dungeon_type { extern std::vector max_dlv; extern std::vector dungeons_info; - -class PlayerType; -DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x); diff --git a/src/spell-kind/spells-world.cpp b/src/spell-kind/spells-world.cpp index b8294266e..36fd4f3bb 100644 --- a/src/spell-kind/spells-world.cpp +++ b/src/spell-kind/spells-world.cpp @@ -1,10 +1,15 @@ -#include "spell-kind/spells-world.h" +/* + * @brief 帰還やテレポート・レベル等、フロアを跨ぐ魔法効果の処理 + * @author Hourier + * @date 2022/10/10 + */ + +#include "spell-kind/spells-world.h" #include "cmd-io/cmd-save.h" #include "core/asking-player.h" #include "core/player-redraw-types.h" #include "dungeon/dungeon.h" #include "dungeon/quest-completion-checker.h" -#include "dungeon/quest.h" #include "floor/cave.h" #include "floor/floor-mode-changer.h" #include "floor/floor-town.h" @@ -20,14 +25,9 @@ #include "market/building-util.h" #include "monster-floor/monster-remover.h" #include "monster-race/monster-race.h" -#include "monster-race/race-ability-mask.h" -#include "monster-race/race-flags-resistance.h" #include "monster-race/race-flags1.h" -#include "monster-race/race-resistance-mask.h" #include "monster/monster-describer.h" #include "monster/monster-description-types.h" -#include "monster/monster-info.h" -#include "player/player-status.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" #include "system/monster-race-definition.h" @@ -366,6 +366,76 @@ void reserve_alter_reality(PlayerType *player_ptr, TIME_EFFECT turns) } /*! + * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。 + * @param note ダンジョンに施す処理記述 + * @param y コンソールY座標 + * @param x コンソールX座標 + * @return 選択されたダンジョンID + */ +static DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x) +{ + DUNGEON_IDX select_dungeon; + if (lite_town || vanilla_town || ironman_downward) { + if (max_dlv[DUNGEON_ANGBAND]) { + return DUNGEON_ANGBAND; + } else { + msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), dungeons_info[DUNGEON_ANGBAND].name.c_str()); + msg_print(nullptr); + return 0; + } + } + + std::vector dun; + + screen_save(); + for (const auto &d_ref : dungeons_info) { + char buf[80]; + bool seiha = false; + + if (d_ref.idx == 0 || !d_ref.maxdepth) { + continue; + } + if (!max_dlv[d_ref.idx]) { + continue; + } + if (MonsterRace(d_ref.final_guardian).is_valid()) { + if (!monraces_info[d_ref.final_guardian].max_num) { + seiha = true; + } + } else if (max_dlv[d_ref.idx] == d_ref.maxdepth) { + seiha = true; + } + + sprintf(buf, _(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"), + static_cast('a' + dun.size()), seiha ? '!' : ' ', d_ref.name.c_str(), (int)max_dlv[d_ref.idx]); + prt(buf, y + dun.size(), x); + dun.push_back(d_ref.idx); + } + + if (dun.empty()) { + prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x); + } + + prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0); + while (true) { + auto i = inkey(); + if ((i == ESCAPE) || dun.empty()) { + screen_load(); + return 0; + } + if (i >= 'a' && i < static_cast('a' + dun.size())) { + select_dungeon = dun[i - 'a']; + break; + } else { + bell(); + } + } + screen_load(); + + return select_dungeon; +} + +/*! * @brief プレイヤーの帰還発動及び中止処理 / * Recall the player to town or dungeon * @param player_ptr プレイヤーへの参照ポインタ -- 2.11.0