summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-11 07:35:25 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-11 07:35:25 +0000
commitdec341f5c123fcaab27d036d70dbef1456ad10fb (patch)
tree4898f65a6e1bca5e6fb93aa066abf34d3147abb8 /crawl-ref/source/mapdef.cc
parentdfca2b67f0771375f668d241bf192f5b80ae1552 (diff)
downloadcrawl-ref-dec341f5c123fcaab27d036d70dbef1456ad10fb.tar.gz
crawl-ref-dec341f5c123fcaab27d036d70dbef1456ad10fb.zip
Allow hydras to be specified by strings like "two-headed hydra" as well
as "2-headed hydra". Also, increase maximum number of hydra heads to 20, since an 19 headed hydra can become a 20 headed one but a 20 headed one can't become 21 headed. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7806 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 7655c48108..7266116331 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -2263,11 +2263,35 @@ void mons_list::get_zombie_type(std::string s, mons_spec &spec) const
mons_spec mons_list::get_hydra_spec(const std::string &name) const
{
- int nheads = atoi(name.c_str());
+ int nheads = -1;
+ std::string prefix = name.substr(0, name.find("-"));
+
+ nheads = atoi(prefix.c_str());
+ if (nheads != 0)
+ ;
+ else if (prefix == "0")
+ nheads = 0;
+ else
+ {
+ // Might be "two-headed hydra" type string.
+ for (int i = 0; i <= 20; i++)
+ if (number_in_words(i) == prefix)
+ {
+ nheads = i;
+ break;
+ }
+ }
+
if (nheads < 1)
nheads = MONS_PROGRAM_BUG; // What can I say? :P
- else if (nheads > 19)
- nheads = 19;
+ else if (nheads > 20)
+ {
+#if DEBUG || DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "Hydra spec wants %d heads, clamping to 20.",
+ nheads);
+#endif
+ nheads = 20;
+ }
return mons_spec(MONS_HYDRA, MONS_PROGRAM_BUG, nheads);
}