// say.js
(function () {
/* global adventurejs A */
/**
* @augments {adventurejs.Verb}
* @class say
* @ajsnode game.dictionary.verbs.say
* @ajsconstruct MyGame.createVerb({ "name": "say", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading ConversationVerbs
* @summary Verb meaning say, as in "say 'boo' to ghost hunter".
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="ajs-player-input">> </span>
*
* </pre>
* <p>
* Description of the verb.
* </p>
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.say = {
name: "say",
prettyname: "say",
past_tense: "said",
synonyms: ["say"],
gerund: "saying",
/**
* @ajsverbstructures
* @memberof say
*/
accepts_structures: [
"verb noun", // say "boo"
"verb noun preposition noun", // say "boo" to char
],
/**
* @memberof say
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
},
},
/**
* @memberof say
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* present: true,
* },
* accepts_preposition: true,
* requires_preposition: true,
* preposition_must_be: ["to", "at", "in"],
* },
*/
phrase2: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
present: true,
},
accepts_preposition: true,
requires_preposition: true,
preposition_must_be: ["to", "at", "in"],
},
/**
* @memberof say
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var msg = "";
// can't talk to non-characters
// if (!(indirect_object instanceof adventurejs.Character)) {
// this.game.debug(
// ` | ${this.name}.js | ${indirect_object.id} is not class Character `
// );
// msg += `${indirect_object.Articlename} {doesn't} appear to be interested. `;
// this.handleFailure(msg);
// return null;
// }
// // can't talk to characters with ask unset
// if (!indirect_object.isDOV(this.name)) {
// this.game.debug(
// ` | ${this.name}.js | ${indirect_object.id}.dov.${this.name} is unset`
// );
// msg += `${indirect_object.Articlename} doesn't seem interested. `;
// this.handleFailure(msg);
// return null;
// }
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var player;
var direct_object;
var msg = "";
// tell x about y
msg += `{We} say ${direct_object.articlename} ${indirect_preposition ? indirect_preposition : ""} ${indirect_object ? indirect_object.articlename : " to {ourself}"}`;
msg = msg.trim();
msg += `. `;
// @TODO transfer of knowledge
return this.handleSuccess(msg, direct_object);
},
};
})(); // tell