diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-08 22:09:25 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-08 22:09:25 +0000 |
commit | f55a8b913e4fb43166f6a3cbd083a4a0f5154358 (patch) | |
tree | eb282082a88a6f133eeefc11651769d856dacbf0 /crawl-ref/source/itemprop.cc | |
parent | 1b7c5aa3c413b3469ada00e521b37aeca57abdd5 (diff) | |
download | crawl-ref-f55a8b913e4fb43166f6a3cbd083a4a0f5154358.tar.gz crawl-ref-f55a8b913e4fb43166f6a3cbd083a4a0f5154358.zip |
Implement FR 2489034: Disallow known scrolls of enchant
armour/recharging on armour that cannot be enchanted or items that
cannot be recharged, respectively.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8337 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r-- | crawl-ref/source/itemprop.cc | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index b7b1c8e326..ac3411bc0f 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1327,17 +1327,24 @@ bool check_armour_shape( const item_def &item, bool quiet ) return (true); } -// If known is true, only returns true for *known* weapons of electrocution, -// and returns false for wands/rods known to be fully charged. -bool item_is_rechargeable(const item_def &it, bool known) +// Returns whether a wand or rod can be charged, or a weapon of electrocution +// enchanted. +// If unknown is true, wands with unknown charges and weapons with unknown +// brand will also return true. +// If hide_charged is true, wands known to be full will return false. +// (This distinction is necessary because even full wands/rods give a message.) +bool item_is_rechargeable(const item_def &it, bool unknown, bool hide_charged) { // These are obvious... if (it.base_type == OBJ_WANDS) { + if (unknown && !hide_charged) + return (true); + // Don't offer wands already maximally charged. - if (known && (it.plus2 == ZAPCOUNT_MAX_CHARGED - || item_ident(it, ISFLAG_KNOW_PLUSES) - && it.plus >= 3 * wand_charge_value(it.sub_type))) + if (it.plus2 == ZAPCOUNT_MAX_CHARGED + || item_ident(it, ISFLAG_KNOW_PLUSES) + && it.plus >= 3 * wand_charge_value(it.sub_type)) { return (false); } @@ -1345,20 +1352,34 @@ bool item_is_rechargeable(const item_def &it, bool known) } else if (item_is_rod(it)) { - if (known && item_ident(it, ISFLAG_KNOW_PLUSES)) + if (unknown && !hide_charged) + return (true); + + if (item_ident(it, ISFLAG_KNOW_PLUSES)) { return (it.plus2 < MAX_ROD_CHARGE * ROD_CHARGE_MULT || it.plus < it.plus2); } return (true); } + else if (it.base_type == OBJ_WEAPONS) + { + if (unknown && !item_type_known(it)) // Could be electrocution. + return (true); - // ...but electric weapons can also be charged. - return (it.base_type == OBJ_WEAPONS - && !is_random_artefact(it) - && !is_fixed_artefact(it) + // Weapons of electrocution can get +1 to-dam this way. + if (!is_artefact(it) && get_weapon_brand(it) == SPWPN_ELECTROCUTION - && (!known || item_type_known(it))); + && item_type_known(it) + && (unknown && !item_ident(it, ISFLAG_KNOW_PLUSES ) + || item_ident(it, ISFLAG_KNOW_PLUSES ) + && it.plus2 < MAX_WPN_ENCHANT)) + { + return (true); + } + } + + return (false); } // Max. charges are 3 times this value. |