// createVerb.js
(function () {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Dictionary.prototype;
/**
* Native verbs are stored as non-classed objects, aka preverbs.
* This method calls the <a href="/doc/adventurejs.Verb.html">Verb()</a>
* constructor and passes data from
* preverb to verb, then adds the new verb to game.dictionary.verbs.
* @memberOf adventurejs.Dictionary
* @method adventurejs.Dictionary#createVerb
* @kind function
* @param {object} preverb A generic object.
* @returns {Verb} The constructed verb
*/
p.createVerb = function (preverb) {
// add new verb to the dictionary
if ("undefined" === typeof preverb) {
var msg = "createVerb received a bad value: " + preverb;
this.game.log("warn", 0, msg, "dictionary");
return false;
}
if ("undefined" === typeof preverb.name) {
var msg = "createVerb received a preverb without a name: " + preverb;
this.game.log("warn", 0, msg, "dictionary");
return false;
}
if (this.verbs[preverb.name]) {
var msg =
"createVerb.js > Found an existing verb named " + preverb.name + ". ";
this.game.log("warn", "critical", msg, "dictionary");
return false;
}
this.verbs[preverb.name] = new adventurejs.Verb(this.game);
//if(preverb.phrase1) this.verbs[preverb.name].phrase1 = new adventurejs.Phrase();
//if(preverb.phrase2) this.verbs[preverb.name].phrase2 = new adventurejs.Phrase();
//if(preverb.phrase3) this.verbs[preverb.name].phrase3 = new adventurejs.Phrase();
this.verbs[preverb.name].set(preverb);
this.verbs[preverb.name].validate();
this.verbs[preverb.name].initialize();
this.verb_lookup[preverb.name] = {
synonyms: preverb.synonyms,
};
return this.verbs[preverb.name];
};
})();