summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-08-12 03:40:09 -0400
committerJesse Luehrs <doy@tozt.net>2014-08-12 03:48:26 -0400
commit32f1ee216dfee8c3c4932ec5944b1bc357b429f3 (patch)
tree3f284ab600dbb73636a923cd34bcc6d68977fcab
parentf883cba7661e1b9ba92ca996953deb9c63c602c7 (diff)
downloadcrawl-ref-32f1ee216dfee8c3c4932ec5944b1bc357b429f3.tar.gz
crawl-ref-32f1ee216dfee8c3c4932ec5944b1bc357b429f3.zip
also apply weapon and armour brands
-rw-r--r--crawl-ref/source/wiz-you.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/wiz-you.cc b/crawl-ref/source/wiz-you.cc
index 9ffdf85f2a..c30bf0e01a 100644
--- a/crawl-ref/source/wiz-you.cc
+++ b/crawl-ref/source/wiz-you.cc
@@ -1116,6 +1116,55 @@ static item_def _item_from_string(string s)
ret.quantity = 1;
item_colour(ret);
+ while (end < s.length())
+ {
+ size_t begin_brand = s.find_first_not_of("{(, ", end);
+ if (begin_brand == string::npos)
+ break;
+ size_t end_brand = s.find_first_of("}), ", begin_brand);
+ if (end_brand == begin_brand)
+ break;
+ else if (end_brand == string::npos)
+ end_brand = s.length();
+ string brand_name = s.substr(begin_brand, end_brand - begin_brand);
+
+ bool found = false;
+ switch (ret.base_type)
+ {
+ case OBJ_WEAPONS:
+ for (int i = SPWPN_NORMAL; i < NUM_SPECIAL_WEAPONS; ++i)
+ {
+ ret.special = i;
+ if (brand_name == weapon_brand_name(ret, true))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ ret.special = SPWPN_NORMAL;
+ break;
+ case OBJ_ARMOUR:
+ for (int i = SPARM_NORMAL; i < NUM_SPECIAL_ARMOURS; ++i)
+ {
+ ret.special = i;
+ if (brand_name == armour_ego_name(ret, true))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ ret.special = SPARM_NORMAL;
+ break;
+ // XXX
+ default:
+ break;
+ }
+
+ end = end_brand;
+ }
+
return ret;
}