summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-09 19:25:07 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-09 19:25:07 -0700
commit682efee855c84516f0f073926efb9357813b0adc (patch)
tree50677162db4cee40a9cda51c6eba26e0ac8f03ae /crawl-ref/source/itemprop.cc
parentd32eec0d69ecfa2875473e2f6806323ca6585114 (diff)
downloadcrawl-ref-682efee855c84516f0f073926efb9357813b0adc.tar.gz
crawl-ref-682efee855c84516f0f073926efb9357813b0adc.zip
Refactor weapon property code
Mainly relevant to chaos champions (should mean that melee_only champions no longer spawn with slings, as a bonus), but also in preparation for adding more weapon types.
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc101
1 files changed, 67 insertions, 34 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 659a36be61..a1554e5587 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1406,54 +1406,87 @@ hands_reqd_type hands_reqd(const actor* ac, object_class_type base_type, int sub
return ac->hands_reqd(item);
}
+/**
+ * Is the provided type a kind of giant club?
+ *
+ * @param wpn_type The type of weapon under consideration.
+ * @return Whether it's a kind of giant club.
+ */
bool is_giant_club_type(int wpn_type)
{
return wpn_type == WPN_GIANT_CLUB
|| wpn_type == WPN_GIANT_SPIKED_CLUB;
}
-bool is_demonic(const item_def &item)
+/**
+ * Is the provided type a kind of ranged weapon?
+ *
+ * @param wpn_type The type of weapon under consideration.
+ * @return Whether it's a kind of launcher.
+ */
+bool is_ranged_weapon_type(int wpn_type)
{
- if (item.base_type == OBJ_WEAPONS)
- {
- switch (item.sub_type)
- {
- case WPN_DEMON_BLADE:
- case WPN_DEMON_WHIP:
- case WPN_DEMON_TRIDENT:
- return true;
+ return Weapon_prop[wpn_type].dam_type == DAMV_NON_MELEE;
+}
- default:
- break;
- }
- }
+/**
+ * Is the provided type a kind of demon weapon?
+ *
+ * @param wpn_type The type of weapon under consideration.
+ * @return Whether it's a kind of demon weapon.
+ */
+bool is_demonic_weapon_type(int wpn_type)
+{
+ return wpn_type == WPN_DEMON_BLADE
+ || wpn_type == WPN_DEMON_WHIP
+ || wpn_type == WPN_DEMON_TRIDENT;
+}
- return false;
+/**
+ * Is the provided type a kind of blessed weapon?
+ *
+ * @param wpn_type The type of weapon under consideration.
+ * @return Whether it's a kind of blessed weapon.
+ */
+bool is_blessed_weapon_type(int wpn_type)
+{
+ return wpn_type >= WPN_BLESSED_FALCHION && wpn_type <= WPN_TRISHULA;
}
-bool is_blessed(const item_def &item)
+/**
+ * Is the weapon type provided magic (& can't be generated in a usual way?)
+ * (I.e., magic staffs & rods.)
+ *
+ * @param wpn_type The type of weapon under consideration.
+ * @return Whether it's a magic staff or rod.
+ */
+bool is_magic_weapon_type(int wpn_type)
{
- if (item.base_type == OBJ_WEAPONS)
- {
- switch (item.sub_type)
- {
- case WPN_BLESSED_FALCHION:
- case WPN_BLESSED_LONG_SWORD:
- case WPN_BLESSED_SCIMITAR:
- case WPN_EUDEMON_BLADE:
- case WPN_BLESSED_BASTARD_SWORD:
- case WPN_BLESSED_GREAT_SWORD:
- case WPN_BLESSED_CLAYMORE:
- case WPN_SACRED_SCOURGE:
- case WPN_TRISHULA:
- return true;
+ return wpn_type == WPN_STAFF || wpn_type == WPN_ROD;
+}
- default:
- break;
- }
- }
+/**
+ * Is the provided item a demon weapon?
+ *
+ * @param wpn_type The item under consideration.
+ * @return Whether the given item is a demon weapon.
+ */
+bool is_demonic(const item_def &item)
+{
+ return item.base_type == OBJ_WEAPONS
+ && is_demonic_weapon_type(item.sub_type);
+}
- return false;
+/**
+ * Is the provided item a blessed weapon? (Not just holy wrath.)
+ *
+ * @param wpn_type The item under consideration.
+ * @return Whether the given item is a blessed weapon.
+ */
+bool is_blessed(const item_def &item)
+{
+ return item.base_type == OBJ_WEAPONS
+ && is_blessed_weapon_type(item.sub_type);
}
bool is_blessed_convertible(const item_def &item)