// tap.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class tap
* @ajsnode game.dictionary.verbs.tap
* @ajsconstruct MyGame.createVerb({ "name": "tap", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading GesticulationVerbs
* @summary Verb meaning tap, as in "tap keyboard".
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> tap window</span>
* You tap on the window in hopes of catching Nurse Emily's attention.
* Unfortunately it's Doctor Fortescue who turns. You duck beneath the
* window, now hoping to go unseen. Who knows what might happen if
* you're caught out of bed. You might be branded a malingerer and sent
* to the stockade...or worse, get sent back to the front lines.
* </pre>
* <p>
* <strong>Tap</strong> a
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset}.
* Requires that the Asset to be tapped has
* asset.dov.tap.enabled set to true.
* No special logic is provided with the verb.
* Authors wanting to make use of it may need to use a method such
* as verb hooks. See
* <a href="/doc/Scripting_VerbPhases.html">Verb Phases</a>
* to learn more.
* </p>
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.tap = {
name: "tap",
prettyname: "tap",
past_tense: "tapped",
synonyms: ["tap"],
/**
* @ajsverbstructures
* @memberof wave
*/
accepts_structures: [
"verb",
"verb noun",
"verb preposition noun",
"verb noun preposition noun",
],
/**
* @memberof tap
* @ajsverbphrase
* phrase1:
* {
* accepts_noun:true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* reachable: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
},
/**
* @memberof tap
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* reachable: true,
* },
* accepts_preposition: true,
* requires_preposition: true,
* //accepts_these_prepositions: [ "with" ],
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
accepts_preposition: true,
requires_preposition: true,
//accepts_these_prepositions: ["with"],
},
/**
* @memberof tap
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var player = this.game.getPlayer();
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var msg = "";
var results;
// parsed sentence structure: verb
if (input.hasStructure("verb")) {
this.game.debug(`F1995 | ${this.name}.js | no object given`);
msg += `$(We) drum $(our) fingers on the nearest surface. `;
this.handleFailure(msg);
return null;
}
if (!direct_object.isDOV("tap")) {
this.game.debug(
`F1430 | ${this.name}.js | ${direct_object.id}.dov.tap.enabled is false `
);
msg += `$(We) can't tap ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
// parsed sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
if (input.hasStructure("verb noun preposition noun")) {
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var player = this.game.getPlayer();
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var msg = "";
var results;
this.game.debug(`F1431 | ${this.name}.js | print doSuccess `);
// compose output
msg += `$(We) ${this.name}`;
msg += `${direct_preposition ? " " + direct_preposition : ""}`;
msg += `${direct_object ? " " + direct_object.articlename : ""}`;
msg += `${indirect_preposition ? " " + indirect_preposition : ""}`;
msg += `${indirect_object ? " " + indirect_object.articlename : ""}`;
msg += `. `;
// print output
this.handleSuccess(msg, direct_object);
return true;
},
};
})(); // tap