summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc20
1 files changed, 20 insertions, 0 deletions
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<int>( 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