From 9ce06e5785e27989b3f1cc68fcee1a03f824ef69 Mon Sep 17 00:00:00 2001 From: Habu Date: Mon, 1 Jul 2024 00:28:28 +0900 Subject: [PATCH] =?utf8?q?[Feature]=20PlayerRealm:=20=E8=81=B7=E6=A5=AD?= =?utf8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=A6=E9=AD=94=E6=B3=95?= =?utf8?q?=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PlayerRealmクラスの静的メンバ関数 get_spell_info に、指定した職業の テーブルから魔法情報を取得できるようにする引数を追加する。 引数を省略した場合はこれまで通り現在のプレイヤーの職業のテーブル (グローバル変数mp_ptrが指している)から魔法情報を取得する。 --- src/player/player-realm.cpp | 5 ++++- src/player/player-realm.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/player/player-realm.cpp b/src/player/player-realm.cpp index 94b11be6e..18c02e048 100644 --- a/src/player/player-realm.cpp +++ b/src/player/player-realm.cpp @@ -89,7 +89,7 @@ const LocalizedString &PlayerRealm::get_name(int realm) return it->second; } -const magic_type &PlayerRealm::get_spell_info(int realm, int spell_idx) +const magic_type &PlayerRealm::get_spell_info(int realm, int spell_idx, std::optional pclass) { if (spell_idx < 0 || 32 <= spell_idx) { THROW_EXCEPTION(std::invalid_argument, format("Invalid spell idx: %d", spell_idx)); @@ -98,6 +98,9 @@ const magic_type &PlayerRealm::get_spell_info(int realm, int spell_idx) const auto realm_enum = i2enum(realm); if (MAGIC_REALM_RANGE.contains(realm_enum)) { + if (pclass) { + return class_magics_info.at(enum2i(*pclass)).info[realm - 1][spell_idx]; + } return mp_ptr->info[realm - 1][spell_idx]; } if (TECHNIC_REALM_RANGE.contains(realm_enum)) { diff --git a/src/player/player-realm.h b/src/player/player-realm.h index 89e84e101..bf59e1d5a 100644 --- a/src/player/player-realm.h +++ b/src/player/player-realm.h @@ -4,6 +4,7 @@ #include "system/angband.h" #include "util/flag-group.h" #include +#include #include using RealmChoices = FlagGroup; @@ -18,7 +19,7 @@ public: PlayerRealm(PlayerType *player_ptr); static const LocalizedString &get_name(int realm); - static const magic_type &get_spell_info(int realm, int num); + static const magic_type &get_spell_info(int realm, int num, std::optional pclass = std::nullopt); static ItemKindType get_book(int realm); static RealmChoices get_realm1_choices(PlayerClassType pclass); static RealmChoices get_realm2_choices(PlayerClassType pclass); -- 2.11.0