// wave.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class wave
* @ajsnode game.dictionary.verbs.wave
* @ajsconstruct MyGame.createVerb({ "name": "wave", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading GesticulationVerbs
* @summary Verb meaning wave, as in "wave at Queen" or "wave pennant".
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> wave at dock</span>
* You wave at the people remaining on the dock. Poor bastards who
* couldn't afford the ticket. Oh well, sod 'em all. You don't give
* them another thought as you turn to find your cabin aboard the
* RMS Titanic.
* </pre>
* <p>
* <strong>Wave</strong> can be intransitive, or it can take a
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset} to be waved.
* Wave doesn't provide any special logic.
* 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>
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.wave = {
name: "wave",
past_tense: "waved",
synonyms: ["wave"],
/**
* @ajsverbstructures
* @memberof wave
*/
accepts_structures: [
"verb",
"verb noun",
"verb preposition noun",
"verb noun preposition noun",
],
player_must_be: {
not_constrained: true,
},
/**
* @memberof wave
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* },
* accepts_preposition: true,
* accepts_these_prepositions: [ 'at', 'to' ],
* },
*/
phrase1: {
accepts_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
},
accepts_preposition: true,
accepts_these_prepositions: ["at", "to"],
},
/**
* @memberof wave
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* },
* requires_preposition: true,
* accepts_preposition: true,
* accepts_these_prepositions: [ 'at', 'to' ],
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
},
requires_preposition: true,
accepts_preposition: true,
accepts_these_prepositions: ["at", "to"],
},
/**
* @memberof wave
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
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 player = this.game.getPlayer();
var msg = "";
if (direct_object && !direct_preposition) {
// is player holding asset?
//if( !direct_object.isIn(player) )
if (0 === this.game.parser.selectInHands(direct_object.id).length) {
this.game.debug(
`F1600 | ${this.name}.js | ${direct_object.id}.isIn player is false `,
);
msg += `$(We're) not holding ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
}
// player input "wave x at y"
if (indirect_object) {
return true;
}
// player input "wave x" or "wave at x"
else if (direct_object) {
// player input "wave at x"
if (direct_preposition) {
}
// player input "wave x"
if (!direct_preposition) {
}
return true;
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
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 player = this.game.getPlayer();
var results;
var msg = "";
this.game.debug(`F1494 | ${this.name}.js | print doSuccess `);
// player input "wave x at y"
if (indirect_object) {
msg += `$(We) wave ${direct_object.articlename} ${indirect_preposition} ${indirect_object.articlename}. `;
}
// player input "wave x" or "wave at x"
else if (direct_object) {
// player input "wave at x"
if (direct_preposition) {
msg += `$(We) wave ${direct_preposition} ${direct_object.articlename}. `;
}
// player input "wave x"
if (!direct_preposition) {
msg += `$(We) wave ${direct_object.articlename}. `;
}
} else {
msg += "$(We) wave! ";
}
// print output
this.handleSuccess(msg, direct_object);
return true;
},
};
})(); // wave