// read.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class read
* @ajsnode game.dictionary.verbs.read
* @ajsconstruct MyGame.createVerb({ "name": "read", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading CompositionVerbs
* @summary Verb meaning read asset, as in "read scroll".
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> read grimoire</span>
* You read the ancient grimoire. Instantly, your head begins to fill with
* ancient spells. Lead to gold! Levitation! Spiritual transformation?
* Your mind expands with a rush of incoming knowledge. Or does it?
* Do minds have a maximum capacity? Does it feel as if the new
* spells are overwriting your own memories? You try to recall a childhood
* memory, and turn up a spell to purify water. You think back to your
* first kiss, and find a spell to transform yourself into an eagle. You...
* no, there is no you. There is only the spellbook, and the timeless, immortal
* spells within it.
* </pre>
* <p>
* <strong>Read</strong> requires that the
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset} to be read has
* asset.dov.read.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.read = {
name: "read",
prettyname: "read",
past_tense: "read",
synonyms: ["read"],
/**
* @memberof read
* @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 read
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var player = this.game.getPlayer();
var msg = "";
var results;
// parsed sentence structure: verb
if (input.hasStructure("verb")) {
}
// parsed sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
if (!direct_object.isDOV("read")) {
this.game.debug(
`F1388 | ${this.name}.js | ${direct_object.id}.dov.read.enabled is false `
);
msg += `$(We) can't read ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (
direct_object.must.be_in_hands_to_read &&
player.id !== direct_object.getPlaceAssetId()
) {
this.game.debug(
`F1389 | ${this.name}.js | ${direct_object.id}.must.be_in_hands_to_read `
);
msg += `$(We) have to be holding ${direct_object.articlename} in order to read it. `;
this.handleFailure(msg);
return null;
}
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 = "";
// parsed sentence structure: verb
if (input.hasStructure("verb")) {
}
// parsed sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
this.game.debug(`F1390 | ${this.name}.js | print doSuccess `);
msg += `$(We) read ${direct_object.articlename}. `;
// print output
this.handleSuccess(msg, direct_object);
return true;
}, // read
};
})();