// ask.js
(function () {
/*global adventurejs A*/
/**
* @augments {adventurejs.Verb}
* @class ask
* @ajsnode game.dictionary.verbs.ask
* @ajsconstruct MyGame.createVerb({ "name": "ask", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading Conversation Verbs
* @summary Verb meaning ask something of a character.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> ask large duck about crackers</span>
* The large duck shrugs guiltily, snorting cracker crumbs from its beak.
* </pre>
* <p>
* <strong>Ask {@link adventurejs.NPC|NPC} about thing</strong>.
* A useful return requires that the NPC be programmed with
* "knowledge" of the thing through a method such as a verb override.
* To learn about verb hooks,
* see <a href="/doc/Scripting_VerbPhases.html">Verb Phases</a>.
* </p>
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
* @todo logic if player inputs "ask about thing" without noun
* @todo most everything, this is a stub
*/
A.Preverbs.ask = {
name: "ask",
prettyname: "ask about",
synonyms: ["ask about"],
//verb_prep_noun: ["ask about"], // ask about thing
//verb_noun_prep_noun: ["ask about"], // ask person about thing
gerund: "asking",
/**
* @memberof ask
* @ajsverbphrase
* phrase1:{
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* present: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
noun_must_be: {
known: true,
present: true,
},
},
/**
* @memberof ask
* @ajsverbphrase
* phrase2:{
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* },
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
},
},
/**
* @memberof ask
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var verb_phrase = input.verb_phrase;
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var output_class = input.output_class;
var msg = "";
if (verb_phrase === "ask about") {
//
}
// can't talk to non-characters
if (!(direct_object instanceof adventurejs.Character)) {
this.game.debug(
`D1231 | ${this.name}.js | ${direct_object.id} is not class Character`
);
msg += `${direct_object.Articlename} doesn't answer. `;
this.handleFailure(msg);
return null;
}
return true;
},
doSuccess: function () {
this.game.debug(`D1232 | ${this.name}.js | print success`);
var input = this.game.getInput();
var verb_phrase = input.verb_phrase;
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var output_class = input.output_class;
var msg = "";
// ask x about y
msg += `$(We) ask ${direct_object.articlename} about ${indirect_object.articlename}. `;
// @TODO transfer of knowledge
return this.handleSuccess(msg, direct_object);
},
};
})(); // ask