From 054c713cec71c3010b1ac3eb0848f2b601db982f Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 15 Aug 2007 21:32:33 +0000 Subject: 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 --- crawl-ref/source/spl-book.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'crawl-ref/source/spl-book.cc') 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; -- cgit v1.2.3-54-g00ecf