From 6bb8ebbe1d9b86ce5cb492bd0a59cd8b29e831ef Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 12 Mar 2007 20:42:42 +0000 Subject: Added KFEAT:, KITEM: and KMONS: map directives to allow placing specific monsters, terrain (named altars, traps, shops) and items all on the same square. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1028 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/describe.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'crawl-ref/source/describe.cc') diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 3929106b4e..20a66edbce 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -332,11 +332,31 @@ static const char *trap_names[] = const char *trap_name(trap_type trap) { + ASSERT(NUM_TRAPS == sizeof(trap_names) / sizeof(*trap_names)); + if (trap >= TRAP_DART && trap < NUM_TRAPS) return trap_names[ static_cast( trap ) ]; return (NULL); } +int str_to_trap(const std::string &s) +{ + ASSERT(NUM_TRAPS == sizeof(trap_names) / sizeof(*trap_names)); + + if (s == "random") + return (TRAP_RANDOM); + else if (s == "suitable") + return (TRAP_INDEPTH); + + for (int i = 0; i < NUM_TRAPS; ++i) + { + if (trap_names[i] == s) + return (i); + } + + return (-1); +} + //--------------------------------------------------------------- // // describe_demon -- cgit v1.2.3-54-g00ecf