return;
}
- int this_type = o_ptr->is_weapon_ammo() ? 23 : 19;
+ const auto this_type = o_ptr->is_weapon_ammo() ? 23 : 19;
switch (randint1(this_type)) {
case 1:
case 2:
auto tohit2 = static_cast<short>(m_bonus(10, this->level));
auto todam2 = static_cast<short>(m_bonus(10, this->level));
- if ((this->o_ptr->tval == ItemKindType::BOLT) || (this->o_ptr->tval == ItemKindType::ARROW) || (this->o_ptr->tval == ItemKindType::SHOT)) {
+ if (this->o_ptr->is_ammo()) {
tohit2 = (tohit2 + 1) / 2;
todam2 = (todam2 + 1) / 2;
}
#define TV_EQUIP_BEGIN ItemKindType::SHOT
#define TV_EQUIP_END ItemKindType::CARD
-#define TV_MISSILE_BEGIN ItemKindType::SHOT
-#define TV_MISSILE_END ItemKindType::BOLT
#define TV_WEARABLE_BEGIN ItemKindType::BOW
#define TV_WEARABLE_END ItemKindType::CARD
#define TV_WEAPON_BEGIN ItemKindType::BOW
return consumption;
}
- if ((o_ptr->tval >= ItemKindType::SHOT) && (o_ptr->tval <= ItemKindType::BOLT)) {
+ if (o_ptr->is_ammo()) {
consumption = (consumption + 9) / 10;
}
}
}
+bool BaseitemKey::is_ammo() const
+{
+ switch (this->type_value) {
+ case ItemKindType::SHOT:
+ case ItemKindType::ARROW:
+ case ItemKindType::BOLT:
+ return true;
+ default:
+ return false;
+ }
+}
+
BaseitemInfo::BaseitemInfo()
: bi_key(ItemKindType::NONE)
{
bool is_spell_book() const;
bool is_high_level_book() const;
bool is_melee_weapon() const;
+ bool is_ammo() const;
private:
ItemKindType type_value;
}
/*!
- * @brief アイテムが武器や矢弾として使用できるかを返す / Check if an object is weapon (including bows and ammo)
- * Rare weapons/aromors including Blade of Chaos, Dragon armors, etc.
+ * @brief アイテムが武器や矢弾として使用できるかを返す
* @return 武器や矢弾として使えるならばtrueを返す
*/
bool ItemEntity::is_weapon_ammo() const
{
- return (TV_MISSILE_BEGIN <= this->tval) && (this->tval <= TV_WEAPON_END);
+ return this->is_weapon() || this->is_ammo();
}
/*!
*/
bool ItemEntity::is_ammo() const
{
- return (TV_MISSILE_BEGIN <= this->tval) && (this->tval <= TV_MISSILE_END);
+ return BaseitemKey(this->tval).is_ammo();
}
/*!