distinguish between stairs and portals.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1770 c06c8d41-db1a-0410-9941-cceddc491573
UOW2X5KTUHYCM73SWNOSJPHUKWVLF3OJTNSISSSENEURBX2XWHVQC
GMSGNBZKUJ3DDTOGLQJ3VUBUYIECAW6PDDHYFPGSOHSG2TUUKJRAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
AXQJOPTECRU3ECV3ICDUR6SGBIOIZT5HIOSJ77MRLF5ECGOITMDQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
TAHSTXR7ROOMDFUSBUU4ZAIEWQLAS5CIRCTARLD4Q2BGNLSL7E5QC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
IPXXB4VRVZWOU5DKQ5ZTD37LS3QNK2R6APNZUO672YEEJT6OFAYQC
ILOED4VB4I6VPAUTR75ZWX6MXDYXB5DO2EDK2UH67O3HNKWV23RQC
GDHH6O4KVTDWSENR573WKVFCRM2L4AVOBRSVPI6F5A2UR7U7SPXAC
PL6I2CMSTHY5ZHWVMIQE5YTM5S5VPKBNZM6QJVHZSSKOJGIJ5W4AC
YHSVOROKPYS33Y4RYZRVZTE3G5LXOFX52HEDNLV6HIXOJYNOKH3QC
WW6THKR7JN447YC23YYHYYNH7ABMCFFSECNUFTIJBZX6JHX6W7TAC
BWAQ3FHBBM6G3K3KYP75CRTR343RDQZJRYX5ZGYUEXYBAC3APDLAC
56C44YMFHZ62GXAAOLYSLLGBVGRWXB53W2VI37Q26ZECEK2XG5SQC
W5VEC2PBIM5DMU5233HOWAZUEPTGWJRZZIA3H35YYQQW6BTP6XUAC
bool is_stair(unsigned gridc);
bool is_travelable_stair(unsigned gridc);
command_type stair_direction(int stair_feat);
bool is_stair(dungeon_feature_type gridc);
bool is_travelable_stair(dungeon_feature_type gridc);
command_type stair_direction(dungeon_feature_type stair_feat);
private:
template <class C> void say_any(const C &coll, const char *stub) const;
template <class citer> bool has_duplicates(citer, citer) const;
std::string cleaned_feature_description(dungeon_feature_type feature) const;
void add_item(const item_def &item);
private:
template <class C> void say_any(const C &coll, const char *stub) const;
template <class citer> bool has_duplicates(citer, citer) const;
std::string cleaned_feature_description(dungeon_feature_type feature) const;
void add_item(const item_def &item);
void add_stair(const named_thing<int> &stair);
std::vector<std::string> apply_quantities(
const std::vector< named_thing<int> > &v) const;
bool merge_feature(
std::vector< named_thing<int> > &v,
const named_thing<int> &feat) const;
void explore_discoveries::add_stair(
const explore_discoveries::named_thing<int> &stair)
{
if (merge_feature(stairs, stair) || merge_feature(portals, stair))
return;
// Hackadelic
if (stair.name.find("stair") != std::string::npos)
stairs.push_back(stair);
else
portals.push_back(stair);
}
std::vector<std::string> explore_discoveries::apply_quantities(
const std::vector< named_thing<int> > &v) const
{
static const char *feature_plural_qualifiers[] =
{
" leading ", " back to ", " to ", " of "
};
std::vector<std::string> things;
for (int i = 0, size = v.size(); i < size; ++i)
{
const named_thing<int> &nt = v[i];
if (nt.thing == 1)
things.push_back(article_a(nt.name));
else
things.push_back(number_in_words(nt.thing)
+ " "
+ pluralise(nt.name, feature_plural_qualifiers));
}
return (things);
}
}
// Naively prefix A/an to a noun.
std::string article_a(const std::string &name, bool lowercase)
{
if (!name.length()) return name;
const char *a = lowercase? "a " : "A ";
const char *an = lowercase? "an " : "An ";
switch (name[0])
{
case 'a': case 'e': case 'i': case 'o': case 'u':
case 'A': case 'E': case 'I': case 'O': case 'U':
return an + name;
default:
return a + name;
}
// Pluralise first word of names like 'eye of draining' or
// 'scrolls labeled FOOBAR', but only if the whole name is not
// suffixed by a supplied modifier, such as 'zombie' or 'skeleton'
if ( (pos = name.find(" of ")) != std::string::npos
&& !ends_with(name, no_of) )
return pluralise(name.substr(0, pos)) + name.substr(pos);
else if ( (pos = name.find(" labeled ")) != std::string::npos
&& !ends_with(name, no_of) )
return pluralise(name.substr(0, pos)) + name.substr(pos);
else if (ends_with(name, "us"))
if (qualifiers)
{
for (int i = 0; qualifiers[i]; ++i)
if ((pos = name.find(qualifiers[i])) != std::string::npos
&& !ends_with(name, no_qualifier))
{
return pluralise(name.substr(0, pos)) + name.substr(pos);
}
}
if (ends_with(name, "us"))
// Naively prefix A/an to a monster name. At the moment, we don't have monster
// names that demand more sophistication (maybe ynoxinul - don't know how
// that's pronounced).
static std::string article_a(const std::string &name)
{
if (!name.length()) return name;
switch (name[0])
{
case 'a': case 'e': case 'i': case 'o': case 'u':
case 'A': case 'E': case 'I': case 'O': case 'U':
return "An " + name;
default:
return "A " + name;
}
}