summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-26 10:39:39 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-26 10:39:39 +0000
commit61cae4a761c2f72cda44ae269c7007b37a0c14a7 (patch)
treefec8ec71ca7ca6eebd9d48881bc5ee3fe27d04c1 /crawl-ref/source/itemprop.cc
parentd4acdf4a6a4b73607d58714a66efd372674adb56 (diff)
downloadcrawl-ref-61cae4a761c2f72cda44ae269c7007b37a0c14a7.tar.gz
crawl-ref-61cae4a761c2f72cda44ae269c7007b37a0c14a7.zip
Misc. minor cleanups. (Yes, a huge amount of them but still...)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6146 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc290
1 files changed, 145 insertions, 145 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 912153f1c7..dd26e6bd3e 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2160,7 +2160,7 @@ bool food_is_veg( const item_def &item )
bool is_blood_potion( const item_def &item)
{
if (item.base_type != OBJ_POTIONS)
- return false;
+ return (false);
return (item.sub_type == POT_BLOOD
|| item.sub_type == POT_BLOOD_COAGULATED);
@@ -2264,183 +2264,183 @@ int property( const item_def &item, int prop_type )
return (0);
}
+// Returns true if item is evokable.
bool gives_ability( const item_def &item )
{
if (!item_type_known(item))
- return false;
+ return (false);
switch (item.base_type)
{
- case OBJ_WEAPONS:
- {
- // unwielded weapon
- item_def *weap = you.slot_item(EQ_WEAPON);
- if (!weap || (*weap).slot != item.slot)
- return false;
- break;
- }
- case OBJ_JEWELLERY:
- {
- if ( !jewellery_is_amulet(item))
- {
- // unworn ring
- item_def *lring = you.slot_item(EQ_LEFT_RING);
- item_def *rring = you.slot_item(EQ_RIGHT_RING);
- if ((!lring || (*lring).slot != item.slot)
- && (!rring || (*rring).slot != item.slot))
- {
- return false;
- }
-
- if (item.sub_type == RING_TELEPORTATION
- || item.sub_type == RING_LEVITATION
- || item.sub_type == RING_INVISIBILITY)
- {
- return true;
- }
- }
- else
- {
- // unworn amulet
- item_def *amul = you.slot_item(EQ_AMULET);
- if (!amul || (*amul).slot != item.slot)
- return false;
-
- if (item.sub_type == AMU_RAGE)
- return true;
- }
- break;
- }
- case OBJ_ARMOUR:
- {
- const equipment_type eq = get_armour_slot(item);
- if (eq == EQ_NONE)
- return false;
-
- // unworn armour
- item_def *arm = you.slot_item(eq);
- if (!arm || (*arm).slot != item.slot)
- return false;
- break;
- }
- default:
- return false;
+ case OBJ_WEAPONS:
+ {
+ // unwielded weapon
+ item_def *weap = you.slot_item(EQ_WEAPON);
+ if (!weap || (*weap).slot != item.slot)
+ return (false);
+ break;
+ }
+ case OBJ_JEWELLERY:
+ {
+ if (!jewellery_is_amulet(item))
+ {
+ // unworn ring
+ item_def *lring = you.slot_item(EQ_LEFT_RING);
+ item_def *rring = you.slot_item(EQ_RIGHT_RING);
+ if ((!lring || (*lring).slot != item.slot)
+ && (!rring || (*rring).slot != item.slot))
+ {
+ return (false);
+ }
+
+ if (item.sub_type == RING_TELEPORTATION
+ || item.sub_type == RING_LEVITATION
+ || item.sub_type == RING_INVISIBILITY)
+ {
+ return (true);
+ }
+ }
+ else
+ {
+ // unworn amulet
+ item_def *amul = you.slot_item(EQ_AMULET);
+ if (!amul || (*amul).slot != item.slot)
+ return (false);
+
+ if (item.sub_type == AMU_RAGE)
+ return (true);
+ }
+ break;
+ }
+ case OBJ_ARMOUR:
+ {
+ const equipment_type eq = get_armour_slot(item);
+ if (eq == EQ_NONE)
+ return (false);
+
+ // unworn armour
+ item_def *arm = you.slot_item(eq);
+ if (!arm || (*arm).slot != item.slot)
+ return (false);
+ break;
+ }
+ default:
+ return (false);
}
if (!is_random_artefact(item))
- return false;
+ return (false);
- // check for evokable randart properties
+ // Check for evokable randart properties.
for (int rap = RAP_INVISIBLE; rap <= RAP_MAPPING; rap++)
- {
if (randart_wpn_property( item, static_cast<randart_prop_type>(rap) ))
- return true;
- }
+ return (true);
- return false;
+ return (false);
}
+// Returns true if the item confers an intrinsic that is shown on the % screen.#
bool gives_resistance( const item_def &item )
{
if (!item_type_known(item))
- return false;
+ return (false);
switch (item.base_type)
{
- case OBJ_WEAPONS:
- {
- // unwielded weapon
- item_def *weap = you.slot_item(EQ_WEAPON);
- if (!weap || (*weap).slot != item.slot)
- return false;
- break;
- }
- case OBJ_JEWELLERY:
- {
- if (item.sub_type < NUM_RINGS)
- {
- // unworn ring
- item_def *lring = you.slot_item(EQ_LEFT_RING);
- item_def *rring = you.slot_item(EQ_RIGHT_RING);
- if ((!lring || (*lring).slot != item.slot)
- && (!rring || (*rring).slot != item.slot))
- {
- return false;
- }
-
- if (item.sub_type >= RING_PROTECTION_FROM_FIRE
- && item.sub_type <= RING_PROTECTION_FROM_COLD
- || item.sub_type == RING_SEE_INVISIBLE
- || item.sub_type >= RING_LIFE_PROTECTION
- && item.sub_type <= RING_TELEPORT_CONTROL
- || item.sub_type == RING_SUSTAIN_ABILITIES)
- {
- return true;
- }
- }
- else
- {
- // unworn amulet
- item_def *amul = you.slot_item(EQ_AMULET);
- if (!amul || (*amul).slot != item.slot)
- return false;
-
- if (item.sub_type != AMU_RAGE && item.sub_type != AMU_INACCURACY)
- return true;
- }
- break;
- }
- case OBJ_ARMOUR:
- {
- const equipment_type eq = get_armour_slot(item);
- if (eq == EQ_NONE)
- return false;
-
- // unworn armour
- item_def *arm = you.slot_item(eq);
- if (!arm || (*arm).slot != item.slot)
- return false;
- break;
-
- const int ego = get_armour_ego_type( item );
- if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE
- || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY)
- {
- return true;
- }
- }
- case OBJ_STAVES:
- {
- // unwielded weapon
- item_def *weap = you.slot_item(EQ_WEAPON);
- if (!weap || (*weap).slot != item.slot)
- return false;
-
- if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON
- || item.sub_type == STAFF_AIR)
- {
- return true;
- }
- return false;
- }
- default:
- return false;
+ case OBJ_WEAPONS:
+ {
+ // unwielded weapon
+ item_def *weap = you.slot_item(EQ_WEAPON);
+ if (!weap || (*weap).slot != item.slot)
+ return (false);
+ break;
+ }
+ case OBJ_JEWELLERY:
+ {
+ if (item.sub_type < NUM_RINGS)
+ {
+ // unworn ring
+ item_def *lring = you.slot_item(EQ_LEFT_RING);
+ item_def *rring = you.slot_item(EQ_RIGHT_RING);
+ if ((!lring || (*lring).slot != item.slot)
+ && (!rring || (*rring).slot != item.slot))
+ {
+ return (false);
+ }
+
+ if (item.sub_type >= RING_PROTECTION_FROM_FIRE
+ && item.sub_type <= RING_PROTECTION_FROM_COLD
+ || item.sub_type == RING_SEE_INVISIBLE
+ || item.sub_type >= RING_LIFE_PROTECTION
+ && item.sub_type <= RING_TELEPORT_CONTROL
+ || item.sub_type == RING_SUSTAIN_ABILITIES)
+ {
+ return (true);
+ }
+ }
+ else
+ {
+ // unworn amulet
+ item_def *amul = you.slot_item(EQ_AMULET);
+ if (!amul || (*amul).slot != item.slot)
+ return (false);
+
+ if (item.sub_type != AMU_RAGE && item.sub_type != AMU_INACCURACY)
+ return (true);
+ }
+ break;
+ }
+ case OBJ_ARMOUR:
+ {
+ const equipment_type eq = get_armour_slot(item);
+ if (eq == EQ_NONE)
+ return (false);
+
+ // unworn armour
+ item_def *arm = you.slot_item(eq);
+ if (!arm || (*arm).slot != item.slot)
+ return (false);
+ break;
+
+ const int ego = get_armour_ego_type( item );
+ if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE
+ || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY)
+ {
+ return (true);
+ }
+ }
+ case OBJ_STAVES:
+ {
+ // unwielded staff
+ item_def *weap = you.slot_item(EQ_WEAPON);
+ if (!weap || (*weap).slot != item.slot)
+ return (false);
+
+ if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON
+ || item.sub_type == STAFF_AIR)
+ {
+ return (true);
+ }
+ return (false);
+ }
+ default:
+ return (false);
}
if (!is_random_artefact(item))
- return false;
+ return (false);
- // check for randart resistances
+ // Check for randart resistances.
for (int rap = RAP_FIRE; rap <= RAP_CAN_TELEPORT; rap++)
{
if (rap == RAP_MAGIC || rap >= RAP_INVISIBLE && rap != RAP_CAN_TELEPORT)
continue;
if (randart_wpn_property( item, static_cast<randart_prop_type>(rap) ))
- return true;
+ return (true);
}
- return false;
+ return (false);
}
int item_mass( const item_def &item )