summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-25 19:41:46 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-25 19:41:46 +0000
commite46965c192b6ddc04357366a2f136d6e2115bb59 (patch)
treed35217c1c5b22d20e6070865ff92fefe7d5a1cd1 /crawl-ref/source/describe.cc
parent3729bb7d83361ee5032dcc513e5740da08798be6 (diff)
downloadcrawl-ref-e46965c192b6ddc04357366a2f136d6e2115bb59.tar.gz
crawl-ref-e46965c192b6ddc04357366a2f136d6e2115bb59.zip
Allow describing rod/spellbook spells from the examine command (jarpiain).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1370 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc62
1 files changed, 48 insertions, 14 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 2cc47ab016..e635114093 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3470,25 +3470,14 @@ void describe_feature_wide(int x, int y)
getch();
}
-//---------------------------------------------------------------
-//
-// describe_item
-//
-// Describes all items in the game.
-//
-//---------------------------------------------------------------
-void describe_item( const item_def &item )
+static void show_item_description(const item_def &item)
{
clrscr();
std::string description = get_item_description( item, 1 );
print_description(description);
- if ( (item.base_type == OBJ_BOOKS && item_type_known(item)
- && item.sub_type != BOOK_DESTRUCTION
- && item.sub_type != BOOK_MANUAL)
- ||
- count_staff_spells(item, true) > 1 )
+ if (item.has_spells())
{
formatted_string fs;
item_def dup = item;
@@ -3499,10 +3488,55 @@ void describe_item( const item_def &item )
&fs );
fs.display(2, -2);
}
+}
+
+static bool describe_spells(const item_def &item)
+{
+ int c = getch();
+ if (c < 'a' || c > 'h') //jmf: was 'g', but 8=h
+ {
+ mesclr( true );
+ return (false);
+ }
+
+ const int spell_index = letter_to_index(c);
+
+ spell_type nthing =
+ which_spell_in_book(item.book_number(), spell_index);
+ if (nthing == SPELL_NO_SPELL)
+ return (false);
+
+ describe_spell( nthing );
+ return (true);
+}
+//---------------------------------------------------------------
+//
+// describe_item
+//
+// Describes all items in the game.
+//
+//---------------------------------------------------------------
+void describe_item( const item_def &item )
+{
+ for (;;)
+ {
+ show_item_description(item);
+ if (item.has_spells())
+ {
+ gotoxy(1, wherey());
+ textcolor(LIGHTGREY);
+ cprintf("Select a spell to read its description.");
+ if (!describe_spells(item))
+ return;
+ continue;
+ }
+ break;
+ }
+
if (getch() == 0)
getch();
-} // end describe_item()
+}
//---------------------------------------------------------------