// show.js
(function () {
/* global adventurejs A */
/**
* @augments {adventurejs.Verb}
* @class show
* @ajsnode game.dictionary.verbs.show
* @ajsconstruct MyGame.createVerb({ "name": "show", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading ConversationVerbs
* @summary Verb meaning show, as in "show banana to monkey".
* @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.show = {
name: "show",
prettyname: "show to",
past_tense: "showed",
synonyms: [],
// verb_prep_noun: ["show to"], // tell about thing
// verb_noun_prep_noun: ["show to"], // show thing to character
gerund: "showing",
/**
* @ajsverbstructures
* @memberof show
*/
accepts_structures: [
"verb noun noun", // show character thing
"verb noun preposition noun", // show thing to character
],
/**
* @memberof show
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* present: true,
* tangible: true,
* visible: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
present: true,
tangible: true,
visible: true,
},
},
/**
* @memberof show
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* // character: true,
* },
* },
*/
phrase2: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
// character: true,
},
requires_preposition: true,
preposition_must_be: ["to"],
},
/**
* @memberof show
* @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 = "";
// sentence structure: verb noun noun
if (input.hasStructure("verb noun noun")) {
input.swapPhrases(1, 2);
input.setPreposition(2, "to");
direct_object = input.getAsset(1);
indirect_object = input.getAsset(2);
}
// if (verb_phrase === "show to") {
// //
// }
// no indirect object given
// if( "undefined" === typeof input.parsedNoun2 )
// {
// input.parsedNoun2 = A.clone.call(this.game, input.parsedNoun1 );
// input.parsedNoun1 = undefined;
// input.setSoftPrompt({ index: 2, type: "noun", noun1: true, verb: 'tell' });
// var msg = "To whom would you like to tell it? ";
// this.handleFailure(msg);
// return null;
// }
// can't show to non-characters
if (!(indirect_object instanceof adventurejs.Character)) {
this.game.debug(
`D1187 | ${this.name}.js | ${direct_object.id} is not class Character `
);
msg += `${direct_object.Articlename} doesn't appear to be interested. `;
this.handleFailure(msg);
return null;
}
// can't show to characters with show unset
if (!indirect_object.isIOV(this.name)) {
this.game.debug(
`D1350 | ${this.name}.js | ${indirect_object.id}.iov.${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 player;
var direct_object;
var msg = "";
// show x to y
msg += `{We} show ${direct_object.articlename} to ${indirect_object.articlename}. `;
// @TODO transfer of abstract knowledge
indirect_object.knowAsset(direct_object, true);
indirect_object.seeAsset(direct_object, true);
return this.handleSuccess(msg, direct_object);
},
};
})(); // tell