if (ae_ptr->o_ptr->is_random_artifact()) {
auto act_ptr = find_activation_info(ae_ptr->o_ptr);
if (act_ptr.has_value()) {
- ae_ptr->lev = act_ptr->level;
+ ae_ptr->lev = act_ptr.value()->level;
}
return;
static bool activate_artifact(player_type *player_ptr, object_type *o_ptr)
{
concptr name = k_info[o_ptr->k_idx].name.c_str();
- auto act_ptr = find_activation_info(o_ptr);
- if (!act_ptr.has_value()) {
+ auto tmp_act_ptr = find_activation_info(o_ptr);
+ if (!tmp_act_ptr.has_value()) {
msg_print("Activation information is not found.");
return false;
}
- if (!switch_activation(player_ptr, &o_ptr, &act_ptr.value(), name)) {
+ auto *act_ptr = tmp_act_ptr.value();
+ if (!switch_activation(player_ptr, &o_ptr, act_ptr, name)) {
return false;
}
* @param o_ptr 対象のオブジェクト構造体ポインタ
* @return 発動効果構造体のポインタを返す
*/
-const std::optional<activation_type> find_activation_info(const object_type *o_ptr)
+std::optional<const activation_type *> find_activation_info(const object_type *o_ptr)
{
const auto index = activation_index(o_ptr);
- for (auto &p : activation_info) {
+ for (const auto &p : activation_info) {
if (p.index == index) {
- return p;
+ return &p;
}
}
struct activation_type;
struct object_type;;
int activation_index(const object_type *o_ptr);
-const std::optional<activation_type> find_activation_info(const object_type *o_ptr);
+std::optional<const activation_type *> find_activation_info(const object_type *o_ptr);
* @brief ランダムアーティファクトの発動ID定義
*/
enum random_art_activation_type : uint8_t {
+ ACT_NONE = 0,
ACT_SUNLIGHT = 1,
ACT_BO_MISS_1 = 2,
ACT_BA_POIS_1 = 3,
{ "ELBERETH", ACT_ELBERETH, 10, 30000, { 75, 0 }, _("エルベレスの結界", "Rune of Elbereth") },
{ "DETECT_TREASURE", ACT_DETECT_TREASURE, 10, 3000, {35, 0}, _("財宝感知", "detect treasure") },
- { nullptr, 0, 0, 0, { 0, 0 }, "" },
+ { nullptr, ACT_NONE, 0, 0, { 0, 0 }, "" },
};
#include "system/angband.h"
#include <vector>
+enum random_art_activation_type : uint8_t;
struct activation_type {
concptr flag;
- byte index;
+ random_art_activation_type index;
byte level;
int32_t value;
struct {
return _("未定義", "something undefined");
}
- concptr desc = act_ptr->desc;
- switch (act_ptr->index) {
+ concptr desc = act_ptr.value()->desc;
+ switch (act_ptr.value()->index) {
case ACT_BR_FIRE:
if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
desc = _("火炎のブレス (200) と火への耐性", "breathe fire (200) and resist fire");
}
/* Timeout description */
- int constant = act_ptr->timeout.constant;
- int dice = act_ptr->timeout.dice;
+ int constant = act_ptr.value()->timeout.constant;
+ int dice = act_ptr.value()->timeout.dice;
if (constant == 0 && dice == 0) {
/* We can activate it every turn */
strcpy(timeout, _("いつでも", "every turn"));
} else if (constant < 0) {
/* Activations that have special timeout */
- switch (act_ptr->index) {
+ switch (act_ptr.value()->index) {
case ACT_BR_FIRE:
sprintf(timeout, _("%d ターン毎", "every %d turns"), ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
break;
if (o_ptr->art_name && (o_ptr->art_flags.has(TR_ACTIVATE))) {
auto act_ptr = find_activation_info(o_ptr);
if (act_ptr.has_value()) {
- total += act_ptr->value;
+ total += act_ptr.value()->value;
}
}