git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2802 c06c8d41-db1a-0410-9941-cceddc491573
TYRQMDB4PCK6K4WOC6XSMAGRR2FIEUIQSM7RQO7ZZ44MY37HEA3QC
static int randart_add_one_property( const item_def &item,
randart_properties_t &proprt )
{
// This function assumes that no properties have been added to this
// randart yet.
const object_class_type cl = item.base_type;
const int ty = item.sub_type;
// 0 - ac, 1 - ev, 2 - str, 3 - int, 4 - dex
int prop;
int skip = -1;
// Determine if we need to skip any of the above.
if (cl == OBJ_ARMOUR || cl == OBJ_JEWELLERY && ty == RING_PROTECTION)
skip = 0;
else if (cl == OBJ_JEWELLERY && ty == RING_EVASION)
skip = 1;
else if (cl == OBJ_JEWELLERY && ty == RING_STRENGTH)
skip = 2;
else if (cl == OBJ_JEWELLERY && ty == RING_INTELLIGENCE)
skip = 3;
else if (cl == OBJ_JEWELLERY && ty == RING_DEXTERITY)
skip = 4;
// Pick a random enchantment, taking into account the skipped index.
if (skip >= 0)
{
prop = random2(4);
if (prop >= skip)
prop++;
}
else
{
prop = random2(5);
}
bool negench = one_chance_in(4);
switch(prop)
{
default:
case 0:
if (negench)
proprt[RAP_AC] -= 1 + random2(3) + random2(3) + random2(3);
else
proprt[RAP_AC] = 1 + random2(3) + random2(3) + random2(3);
break;
case 1:
if (negench)
proprt[RAP_EVASION] -= 1 + random2(3) + random2(3) + random2(3);
else
proprt[RAP_EVASION] = 1 + random2(3) + random2(3) + random2(3);
break;
case 2:
if (negench)
proprt[RAP_STRENGTH] -= 1 + random2(3) + random2(3)
+ random2(3);
else
proprt[RAP_STRENGTH] = 1 + random2(3) + random2(2);
break;
case 3:
if (negench)
proprt[RAP_INTELLIGENCE] -= 1 + random2(3) + random2(3)
+ random2(3);
else
proprt[RAP_INTELLIGENCE] = 1 + random2(3) + random2(2);
break;
case 4:
if (negench)
proprt[RAP_DEXTERITY] -= 1 + random2(3) + random2(3)
+ random2(3);
else
proprt[RAP_DEXTERITY] = 1 + random2(3) + random2(2);
break;
}
return negench ? 0 : 1;
}