summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-util.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-25 09:11:50 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-25 09:11:50 +0000
commit7b4927dc530fe713ac4c784af53e1958d78a4eeb (patch)
tree580ca94f8645c5c578d37b92668bac145215b285 /crawl-ref/source/spl-util.cc
parentc04f1e2e70434d149a12d097f79efb9178e593ef (diff)
downloadcrawl-ref-7b4927dc530fe713ac4c784af53e1958d78a4eeb.tar.gz
crawl-ref-7b4927dc530fe713ac4c784af53e1958d78a4eeb.zip
Spell changes: strengthened stone arrow and the storms, weakened bolts of fire and cold, and crystal spear.
(Re)allow partial spell names when using &Z in wizmode. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2543 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-util.cc')
-rw-r--r--crawl-ref/source/spl-util.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 2f06175670..9cbaace2df 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -76,13 +76,14 @@ void init_spell_descs(void)
spell_list[spelldata[i].id] = i;
} // end init_spell_descs()
-spell_type spell_by_name(std::string name)
+spell_type spell_by_name(std::string name, bool partial_match)
{
if (name.empty())
return (SPELL_NO_SPELL);
lowercase(name);
-
+
+ int spellmatch = -1;
for (int i = 0; i < NUM_SPELLS; i++)
{
spell_type type = static_cast<spell_type>(i);
@@ -90,11 +91,16 @@ spell_type spell_by_name(std::string name)
if (!sptitle)
continue;
- if (name == lowercase_string(sptitle))
+ const std::string spell_name = lowercase_string(sptitle);
+ if (name == spell_name)
return (type);
+
+ if (partial_match && spell_name.find(name) != std::string::npos)
+ spellmatch = i;
}
- return (SPELL_NO_SPELL);
+ return (spellmatch != -1? static_cast<spell_type>(spellmatch)
+ : SPELL_NO_SPELL);
}
int get_spell_slot_by_letter( char letter )