diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-29 11:11:32 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-29 11:11:32 +0000 |
commit | 7fcfce7d250e09f85bc09f9e720dda5cf723e68e (patch) | |
tree | f70f14cb977e44bcded985b8527e7cd01ad50663 /crawl-ref/source/describe.cc | |
parent | 10a49dc866d7cb5b0d5fe0400ae02f30e8be4d85 (diff) | |
download | crawl-ref-7fcfce7d250e09f85bc09f9e720dda5cf723e68e.tar.gz crawl-ref-7fcfce7d250e09f85bc09f9e720dda5cf723e68e.zip |
* Dump spells contained in randart spellbooks, marking memorised spells
with an asterisk.
* Sif Muna no longer gifts the books specific to Kiku and Vehumet
(Necronomicon, Annihilations, Demonology) though the spells contained
there-in may crop up in randart books.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8011 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r-- | crawl-ref/source/describe.cc | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 42bf6aa797..25a95d3f45 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1625,6 +1625,58 @@ static std::string _describe_deck( const item_def &item ) return (description); } +// Adds a list of all spells contained in a book or rod to its +// description string. +void append_spells(std::string &desc, const item_def &item) +{ + if (!item.has_spells()) + return; + + desc += "$$Spells Type Level$"; + + for (int j = 0; j < 8; j++) + { + spell_type stype = which_spell_in_book(item, j); + if (stype == SPELL_NO_SPELL) + continue; + + std::string name = (is_memorised(stype)) ? "*" : ""; + name += spell_title(stype); + desc += name; + for (unsigned int i = 0; i < 35 - name.length(); i++) + desc += " "; + + name = ""; + if (item.base_type == OBJ_STAVES) + name += "Evocations"; + else + { + bool already = false; + + for (int i = 0; i <= SPTYP_LAST_EXPONENT; i++) + { + if (spell_typematch( stype, 1 << i )) + { + if (already) + name += "/" ; + + name += spelltype_name( 1 << i ); + already = true; + } + } + } + desc += name; + + for (unsigned int i = 36; i < 65 - name.length(); i++) + desc += " "; + + char sval[3]; + itoa( spell_difficulty( stype ), sval, 10 ); + desc += sval; + desc += "$"; + } +} + // ======================================================================== // Public Functions // ======================================================================== @@ -1714,7 +1766,8 @@ std::string get_item_description( const item_def &item, bool verbose, description << ".$"; } else if (verbose || (item.base_type != OBJ_WEAPONS - && item.base_type != OBJ_ARMOUR)) + && item.base_type != OBJ_ARMOUR + && item.base_type != OBJ_BOOKS)) { description << "$$"; @@ -1779,7 +1832,7 @@ std::string get_item_description( const item_def &item, bool verbose, std::string desc; switch (item.base_type) { - // Weapons, armour, jewellery might be artefacts. + // Weapons, armour, jewellery, books might be artefacts. case OBJ_WEAPONS: desc = _describe_weapon( item, verbose ); if (desc.empty()) @@ -1804,6 +1857,22 @@ std::string get_item_description( const item_def &item, bool verbose, description << desc; break; + case OBJ_BOOKS: + if (!player_can_read_spellbook( item )) + { + description << "$This book is beyond your current level of " + "understanding."; + } + else if (!verbose && is_random_artefact( item )) + { + append_spells( desc, item ); + if (desc.empty()) + need_extra_line = false; + else + description << desc; + } + break; + case OBJ_MISSILES: description << _describe_ammo( item ); break; @@ -1905,14 +1974,6 @@ std::string get_item_description( const item_def &item, bool verbose, description << _describe_deck( item ); break; - case OBJ_BOOKS: - if (!player_can_read_spellbook( item )) - { - description << "$This book is beyond your current level of " - "understanding."; - } - break; - case OBJ_POTIONS: #ifdef DEBUG_BLOOD_POTIONS // List content of timer vector for blood potions. |