git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1370 c06c8d41-db1a-0410-9941-cceddc491573
JVSCP4FTW2G57C6YD5HZOZXTODGZH7TR75JQGFJBEPX3LCZH236QC
25VJTGR3AWZJ7OHKYWS53VJ6TVMMU6UT7BA6V3QVVWDGI6FYKD7QC
2KTJHQUX2LTU2BCLS5YXVRRKMOYKKIZAPF2LBKORFGSHEN5IO3IAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
CIPVRZGLOZHCERK6YPOBV3P2E4IAB4H6D5EHLRQE2O5E4P4VCBUAC
////////////////////////////////////////////////////////////////////////
// item_def functions.
bool item_def::has_spells() const
{
return ((base_type == OBJ_BOOKS && item_type_known(*this)
&& sub_type != BOOK_DESTRUCTION
&& sub_type != BOOK_MANUAL)
|| count_staff_spells(*this, true) > 1);
}
int item_def::book_number() const
{
return (base_type == OBJ_BOOKS? sub_type :
base_type == OBJ_STAVES? sub_type + 40 :
-1);
}
//---------------------------------------------------------------
//
// describe_item
//
// Describes all items in the game.
//
//---------------------------------------------------------------
void describe_item( const item_def &item )
static void show_item_description(const item_def &item)
}
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;
}