// wait.js
(function () {
/* global adventurejs A */
/**
* @augments {adventurejs.Verb}
* @class wait
* @ajsnode game.dictionary.verbs.wait
* @ajsconstruct MyGame.createVerb({ "name": "wait", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading UtilityVerbs
* @summary Verb that waits for one turn.
* @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">> wait</span>
* You wait one turn. Three buses arrive.
* </pre>
* <p>
* <code>Wait</code> one turn.
* </p>
*/
A.Preverbs.wait = {
name: "wait",
past_tense: "waited",
synonyms: ["wait", "z"],
gerund: "waiting",
/**
* @ajsverbstructures
* @memberof wait
*/
accepts_structures: ["verb", "verb noun noun"],
/**
* @memberof wait
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
noun_must_be: {
known: true,
},
},
/**
* @memberof wait
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* },
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
},
},
doTry: function () {
var input = this.game.getInput();
var asset1 = input.getAsset(1);
var asset2 = input.getAsset(2);
var msg = "";
if (asset1 && !asset1.hasClass("GlobalNumber")) {
this.game.debug(
`D1536 | ${this.name}.js | ${asset1.id} can only be a number `
);
msg += `{We} {don't} know how to ${input.input}. `;
this.handleFailure(msg);
return null;
}
if (asset2 && !asset2.is.time) {
this.game.debug(
`D1537 | ${this.name}.js | ${asset2.id} can only be a measure of turns or time `
);
msg += `{We} {don't} know how to ${input.input}. `;
this.handleFailure(msg);
return null;
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var asset1 = input.getAsset(1);
var asset2 = input.getAsset(2);
var msg = "";
if (asset1 && asset2) {
// queue additional wait turns
for (let i = 0; i < asset1.values[0]; i++) {
this.game.parser.input_queue.push({
input: "wait",
printInput: false,
});
}
} else {
// compose output
msg += `{We} ${this.agree()} a turn. `;
// --------------------------------------------------
// print output
// --------------------------------------------------
return this.handleSuccess(msg);
}
},
};
})();