OSDN Git Service

[Refactor] #4177 random_art_bias_type をenum class RandomArtifactBias に変えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Thu, 30 May 2024 12:01:37 +0000 (21:01 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Fri, 31 May 2024 23:01:41 +0000 (08:01 +0900)
12 files changed:
src/artifact/random-art-activation.cpp
src/artifact/random-art-bias-types.h
src/artifact/random-art-characteristics.cpp
src/artifact/random-art-generator.cpp
src/artifact/random-art-misc.cpp
src/artifact/random-art-pval-investor.cpp
src/artifact/random-art-resistance.cpp
src/artifact/random-art-slay.cpp
src/system/item-entity.cpp
src/system/item-entity.h
src/wizard/artifact-bias-table.cpp
src/wizard/artifact-bias-table.h

index c7d9353..857d60e 100644 (file)
@@ -221,54 +221,64 @@ void give_activation_power(ItemEntity *o_ptr)
     RandomArtActType type = RandomArtActType::NONE;
     int chance = 0;
     switch (o_ptr->artifact_bias) {
-    case BIAS_ELEC:
+    case RandomArtifactBias::ELEC:
         type = invest_activation_elec();
         chance = 101;
         break;
-    case BIAS_POIS:
+    case RandomArtifactBias::POIS:
         type = RandomArtActType::BA_POIS_1;
         chance = 101;
         break;
-    case BIAS_FIRE:
+    case RandomArtifactBias::FIRE:
         type = invest_activation_fire();
         chance = 101;
         break;
-    case BIAS_COLD:
+    case RandomArtifactBias::COLD:
         type = invest_activation_cold();
         chance = 101;
         break;
-    case BIAS_CHAOS:
+    case RandomArtifactBias::ACID:
+    case RandomArtifactBias::STR:
+    case RandomArtifactBias::INT:
+    case RandomArtifactBias::WIS:
+    case RandomArtifactBias::DEX:
+    case RandomArtifactBias::CON:
+    case RandomArtifactBias::CHR:
+        break;
+    case RandomArtifactBias::CHAOS:
         type = invest_activation_chaos();
         chance = 50;
         break;
-    case BIAS_PRIESTLY:
+    case RandomArtifactBias::PRIESTLY:
         type = invest_activation_priest();
         chance = 101;
         break;
-    case BIAS_NECROMANTIC:
+    case RandomArtifactBias::NECROMANTIC:
         type = invest_activation_necromancy();
         chance = 101;
         break;
-    case BIAS_LAW:
+    case RandomArtifactBias::LAW:
         type = invest_activation_law();
         chance = 101;
         break;
-    case BIAS_ROGUE:
+    case RandomArtifactBias::ROGUE:
         type = invest_activation_rogue();
         chance = 101;
         break;
-    case BIAS_MAGE:
+    case RandomArtifactBias::MAGE:
         type = invest_activation_mage();
         chance = 66;
         break;
-    case BIAS_WARRIOR:
+    case RandomArtifactBias::WARRIOR:
         type = invest_activation_warrior();
         chance = 80;
         break;
-    case BIAS_RANGER:
+    case RandomArtifactBias::RANGER:
         type = invest_activation_ranger();
         chance = 101;
         break;
+    default:
+        THROW_EXCEPTION(std::runtime_error, "Invalid artifact bias was set!");
     }
 
     if ((type == RandomArtActType::NONE) || (randint1(100) >= chance)) {
index 3f7d4c9..051f09a 100644 (file)
@@ -4,26 +4,26 @@
  * @brief ランダムアーティファクトのバイアス定義
  */
 
-enum random_art_bias_type : int {
-    BIAS_NONE = 0,
-    BIAS_ELEC = 1, /*!< ランダムアーティファクトバイアス:電撃 */
-    BIAS_POIS = 2, /*!< ランダムアーティファクトバイアス:毒 */
-    BIAS_FIRE = 3, /*!< ランダムアーティファクトバイアス:火炎 */
-    BIAS_COLD = 4, /*!< ランダムアーティファクトバイアス:冷気 */
-    BIAS_ACID = 5, /*!< ランダムアーティファクトバイアス:酸 */
-    BIAS_STR = 6, /*!< ランダムアーティファクトバイアス:腕力 */
-    BIAS_INT = 7, /*!< ランダムアーティファクトバイアス:知力 */
-    BIAS_WIS = 8, /*!< ランダムアーティファクトバイアス:賢さ */
-    BIAS_DEX = 9, /*!< ランダムアーティファクトバイアス:器用さ */
-    BIAS_CON = 10, /*!< ランダムアーティファクトバイアス:耐久 */
-    BIAS_CHR = 11, /*!< ランダムアーティファクトバイアス:魅力 */
-    BIAS_CHAOS = 12, /*!< ランダムアーティファクトバイアス:混沌 */
-    BIAS_PRIESTLY = 13, /*!< ランダムアーティファクトバイアス:プリースト系 */
-    BIAS_NECROMANTIC = 14, /*!< ランダムアーティファクトバイアス:死霊 */
-    BIAS_LAW = 15, /*!< ランダムアーティファクトバイアス:法 */
-    BIAS_ROGUE = 16, /*!< ランダムアーティファクトバイアス:盗賊系 */
-    BIAS_MAGE = 17, /*!< ランダムアーティファクトバイアス:メイジ系 */
-    BIAS_WARRIOR = 18, /*!< ランダムアーティファクトバイアス:戦士系 */
-    BIAS_RANGER = 19, /*!< ランダムアーティファクトバイアス:レンジャー系 */
-    MAX_BIAS = 20, /*!< ランダムアーティファクトバイアス:最大数 */
+enum class RandomArtifactBias : int {
+    NONE = 0,
+    ELEC = 1, /*!< ランダムアーティファクトバイアス:電撃 */
+    POIS = 2, /*!< ランダムアーティファクトバイアス:毒 */
+    FIRE = 3, /*!< ランダムアーティファクトバイアス:火炎 */
+    COLD = 4, /*!< ランダムアーティファクトバイアス:冷気 */
+    ACID = 5, /*!< ランダムアーティファクトバイアス:酸 */
+    STR = 6, /*!< ランダムアーティファクトバイアス:腕力 */
+    INT = 7, /*!< ランダムアーティファクトバイアス:知力 */
+    WIS = 8, /*!< ランダムアーティファクトバイアス:賢さ */
+    DEX = 9, /*!< ランダムアーティファクトバイアス:器用さ */
+    CON = 10, /*!< ランダムアーティファクトバイアス:耐久 */
+    CHR = 11, /*!< ランダムアーティファクトバイアス:魅力 */
+    CHAOS = 12, /*!< ランダムアーティファクトバイアス:混沌 */
+    PRIESTLY = 13, /*!< ランダムアーティファクトバイアス:プリースト系 */
+    NECROMANTIC = 14, /*!< ランダムアーティファクトバイアス:死霊 */
+    LAW = 15, /*!< ランダムアーティファクトバイアス:法 */
+    ROGUE = 16, /*!< ランダムアーティファクトバイアス:盗賊系 */
+    MAGE = 17, /*!< ランダムアーティファクトバイアス:メイジ系 */
+    WARRIOR = 18, /*!< ランダムアーティファクトバイアス:戦士系 */
+    RANGER = 19, /*!< ランダムアーティファクトバイアス:レンジャー系 */
+    MAX,
 };
index a53c3ee..3f48268 100644 (file)
@@ -147,8 +147,8 @@ std::string get_random_name(const ItemEntity &item, bool armour, int power)
         return get_table_name();
     }
 
-    auto filename = get_random_art_filename(armour, power);
-    auto random_artifact_name = get_random_line(filename.data(), item.artifact_bias);
+    const auto filename = get_random_art_filename(armour, power);
+    const auto random_artifact_name = get_random_line(filename.data(), enum2i(item.artifact_bias));
 #ifdef JP
     if (random_artifact_name) {
         return *random_artifact_name;
index 838ab5a..bb572d7 100644 (file)
@@ -80,74 +80,74 @@ static void set_artifact_bias(PlayerType *player_ptr, ItemEntity *o_ptr, int *wa
     case PlayerClassType::SAMURAI:
     case PlayerClassType::CAVALRY:
     case PlayerClassType::SMITH:
-        o_ptr->artifact_bias = BIAS_WARRIOR;
+        o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         break;
     case PlayerClassType::MAGE:
     case PlayerClassType::HIGH_MAGE:
     case PlayerClassType::SORCERER:
     case PlayerClassType::MAGIC_EATER:
     case PlayerClassType::BLUE_MAGE:
-        o_ptr->artifact_bias = BIAS_MAGE;
+        o_ptr->artifact_bias = RandomArtifactBias::MAGE;
         break;
     case PlayerClassType::PRIEST:
-        o_ptr->artifact_bias = BIAS_PRIESTLY;
+        o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         break;
     case PlayerClassType::ROGUE:
     case PlayerClassType::NINJA:
-        o_ptr->artifact_bias = BIAS_ROGUE;
+        o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         *warrior_artifact_bias = 25;
         break;
     case PlayerClassType::RANGER:
     case PlayerClassType::SNIPER:
-        o_ptr->artifact_bias = BIAS_RANGER;
+        o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         *warrior_artifact_bias = 30;
         break;
     case PlayerClassType::PALADIN:
-        o_ptr->artifact_bias = BIAS_PRIESTLY;
+        o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         *warrior_artifact_bias = 40;
         break;
     case PlayerClassType::WARRIOR_MAGE:
     case PlayerClassType::RED_MAGE:
-        o_ptr->artifact_bias = BIAS_MAGE;
+        o_ptr->artifact_bias = RandomArtifactBias::MAGE;
         *warrior_artifact_bias = 40;
         break;
     case PlayerClassType::CHAOS_WARRIOR:
-        o_ptr->artifact_bias = BIAS_CHAOS;
+        o_ptr->artifact_bias = RandomArtifactBias::CHAOS;
         *warrior_artifact_bias = 40;
         break;
     case PlayerClassType::MONK:
     case PlayerClassType::FORCETRAINER:
-        o_ptr->artifact_bias = BIAS_PRIESTLY;
+        o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         break;
     case PlayerClassType::MINDCRAFTER:
     case PlayerClassType::BARD:
         if (randint1(5) > 2) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
         break;
     case PlayerClassType::TOURIST:
         if (randint1(5) > 2) {
-            o_ptr->artifact_bias = BIAS_WARRIOR;
+            o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         }
         break;
     case PlayerClassType::IMITATOR:
         if (randint1(2) > 1) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
         break;
     case PlayerClassType::BEASTMASTER:
-        o_ptr->artifact_bias = BIAS_CHR;
+        o_ptr->artifact_bias = RandomArtifactBias::CHR;
         *warrior_artifact_bias = 50;
         break;
     case PlayerClassType::MIRROR_MASTER:
         if (randint1(4) > 1) {
-            o_ptr->artifact_bias = BIAS_MAGE;
+            o_ptr->artifact_bias = RandomArtifactBias::MAGE;
         } else {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
         break;
     case PlayerClassType::ELEMENTALIST:
-        o_ptr->artifact_bias = one_in_(2) ? BIAS_MAGE : BIAS_INT;
+        o_ptr->artifact_bias = one_in_(2) ? RandomArtifactBias::MAGE : RandomArtifactBias::INT;
         break;
 
     case PlayerClassType::MAX:
@@ -163,7 +163,7 @@ static void decide_warrior_bias(PlayerType *player_ptr, ItemEntity *o_ptr, const
     }
 
     if (a_scroll && (randint1(100) <= warrior_artifact_bias)) {
-        o_ptr->artifact_bias = BIAS_WARRIOR;
+        o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
     }
 }
 
@@ -415,7 +415,7 @@ static void generate_unnatural_random_artifact(
     o_ptr->randart_name = name_unnatural_random_artifact(player_ptr, o_ptr, a_scroll, power_level);
     msg_format_wizard(player_ptr, CHEAT_OBJECT,
         _("パワー %d で 価値 %d のランダムアーティファクト生成 バイアスは「%s」", "Random artifact generated - Power:%d Value:%d Bias:%s."), max_powers,
-        total_flags, ARTIFACT_BIAS_NAMES.at(i2enum<random_art_bias_type>(o_ptr->artifact_bias)).data());
+        total_flags, ARTIFACT_BIAS_NAMES.at(o_ptr->artifact_bias).data());
     static constexpr auto flags = {
         SubWindowRedrawingFlag::INVENTORY,
         SubWindowRedrawingFlag::EQUIPMENT,
@@ -435,7 +435,7 @@ static void generate_unnatural_random_artifact(
  */
 bool become_random_artifact(PlayerType *player_ptr, ItemEntity *o_ptr, bool a_scroll)
 {
-    o_ptr->artifact_bias = 0;
+    o_ptr->artifact_bias = RandomArtifactBias::NONE;
     o_ptr->fa_id = FixedArtifactId::NONE;
     o_ptr->ego_idx = EgoType::NONE;
     o_ptr->art_flags |= o_ptr->get_baseitem().flags;
@@ -469,7 +469,7 @@ bool become_random_artifact(PlayerType *player_ptr, ItemEntity *o_ptr, bool a_sc
     }
 
     invest_negative_modified_value(o_ptr);
-    if (((o_ptr->artifact_bias == BIAS_MAGE) || (o_ptr->artifact_bias == BIAS_INT)) && (o_ptr->bi_key.tval() == ItemKindType::GLOVES)) {
+    if (((o_ptr->artifact_bias == RandomArtifactBias::MAGE) || (o_ptr->artifact_bias == RandomArtifactBias::INT)) && (o_ptr->bi_key.tval() == ItemKindType::GLOVES)) {
         o_ptr->art_flags.set(TR_FREE_ACT);
     }
 
index e2047e8..4e5ce20 100644 (file)
@@ -110,23 +110,23 @@ static bool invest_misc_res_curse(ItemEntity *o_ptr)
 static bool switch_misc_bias(ItemEntity *o_ptr)
 {
     switch (o_ptr->artifact_bias) {
-    case BIAS_RANGER:
+    case RandomArtifactBias::RANGER:
         return invest_misc_ranger(o_ptr);
-    case BIAS_STR:
+    case RandomArtifactBias::STR:
         return invest_misc_strength(o_ptr);
-    case BIAS_INT:
+    case RandomArtifactBias::INT:
         return invest_misc_intelligence(o_ptr);
-    case BIAS_WIS:
+    case RandomArtifactBias::WIS:
         return invest_misc_wisdom(o_ptr);
-    case BIAS_DEX:
+    case RandomArtifactBias::DEX:
         return invest_misc_dexterity(o_ptr);
-    case BIAS_CON:
+    case RandomArtifactBias::CON:
         return invest_misc_constitution(o_ptr);
-    case BIAS_CHR:
+    case RandomArtifactBias::CHR:
         return invest_misc_charisma(o_ptr);
-    case BIAS_CHAOS:
+    case RandomArtifactBias::CHAOS:
         return invest_misc_chaos(o_ptr);
-    case BIAS_FIRE:
+    case RandomArtifactBias::FIRE:
         if (o_ptr->art_flags.has_not(TR_LITE_1)) {
             o_ptr->art_flags.set(TR_LITE_1);
         }
@@ -155,16 +155,16 @@ static void invest_misc_hit_dice(ItemEntity *o_ptr)
 
 static void invest_misc_string_esp(ItemEntity *o_ptr)
 {
-    constexpr std::array<std::tuple<tr_type, random_art_bias_type, int>, 3> candidates = { {
-        { TR_ESP_EVIL, BIAS_LAW, 3 },
-        { TR_ESP_NONLIVING, BIAS_MAGE, 3 },
-        { TR_TELEPATHY, BIAS_MAGE, 9 },
+    constexpr std::array<std::tuple<tr_type, RandomArtifactBias, int>, 3> candidates = { {
+        { TR_ESP_EVIL, RandomArtifactBias::LAW, 3 },
+        { TR_ESP_NONLIVING, RandomArtifactBias::MAGE, 3 },
+        { TR_TELEPATHY, RandomArtifactBias::MAGE, 9 },
     } };
 
     const auto &[flag, bias, denom] = rand_choice(candidates);
 
     o_ptr->art_flags.set(flag);
-    if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(denom)) {
+    if ((o_ptr->artifact_bias == RandomArtifactBias::NONE) && one_in_(denom)) {
         o_ptr->artifact_bias = bias;
     }
 }
@@ -174,17 +174,17 @@ static void switch_investment_weak_esps(ItemEntity *o_ptr, const int num_esp)
     switch (num_esp) {
     case 1:
         o_ptr->art_flags.set(TR_ESP_ANIMAL);
-        if (!o_ptr->artifact_bias && one_in_(4)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && one_in_(4)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
 
         break;
     case 2:
         o_ptr->art_flags.set(TR_ESP_UNDEAD);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
-        } else if (!o_ptr->artifact_bias && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_NECROMANTIC;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
+        } else if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
         }
 
         break;
@@ -205,22 +205,22 @@ static void switch_investment_weak_esps(ItemEntity *o_ptr, const int num_esp)
         break;
     case 8:
         o_ptr->art_flags.set(TR_ESP_HUMAN);
-        if (!o_ptr->artifact_bias && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
     case 9:
         o_ptr->art_flags.set(TR_ESP_GOOD);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_LAW;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::LAW;
         }
 
         break;
     case 10:
         o_ptr->art_flags.set(TR_ESP_UNIQUE);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_LAW;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::LAW;
         }
 
         break;
@@ -267,43 +267,43 @@ void random_misc(PlayerType *player_ptr, ItemEntity *o_ptr)
     switch (randint1(34)) {
     case 1:
         o_ptr->art_flags.set(TR_SUST_STR);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_STR;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::STR;
         }
 
         break;
     case 2:
         o_ptr->art_flags.set(TR_SUST_INT);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_INT;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::INT;
         }
 
         break;
     case 3:
         o_ptr->art_flags.set(TR_SUST_WIS);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_WIS;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::WIS;
         }
 
         break;
     case 4:
         o_ptr->art_flags.set(TR_SUST_DEX);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_DEX;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::DEX;
         }
 
         break;
     case 5:
         o_ptr->art_flags.set(TR_SUST_CON);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_CON;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::CON;
         }
 
         break;
     case 6:
         o_ptr->art_flags.set(TR_SUST_CHR);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_CHR;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::CHR;
         }
 
         break;
@@ -314,10 +314,10 @@ void random_misc(PlayerType *player_ptr, ItemEntity *o_ptr)
         break;
     case 9:
         o_ptr->art_flags.set(TR_HOLD_EXP);
-        if (!o_ptr->artifact_bias && one_in_(5)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
-        } else if (!o_ptr->artifact_bias && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_NECROMANTIC;
+        if (!o_ptr->has_bias() && one_in_(5)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
+        } else if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
         }
 
         break;
index d9dd0c1..6c98c5f 100644 (file)
@@ -107,26 +107,26 @@ static bool random_art_bias_search(ItemEntity *o_ptr)
 static bool switch_random_art_bias(ItemEntity *o_ptr)
 {
     switch (o_ptr->artifact_bias) {
-    case BIAS_WARRIOR:
+    case RandomArtifactBias::WARRIOR:
         return random_art_bias_strength(o_ptr) || random_art_bias_constitution(o_ptr) || random_art_bias_dexterity(o_ptr);
-    case BIAS_MAGE:
+    case RandomArtifactBias::MAGE:
         return random_art_bias_intelligence(o_ptr) || random_art_bias_magic_mastery(o_ptr);
-    case BIAS_RANGER:
+    case RandomArtifactBias::RANGER:
         return random_art_bias_dexterity(o_ptr) || random_art_bias_constitution(o_ptr) || random_art_bias_strength(o_ptr);
-    case BIAS_ROGUE:
+    case RandomArtifactBias::ROGUE:
         return random_art_bias_stealth(o_ptr) || random_art_bias_search(o_ptr);
-    case BIAS_STR:
+    case RandomArtifactBias::STR:
         return random_art_bias_strength(o_ptr);
-    case BIAS_INT:
+    case RandomArtifactBias::INT:
         return random_art_bias_intelligence(o_ptr);
-    case BIAS_PRIESTLY:
-    case BIAS_WIS:
+    case RandomArtifactBias::PRIESTLY:
+    case RandomArtifactBias::WIS:
         return random_art_bias_wisdom(o_ptr);
-    case BIAS_DEX:
+    case RandomArtifactBias::DEX:
         return random_art_bias_dexterity(o_ptr);
-    case BIAS_CON:
+    case RandomArtifactBias::CON:
         return random_art_bias_constitution(o_ptr);
-    case BIAS_CHR:
+    case RandomArtifactBias::CHR:
         return random_art_bias_charisma(o_ptr);
     default:
         return false;
@@ -135,7 +135,7 @@ static bool switch_random_art_bias(ItemEntity *o_ptr)
 
 static bool random_art_bias_decrease_mana(ItemEntity *o_ptr)
 {
-    auto should_skip = (o_ptr->artifact_bias != BIAS_MAGE) && (o_ptr->artifact_bias != BIAS_PRIESTLY);
+    auto should_skip = (o_ptr->artifact_bias != RandomArtifactBias::MAGE) && (o_ptr->artifact_bias != RandomArtifactBias::PRIESTLY);
     should_skip |= o_ptr->bi_key != BaseitemKey(ItemKindType::SOFT_ARMOR, SV_ROBE);
     should_skip |= o_ptr->art_flags.has(TR_DEC_MANA);
     if (should_skip || !one_in_(3)) {
@@ -164,74 +164,74 @@ void random_plus(ItemEntity *o_ptr)
     case 1:
     case 2:
         o_ptr->art_flags.set(TR_STR);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_STR;
-        } else if (!o_ptr->artifact_bias && one_in_(7)) {
-            o_ptr->artifact_bias = BIAS_WARRIOR;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::STR;
+        } else if (!o_ptr->has_bias() && one_in_(7)) {
+            o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         }
 
         break;
     case 3:
     case 4:
         o_ptr->art_flags.set(TR_INT);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_INT;
-        } else if (!o_ptr->artifact_bias && one_in_(7)) {
-            o_ptr->artifact_bias = BIAS_MAGE;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::INT;
+        } else if (!o_ptr->has_bias() && one_in_(7)) {
+            o_ptr->artifact_bias = RandomArtifactBias::MAGE;
         }
 
         break;
     case 5:
     case 6:
         o_ptr->art_flags.set(TR_WIS);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_WIS;
-        } else if (!o_ptr->artifact_bias && one_in_(7)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::WIS;
+        } else if (!o_ptr->has_bias() && one_in_(7)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
 
         break;
     case 7:
     case 8:
         o_ptr->art_flags.set(TR_DEX);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_DEX;
-        } else if (!o_ptr->artifact_bias && one_in_(7)) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::DEX;
+        } else if (!o_ptr->has_bias() && one_in_(7)) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
     case 9:
     case 10:
         o_ptr->art_flags.set(TR_CON);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_CON;
-        } else if (!o_ptr->artifact_bias && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::CON;
+        } else if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
 
         break;
     case 11:
     case 12:
         o_ptr->art_flags.set(TR_CHR);
-        if (!o_ptr->artifact_bias && !one_in_(13)) {
-            o_ptr->artifact_bias = BIAS_CHR;
+        if (!o_ptr->has_bias() && !one_in_(13)) {
+            o_ptr->artifact_bias = RandomArtifactBias::CHR;
         }
 
         break;
     case 13:
     case 14:
         o_ptr->art_flags.set(TR_STEALTH);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
     case 15:
     case 16:
         o_ptr->art_flags.set(TR_SEARCH);
-        if (!o_ptr->artifact_bias && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
 
         break;
@@ -241,8 +241,8 @@ void random_plus(ItemEntity *o_ptr)
         break;
     case 19:
         o_ptr->art_flags.set(TR_SPEED);
-        if (!o_ptr->artifact_bias && one_in_(11)) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias() && one_in_(11)) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
@@ -258,8 +258,8 @@ void random_plus(ItemEntity *o_ptr)
         }
 
         o_ptr->art_flags.set(TR_BLOWS);
-        if (!o_ptr->artifact_bias && one_in_(11)) {
-            o_ptr->artifact_bias = BIAS_WARRIOR;
+        if (!o_ptr->has_bias() && one_in_(11)) {
+            o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         }
 
         break;
index 1cc82d9..c561d4d 100644 (file)
@@ -74,25 +74,25 @@ static bool random_art_resistance(ItemEntity *o_ptr, tr_type tr_res_flag, bool s
 static bool switch_random_art_resistance(ItemEntity *o_ptr)
 {
     switch (o_ptr->artifact_bias) {
-    case BIAS_ACID:
+    case RandomArtifactBias::ACID:
         return random_art_resistance(o_ptr, TR_RES_ACID) || random_art_immunity(o_ptr, TR_IM_ACID);
-    case BIAS_ELEC:
+    case RandomArtifactBias::ELEC:
         return random_art_resistance(o_ptr, TR_RES_ELEC) || random_art_aura(o_ptr, TR_SH_ELEC) || random_art_immunity(o_ptr, TR_IM_ELEC);
-    case BIAS_FIRE:
+    case RandomArtifactBias::FIRE:
         return random_art_resistance(o_ptr, TR_RES_FIRE) || random_art_aura(o_ptr, TR_SH_FIRE) || random_art_immunity(o_ptr, TR_IM_FIRE);
-    case BIAS_COLD:
+    case RandomArtifactBias::COLD:
         return random_art_resistance(o_ptr, TR_RES_COLD) || random_art_aura(o_ptr, TR_SH_COLD) || random_art_immunity(o_ptr, TR_IM_COLD);
-    case BIAS_POIS:
+    case RandomArtifactBias::POIS:
         return random_art_resistance(o_ptr, TR_RES_POIS);
-    case BIAS_PRIESTLY:
+    case RandomArtifactBias::PRIESTLY:
         return random_art_resistance(o_ptr, TR_RES_CURSE);
-    case BIAS_WARRIOR:
+    case RandomArtifactBias::WARRIOR:
         return random_art_resistance(o_ptr, TR_RES_FEAR, one_in_(3)) || random_art_resistance(o_ptr, TR_NO_MAGIC, !one_in_(3));
-    case BIAS_RANGER:
+    case RandomArtifactBias::RANGER:
         return random_art_resistance(o_ptr, TR_RES_WATER) || random_art_resistance(o_ptr, TR_RES_POIS);
-    case BIAS_NECROMANTIC:
+    case RandomArtifactBias::NECROMANTIC:
         return random_art_resistance(o_ptr, TR_RES_NETHER) || random_art_resistance(o_ptr, TR_RES_POIS) || random_art_resistance(o_ptr, TR_RES_DARK);
-    case BIAS_CHAOS:
+    case RandomArtifactBias::CHAOS:
         return random_art_resistance(o_ptr, TR_RES_CHAOS) || random_art_resistance(o_ptr, TR_RES_CONF) || random_art_resistance(o_ptr, TR_RES_DISEN);
     default:
         return false;
@@ -108,8 +108,8 @@ static void set_weird_bias_acid(ItemEntity *o_ptr)
     }
 
     o_ptr->art_flags.set(TR_IM_ACID);
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_ACID;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::ACID;
     }
 }
 
@@ -122,8 +122,8 @@ static void set_weird_bias_elec(ItemEntity *o_ptr)
     }
 
     o_ptr->art_flags.set(TR_IM_ELEC);
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_ELEC;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::ELEC;
     }
 }
 
@@ -136,8 +136,8 @@ static void set_weird_bias_cold(ItemEntity *o_ptr)
     }
 
     o_ptr->art_flags.set(TR_IM_COLD);
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_COLD;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::COLD;
     }
 }
 
