summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemname.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-31 17:44:23 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-31 17:44:23 +0000
commit8d620e1509fe04db564a5f46e32046d0ed61d714 (patch)
treedafee486172262a4aeb69878e0f290df62cdad69 /crawl-ref/source/itemname.cc
parent84dcd8dbdcbdbbcb08794426c634dce42d98e935 (diff)
downloadcrawl-ref-8d620e1509fe04db564a5f46e32046d0ed61d714.tar.gz
crawl-ref-8d620e1509fe04db564a5f46e32046d0ed61d714.zip
Modify menu_colour_item_prefix() to also handle stuff like contaminated
or poisonous chunks. Throw out all those special cases in food_colouring.txt and replace them with logic. I sure hope I got all special cases, but if not they should be easy enough to add. The functions are currently all in food.cc but they could easily be moved over to clua.cc and adapted accordingly if needed. New prefix shortcuts: * inedible (full herbi/carnivorousness, rotten food for non-saprovores) * preferred (respects foovorousness, rotten for ghouls, royal jelly for everyone) * poisonous * contaminated * mutagenic * rot-inducing (I also added one-liners to the descriptions of chunks of those types.) The changes apply to all menu types, but they don't handle messages. This is problematic in that you'd have to check the pickup menu to see which corpses are worth butchering, but I'm still against keeping all those manual checks for (currently) poisonous/mutagenic/... corpses, esp. as information like this can date quickly. Instead the butchering interface should be improved to somehow handle that, possibly by overriding the prompt colour with the specified colour if necessary. I don't think there are any other cases where this is important. Also add a prefix for equipped items and artefacts, so they can be easily checked for as well. I really think the identified/unidentified prefix should become default (and the option removed) - this allows for easy differentiation between identified and non-identified artefacts. The "known" prefix (for known wand charges or enchantments) is a bit less interesting but wouldn't hurt any (I think). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5373 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemname.cc')
-rw-r--r--crawl-ref/source/itemname.cc58
1 files changed, 48 insertions, 10 deletions
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 70ecb6fa8f..4b3ca9f252 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -36,6 +36,7 @@
#include "makeitem.h"
#include "mon-util.h"
#include "notes.h"
+#include "player.h"
#include "quiver.h"
#include "randart.h"
#include "skills2.h"
@@ -2150,7 +2151,7 @@ bool is_interesting_item( const item_def& item )
const std::string menu_colour_item_prefix(const item_def &item)
{
- std::string str = "";
+ std::vector<std::string> prefixes;
if (Options.menu_colour_prefix_id)
{
@@ -2158,7 +2159,7 @@ const std::string menu_colour_item_prefix(const item_def &item)
|| item.base_type == OBJ_FOOD
|| item.base_type == OBJ_CORPSES)
{
- str += "identified ";
+ prefixes.push_back("identified");
}
else
{
@@ -2168,7 +2169,8 @@ const std::string menu_colour_item_prefix(const item_def &item)
// Wands are only fully identified if we know the
// number of charges.
if (item.base_type == OBJ_WANDS)
- str += "known ";
+ prefixes.push_back("known");
+
// Rings are fully identified simply by knowing their
// type, unless the ring has plusses, like a ring of
// dexterity.
@@ -2176,26 +2178,62 @@ const std::string menu_colour_item_prefix(const item_def &item)
&& !jewellery_is_amulet(item))
{
if (item.plus == 0 && item.plus2 == 0)
- str += "identified ";
+ prefixes.push_back("identified");
else
- str += "known ";
+ prefixes.push_back("known");
}
// All other types of magical items are fully identified
// simply by knowing the type
else
- str += "identified ";
+ prefixes.push_back("identified");
}
else
- str += "unidentified ";
+ prefixes.push_back("unidentified");
}
}
- if (Options.menu_colour_prefix_class)
+ switch (item.base_type)
{
- str += item_class_name(item.base_type, true) + " ";
+ case OBJ_FOOD:
+ if (!can_ingest(item.base_type, item.sub_type, true, true, false)
+ || food_is_rotten(item)
+ && !player_mutation_level(MUT_SAPROVOROUS))
+ {
+ prefixes.push_back("inedible");
+ }
+ else if (is_preferred_food(item))
+ prefixes.push_back("preferred");
+
+ // intentional fall-through
+ case OBJ_CORPSES:
+ if (is_poisonous(item) && !player_res_poison())
+ prefixes.push_back("poisonous");
+ else if (is_mutagenic(item))
+ prefixes.push_back("mutagenic");
+ else if (is_contaminated(item))
+ prefixes.push_back("contaminated");
+ else if (causes_rot(item))
+ prefixes.push_back("rot-inducing");
+ break;
+
+ case OBJ_WEAPONS:
+ case OBJ_ARMOUR:
+ case OBJ_JEWELLERY:
+ if (item_is_equipped(item))
+ prefixes.push_back("equipped");
+ if (is_artefact(item))
+ prefixes.push_back("artefact");
+ default:
+ break;
}
- return str;
+ if (Options.menu_colour_prefix_class)
+ prefixes.push_back(item_class_name(item.base_type, true));
+
+ std::string result = comma_separated_line(prefixes.begin(), prefixes.end(),
+ " ", " ");
+
+ return result;
}
typedef std::map<std::string, item_types_pair> item_names_map;