From 3719e3c8c35ad7bd924373512c25ce7828d62a03 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 13 Apr 2007 14:08:38 +0000 Subject: Fixed bad grammar on shield block messages in melee. Split up Abyss/Pan/Labyrinth save files. The only practical use right now is to be able to correctly place Abyss and Pan ghosts. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1295 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/Kills.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'crawl-ref/source/Kills.cc') diff --git a/crawl-ref/source/Kills.cc b/crawl-ref/source/Kills.cc index 8a85e04921..8f16ef81cc 100644 --- a/crawl-ref/source/Kills.cc +++ b/crawl-ref/source/Kills.cc @@ -347,7 +347,16 @@ static bool ends_with(const std::string &s, const char *suffixes[]) return false; } -// For monster names ending with these suffixes, we pluralize directly without +std::string apostrophise(const std::string &name) +{ + if (name.empty()) + return (name); + + const char lastc = name[ name.length() - 1 ]; + return (name + (lastc == 's' || lastc == 'x'? "'" : "'s")); +} + +// For monster names ending with these suffixes, we pluralise directly without // attempting to use the "of" rule. For instance: // // moth of wrath => moths of wrath but @@ -361,18 +370,18 @@ static const char *modifier_suffixes[] = "zombie", "skeleton", "simulacrum", NULL, }; -// Pluralizes a monster name. This'll need to be updated for correctness +// Pluralises a monster name. This'll need to be updated for correctness // whenever new monsters are added. -std::string pluralize(const std::string &name, +std::string pluralise(const std::string &name, const char *no_of[]) { std::string::size_type pos; - // Pluralize first word of names like 'eye of draining', but only if the + // Pluralise first word of names like 'eye of draining', but only if the // whole name is not suffixed by a modifier, such as 'zombie' or 'skeleton' if ( (pos = name.find(" of ")) != std::string::npos && !ends_with(name, no_of) ) - return pluralize(name.substr(0, pos)) + name.substr(pos); + return pluralise(name.substr(0, pos)) + name.substr(pos); else if (ends_with(name, "us")) // Fungus, ufetubus, for instance. return name.substr(0, name.length() - 2) + "i"; @@ -428,14 +437,14 @@ static std::string article_a(const std::string &name) } // For a non-unique monster, prefixes a suitable article if we have only one -// kill, else prefixes a kill count and pluralizes the monster name. +// kill, else prefixes a kill count and pluralises the monster name. static std::string n_names(const std::string &name, int n) { if (n > 1) { char buf[20]; snprintf(buf, sizeof buf, "%d ", n); - return buf + pluralize(name, modifier_suffixes); + return buf + pluralise(name, modifier_suffixes); } else return article_a(name); @@ -545,11 +554,11 @@ std::string kill_def::info(const kill_monster_desc &md) const if (!mons_is_unique(md.monnum)) { - // Pluralize as needed + // Pluralise as needed name = n_names(name, kills); // We brand shapeshifters with the (shapeshifter) qualifier. This - // has to be done after doing pluralize(), else we get very odd plurals + // has to be done after doing pluralise(), else we get very odd plurals // :) if (md.modifier == kill_monster_desc::M_SHAPESHIFTER && md.monnum != MONS_SHAPESHIFTER && -- cgit v1.2.3-54-g00ecf