@@ -150,26 +150,26 @@ static void set_weird_bias_fire(ItemEntity *o_ptr)
     }
 
     o_ptr->art_flags.set(TR_IM_FIRE);
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_FIRE;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::FIRE;
     }
 }
 
 static void set_bias_pois(ItemEntity *o_ptr)
 {
     o_ptr->art_flags.set(TR_RES_POIS);
-    if (!o_ptr->artifact_bias && !one_in_(4)) {
-        o_ptr->artifact_bias = BIAS_POIS;
+    if (!o_ptr->has_bias() && !one_in_(4)) {
+        o_ptr->artifact_bias = RandomArtifactBias::POIS;
         return;
     }
 
-    if (!o_ptr->artifact_bias && one_in_(2)) {
-        o_ptr->artifact_bias = BIAS_NECROMANTIC;
+    if (!o_ptr->has_bias() && one_in_(2)) {
+        o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
         return;
     }
 
-    if (!o_ptr->artifact_bias && one_in_(2)) {
-        o_ptr->artifact_bias = BIAS_ROGUE;
+    if (!o_ptr->has_bias() && one_in_(2)) {
+        o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
     }
 }
 
@@ -182,8 +182,8 @@ static void set_weird_bias_aura_elec(ItemEntity *o_ptr)
         random_resistance(o_ptr);
     }
 
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_ELEC;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::ELEC;
     }
 }
 
