From 82782400c4bc995af9bf5db8201bea131ea095ae Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:20:02 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#3766=20build=5Factivation=5Fdescri?= =?utf8?q?ption()=20=E3=82=92ItemEntity=20=E3=81=AE=E3=82=AA=E3=83=96?= =?utf8?q?=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=83=A1=E3=82=BD=E3=83=83?= =?utf8?q?=E3=83=89=E3=81=B8=E7=A7=BB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/object/object-info.cpp | 61 +------------------------------ src/system/item-entity.cpp | 89 ++++++++++++++++++++++++++++++++++++---------- src/system/item-entity.h | 3 +- 3 files changed, 73 insertions(+), 80 deletions(-) diff --git a/src/object/object-info.cpp b/src/object/object-info.cpp index 15c686d5e..fa3079407 100644 --- a/src/object/object-info.cpp +++ b/src/object/object-info.cpp @@ -11,77 +11,18 @@ */ #include "object/object-info.h" -#include "artifact/fixed-art-types.h" #include "artifact/random-art-effects.h" #include "inventory/inventory-slot-types.h" -#include "monster-race/monster-race.h" #include "object-enchant/activation-info-table.h" -#include "object-enchant/object-ego.h" #include "player-base/player-class.h" #include "player/player-realm.h" #include "realm/realm-names-table.h" -#include "sv-definition/sv-other-types.h" #include "sv-definition/sv-ring-types.h" -#include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" -#include "system/monster-race-info.h" -#include "system/player-type-definition.h" -#include "term/term-color-types.h" -#include "util/bit-flags-calculator.h" #include "util/int-char-converter.h" #include -static std::string build_activation_description(const activation_type &act, const ItemEntity &item) -{ - switch (act.index) { - case RandomArtActType::NONE: - return act.desc; - case RandomArtActType::BR_FIRE: - if (item.bi_key == BaseitemKey(ItemKindType::RING, SV_RING_FLAMES)) { - return _("火炎のブレス (200) と火への耐性", "breathe fire (200) and resist fire"); - } - - return act.desc; - case RandomArtActType::BR_COLD: - if (item.bi_key == BaseitemKey(ItemKindType::RING, SV_RING_ICE)) { - return _("冷気のブレス (200) と冷気への耐性", "breathe cold (200) and resist cold"); - } - - return act.desc; - case RandomArtActType::BR_DRAGON: - return item.build_activation_description_dragon_breath(); - case RandomArtActType::AGGRAVATE: - if (item.is_specific_artifact(FixedArtifactId::HYOUSIGI)) { - return _("拍子木を打ちならす", "beat wooden clappers"); - } - - return act.desc; - case RandomArtActType::ACID_BALL_AND_RESISTANCE: - return _("アシッド・ボール (100) と酸への耐性", "ball of acid (100) and resist acid"); - case RandomArtActType::FIRE_BALL_AND_RESISTANCE: - return _("ファイア・ボール (100) と火への耐性", "ball of fire (100) and resist fire"); - case RandomArtActType::COLD_BALL_AND_RESISTANCE: - return _("アイス・ボール (100) と冷気への耐性", "ball of cold (100) and resist cold"); - case RandomArtActType::ELEC_BALL_AND_RESISTANCE: - return _("サンダー・ボール (100) と電撃への耐性", "ball of elec (100) and resist elec"); - case RandomArtActType::POIS_BALL_AND_RESISTANCE: - return _("ポイズン・ボール (100) と毒への耐性", "ball of poison (100) and resist elec"); - case RandomArtActType::RESIST_ACID: - return _("一時的な酸への耐性", "temporary resist acid"); - case RandomArtActType::RESIST_FIRE: - return _("一時的な火への耐性", "temporary resist fire"); - case RandomArtActType::RESIST_COLD: - return _("一時的な冷気への耐性", "temporary resist cold"); - case RandomArtActType::RESIST_ELEC: - return _("一時的な電撃への耐性", "temporary resist elec"); - case RandomArtActType::RESIST_POIS: - return _("一時的な毒への耐性", "temporary resist elec"); - default: - return act.desc; - } -} - static std::string build_timeout_description(const activation_type &act, const ItemEntity &item) { const auto constant = act.timeout.constant; @@ -137,7 +78,7 @@ static std::string item_activation_aux(const ItemEntity *o_ptr) return _("未定義", "something undefined"); } - const auto desc = build_activation_description(*it, *o_ptr); + const auto desc = o_ptr->build_activation_description(*it); const auto timeout = build_timeout_description(*it, *o_ptr); std::stringstream ss; ss << desc << _(" : ", " ") << timeout; diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp index 5e3343719..fd2db7ba4 100644 --- a/src/system/item-entity.cpp +++ b/src/system/item-entity.cpp @@ -20,6 +20,7 @@ #include "smith/object-smith.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-other-types.h" +#include "sv-definition/sv-ring-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/artifact-type-definition.h" #include "system/baseitem-info.h" @@ -906,29 +907,54 @@ TrFlags ItemEntity::get_flags_known() const return flags; } -/*! - * @brief アイテムの発動効果名称を返す (ドラゴンブレス) - * @return 発動名称 - */ -std::string ItemEntity::build_activation_description_dragon_breath() const +std::string ItemEntity::build_activation_description(const activation_type &act) const { - std::stringstream ss; - ss << _("", "breathe "); - auto n = 0; - const auto flags = this->get_flags(); - for (auto i = 0; dragonbreath_info[i].flag != 0; i++) { - if (flags.has(dragonbreath_info[i].flag)) { - if (n > 0) { - ss << _("、", ", "); - } + switch (act.index) { + case RandomArtActType::NONE: + return act.desc; + case RandomArtActType::BR_FIRE: + if (this->bi_key == BaseitemKey(ItemKindType::RING, SV_RING_FLAMES)) { + return _("火炎のブレス (200) と火への耐性", "breathe fire (200) and resist fire"); + } - ss << dragonbreath_info[i].name; - n++; + return act.desc; + case RandomArtActType::BR_COLD: + if (this->bi_key == BaseitemKey(ItemKindType::RING, SV_RING_ICE)) { + return _("冷気のブレス (200) と冷気への耐性", "breathe cold (200) and resist cold"); } - } - ss << _("のブレス(250)", " (250)"); - return ss.str(); + return act.desc; + case RandomArtActType::BR_DRAGON: + return this->build_activation_description_dragon_breath(); + case RandomArtActType::AGGRAVATE: + if (this->is_specific_artifact(FixedArtifactId::HYOUSIGI)) { + return _("拍子木を打ちならす", "beat wooden clappers"); + } + + return act.desc; + case RandomArtActType::ACID_BALL_AND_RESISTANCE: + return _("アシッド・ボール (100) と酸への耐性", "ball of acid (100) and resist acid"); + case RandomArtActType::FIRE_BALL_AND_RESISTANCE: + return _("ファイア・ボール (100) と火への耐性", "ball of fire (100) and resist fire"); + case RandomArtActType::COLD_BALL_AND_RESISTANCE: + return _("アイス・ボール (100) と冷気への耐性", "ball of cold (100) and resist cold"); + case RandomArtActType::ELEC_BALL_AND_RESISTANCE: + return _("サンダー・ボール (100) と電撃への耐性", "ball of elec (100) and resist elec"); + case RandomArtActType::POIS_BALL_AND_RESISTANCE: + return _("ポイズン・ボール (100) と毒への耐性", "ball of poison (100) and resist elec"); + case RandomArtActType::RESIST_ACID: + return _("一時的な酸への耐性", "temporary resist acid"); + case RandomArtActType::RESIST_FIRE: + return _("一時的な火への耐性", "temporary resist fire"); + case RandomArtActType::RESIST_COLD: + return _("一時的な冷気への耐性", "temporary resist cold"); + case RandomArtActType::RESIST_ELEC: + return _("一時的な電撃への耐性", "temporary resist elec"); + case RandomArtActType::RESIST_POIS: + return _("一時的な毒への耐性", "temporary resist elec"); + default: + return act.desc; + } } /*! @@ -1019,3 +1045,28 @@ RandomArtActType ItemEntity::get_activation_index() const return this->activation_id; } + +/*! + * @brief アイテムの発動効果名称を返す (ドラゴンブレス) + * @return 発動名称 + */ +std::string ItemEntity::build_activation_description_dragon_breath() const +{ + std::stringstream ss; + ss << _("", "breathe "); + auto n = 0; + const auto flags = this->get_flags(); + for (auto i = 0; dragonbreath_info[i].flag != 0; i++) { + if (flags.has(dragonbreath_info[i].flag)) { + if (n > 0) { + ss << _("、", ", "); + } + + ss << dragonbreath_info[i].name; + n++; + } + } + + ss << _("のブレス(250)", " (250)"); + return ss.str(); +} diff --git a/src/system/item-entity.h b/src/system/item-entity.h index 76be3ea1d..bf9b15d45 100644 --- a/src/system/item-entity.h +++ b/src/system/item-entity.h @@ -147,7 +147,7 @@ public: ArtifactType &get_fixed_artifact() const; TrFlags get_flags() const; TrFlags get_flags_known() const; - std::string build_activation_description_dragon_breath() const; + std::string build_activation_description(const activation_type &act) const; void mark_as_known(); void mark_as_tried(); @@ -158,4 +158,5 @@ private: int calc_capture_value() const; void modify_ego_lite_flags(TrFlags &flags) const; RandomArtActType get_activation_index() const; + std::string build_activation_description_dragon_breath() const; }; -- 2.11.0