summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-21 08:23:35 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-21 08:23:35 +0000
commita36fd3f9f0e5bde3dd9d74e1742cfbd2f045c635 (patch)
tree162c04f1bb86a4f1bde64d55c69c81ee65b38680 /crawl-ref/source/mapdef.cc
parent02c7a7e290da364ed194a72ccc42240afe19e344 (diff)
downloadcrawl-ref-a36fd3f9f0e5bde3dd9d74e1742cfbd2f045c635.tar.gz
crawl-ref-a36fd3f9f0e5bde3dd9d74e1742cfbd2f045c635.zip
Allow vaults to request use of the acquirement code with "acquire <item_class>" or "acquire:<god> <item_class>" in item specs (due).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10765 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index b9df39c83f..71f28e40f5 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -34,6 +34,7 @@ REVISION("$Rev$");
#include "monplace.h"
#include "mon-util.h"
#include "place.h"
+#include "religion.h"
#include "stuff.h"
#include "tags.h"
@@ -2823,6 +2824,15 @@ static int str_to_ego(item_spec &spec, std::string ego_str)
return 0;
}
+int item_list::parse_acquirement_source(const std::string &source)
+{
+ const std::string god_name(replace_all_of(source, "_", " "));
+ const god_type god(string_to_god(god_name.c_str(), true));
+ if (god == GOD_NO_GOD)
+ error = make_stringf("unknown god name: '%s'", god_name.c_str());
+ return (god);
+}
+
item_spec item_list::parse_single_spec(std::string s)
{
item_spec result;
@@ -2844,6 +2854,22 @@ item_spec item_list::parse_single_spec(std::string s)
if (qty != TAG_UNFOUND)
result.qty = qty;
+ const std::string acquirement_source = strip_tag_prefix(s, "acquire:");
+ if (!acquirement_source.empty() || strip_tag(s, "acquire"))
+ {
+ if (!acquirement_source.empty())
+ result.acquirement_source =
+ parse_acquirement_source(acquirement_source);
+ // If requesting acquirement, must specify item base type or
+ // "any".
+ result.level = ISPEC_ACQUIREMENT;
+ if (s == "any")
+ result.base_type = OBJ_RANDOM;
+ else
+ parse_random_by_class(s, result);
+ return (result);
+ }
+
std::string ego_str = strip_tag_prefix(s, "ego:");
std::string race_str = strip_tag_prefix(s, "race:");
lowercase(ego_str);