From a36fd3f9f0e5bde3dd9d74e1742cfbd2f045c635 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 21 Sep 2009 08:23:35 +0000 Subject: Allow vaults to request use of the acquirement code with "acquire " or "acquire: " in item specs (due). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10765 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mapdef.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crawl-ref/source/mapdef.cc') 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); -- cgit v1.2.3-54-g00ecf