@@ -196,8 +196,8 @@ static void set_weird_bias_aura_fire(ItemEntity *o_ptr)
         random_resistance(o_ptr);
     }
 
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_FIRE;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::FIRE;
     }
 }
 
@@ -227,8 +227,8 @@ static void set_weird_bias_aura_cold(ItemEntity *o_ptr)
         random_resistance(o_ptr);
     }
 
-    if (!o_ptr->artifact_bias) {
-        o_ptr->artifact_bias = BIAS_COLD;
+    if (!o_ptr->has_bias()) {
+        o_ptr->artifact_bias = RandomArtifactBias::COLD;
     }
 }
 
@@ -264,8 +264,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 6:
     case 13:
         o_ptr->art_flags.set(TR_RES_ACID);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_ACID;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::ACID;
         }
 
         break;
@@ -273,8 +273,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 8:
     case 14:
         o_ptr->art_flags.set(TR_RES_ELEC);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_ELEC;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::ELEC;
         }
 
         break;
@@ -282,8 +282,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 10:
     case 15:
         o_ptr->art_flags.set(TR_RES_FIRE);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_FIRE;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::FIRE;
         }
 
         break;
@@ -291,8 +291,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 12:
     case 16:
         o_ptr->art_flags.set(TR_RES_COLD);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_COLD;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::COLD;
         }
 
         break;
