diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-08-15 21:32:33 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-08-15 21:32:33 +0000 |
commit | 054c713cec71c3010b1ac3eb0848f2b601db982f (patch) | |
tree | da7a575a718b842b7ea15bb8ffc59efdccc2ff95 /crawl-ref/source/spl-book.cc | |
parent | 54f595ca30391a4e95ae1f46706d9c7cc5a6b6a8 (diff) | |
download | crawl-ref-054c713cec71c3010b1ac3eb0848f2b601db982f.tar.gz crawl-ref-054c713cec71c3010b1ac3eb0848f2b601db982f.zip |
More stuff for the tutorial:
- Enhanced handling of spellbooks and artefacts.
- Feature descriptions now cover altars.
- Added monster descriptions (out of depth and brands).
Also:
- space-only inscription counts as no inscription
- ring of teleportation autoID's if no teleport randart
In my last commit I forgot to mention that the
descriptions were suggested by Richard Gould, and
I'd like to give credit where credit is due. :)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2005 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-book.cc')
-rw-r--r-- | crawl-ref/source/spl-book.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 0d4309d7cf..f4734d2f79 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1131,6 +1131,43 @@ bool undead_cannot_memorise(spell_type spell, char being) return false; } // end undead_cannot_memorise() +bool player_can_memorize(item_def &book) +{ + if (book.base_type != OBJ_BOOKS || book.sub_type == BOOK_MANUAL) + return false; + + if (!player_spell_levels()) + return false; + + for (int j = 0; j < SPELLBOOK_SIZE; j++) + { + const spell_type stype = which_spell_in_book(book.book_number(), j); + + if (stype == SPELL_NO_SPELL) + continue; + + // easiest spell already too difficult + if (spell_difficulty(stype) > you.experience_level + || player_spell_levels() < spell_levels_required(stype)) + { + return false; + } + + bool knowsSpell = false; + for (int i = 0; i < 25 && !knowsSpell; i++) + { + knowsSpell = (you.spells[i] == stype); + } + + // don't already know this spell + if (!knowsSpell) + { + return true; + } + } + return false; +} + bool learn_spell(void) { int chance = 0; |