// getVerbAgreement.js
/* global adventurejs A */
/**
* Return name of the verb taking into consideration
* third-person singular present tense for subjects
* using nonhuman / male / female pronouns (he/she/it)
* or proper name.
* @memberOf adventurejs
* @method adventurejs#getVerbAgreement
* @param {String} verb_name The name of a verb.
* @returns {String} Returns the verb, in agreement with the subject of the current turn.
* @note This is a duplicate of a method on verb and though it makes
* structural sense to put it here, calling it from verb lets us say
* this.agree() vs A.getVerbAgreement.call(this.game, verb.name, this)
*/
adventurejs.getVerbAgreement = function Adventurejs_getVerbAgreement(
verb_name
) {
console.warn("getVerbAgreement", verb_name);
if (!verb_name) return "";
const player = this.game.getPlayer();
const subject = this.game.getInput().getSubject();
const subject_has_propername =
subject && subject.id !== player.id && subject.propername;
if (
subject_has_propername ||
["nonhuman", "male", "female"].includes(
this.game.getInput().getSubject().pronouns
)
) {
if (
verb_name.endsWith("ch") ||
verb_name.endsWith("sh") ||
verb_name.endsWith("x") ||
verb_name.endsWith("s") ||
verb_name.endsWith("z") ||
verb_name.endsWith("o")
) {
return verb_name + "es";
} else if (verb_name.endsWith("y") && !/[aeiou]y$/.test(verb_name)) {
return verb_name.slice(0, -1) + "ies"; // Change "y" to "ies"
} else {
return verb_name + "s"; // Default case
}
} else {
return verb_name;
}
};