@@ -303,8 +303,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 19:
     case 20:
         o_ptr->art_flags.set(TR_RES_FEAR);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_WARRIOR;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         }
 
         break;
@@ -321,8 +321,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 25:
     case 26:
         o_ptr->art_flags.set(TR_RES_CONF);
-        if (!o_ptr->artifact_bias && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_CHAOS;
+        if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::CHAOS;
         }
 
         break;
@@ -337,8 +337,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 31:
     case 32:
         o_ptr->art_flags.set(TR_RES_NETHER);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_NECROMANTIC;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
         }
 
         break;
@@ -349,8 +349,8 @@ void random_resistance(ItemEntity *o_ptr)
     case 35:
     case 36:
         o_ptr->art_flags.set(TR_RES_CHAOS);
-        if (!o_ptr->artifact_bias && one_in_(2)) {
-            o_ptr->artifact_bias = BIAS_CHAOS;
+        if (!o_ptr->has_bias() && one_in_(2)) {
+            o_ptr->artifact_bias = RandomArtifactBias::CHAOS;
         }
 
         break;
@@ -363,14 +363,14 @@ void random_resistance(ItemEntity *o_ptr)
         break;
     case 40:
         o_ptr->art_flags.set(TR_RES_WATER);
-        if (!o_ptr->artifact_bias && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
         break;
     case 41:
         o_ptr->art_flags.set(TR_RES_CURSE);
-        if (!o_ptr->artifact_bias && one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+        if (!o_ptr->has_bias() && one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
         break;
     case 42:
index 1d913c7..20b195f 100644 (file)
@@ -26,8 +26,8 @@ static bool random_art_slay_bow(ItemEntity *o_ptr)
             o_ptr->art_flags.reset(TR_XTRA_SHOTS);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
 
         return true;
@@ -37,8 +37,8 @@ static bool random_art_slay_bow(ItemEntity *o_ptr)
             o_ptr->art_flags.reset(TR_XTRA_MIGHT);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_RANGER;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::RANGER;
         }
 
         return true;
@@ -168,12 +168,12 @@ static bool random_art_slay_demon(ItemEntity *o_ptr)
 static bool switch_random_art_slay(ItemEntity *o_ptr)
 {
     switch (o_ptr->artifact_bias) {
-    case BIAS_CHAOS:
+    case RandomArtifactBias::CHAOS:
         return random_art_slay_chaos(o_ptr);
-    case BIAS_MAGE:
-    case BIAS_INT:
+    case RandomArtifactBias::MAGE:
+    case RandomArtifactBias::INT:
         return random_art_brand_magical(o_ptr);
-    case BIAS_PRIESTLY: {
+    case RandomArtifactBias::PRIESTLY: {
         const auto tval = o_ptr->bi_key.tval();
         if (((tval == ItemKindType::SWORD) || (tval == ItemKindType::POLEARM)) && o_ptr->art_flags.has_not(TR_BLESSED)) {
             o_ptr->art_flags.set(TR_BLESSED);
@@ -181,11 +181,11 @@ static bool switch_random_art_slay(ItemEntity *o_ptr)
 
         return false;
     }
-    case BIAS_NECROMANTIC:
+    case RandomArtifactBias::NECROMANTIC:
         return random_art_slay_vampiric(o_ptr) || random_art_slay_brand_pois(o_ptr);
-    case BIAS_RANGER:
+    case RandomArtifactBias::RANGER:
         return random_art_slay_animal(o_ptr);
-    case BIAS_ROGUE: {
+    case RandomArtifactBias::ROGUE: {
         auto is_throwable = o_ptr->bi_key == BaseitemKey(ItemKindType::SWORD, SV_DAGGER);
         is_throwable |= o_ptr->bi_key == BaseitemKey(ItemKindType::POLEARM, SV_SPEAR);
         if (is_throwable && o_ptr->art_flags.has_not(TR_THROW)) {
@@ -194,17 +194,17 @@ static bool switch_random_art_slay(ItemEntity *o_ptr)
 
         return random_art_slay_brand_pois(o_ptr);
     }
-    case BIAS_POIS:
+    case RandomArtifactBias::POIS:
         return random_art_slay_brand_pois(o_ptr);
-    case BIAS_ACID:
+    case RandomArtifactBias::ACID:
         return random_art_slay_brand_acid(o_ptr);
-    case BIAS_ELEC:
+    case RandomArtifactBias::ELEC:
         return random_art_slay_brand_elec(o_ptr);
-    case BIAS_FIRE:
+    case RandomArtifactBias::FIRE:
         return random_art_slay_brand_fire(o_ptr);
-    case BIAS_COLD:
+    case RandomArtifactBias::COLD:
         return random_art_slay_brand_cold(o_ptr);
-    case BIAS_LAW:
+    case RandomArtifactBias::LAW:
         return random_art_slay_evil(o_ptr) || random_art_slay_undead(o_ptr) || random_art_slay_demon(o_ptr);
     default:
         return false;
@@ -244,13 +244,13 @@ void random_slay(ItemEntity *o_ptr)
             o_ptr->art_flags.set(TR_SLAY_EVIL);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
-            o_ptr->artifact_bias = BIAS_LAW;
+        if (!o_ptr->has_bias() && one_in_(2)) {
+            o_ptr->artifact_bias = RandomArtifactBias::LAW;
             break;
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
 
         break;
@@ -262,8 +262,8 @@ void random_slay(ItemEntity *o_ptr)
             o_ptr->art_flags.set(TR_SLAY_UNDEAD);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
 
         break;
@@ -275,8 +275,8 @@ void random_slay(ItemEntity *o_ptr)
             o_ptr->art_flags.set(TR_SLAY_DEMON);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_PRIESTLY;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::PRIESTLY;
         }
 
         break;
@@ -322,8 +322,8 @@ void random_slay(ItemEntity *o_ptr)
         }
 
         o_ptr->art_flags.set(TR_VORPAL);
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_WARRIOR;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::WARRIOR;
         }
 
         break;
@@ -333,64 +333,64 @@ void random_slay(ItemEntity *o_ptr)
     case 21:
     case 22:
         o_ptr->art_flags.set(TR_BRAND_FIRE);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_FIRE;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::FIRE;
         }
 
         break;
     case 23:
     case 24:
         o_ptr->art_flags.set(TR_BRAND_COLD);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_COLD;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::COLD;
         }
 
         break;
     case 25:
     case 26:
         o_ptr->art_flags.set(TR_BRAND_ELEC);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_ELEC;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::ELEC;
         }
 
         break;
     case 27:
     case 28:
         o_ptr->art_flags.set(TR_BRAND_ACID);
-        if (!o_ptr->artifact_bias) {
-            o_ptr->artifact_bias = BIAS_ACID;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::ACID;
         }
 
         break;
     case 29:
     case 30:
         o_ptr->art_flags.set(TR_BRAND_POIS);
-        if ((o_ptr->artifact_bias == BIAS_NONE) && !one_in_(3)) {
-            o_ptr->artifact_bias = BIAS_POIS;
+        if (!o_ptr->has_bias() && !one_in_(3)) {
+            o_ptr->artifact_bias = RandomArtifactBias::POIS;
             break;
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(6)) {
-            o_ptr->artifact_bias = BIAS_NECROMANTIC;
+        if (!o_ptr->has_bias() && one_in_(6)) {
+            o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
             break;
         }
 
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
     case 31:
         o_ptr->art_flags.set(TR_VAMPIRIC);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_NECROMANTIC;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::NECROMANTIC;
         }
 
         break;
     case 32:
         o_ptr->art_flags.set(TR_FORCE_WEAPON);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = (one_in_(2) ? RandomArtifactBias::MAGE : RandomArtifactBias::PRIESTLY);
         }
 
         break;
@@ -405,15 +405,15 @@ void random_slay(ItemEntity *o_ptr)
         break;
     case 35:
         o_ptr->art_flags.set(TR_BRAND_MAGIC);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_MAGE;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::MAGE;
         }
         break;
     case 36:
     case 37:
         o_ptr->art_flags.set(TR_CHAOTIC);
-        if (o_ptr->artifact_bias == BIAS_NONE) {
-            o_ptr->artifact_bias = BIAS_CHAOS;
+        if (!o_ptr->has_bias()) {
+            o_ptr->artifact_bias = RandomArtifactBias::CHAOS;
         }
 
         break;
@@ -424,13 +424,13 @@ void random_slay(ItemEntity *o_ptr)
             o_ptr->art_flags.set(TR_SLAY_GOOD);
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
-            o_ptr->artifact_bias = BIAS_POIS;
+        if (!o_ptr->has_bias() && one_in_(2)) {
+            o_ptr->artifact_bias = RandomArtifactBias::POIS;
             break;
         }
 
-        if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
-            o_ptr->artifact_bias = BIAS_ROGUE;
+        if (!o_ptr->has_bias() && one_in_(9)) {
+            o_ptr->artifact_bias = RandomArtifactBias::ROGUE;
         }
 
         break;
index 25110a2..16a68a2 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "system/item-entity.h"
 #include "artifact/fixed-art-types.h"
+#include "artifact/random-art-bias-types.h"
 #include "artifact/random-art-effects.h"
 #include "monster-race/monster-race.h"
 #include "object-enchant/activation-info-table.h"
@@ -773,6 +774,11 @@ bool ItemEntity::has_activation() const
     return this->get_activation_index() != RandomArtActType::NONE;
 }
 
+bool ItemEntity::has_bias() const
+{
+    return this->artifact_bias != RandomArtifactBias::NONE;
+}
+
 BaseitemInfo &ItemEntity::get_baseitem() const
 {
     return BaseitemList::get_instance().get_baseitem(this->bi_id);
index f0ebc34..e40c938 100644 (file)
@@ -22,6 +22,7 @@
 enum class FixedArtifactId : short;
 enum class ItemKindType : short;
 enum class SmithEffectType : int16_t;
+enum class RandomArtifactBias : int;
 enum class RandomArtActType : short;
 
 class ActivationType;
@@ -75,7 +76,7 @@ public:
     TrFlags art_flags{}; /*!< Extra Flags for ego and artifacts */
     EnumClassFlagGroup<CurseTraitType> curse_flags{}; /*!< Flags for curse */
     MONSTER_IDX held_m_idx{}; /*!< アイテムを所持しているモンスターID (いないなら 0) / Monster holding us (if any) */
-    int artifact_bias{}; /*!< ランダムアーティファクト生成時のバイアスID */
+    RandomArtifactBias artifact_bias{}; /*!< ランダムアーティファクト生成時のバイアスID */
 
     void wipe();
     void copy_from(const ItemEntity *j_ptr);
@@ -145,6 +146,7 @@ public:
     bool is_inscribed() const;
     std::vector<ActivationType>::const_iterator find_activation_info() const;
     bool has_activation() const;
+    bool has_bias() const;
 
     BaseitemInfo &get_baseitem() const;
     EgoItemDefinition &get_ego() const;
index dce05e1..9ebc4a2 100644 (file)
@@ -5,25 +5,25 @@
 /*!
  * @brief ランダムアーティファクトのバイアス名称テーブル
  */
-const std::map<random_art_bias_type, std::string> ARTIFACT_BIAS_NAMES = {
-    { BIAS_NONE, _("なし", "None") },
-    { BIAS_ELEC, _("電撃", "Elec") },
-    { BIAS_POIS, _("毒", "Poison") },
-    { BIAS_FIRE, _("火炎", "Fire") },
-    { BIAS_COLD, _("冷気", "Cold") },
-    { BIAS_ACID, _("酸", "Acid") },
-    { BIAS_STR, _("腕力", "STR") },
-    { BIAS_INT, _("知力", "INT") },
-    { BIAS_WIS, _("賢さ", "WIS") },
-    { BIAS_DEX, _("器用さ", "DEX") },
-    { BIAS_CON, _("耐久", "CON") },
-    { BIAS_CHR, _("魅力", "CHA") },
-    { BIAS_CHAOS, _("混沌", "Chaos") },
-    { BIAS_PRIESTLY, _("プリースト", "Priestly") },
-    { BIAS_NECROMANTIC, _("死霊", "Necromantic") },
-    { BIAS_LAW, _("法", "Law") },
-    { BIAS_ROGUE, _("盗賊", "Rogue") },
-    { BIAS_MAGE, _("メイジ", "Mage") },
-    { BIAS_WARRIOR, _("戦士", "Warrior") },
-    { BIAS_RANGER, _("レンジャー", "Ranger") },
+const std::map<RandomArtifactBias, std::string> ARTIFACT_BIAS_NAMES = {
+    { RandomArtifactBias::NONE, _("なし", "None") },
+    { RandomArtifactBias::ELEC, _("電撃", "Elec") },
+    { RandomArtifactBias::POIS, _("毒", "Poison") },
+    { RandomArtifactBias::FIRE, _("火炎", "Fire") },
+    { RandomArtifactBias::COLD, _("冷気", "Cold") },
+    { RandomArtifactBias::ACID, _("酸", "Acid") },
+    { RandomArtifactBias::STR, _("腕力", "STR") },
+    { RandomArtifactBias::INT, _("知力", "INT") },
+    { RandomArtifactBias::WIS, _("賢さ", "WIS") },
+    { RandomArtifactBias::DEX, _("器用さ", "DEX") },
+    { RandomArtifactBias::CON, _("耐久", "CON") },
+    { RandomArtifactBias::CHR, _("魅力", "CHA") },
+    { RandomArtifactBias::CHAOS, _("混沌", "Chaos") },
+    { RandomArtifactBias::PRIESTLY, _("プリースト", "Priestly") },
+    { RandomArtifactBias::NECROMANTIC, _("死霊", "Necromantic") },
+    { RandomArtifactBias::LAW, _("法", "Law") },
+    { RandomArtifactBias::ROGUE, _("盗賊", "Rogue") },
+    { RandomArtifactBias::MAGE, _("メイジ", "Mage") },
+    { RandomArtifactBias::WARRIOR, _("戦士", "Warrior") },
+    { RandomArtifactBias::RANGER, _("レンジャー", "Ranger") },
 };
index 65ca0c4..59ea2d7 100644 (file)
@@ -3,5 +3,5 @@
 #include <map>
 #include <string>
 
-enum random_art_bias_type : int;
-extern const std::map<random_art_bias_type, std::string> ARTIFACT_BIAS_NAMES;
+enum class RandomArtifactBias : int;
+extern const std::map<RandomArtifactBias, std::string> ARTIFACT_BIAS_NAMES;