// getVerb.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Dictionary.prototype;
/**
* A method to get a dictionary verb object from a verb name string.
* @memberOf AdventureJS.Dictionary
* @method AdventureJS.Dictionary#getVerb
* @param {String} verb
* @returns {object}
* @TODO this needs more robust case handling due to
* camelCase verbs like getOn.
* @TODO this needs to handle synonyms.
*/
p.getVerb = function Dictionary_getVerb(verb) {
if ("string" !== typeof verb) return false;
const direction = this.getDirection(verb);
let found =
this.verbs[verb] ||
this.verbs[verb.toLowerCase()] ||
this.verbs[this.getDirection(verb)] ||
null;
if (!found) {
for (let v in this.verb_lookup) {
const lookup = this.verb_lookup[v];
if (lookup?.synonyms?.includes(verb)) {
return this.verbs[v];
}
}
}
return found;
};
})();