From dec341f5c123fcaab27d036d70dbef1456ad10fb Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 11 Dec 2008 07:35:25 +0000 Subject: 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 --- crawl-ref/source/mapdef.cc | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'crawl-ref') 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); } -- cgit v1.2.3-54-g00ecf