with a stat property that will be fatal.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2839 c06c8d41-db1a-0410-9941-cceddc491573
P3BAFR6LTI7HANQCRLZWJ7LRJYFPFYIG7OVZV4RZM5EAMODRJKZAC
CHUJFZ7HBTS6IC46OJQEMWSQV5QLF7LCPBYW5NPSEM4L6OT3PJVQC
IKKMJHAWBTZFUVGXCLQZ46PV5RRAMNJGUWKPJTVXVMMWW5QGWPLAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
SN3VSV7G6NF6NLX5E47QJQQFDIPC2LQUUYGZMH6AWBF3FOUHXCBQC
7AWYHENXBDI4OLKU7JD56YAKT5RO6UZ67HEBNPOILXCIFW6BONRAC
HFCPPPYI366EDKNBDGVNSAW76OGQA2NYTKLSP4LC3VYKHPLWFJ6QC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
KHHAE5ZK7ITEZVMMUKYROKECLE2RU5ZU5OQ4Z4XSRQXE2R65O67AC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
}
// Checks whether a to-be-worn or to-be-removed item affects
// character stats and whether wearing/removing it could be fatal.
// If so, warns the player.
bool safe_to_remove_or_wear(const item_def &item, bool remove)
{
int prop_str = 0;
int prop_dex = 0;
int prop_int = 0;
// don't warn when putting on an unknown item
if (item.base_type == OBJ_JEWELLERY && item_ident( item, ISFLAG_KNOW_PLUSES ))
{
switch (item.sub_type)
{
case RING_STRENGTH:
if (item.plus != 0)
prop_str = item.plus;
break;
case RING_DEXTERITY:
if (item.plus != 0)
prop_dex = item.plus;
break;
case RING_INTELLIGENCE:
if (item.plus != 0)
prop_int = item.plus;
break;
default:
break;
}
}
if (is_random_artefact( item ))
{
prop_str += randart_known_wpn_property(item, RAP_STRENGTH);
prop_int += randart_known_wpn_property(item, RAP_INTELLIGENCE);
prop_dex += randart_known_wpn_property(item, RAP_DEXTERITY);
}
if (remove)
{
std::string prompt = item.base_type == OBJ_WEAPONS ? "Unwield" : "Remov";
prompt += "ing this item could be fatal. ";
prompt += item.base_type == OBJ_WEAPONS ? "Unwield" : "Remove";
prompt += " anyway? ";
if ((prop_str >= you.strength || prop_int >= you.intel ||
prop_dex >= you.dex)
&& !yesno(prompt.c_str(), false, 'n'))
{
return (false);
}
}
else // put on
{
std::string prompt = item.base_type == OBJ_WEAPONS ? "Wield" : "Wear";
prompt += "ing this item could be fatal. ";
prompt += item.base_type == OBJ_WEAPONS ? "Wield" : "Put on";
prompt += " anyway? ";
if ((-prop_str >= you.strength || -prop_int >= you.intel ||
-prop_dex >= you.dex)
&& !yesno(prompt.c_str(), false, 'n'))
{
return (false);
}
}
return (true);