summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-07-15 10:16:50 -0400
committerNeil Moore <neil@s-z.org>2014-07-15 10:21:01 -0400
commitda4b28bb0ac7045adf7b1596e86c35aeb58ea41f (patch)
treed75edda74dd1440f0310ac9546841a8ee8e9e86c
parent3be80b4b66ba0cd025360de7a3f20401edf01a09 (diff)
downloadcrawl-ref-da4b28bb0ac7045adf7b1596e86c35aeb58ea41f.tar.gz
crawl-ref-da4b28bb0ac7045adf7b1596e86c35aeb58ea41f.zip
More code to data: pronoun declensions.
Also improve a comment by making some examples less ambiguous.
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/mon-enum.h1
-rw-r--r--crawl-ref/source/mon-util.cc40
3 files changed, 16 insertions, 26 deletions
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index b2b556823c..e9c857b288 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -3590,6 +3590,7 @@ enum pronoun_type
PRONOUN_POSSESSIVE,
PRONOUN_REFLEXIVE,
PRONOUN_OBJECTIVE,
+ NUM_PRONOUN_CASES
};
// Be sure to update _prop_name[] in wiz-item.cc to match. Also
diff --git a/crawl-ref/source/mon-enum.h b/crawl-ref/source/mon-enum.h
index b4b7cbf043..012c166e3e 100644
--- a/crawl-ref/source/mon-enum.h
+++ b/crawl-ref/source/mon-enum.h
@@ -26,6 +26,7 @@ enum gender_type
GENDER_NEUTER,
GENDER_MALE,
GENDER_FEMALE,
+ NUM_GENDERS
};
// TODO: Unify this and a player_equivalent (if applicable)
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 19804309ae..f26351c90b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -3702,38 +3702,26 @@ static gender_type _mons_class_gender(monster_type mc)
return gender;
}
+static const char * const _pronoun_declension[][NUM_PRONOUN_CASES] =
+{
+ // subj poss refl obj
+ { "it", "its", "itself", "it" }, // neuter
+ { "he", "his", "himself", "him" }, // masculine
+ { "she", "her", "herself", "her" }, // feminine
+};
+
// Use of variant (case is irrelevant here):
// PRONOUN_SUBJECTIVE : _She_ is tap dancing.
-// PRONOUN_POSSESSIVE : _Her_ sword explodes!
+// PRONOUN_POSSESSIVE : _Its_ sword explodes!
// PRONOUN_REFLEXIVE : The wizard mumbles to _herself_.
-// PRONOUN_OBJECTIVE : You miss _her_.
-
+// PRONOUN_OBJECTIVE : You miss _him_.
const char *mons_pronoun(monster_type mon_type, pronoun_type variant,
bool visible)
{
- gender_type gender = !visible ? GENDER_NEUTER
- : _mons_class_gender(mon_type);
-
- switch (variant)
- {
- case PRONOUN_SUBJECTIVE:
- return gender == GENDER_NEUTER ? "it" :
- gender == GENDER_MALE ? "he" : "she";
-
- case PRONOUN_POSSESSIVE:
- return gender == GENDER_NEUTER ? "its" :
- gender == GENDER_MALE ? "his" : "her";
-
- case PRONOUN_REFLEXIVE:
- return gender == GENDER_NEUTER ? "itself" :
- gender == GENDER_MALE ? "himself" : "herself";
-
- case PRONOUN_OBJECTIVE:
- return gender == GENDER_NEUTER ? "it" :
- gender == GENDER_MALE ? "him" : "her";
- }
-
- return "";
+ COMPILE_CHECK(ARRAYSZ(_pronoun_declension) == NUM_GENDERS);
+ const gender_type gender = !visible ? GENDER_NEUTER
+ : _mons_class_gender(mon_type);
+ return _pronoun_declension[gender][variant];
}
// Checks if the monster can use smiting/torment to attack without