#include "target/target-getter.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
+#include <utility>
+#include <vector>
/*!
* @brief 発動によるブレスの属性をアイテムの耐性から選択し、実行を処理する。/ Dragon breath activation
return false;
}
- const auto resistance_flags = o_ptr->get_flags();
-
- AttributeType type[20];
- int n = 0;
- concptr name[20];
- for (int i = 0; dragonbreath_info[i].flag != 0; i++) {
- if (resistance_flags.has(dragonbreath_info[i].flag)) {
- type[n] = dragonbreath_info[i].type;
- name[n] = dragonbreath_info[i].name;
- n++;
+ const auto flags = o_ptr->get_flags();
+ std::vector<std::pair<AttributeType, std::string>> breaths;
+ for (const auto &dragon_breath : dragonbreath_info) {
+ if (flags.has(dragon_breath.flag)) {
+ breaths.push_back({ dragon_breath.type, dragon_breath.name });
}
}
- if (n == 0) {
+ if (breaths.empty()) {
return false;
}
(void)SpellHex(player_ptr).stop_all_spells();
}
- int t = randint0(n);
- msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), name[t]);
- fire_breath(player_ptr, type[t], dir, 250, 4);
+ const auto t = randint0(breaths.size());
+ msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), breaths[t].second.data());
+ fire_breath(player_ptr, breaths[t].first, dir, 250, 4);
return true;
}
#include "object-enchant/dragon-breaths-table.h"
#include "effect/attribute-types.h"
+#include "locale/language-switcher.h"
+#include "object-enchant/tr-types.h"
/*!
* @brief 装備耐性に準じたブレス効果の選択テーブル /
* Define flags, effect type, name for dragon breath activation
*/
-const dragonbreath_type dragonbreath_info[] = {
+const std::vector<dragonbreath_type> dragonbreath_info = {
{ TR_RES_ACID, AttributeType::ACID, _("酸", "acid") },
{ TR_RES_ELEC, AttributeType::ELEC, _("電撃", "lightning") },
{ TR_RES_FIRE, AttributeType::FIRE, _("火炎", "fire") },
{ TR_RES_NETHER, AttributeType::NETHER, _("地獄", "nether") },
{ TR_RES_CHAOS, AttributeType::CHAOS, _("カオス", "chaos") },
{ TR_RES_DISEN, AttributeType::DISENCHANT, _("劣化", "disenchantment") },
- { TR_STR, AttributeType::NONE, nullptr }
};
#pragma once
-#include "effect/attribute-types.h"
-#include "object-enchant/tr-types.h"
-#include "system/angband.h"
+#include <vector>
+enum tr_type : int;
+enum class AttributeType;
struct dragonbreath_type {
tr_type flag;
AttributeType type;
- concptr name;
+ std::string name;
};
-extern const dragonbreath_type dragonbreath_info[];
+extern const std::vector<dragonbreath_type> dragonbreath_info;
#pragma once
-#include "system/angband.h"
-
#include <array>
/*!
* @todo TRが何の略か分かる人、補足求む
*/
-enum tr_type : int32_t {
+enum tr_type : int {
TR_STR = 0, /* STR += "pval" */
TR_INT = 1, /* INT += "pval" */
TR_WIS = 2, /* WIS += "pval" */
#include <vector>
enum class SmithEssenceType : int16_t;
-enum tr_type : int32_t;
+enum tr_type : int;
/*!
* @brief エッセンス抽出情報構造体
*/
std::string ItemEntity::build_activation_description_dragon_breath() const
{
+ const auto flags = this->get_flags();
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++;
+ auto has_multi_breaths = false;
+ for (const auto &dragon_breath : dragonbreath_info) {
+ if (flags.has_not(dragon_breath.flag)) {
+ continue;
}
+
+ if (has_multi_breaths) {
+ ss << _("、", ", ");
+ }
+
+ ss << dragon_breath.name;
+ has_multi_breaths = true;
}
ss << _("のブレス(250)", " (250)");