Allow arbitrarily many different genders.
This commit is contained in:
parent
a7b9bca797
commit
3dc4d3d262
|
@ -80,22 +80,6 @@
|
||||||
Specified as dynamic so that you can rebind this to suit your needs."
|
Specified as dynamic so that you can rebind this to suit your needs."
|
||||||
3)
|
3)
|
||||||
|
|
||||||
(def ^:dynamic *male-suffixes*
|
|
||||||
"Suffixes which may be appended to male names. Note that suffixes will
|
|
||||||
only be appended if the base name ends in a consonant. If your culture does
|
|
||||||
not use gender-specific name suffixes, bind this to `nil`.
|
|
||||||
|
|
||||||
Specified as dynamic so that you can rebind this to suit your needs."
|
|
||||||
'("" "an" "on" "en"))
|
|
||||||
|
|
||||||
(def ^:dynamic *female-suffixes*
|
|
||||||
"Suffixes which may be appended to female names. Note that suffixes will
|
|
||||||
only be appended if the base name ends in a consonant. If your culture does
|
|
||||||
not use gender-specific name suffixes, bind this to `nil`.
|
|
||||||
|
|
||||||
Specified as dynamic so that you can rebind this to suit your needs."
|
|
||||||
'("" "a" "i" "iy" "y"))
|
|
||||||
|
|
||||||
(defn- max-consecutive
|
(defn- max-consecutive
|
||||||
[name type]
|
[name type]
|
||||||
(last
|
(last
|
||||||
|
@ -138,17 +122,28 @@ not use gender-specific name suffixes, bind this to `nil`.
|
||||||
(cond (and m (zero? (.getEditDistance m))) false
|
(cond (and m (zero? (.getEditDistance m))) false
|
||||||
:else true))))
|
:else true))))
|
||||||
|
|
||||||
|
(def ^:dynamic *genders*
|
||||||
|
"Genders of characters in your game world, with name suffixes appropriate to
|
||||||
|
those genders.
|
||||||
|
|
||||||
|
Specified as dynamic so that you can rebind this to suit your needs. If the
|
||||||
|
cultures of your world do not use gender-specific suffixes, the `:suffixes`
|
||||||
|
values should be `nil`. Repeated suffixes will be used more frequently."
|
||||||
|
{:female {:suffixes ["" "a" "a" "a" "i" "iy" "iy" "y"]}
|
||||||
|
:male {:suffixes ["" "an" "an" "en" "en" "en" "on"]}})
|
||||||
|
|
||||||
(defn gender-suffix
|
(defn gender-suffix
|
||||||
"Return a suitable gender suffix for this `base-name` given this `gender`.
|
"Return a suitable gender suffix for this `base-name` given this `gender`.
|
||||||
Default is no suffix."
|
`gender` may be a keyword, or a map which has a keyword value to the
|
||||||
|
keyword `:gender`. Keywords which are not keys in the current binding of
|
||||||
|
`*genders*` will be ignored. Default is no suffix."
|
||||||
[base-name gender]
|
[base-name gender]
|
||||||
(let [last-consonant? (consonant? (last (seq base-name)))
|
(let [last-consonant? (consonant? (last (seq base-name)))
|
||||||
g' (if (keyword? gender) gender (:gender gender))]
|
g' (if (keyword? gender) gender (:gender gender))]
|
||||||
(or
|
(or
|
||||||
(when last-consonant?
|
(when last-consonant?
|
||||||
(case g'
|
(when g'
|
||||||
:male (rand-nth *male-suffixes*)
|
(rand-nth (-> *genders* g' :suffixes))))
|
||||||
:female (rand-nth *female-suffixes*)))
|
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
(defn generate
|
(defn generate
|
||||||
|
|
Loading…
Reference in a new issue