From f55a8b913e4fb43166f6a3cbd083a4a0f5154358 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Thu, 8 Jan 2009 22:09:25 +0000 Subject: 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 --- crawl-ref/source/item_use.cc | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'crawl-ref/source/item_use.cc') diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 731d10567b..94a0c150b9 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -4167,24 +4167,40 @@ bool enchant_armour(int &ac_change, bool quiet, item_def &arm) static bool _handle_enchant_armour(int item_slot) { - if (item_slot == -1) + do { - item_slot = prompt_invent_item("Enchant which item?", MT_INVLIST, - OSEL_ENCH_ARM, true, true, false); - } + if (item_slot == -1) + { + item_slot = prompt_invent_item("Enchant which item?", MT_INVLIST, + OSEL_ENCH_ARM, true, true, false); + } + if (prompt_failed(item_slot)) + return (false); - if (prompt_failed(item_slot)) - return (false); + item_def& arm(you.inv[item_slot]); - item_def& arm(you.inv[item_slot]); + if (!is_enchantable_armour(arm, true, true)) + { + mpr("Choose some type of armour to enchant, or Esc to abort."); + if (Options.auto_list) + more(); - int ac_change; - bool result = enchant_armour(ac_change, false, arm); + item_slot = -1; + continue; + } - if (ac_change) - you.redraw_armour_class = true; + // Okay, we may actually (attempt to) enchant something. + int ac_change; + bool result = enchant_armour(ac_change, false, arm); - return (result); + if (ac_change) + you.redraw_armour_class = true; + + return (result); + } + while (true); + + return (false); } static void handle_read_book(int item_slot) @@ -4262,7 +4278,7 @@ static bool _scroll_modify_item(item_def scroll) } break; case SCR_RECHARGING: - if (item_is_rechargeable(item)) + if (item_is_rechargeable(item, true)) { // Might still fail on highly enchanted weapons of electrocution. // (If so, already prints the "Nothing happens" message.) -- cgit v1.2.3-54-g00ecf